PropCharger - USB Device Charger and P/S
photomankc
Posts: 943
Well, I'm going to call my Propeller based USB device charger/power supply done. My goals were to create a system that could use simple AA NiMH batteries and power a USB device with a cut-off once the batteries were nearing exhaustion to prevent damage. I also wanted a device that I could set to charge for a few hours and then turn off so I could set it overnight and forget it. I have met those goals with the current design. Posted below is my write-up I'm working on for my home page:
**Code and Schematics and other documents to follow**
The PropCharger is a USB device charger powered by 6AA batteries to allow it to recharge large capacity USB devices using standard AA rechargeable batteries. The heart of the charger is a Parallax Propeller microcontroller and 2 voltage regulators. One regulator supplies the microcontroller with the 3.3V supply it requires and the other powers the USB device at 5V. The 5V regulator can provide a solid 5V output with a battery voltage as low as 5.5V Practical limitations of rechargeable batteries however limit the system to about 6V. Discharging the batteries more may damage them, which is what the MCU is there to prevent.
Background
This all started with the simple idea of making a brain-dead recharger for an IPOD Touch. Most of the LiPo batteries out there were not terribly high capacity and most would only fully charge a high-capacity device one or less times. My original design was a simple 7805 regulator and LED from Radio Shack and some wire on a two inch perfboard. It worked. It had two huge flaws though. First was that it was horribly inefficient. It burned a large part of the power as heat and provided next to no benefit for that. Second, it was brain dead. Leave the batteries attached and they would be sucked dry. Very bad news for rechargeable batteries. They do not tolerate being discharged completely very well. So simple and neat, but not terribly useful.
Next I started looking for IC solutions to the second issue. There are ways to achieve it but they all involved fiddly circuits with analog components and there was always a snag. A big one was the HUGE rebound that NiMH batteries have in voltage when they are unloaded. They can be next to dead and rebound by more than a volt when the load is removed which was hard to handle in the circuits I was looking at. I also wanted to add a timer to the device to allow it shut off after a predetermined time so that batteries were not wasted powering a fully charged device. To do that with separate chips was just getting silly. I was going to need something with some brains.
As I was browsing Radio Shack I bumped into the Parallax Basic Stamp kit they sell. The Basic Stamp is simple microcontroller, programmed in a dialect of BASIC. Just what I was going to need. I picked that kit up and took it home to start learning. It was an MCU with support chips all on a single board so I could not use this one in the final design but I knew it would be useful for other projects anyway. In a couple of nights I had my smart charger and it was pretty good. Now I could even have it indicate it’s battery state with Green/Yellow/Red and do so only when a button was pushed to save the juice of lighting LEDs. A couple of problems surfaced though.
Cost - The basic stamp was around $40 for the IC. Pretty steep to shell out for a dedicated charger. Also the stamp had no way to really accurately note the passage of time. I could rather crudely count the number of times it ran the main loop and get pretty close but any changes in the execution flow added errors and they could accumulate quickly. There was also the sleep mode glitch that causes it to stop asserting its output every so often while sleeping. Also it was slow. The main loop was slow enough that button presses felt sluggish. I continued my search for something a bit more practical.
That’s when I ran into the Propeller chip. At $8.00 it was more reasonable in cost and the killer was that it was MANY times more powerful than the Basic Stamp. In fact it has 8x32bit processors running at 80MHz in the chip and requires only an external crystal and EEPROM chip to get working. I snapped one up and started breadboarding my design with it as soon as it arrived. In a couple of weeks I had my basic design from the Stamp ported over to the Propeller. It’s programming language is completely different and thus you could not copy-n-paste so it took some learning and translation. In a couple more weeks I had it running the project multi-processor meaning my interface code to monitor the buttons was independent of the backend code watching the battery and so the whole thing just felt more responsive.
I also located the two regulators I needed in the Linear Technology series. The LT1529 5V regulator was perfect in that it did not use up much current to drop the battery voltage even when a heavy load was applied to the USB port. It included a shutdown input that allows the processor to directly command it to turn off the 5V output. This eliminated the need for external circuitry to provide that function. In a few more weeks I had my board soldered together on a protoboard and the functionality was all there. It has been charging devices ever since.
The Design / Operation
The basic design uses two push buttons, three LEDs and some passive components to measure the voltage using an RC time circuit. The RC time measures the time the battery voltage takes to charge a capacitor to the point of tripping a logic high on the Propeller’s input pin. The system measures this many times a second. The longer that process takes the lower the battery voltage. Using that information I can gauge when the battery is at a certain voltage level.
The system also watches for any large drops in battery voltage after startup. This usually indicates a heavy load has been applied to the battery. If it senses such a load it will switch to a second set of battery state trip points that better represent the discharge curve of the batteries under high current. If it later detects a large rebound then it will switch back to the low current trip points since the load on the batteries has been reduced. It’s not fool-proof but it does generally detect the load correctly.
The system generally will indicate the lowest state the batteries reached under load no matter what the unloaded voltage now indicates.
The buttons provide the user with the ability to do the following:
- Check battery state. The device only indicates this on the LEDs when the button is pushed to conserve power.
- Cycle through auto-off timers. Each press cycles through the timers. (None, 1hr, 2hr, 3hr)
- Change battery types. Holding the check battery button will switch to Alkaline mode where the device will run the batteries all the way out before stopping. Holding again will put it back into NiMH mode where full-discharge is prevented.
- Command sleep. Holding the timer button will put the device into sleep mode where it draws only a tiny amount of current. This allows the device to preserve the knowledge of battery state so that when it wakes up and the battery voltage has rebounded with the load removed it does not go back to indicating a higher charge. Sleeping it is what you want to do so long as you are using the same set of batteries.
The LEDs provide the battery state info and other status info. Normal operation is to flash an LED every 5 seconds.
Status flashes (Single brief flash every 5 seconds)
• Green flash - Normal operation, Battery good.
• Yellow flash - Timer operation, Battery good.
• Red flash - Battery low.
Pressing the Battery Check button will cause the device to indicate it’s charge state. This is held for several seconds.
Battery check lights
• Green - approx 30% or more charge remains.
• Yellow - approx 30% or less charge remains.
• Red - approx 10% or less charge remains.
* Note these are approximations. Battery voltage can vary with the load applied and that can shift the numbers a bit in one direction or the other. Small, low current, loads may indicate green down to below 20% because of how little they depress the battery voltage when applied and how steep the final portion of the battery discharge curve is for light loads.
Pressing the Timer button will cycle the auto-off timer setting indicated by the LEDs. The LED is lit for several seconds with each press.
Timer Set Lights
• All LEDs - Timer off.
• Green - 1hr Timer.
• Yellow- 2hr Timer.
• Red- 3hr Timer.
Holding the Battery Check button will change battery modes (NiMH/Alkaline)
Battery Mode Lights
• Flashing green - NiMH
• Flashing red - Alkaline
Holding the Timer button will sleep the device. This is acknowledged with 5 short flashes of the red LED just before sleep mode. Sleep mode is indicated by occasional short flashes of the Red LED about 2 - 3 seconds apart.
Overall I’m pleased with it. I still need to get some type of enclosure for it and figure out how to handle the battery pack. Finding anything with room for 6AA’s is not easy so I may end up making the batteries external. I reduced the clock to 40MHz to save power and according to my measurements the supervisor circuit draws around 15mA total above the draw of the device charging. So I got a ton of functionality into the device for roughly the same loss as that first 7805 regulator. Not sure it’s truly practical but It’s already come in handy a few times.
The LEDs and buttons are going to be mounted using a header to bring them out to the panel. Trying to board mount them all and finding an enclosure to accommodate that was going nowhere largely because the LT1529 is a vertical part and needs a heat-sink but also the height of the DIP chips in sockets also will not allow for it. I hate those cheesy Radio Shack red-cap push buttons so I want to get my tact buttons up to the surface.
Post Edited (photomankc) : 11/5/2009 10:21:14 PM GMT
**Code and Schematics and other documents to follow**
The PropCharger is a USB device charger powered by 6AA batteries to allow it to recharge large capacity USB devices using standard AA rechargeable batteries. The heart of the charger is a Parallax Propeller microcontroller and 2 voltage regulators. One regulator supplies the microcontroller with the 3.3V supply it requires and the other powers the USB device at 5V. The 5V regulator can provide a solid 5V output with a battery voltage as low as 5.5V Practical limitations of rechargeable batteries however limit the system to about 6V. Discharging the batteries more may damage them, which is what the MCU is there to prevent.
Background
This all started with the simple idea of making a brain-dead recharger for an IPOD Touch. Most of the LiPo batteries out there were not terribly high capacity and most would only fully charge a high-capacity device one or less times. My original design was a simple 7805 regulator and LED from Radio Shack and some wire on a two inch perfboard. It worked. It had two huge flaws though. First was that it was horribly inefficient. It burned a large part of the power as heat and provided next to no benefit for that. Second, it was brain dead. Leave the batteries attached and they would be sucked dry. Very bad news for rechargeable batteries. They do not tolerate being discharged completely very well. So simple and neat, but not terribly useful.
Next I started looking for IC solutions to the second issue. There are ways to achieve it but they all involved fiddly circuits with analog components and there was always a snag. A big one was the HUGE rebound that NiMH batteries have in voltage when they are unloaded. They can be next to dead and rebound by more than a volt when the load is removed which was hard to handle in the circuits I was looking at. I also wanted to add a timer to the device to allow it shut off after a predetermined time so that batteries were not wasted powering a fully charged device. To do that with separate chips was just getting silly. I was going to need something with some brains.
As I was browsing Radio Shack I bumped into the Parallax Basic Stamp kit they sell. The Basic Stamp is simple microcontroller, programmed in a dialect of BASIC. Just what I was going to need. I picked that kit up and took it home to start learning. It was an MCU with support chips all on a single board so I could not use this one in the final design but I knew it would be useful for other projects anyway. In a couple of nights I had my smart charger and it was pretty good. Now I could even have it indicate it’s battery state with Green/Yellow/Red and do so only when a button was pushed to save the juice of lighting LEDs. A couple of problems surfaced though.
Cost - The basic stamp was around $40 for the IC. Pretty steep to shell out for a dedicated charger. Also the stamp had no way to really accurately note the passage of time. I could rather crudely count the number of times it ran the main loop and get pretty close but any changes in the execution flow added errors and they could accumulate quickly. There was also the sleep mode glitch that causes it to stop asserting its output every so often while sleeping. Also it was slow. The main loop was slow enough that button presses felt sluggish. I continued my search for something a bit more practical.
That’s when I ran into the Propeller chip. At $8.00 it was more reasonable in cost and the killer was that it was MANY times more powerful than the Basic Stamp. In fact it has 8x32bit processors running at 80MHz in the chip and requires only an external crystal and EEPROM chip to get working. I snapped one up and started breadboarding my design with it as soon as it arrived. In a couple of weeks I had my basic design from the Stamp ported over to the Propeller. It’s programming language is completely different and thus you could not copy-n-paste so it took some learning and translation. In a couple more weeks I had it running the project multi-processor meaning my interface code to monitor the buttons was independent of the backend code watching the battery and so the whole thing just felt more responsive.
I also located the two regulators I needed in the Linear Technology series. The LT1529 5V regulator was perfect in that it did not use up much current to drop the battery voltage even when a heavy load was applied to the USB port. It included a shutdown input that allows the processor to directly command it to turn off the 5V output. This eliminated the need for external circuitry to provide that function. In a few more weeks I had my board soldered together on a protoboard and the functionality was all there. It has been charging devices ever since.
The Design / Operation
The basic design uses two push buttons, three LEDs and some passive components to measure the voltage using an RC time circuit. The RC time measures the time the battery voltage takes to charge a capacitor to the point of tripping a logic high on the Propeller’s input pin. The system measures this many times a second. The longer that process takes the lower the battery voltage. Using that information I can gauge when the battery is at a certain voltage level.
The system also watches for any large drops in battery voltage after startup. This usually indicates a heavy load has been applied to the battery. If it senses such a load it will switch to a second set of battery state trip points that better represent the discharge curve of the batteries under high current. If it later detects a large rebound then it will switch back to the low current trip points since the load on the batteries has been reduced. It’s not fool-proof but it does generally detect the load correctly.
The system generally will indicate the lowest state the batteries reached under load no matter what the unloaded voltage now indicates.
The buttons provide the user with the ability to do the following:
- Check battery state. The device only indicates this on the LEDs when the button is pushed to conserve power.
- Cycle through auto-off timers. Each press cycles through the timers. (None, 1hr, 2hr, 3hr)
- Change battery types. Holding the check battery button will switch to Alkaline mode where the device will run the batteries all the way out before stopping. Holding again will put it back into NiMH mode where full-discharge is prevented.
- Command sleep. Holding the timer button will put the device into sleep mode where it draws only a tiny amount of current. This allows the device to preserve the knowledge of battery state so that when it wakes up and the battery voltage has rebounded with the load removed it does not go back to indicating a higher charge. Sleeping it is what you want to do so long as you are using the same set of batteries.
The LEDs provide the battery state info and other status info. Normal operation is to flash an LED every 5 seconds.
Status flashes (Single brief flash every 5 seconds)
• Green flash - Normal operation, Battery good.
• Yellow flash - Timer operation, Battery good.
• Red flash - Battery low.
Pressing the Battery Check button will cause the device to indicate it’s charge state. This is held for several seconds.
Battery check lights
• Green - approx 30% or more charge remains.
• Yellow - approx 30% or less charge remains.
• Red - approx 10% or less charge remains.
* Note these are approximations. Battery voltage can vary with the load applied and that can shift the numbers a bit in one direction or the other. Small, low current, loads may indicate green down to below 20% because of how little they depress the battery voltage when applied and how steep the final portion of the battery discharge curve is for light loads.
Pressing the Timer button will cycle the auto-off timer setting indicated by the LEDs. The LED is lit for several seconds with each press.
Timer Set Lights
• All LEDs - Timer off.
• Green - 1hr Timer.
• Yellow- 2hr Timer.
• Red- 3hr Timer.
Holding the Battery Check button will change battery modes (NiMH/Alkaline)
Battery Mode Lights
• Flashing green - NiMH
• Flashing red - Alkaline
Holding the Timer button will sleep the device. This is acknowledged with 5 short flashes of the red LED just before sleep mode. Sleep mode is indicated by occasional short flashes of the Red LED about 2 - 3 seconds apart.
Overall I’m pleased with it. I still need to get some type of enclosure for it and figure out how to handle the battery pack. Finding anything with room for 6AA’s is not easy so I may end up making the batteries external. I reduced the clock to 40MHz to save power and according to my measurements the supervisor circuit draws around 15mA total above the draw of the device charging. So I got a ton of functionality into the device for roughly the same loss as that first 7805 regulator. Not sure it’s truly practical but It’s already come in handy a few times.
The LEDs and buttons are going to be mounted using a header to bring them out to the panel. Trying to board mount them all and finding an enclosure to accommodate that was going nowhere largely because the LT1529 is a vertical part and needs a heat-sink but also the height of the DIP chips in sockets also will not allow for it. I hate those cheesy Radio Shack red-cap push buttons so I want to get my tact buttons up to the surface.
Post Edited (photomankc) : 11/5/2009 10:21:14 PM GMT
Comments
Adding some of the support documents I used developing it in this post....
I had started looking at slowing to 20Mhz but after putting it on paper I decided that in all but the most meager current drains it really didn't make much difference so I stuck with 40Mhz.·· That speed still allows my to keep the TV diagnostic code running so if I want to see what's going on, I just pop on my little header-based TV Out board and I get a debug screen.· So far it really shines on high drain stuff like the IPOD touch.· I found that I could usually get two nearly full charges out of it.· Even my expensive little USB LiPo battery pack can't do it twice.· The only down-side is the high self-discharge rate of high capacity NiMH batteries.· You really have to be using freshly charged batteries with it.·
I never could get really satisfactory indicators for the really low current-drain loads.· It has such a strong platue and such a steep drop that unless you are right on the money it can float just over your trip point forever or just under it forever.··I tried to err on the side of not going yellow way early so the end result is a rather long green indication and then a very quick ride to cut-off.· · There are just limits to how accurate you can be based on voltage alone.
Post Edited (photomankc) : 11/6/2009 6:36:06 AM GMT