(article continued from previous page)
The main circuit board for the Water Softener Monitor is not very complicated. Recall that the project measures and displays the level of salt in the brine tank. And, that the project alerts the user if the light is left on in the water softener closet.
The main printed circuit board (PCB) for the water softener monitor.
LED Bar Graph: Avago HDSP-4832 10-element multicolor LED array. I was pleasantly surprised to find that the voltage drop of the various colors is fairly similar (around 2V), so I didn’t need to use different resistors for the green LEDs vs. the red LEDs. In fact, the entire array uses 180 ohm resistors for a current of approximately (5V-2V)/180 ohms=16.6 mA per LED.
The final board has the LED array and photocell mounted on the back of the board. This flips the orientation of the LED diodes (they’re polarized -- unidirectional). To compensate for the flip, the resistors can be fed either 5V or GND from the jumper header. That is, it can be switched from common anode to common cathode.
Of course, the software on the microcontroller also has to compensate by feeding 0V or 5V to turn on the individual LEDs. To make this happen automatically, a trace connects the jumper header to a microcontroller pin. The microcontroller simply reads this pin and adjusts the output.
IC1: Atmel AVR ATtiny861 20-pin DIP microcontroller with 8K of program space and 512 bytes of RAM, running at 1 MHz. I needed the pins, but I didn’t need this much memory (although I’m always grateful to have it).
The maximum current the chip can provide is 200 mA. When all 10 LED elements are lit, the display consumes 167 mA. Since the chip is only running at 1 MHz and only supplies a little power to R1 and a couple of pull-up resistor, it is safely within the power consumption limits.
C1 and C2: 0.1 µF ceramic and 10 µF tantalum capacitors respectively. It is good electrical practice to place such capacitors near chips to smooth the local power supply, particularly when the power supply regulator is located off the board. Furthermore, this matches the test setup on the power-supply datasheets.
C3: 100 µF electrolytic bulk capacitor. Bulk capacitors are used to reduce power fluctuations due to high current components being turned on and off. The Sharp GP2D12 infrared distance sensor draws several hundred milliamps of power during peak usage.
R1: 1 kilohm resistor for limiting current to the base pin of Q1. Without this resistor, the transistor could be damaged by too much current. (Since this is connected to weak microcontroller pin, you could theoretically get away without the resistor in a pinch. But, that wouldn’t be a proper design.)
Q1: Bipolar NPN transistor to control power supplied to the GP2D12 salt-level distance detector. There is no reason to supply power to the detector when the Water Softener Monitor display is turned off. Therefore, Q1 exists to turn power on and off. A 2N2907A transistor would probably work, but I used a fancy Zetex ZTX1048A leftover from the Bipolar H-Bridge project.
R2: Encapsulated photoresistor for detecting ambient lighting. I got it from a photocell grab bag.
R3: A 10 kilohm resistor that forms a voltage divider with photoresistor R2. The analog-to-digital converter on the Atmel microcontroller reads the voltage between R2 and R3 to determine how bright it is in the room. The R3 resistance value was chosen to limit the amount of current consumed by the voltage divider during peak brightness when R2 approaches zero (5V/10000 ohms=half a milliamp in the worst case). A larger resistance for R3 would decrease the accuracy of the analog converter during darker lighting conditions.
SW1: The pushbutton switch and the headers to the left were used during debugging. In the finished board, the pushbutton pin is connected to the photoresistor in the water softener closet to determine if the light was left on. Interestingly, I used the pull-up resistor built into the ATtiny861 chip to form the voltage divider, instead of using a discrete resistor as I did for R3.
There’s been a lot of talk lately about vampire current. That’s power usage from lots of little sources that add up over time. Common examples are individual LEDs, clock displays on every major appliance, plugged-in wall-wart AC adapters for powered-off devices, and other minor electronics.
Because the Water Softener Monitor was not going to be looked at very often, it has been designed to minimize power usage. This saves a bit of money on the electrical bill and is better for the environment.
The microcontroller monitors the room brightness. When the light changes, either the room light has been turned on or someone has passed in front of the wall plate display. The microcontroller then powers up the Sharp distance sensor, takes a reading, and displays the salt level on the LED bar graph display. The entire device uses 185 mA @ 5V (about 1 watt) with all of the LEDs lit.
After three minutes of a stable light source, the LED display and Sharp distance sensor are powered off. The microcontroller enters sleep mode, waking up several times a second to check the room brightness. The total electronic device uses 1.5 mA @ 5V (0.0075 watts) in this state.
(0.0075 watts / 1000) * 1 hour = 0.0000075 kilowatt hours (kWh) of power.
0.0000075 kWh * 24 hours in a day * 365 days in a year = 0.0657 kWh per year.
0.0657 kWh * $0.07 average cost per kWh = less than half a cent to run full time per year.
Fantastic! How green!
Ummm, but I forgot to include the power usage of the AC power supply adapter. There is no way I am going to hook up my ultra-thrifty circuit to an old-fashioned inefficient wall wart.
With the exception of the Dual Fan project, I usually take a slightly higher voltage (7.5VDC to 9VDC) and use a linear voltage regulator (such as a 7805) to drop the voltage to a steady 5V.
This is appropriate for battery packs because the supplied voltage drops over time. But, for plugged-in devices, it wastes 33% to 44% of the power in the linear regulator and adds cost due to the larger PCB board and additional electronic component(s).
A modern commercial ac adapter switching power supply (left side) is cheaper, smaller, lighter, better oriented, and more efficient than the previous generation of linear wall warts (right side).
For the Water Softener Monitor power supply, I chose CUI Inc’s EPS050100-P6P for $5.64 from DigiKey. It is an Energy Star level IV compliant switching regulator with a 5V output. That means that correct voltage is provided directly to my circuit without me having to put in a regulator. And, the power is converted more efficiently from AC through switching technology.
The Energy Star specifications for power supplies of 5 watts are somewhat lame. The power supply needs to use less than 0.5W on idle and must be (0.09*LN(5))+0.49=63.5% or more efficient at the average of 25%, 50%, 75%, and 100% loaded. Although this doesn’t appear to be a very strict standard, it is more difficult for small power supplies to be efficient because of electrical overhead, price pressure, and smaller component sizes. Larger power supplies (such as used in computers) are required to be more efficient because they have a larger overall impact and the price points and box sizes allow for more efficient components choices.
(Source: http://www.energystar.gov/index.cfm?c=ext_power_supplies.power_supplies_consumers)
The other advantages of the CUI power supply are:
The Water Softener Monitor is working well so far. It has no problem determining the approximate amount of salt remaining in the brine tank.
Shortly after being installed, I did have two problems with the light sensors:
The first problem was that the light in the closet is a compact florescent. I set the “on” voltage of the sensor after having worked in the closet for several hours. At that point, the lightbulb had warmed-up and was outputting more light than when it is first turned on. So, I needed to adjust the software value of the lighting to the brightness of when I quickly refill the brine tank and walk away.
The second problem was with the ambient room lighting in the basement. The sensor had no problem detecting my shadow, but the indirect lighting from the overhead lights was not different enough to trip the sensor during the daytime. By lowering the hysteresis value in the software, the device properly turns on whether the room lights are turned on. (Of course, I don’t know whether the device is now turning on randomly when I’m not around to see it.)
Despite the crude installation, I am pleased with the overall results. It is rewarding to see it turn on and remind me of the salt level whenever I pass by.