**Note**
This is a full break-down and analysis of a project I worked on. It contains both information about the project and workflow discussion.
Let's start by answering the question, "what is it that I would like to accomplish with this build".
Having a clear idea of what you are looking to do will help speed things along and keep your electronics project running smooth. On this project I had a very clear idea of what I wanted it to do. It would need to be able to monitor my water level and fill up the sump accordingly. Now that we've got that question answered, we need to decide how we are going to do this. I personally like to doodle, so I often just start jotting down ideas on a sheet of paper and see where it takes me. I have a folder set aside on this project for my initial designs. I take photographs of all my ideas as I go for future reference.
Time is another important factor. I find that if you don't set a time limit on your projects, you probably won't ever finish them; at least, if they're large projects. For the top-up, I knew that I wanted to complete this project over the summer. I set this goal because I knew once I got back to school I would have significantly less time to complete it. The last big question to answer is how much money will I be spending on this? It's something that I rarely ever contemplated when I began working on electronics, because I would simply spend what I needed to finish it. As you could imagine, doing things this way quickly snow-balled into a tremendous amount of money spent. Having a firm set budget is important, but it's also important to be realistic. Don't try to build it so cheap that you can't finish. Leave room for revisions. Before starting this project I looked at several top-up systems on the market and they run anywhere between $70 to $100 on average. I typically try to make sure that my final project doesn't cost much more than it would have if I had purchased it in the first place. I don't mind spending about the same amount of money as purchasing it from a supplier because I enjoy building things myself, but I try hard not to let myself go beyond this point.
The design process can vary, depending on what you're doing. Sometimes everything will come easy to you and you'll have your design knocked out before you even know it, and other times it can be a long and labored endeavor that will have you pulling at your hair. Luckily on the majority of my projects, design work goes smooth as I already have a clear plan of action. Once I started working on this project and got my ideas down on paper, I realized that I wanted a bit more than a simple refill. I was going to have several components that would make this circuit stand out. It was obvious that I would need some type of water level sensor. I opted for an optical sensor, because I had never used one before and they had them on sale at SparkFun. I also wanted a time-out system for it, to keep it from running for too long. Some sort of audible or visual alarm would also be handy on a circuit like this, so I put the both of them in. I would also need a way to turn on AC outlets with it, and because this will turn on and off frequently some type of solid state relay would be good on this rather than a mechanical relay. And finally, if the timer did run out and shut off the circuit, then I would need a way to reset the entire thing and start the timer back up again. I broke it all up into its individual components and I could start building the circuit piece by piece on a breadboard to make sure it was going to work how I wanted. Then I will combine all the individual components and make a single circuit.
The individual components of the Top-Up System, when I had considered building it with the ATtiny
This is a snip of my project file that contains the operation of the Top-Up board. I use these descriptions on my OSH Park page as well
As stated in the preamble, I wanted to avoid using a micro-controller on this build. A controller would have been quite simple to do all these tasks with, but again, I was looking for a challenge. Because of this I started looking at my options. Once I roughed out my simplified schematic with the individual pieces of the circuit, I knew that I could do most of what I wanted with a simple 555 timer. This timer is a good choice because it's robust and cheap. At the time I was building this circuit, the ATtiny85 cost about $5, which was a fairly large blow to the budget on a single part. Now it can be purchased for about $1. If it was this price when I was designing the circuit, I may have considered doing it that way instead of going with the 555 timer, but the timer is still a good choice as it's about half the cost of the ATtiny85 and doesn't require any programming. Another key benefit of the 555 timer is that it's probably not going anywhere anytime soon. It can be a real pain when a part gets discontinued, but Digi-Key typically offers good replacement part recommendations, which can ease the pain.
Now that I've selected the 555 timer, I can begin experimenting with the circuit. I've found that having several breadboards to work with really helps when testing anything more than a small circuit. The benefit of this is the ability to find troubled spots in the circuit easier. It also makes drawing up a final schematic simpler when you can trace your wires to their components without digging through a rats nest wiring job. I take my individual parts of the circuit that I wanted to build and make them one by one, testing them as I go. The very first task I need to complete is designing the portion of the circuit responsible for reading the data from the optical level sensor.
I've broken the build up to 3 breadboards, easing the task of troubleshooting
Optical Level Sensor
Hysteresis Circuit
Alarm System
Fill Timer
AC Outlet Control
Power Supply Unit
To fully understand how this circuit works, we will dive into each of these six sections individually. This is just a detailed summary of the circuits operation. I have written a full document stating the entire theory of operation that can be found here. Let's get started.
I decided to use an Optomax digital liquid level switch for this project because it was readily available on Sparkfun's website and it's a simple to device to use. Though not cheap, I think that cost is justified based on its performance and reliability. As I stated before, the magnetic float switches work fine, but the moving parts are a concern in the operating environment. I've personally had snails stick the switch in the fill position. This doesn't mean that they should not be used, it's just something to be aware of when designing the top-up.
Using the optical level switch is straight forward. It has 3 wires to connect, the V+, Signal, and Ground wire. According to the datasheet, V+ will be a red wire, Signal will be either white or green, and ground will be blue or black. That certainly seems simple enough. Another wonderful thing about this switch is its wide voltage supply range. This sensor will work from 4.5VDC to 15.4VDC, which is great for this project, operating at 12VDC.
Getting water level information from this device is also very simple. It outputs a HIGH value in air and a LOW value in water. The output HIGH signal will be the Voltage Supply - 1V and the LOW signal will be 0V + 0.5V Max. If all we wanted to do was simply trigger a triac or solid state relay, we could just pipe this signal into the gate and call it a day. But we will be doing a bit more to make the circuit function more intelligently.
I also wanted to have the option of using a magnetic float switch. A magnetic float switch uses a simple reed switch and magnet to open and close a circuit. Because of this, I assumed that I could simply use the V+ and Signal line of the circuit to transmit the HIGH and LOW signal. After testing though, I discovered that the circuit behaved erratically. This was solved by simply adding a large value pull-down resistor to the signal line.
Now that we have a functioning sensor, it's time to tackle the ripples and wave problem found in most sumps.
*It's worth stating that all of the information described here, with the exception of the magnetic float switch, is available in the sensors datasheet, which is very well documented and simple to read.
Though it's not entirely necessary, I felt that the inclusion of a hysteresis would benefit this circuit greatly. This lagging effect is exactly what's needed to keep the circuit from flickering the fill pump on and off. I devised a way of doing this by using a Resistor-Capacitor network and a Schmitt trigger.
This part of the circuit is a little bit tricky to understand at first, but with some explanation it becomes quite simple. We have our signal heading into this portion of the circuit on the left hand side. It first sees a 100k current limiting resistor and and 1k limiting resistor heading into the base of a PNP transistor. Lets ignore the PNP transistor for the moment and turn our attention to the 100 micro-Farad capacitor. For a short period of time, a capacitor will allow DC current to pass through it, but as it charges, it becomes saturated and no longer allows any current to pass. Here, the capacitor is being used to create a slow rising input signal to a Schmitt trigger while the signal is HIGH. The PNP transistor is in place to quickly discharge the circuit. The PNP transistor only allows current to flow around it while the base is provided power from the input signal. As soon as the power is removed the transistor will allow current to flow from its emitter to its collector, passing it to ground. It is set up like this because the circuit needs to slowly charge up, but quickly discharge. When the sump is on the cusp of needing to be filled, the crest of the ripples in the water will touch the tip of the sensor.
The RC-network used in the Auto Top-Up System
Following the slow charge circuit is the Schmitt trigger. A Schmitt trigger is a specialized circuit that will allow current to pass when a threshold value is reached. For this project I decided to use an op-amp, the LM358, in a Schmitt trigger configuration for the job. This is a dual operational amplifier, but I'll only be using one side, so it's important to remember to properly terminate the other amplifier. The unused pins should be set with the "+" pin to ground and the "-" pin to output. This will keep from introducing any noise on the operating amplifier.
I'm using a 555 timer to keep track of the fill time. There is so much written about 555 timers that I'm not going to spend a lot of time on the subject here. Some useful places to look at setting up a timer would be here, and here as well. It's worth noting that most of what I learned about the 555 timer came from, "Encyclopedia of Electronic Components" by Charles Platt. I own all 3 volumes and if you are interested in having something physical to read while you study electronics, I highly recommend these books.
I'm running this 555 timer in a typical mono-stable mode. You'll notice in the schematic that there is one switch and two variable resistors. The push button switch is the reset button, for when the timer runs out but you need it to keep filling. I took into consideration that the top-up reservoir ran out of water, you refilled it and wanted to restart the timer. This would be a good way of doing that. The two potentiometers are there to control the amount of time it runs. The 1 mega-ohm potentiometer is an on-board trimmer that I worked into the design if the user required more than about a minute of fill time. The rest of the circuit is straight forward, but I do have a detailed description of it in the theory of operation page if you're interested in reading further into this subject.
The timer circuit with reset button
The next portion of the circuit, the alarm system, functions similarly to the timer. It is two 555 timers in a single package; the 556 timer. This timer is set up as an astable multivibrator, because it will be alternating on and off rapidly. The reason that I've set it up like this is because the piezo buzzer needs an AC signal to operate. Both the timers within the 556 package are set up much the same, but the piezo buzzer needs to cycle much quicker, because in order to produce an audible sound, the frequency needs to be much higher. The other timer is used to flash an LED on and off. I probably could have done this with a dedicated alarm style integrated circuit, or even a piezo buzzer with the siren circuit built in, but once I had ordered a bunch of 555 timers and they became the only IC used, with the exception of the op-amp. This portion of the circuit turns on when the timer runs out.
The alarm system circuit, based on a 556 timer
A solid state relay is a good choice for this project, but that not to say it's the only choice. You could also use a simple mechanical relay, but an aquarium evaporates quickly, in most cases, and the pump will be turning on frequently. Therefore, a solid state relay is a better choice because it has no moving parts, giving it a much longer life. Mechanical relays do tend to fail in the "open position" though, where the solid state relay tends to fail "closed". This should be taken into consideration.
The simplest part of this circuit is the AC power control. I'm using a sturdy and reliable triac to control power to the fill pump. I actually came across this triac while I was taking apart a Christmas time light show control that had broken. I wasn't planning on seeing anything too interesting, just looking for parts I could use in other builds, but I saw some rather neat little IC packages and looked them up on Digi-Key. They've quickly turned into my favorite type of AC power control. Isolation is important in the case of AC to DC interaction, so an MOC3063 opto-isolator is used to transmit the signal to the triac. It is also very important to always use a proper fuse in all your projects dealing with AC. The traces on the board are large, but I still capped this off at 1A MAX. I used a fast-acting fuse as well for safety. Remember to put the fuse on the HOT line and as close to the input source voltage possible, as it should disrupt any chance of a user becoming the path to ground.
This triac and optocoupler will control a fill pump
I really considered using an external power supply as they are cheap and readily available, but because I enjoy a good challenge, I decided to try an on-board power supply unit. I may end up ditching this idea in future revisions, but for the current revision it's what I went with.
I had mentioned earlier that parts do have a finite life and sometimes they get discontinued. I recently received notice that the AC/DC converter I used in this circuit is being discontinued. But if you notice in the picture, Digi-Key offers plenty of time to revise the board and even recommends substitutes. Really this is quite alright as I had already planned on replacing this AC/DC converter with a better one. During the course of this project, the only reasonably priced converter I could locate was the BP5039B12, which came in right around $5 at the time. But shortly after I had finished, I got an email with a new converter that I liked much better for about the same price. The original converter is non-isolated, which always makes me a bit nervous, especially considering that this is being used in saltwater. I know it meets standards, but I would like to have an IC that's isolated. I ordered the PBO-3-S15 converter for around $7 that makes me feel much better because it is isolated.
An email from Digi-Key giving notice a part being discontinued
I ordered that converter in the 15VDC package because I wanted the alarm to sound a bit louder. I know that 15 volts is pushing it on the maximum tolerance for my components, but I can simply add a diode on the sensitive ICs to drop the voltage to a more acceptable level. I have not revised the board to reflect this new converter yet, but I will soon. For now, I will quickly describe the converter in use at the moment.
Beginning at the AC input, a bridge rectifier is used to convert the high voltage AC to high voltage DC. Following this is a surge protecting varistor and smoothing capacitor. The inductor is used to set the feedback to the module and regulate the 12VDC output signal. Another smoothing capacitor is used on the output, along with a reverse-current protection diode. Do note, that this part will be getting discontinued spring, 2018. I will be covering the new converter as soon as I finish revising the board.
The outdated AC/DC converter which will be getting replaced with a better, safer converter in the next revision
There are many board design programs available, including free software. I personally like Fritzing, but I also occasionally use Upverter, a well designed and supported web-based program. Eagle CAD is another option and so is KiCad. On this project I chose to go with Fritzing, not because it is the most powerful software available, but because I find its simplicity appealing. I also didn't have a entirely clear idea of the components I would be using, so using a program like Upverter wouldn't be the best choice in this phase, as Upverter really shines when you have the components picked out ahead of time, like on a final board layout.
I always start with with my main components, like the 555 timer ICs and build the board around those. Next time I start a project, I will record the layout process with either Fritzing or Upverter, maybe both if the board gets revised a couple times. I did not do that for this project, but I will try to describe my process as best I can.
I start by placing my main components, followed by supporting components. I always have my schematic open and sitting to the left of my design window. Then I began routing traces. Fritzing comes with an auto-route option if you drew up your schematic inside of it, but it always looks and works better if you do it yourself. All of these components I'm working with on the initial design are low energy consumption, so trace width isn't as critical if you were working with a high current draw device. It's always easy when you begin routing traces with a blank board, but as the trace count increases, it becomes significantly more challenging to route the traces to their final position.
The first revision board, with rulers and quarter to show scale
Something else worth mentioning is that I purposely tried to use PTH components wherever I could, which eases the difficulty of soldering this initial board. That's not to say I didn't use any SMD components. I just made sure that my PTH parts were on the topside of the board and all the SMD parts were on the bottom. I find it easier to solder this way. Speaking of which, another thing to keep in mind when designing your board is your ability to solder the parts. Don't back yourself into a corner when laying down your components. Keep in mind the size and their location so you don't find yourself awkwardly trying to set a component, especially SMD components.
As you can see in the above image, I broke out the VCC and GND, along with the optocouplers positive and negative terminals so I can supply power to this board when I'm debugging it on the breadboard later. I've got a spot marked out for the piezo element on the board. There were no parts available in Fritzing that matched the piezo buzzer I was using, so I simply used some text dashes and marked it out that way. You can create parts in Fritzing, but it's not a simple task. That's something I think could be better.
Other than that, I just try to keep the board as compact as possible to save money on manufacturing. You can see in the image that I made the board exactly 5cm because that is the cut-off at OSH Park for their cheap boards. I also try to keep the traces short and simple. There are no data lines here, so equal length traces is no issue. I might add that keeping your traces short reduces noise on your lines. If you run your traces long to get you're going, your basically just making an antenna and introducing noise to the circuit.
After laying out the initial design of the board it is time to export the board files and upload them to a manufacturers website. In this case I will be using Seeed Fusion's very competitive service for my initial run. Another board manufacturer I use frequently is OSH Park, but there are more. I like OSH Park because the boards are manufactured right here in the US and the quality is superb. Seeed Fusion offers very good pricing, your choice of board color, and flexible options, but shipping time can vary greatly. I've received boards from them in as little as a week and a half, and some took over a month. OSH Park is a bit more expensive, but they are frequently delivered within 2 weeks. Cutting down delivery time is always a good thing in my book.
I received the boards from Fusion and their quality was very good. Everything appeared to be in order and I began soldering the components to the first revision board. As you can see in the image, I made a couple mistakes on the traces and after debugging the board, I located and corrected them. I find that taking photos of your mistakes is always a good thing, even if your ego disagrees. You'll also notice the in the bottom right hand corner of the PCB, the silkscreen with the name of the project and its revision number. This is a very useful thing to do and I discovered this early on. When you have multiple copies of boards that all look the same, with small changes to correct errors, you need to be able to differentiate those boards.
First revision top-up board, with errors detailed and corrected
Now that I have debugged this board and I'm confident I've corrected the errors, it's time to begin working on the second revision. I will be adding the power supply unit at this time as well.
After I'm sure that the errors of the first revision board have been corrected, I go on to laying out the power supply unit. This is more difficult than the other portion of the circuit because we will be dealing with AC and proper isolation is key to safety. You'll notice in the picture that I've copper-filled the parts of the circuit that don't see high voltage AC. I leave the power supply circuit with bare traces to reduce the risk of any voltage creep. Copper-filling your boards is good practice as it reduces the amount of copper being wasted in the acid bath. The traces on the power supply unit are always max width so they can handle the current being passed on them. In my final revision, I might omit the through hole inputs on the AC line and go with copper pads instead.
The second revision top-up circuit board with on-board power supply unit
Something else that you'll notice in the picture are the sticky notes sitting around the board. I find it crucial to leave good notes when you are doing this kind of work. Every change that I make is documented in the README file and inside the Fritzing file with those sticky notes. It's a good habit to get into. This next snippet is a screen capture of my README.txt file that keep with the projects. It contains all the information about board revisions and the date they took place.
The Top-Up System README.txt file, with information about revisions
Finally it's time to assemble what will hopefully be the final board, but there could still be an error or two that need addressing on this circuit.
Soldering all these surface mount components takes a lot of time, so it's important to minimize mistakes. This board has 62 components and the majority of them are surface mount, so every time I screw up, I get to solder them all over again. It's good soldering practice, I suppose, but it does cost money and more importantly time, so reducing mistakes here is key. You'll notice in the photograph at the top left-hand side, the identifier, AiREA : EH-090516 and in the previous photo with board revision number one it was, AiREA : EH-080116. Those are my initials and the date the board was made. It was over a month before I could get that board manufactured again after debugging the first one. It cost me a lot of time.
Something else I'll point out here in that photo is the cuts that I put on the board to further isolate the AC. I will admit that I do not enjoy working with high voltage AC that much, so I tend to overdue my safety practices when I do have to work with it. It's this reason that I am really considering using an external power supply to power this board and just add a barrel jack or micro USB input to power it. That is, until I came across the new power supply unit that I saw, which included very good isolation and looked much safer to use. I will probably at least try using that one first before I decide if I'm going to go with an external power supply for this build. One last thing to point on, on the picture of the top-side board assembled is that trimmer right near the center with the yellow dial. That's the one I mentioned previously to control the fill-timers long range. The external one is jumped on this board, to the left of it, but it will be used when I print the case for it.
(above) Revision 2.1 of the top-up with the SMD soldered on
(below) The assembled top-side of the Top-Up system circuit
I mentioned previously that this board contains 62 components. To help the soldering process along I create a component reference sheet. The board has silkscreen identifiers on every single one of the components that are used, but their values are not listed on the board. I print this guide out and keep it on the desk next to me so I can easily pick and place them while I'm soldering the board.
Having a component reference guide will make life much easier on projects with a large component count
After assembling the second revision board, I had a couple small errors in the power supply unit to fix, then I ordered the final board revision. I held off on assembling this board because I found out shortly afterward that a newer power supply was available, which was appealing to me, and I wanted to use it instead. A new revision is in the works and this page will be updated to reflect the changes as they are made.