15 days ago •
My prize entry needs a solar charged battery back to power the sensor and transmitter I'm placing in front of my house. Rather than spending a whole lot of time finding domestic suppliers of small photovoltaic panels and trying to spec a nicad or nimh battery pack, I decided to buy a "60 LED Solar Security Light" from Harbor Freight just a few miles from here. The list price was $32.99US, but it was on sale, plus I had a 20% off coupon so it ended up costing me about $20.00US. I doubt that once you consider shipping, I could have bought a solar panel and battery back for less than that. What's more, I ended up with a big LED panel and a motion detector module for use in future projects.
Here is the video of my tear-down and analysis of the light:
The photovoltaic panel and battery pack are going to work great for my project. I think I will duplicate the single-diode "charging circuit": It just can't get simpler than that. Next up, code for the transmitter.
19 days ago •
So, I started working on the code for the sensor/transmitter.
I'd edit code on my bench, flash the chip, haul it all outside to the meter, test it, haul it all back inside, and repeat.
Now, this is Arizona, and it's about 110F out there. I did about 3 cycles of that before I decided something had to change.
I dug around in my shop and came up with a nice little DC gear motor. I attached a magnet to the shaft and tried it out. I pretty quickly figured out that the windings and magnets in the motor were creating a larger field than the magnet on the shaft. Then I got a piece of dowel and extended the magnet away from the motor. This worked well, I could read the magnet without getting magnetic interference from the motor itself. Then another problem cropped up. I was using a variable bench power supply to run the motor. It worked fine, but when I tried to slow the motor down (water meters can run VERY slowly) by reducing the voltage, the motor would just stall. The slowest I could get the motor to reliably spin was about 20 RPM, not nearly slow enough. It seemed pretty clear to me that what I needed was as actual motor controller, and down another rabbit hole I went.
I decided that I needed a PWM motor controller. Since in a PWM system the motor always sees full voltage (just varying duty cycle) it should run a much lower speeds without stalling. Torque from the motor will also fall dramatically, but in this application there is virtually no load on the motor anyway.
I decided to use a Microchip PIC12F1840 microcontroller for my motor driver. I selected this chip because 1) it has an analog to digital converter built in, 2) It also has a PWM generator on chip, and 3) I had a bunch of them laying around. It only took me a few hours to draw up a schematic, find all the parts in my shop, and put the thing together on a breadboard. You can see the schematic HERE.
After another few hours, I had basic software running to do the analog conversion of the voltage level from the speed setting pot, and basic functionality of the PWM generator contained in the PIC. In the above picture you'll notice an LCD display. That display is not part of the final circuitry. I have a few LCD displays with serial backpacks installed and find them invaluable for writing code for microcontrollers. They only take up one pin (TX), and you can send all sorts of debug or status messages to them while you're writing/debugging your code. Once the code is done you can pull out the LCD display and delete the display code from your source.
I was going along fine until I hit a roadblock in the code that had me banging my head on my desk for a couple hours. Luckily Jayson Tautic, a friend from IRC, found the bug. Let's just say that MAYBE I should give up doing binary conversions in my head from now on. Changed a "512" to "256", and it ran perfectly. Thanks Jayson!!
Once I had the code running well, I transferred the circuitry to a little PIC-specific dev board. I tested that construction with the new code and it worked very well. From there, I found an old slat of redwood and mounted the board, motor, pot, magnet, and the sensor. The final result worked perfectly. Using this system I was able to get the motor turning reliably at about 5 RPM. Slower would be better, but that's plenty slow enough to test my sensor, and develop code for the transmitter.
Since this little motor controller project isn't really part of my contest entry, it didn't seem right to fully document it here. I did, however, write up a complete blog post on my website that details the circuitry, and provides all of the source code for the PIC (Public Domain). You can find that page here:
So that's how I spent Labor Day weekend.
I have two goals for this week:
First, I want to get that solar flood light I bought from Harbor Freight torn apart (the true "hack" part of this project) and start looking into scavenging it's panel, batteries,...
Read more »
a month ago •
So, I got a little distracted. I was thinking about the user interface for the receiver end of this project. I've always planned on using a 4-line LCD ( or VFD ) display to present water consumption data to the end user. But it occurred to me that once a person is used to the box sitting there they won't notice it much. Since the whole point of the project is to remind and notify users of their water consumption, I'd need to add something a bit more obvious as an output device in addition to the text display.
I decided that what I needed was a ring of LEDs. One LED would always be lit, and it would step around the circle at a rate that corresponds to the water flow rate as measured from the meter. When the user walked through the room containing the display it would be difficult to not notice the moving display, particularly if it's spinning madly indicating a large flow of water.
I felt that using 16 LEDs would present a nice, contiguous circle. If you look around the web you'll see dozens and dozens of people driving rows of LEDs with shift registers, like the 74HC/LS595. Unless they only ever turn on one or two LEDs at a time, they're all doing it wrong. The '595 can't handle that much current. To drive my display, I chose the TLC59282 from Texas Instruments, available from Digikey. This part is a 16-bit shift register, but it adds constant-current sink drivers to all the outputs. Choosing one resistor sets the current for all of the LEDs. Further, it has a "BLANK" input which enables/disables all of the LEDs.
It also occurred to me this circular display could be handy in other circuits and applications, so decided to make it a stand alone sub-assembly. I almost always breadboard my circuits before committing to a PCB design, but this chip is so simple that I went ahead and ordered PCBs and components at the same time.
NOTE: You can buy these boards! I will post links to the gerbers (when I figure out how) but in the mean time, if you would like to use this display board for one of your projects you can buy them (in sets of three) from OSHPark.com here. I do not make a penny off of this! I simply set up OSHPark to share my design, and others can order board sets directly from them.
You COULD install all of the parts on the same side of the PCB, but my intent is to install the LEDs on the front side, and everything else on the back. If I end up installing this behind something like a tinted panel, I may want to paint the front side (before installing the LEDs) with flat black paint so that you won't see anything but the LEDs through the panel.
The single resistor sets the current level provided to all of the LEDs connected to the display. The data sheet provides a large table to select this resistor value based on desired current and supply voltage. In my case (5V supply, 20mA) the value came out to 2.5K ohms.
It took a little time to select the LED I used. I wanted it to be blue ( because ... well ... water), I wanted it to be in a diffused package so it wasn't glaring, and I wanted to to be fairly low power. I finally found the MT5470-BL, available from Digikey. I am very pleased with these LEDs except that they are still VERY bright, far too bright for this application. Luckily there is the "BLANK" pin on the driver chip. I set up the microcontroller (PIC16F1509 in this case) to generate a PWM signal, and applied that to the "BLANK" pin of the display driver. This approach worked very well, and I found that providing a duty cycle of about 5% on time gave me the brightness I wanted. What's more, if I have time this opens up the possibility of including an ambient light sensor and have the system automatically set the LED brightness based on how light it is in the room.
Now, in this application, there will be a single LED lit and it will progress around the circle indicating...
Read more »