Well its been a while so first an update
My dad has semi retired lately and looking for something to do he has been making wooden things to sell in wood galleries around the place.
He based it on this earlier one and has made some improvements ;->
http://www.candlepowerforums.com/vb...-a-wooden-keyring-torch-for-my-mum&highlight=
So he has been making these for a while now, and he was looking for something to pep them up, I of course opened my big mouth and volunteered to help him.
Now I'm designing a lipo based USB rechargable multi-mode multi-LED behemoth, and it still has to fit into the same package!.
How hard could it be I think, I've designed battery powered stuff with chargers and motors and all sorts of fanciness in the past, I should have known better lol.
Anyway I figured why not open source the design, you guys have helped me in the past ;->
So first some background.
His current torches have a pair of renata(swiss) CR2003 cells in them and rely on the bent leg under the button to run.
He is was doing it with a super wide nichia LED NSDW570GS which is great for lighting up an entire room, but lacks some throw so probably feels less bright for the punters.
Or a (horribly over driven) NSPW500GS-K1 which is blindingly bright when you are trying to light up the keyhole but is super throwy.
On to the new design.
After some playing around with the two LED's we decided we should put both into the package, as far as holding two torches and wandering around at night goes, it gives a really nice ambient light all around and lights up the path a distance in front of you to boot.
Obviously we want the most battery power that can fit in the package, Initially I figured we'd be able to fit in something like a 200mah cell, but that contoured shape really cuts into the available space for a prismatic cell and I wound up settling on this http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=23309 80mah lipo. For $1.12 its cheaper than the two coin cells! unfortunately It'll happily put out enough current to blow both LED's in a second (or much less) so some sort of control is needed.
For charging I have used the MCP73831 (or the 2 viariant, I can never remember) in the past to charge 10Ah worth of cells so I was keen to keep on using that.
For the topology initially I was planning on using a NCP5007 boost controller and running both LED's in series to avoid a buck/boost layout which is always a pain.
I even got to the point of a board layout.
The yellow boarder is is the extent I'm allowed to put components, its 17mm X 15mm outside that is where the board gets clamped.
I'm using kicad for the design work here btw, the newer versions are pretty shiny, the only thing missing is the parts libraries. They can be a bit spotty.
The huge thing going off to the left is a micro usb connector lol.
So this was all looking good until I went and costed it, turns out it would add around $15 to the retail of the torches by the time the shop takes their cut.
That and the two LED's don't match, the narrow one maxes out at like 20-30ma and the wide one wants 70ma.
Back to the drawing board.
I had always wanted to put a micro controller in so we could have it latch on and perhaps do other fancy things so having used AVR's in the past I looked at attinys.
Turns out you can get them starting at like 60 cents for ones with sufficient herbs to run multiple PWM channels and differential ADCs etc.
So I started following that up,
I had a close look at the forward voltage vs current spec and it turns out I can run one LED off a 3.6v cell and actually get most of the battery life out at full drive current.
Naturally, being battery powered I want to be efficient so I look at switch mode.
Turns out that unless I get into the MHZ range the inductors wind up being HUGE and expensive. For a laugh I look at doing it in a linear fashion.
Running the numbers, because the voltage drop is generally so small its actually not *terrible* worst case efficency, IE maximum battery voltage, minimum LED current its still something like 70%.
I'm onto a winner!
The plan is to run the fets in their linear region, sensing the current through a sense resistor and modulate the fet output with PWM through a RC filter.
I've never driven a fet in its linear region, avoided it like the plague lol so, prototype time.
I pick at atmega16u4, partly because I have one and partly so I can use the USB interface to program stuff with.
After many false starts we get the mill cutting PCB's again. (pcb2gcode)
And this my friends is the creation!
its rather rough ;->
however lessons learnt, you must connect ureg to something or otherwise feed ucap something.
Blew up the usb voltage regulator :-<
I got an ultralow quiescent current 3.3v regulator and put that on there, not heeding the manufacturers advice that it needed rather a large cap on its output in order to work.
After screwing around for a an hour I finally read the datasheet and put the cap on there, still nothing. Thankfully dad persisted and realised we were looking at the damn thing backwards.
End result, we have a USB programming connection, and an ugly looking board ;->
YAY!
And here's a schematic.
Anyway after the usual fits and starts we now have a working prototype, the output from the ADC with its 40x gain is nothing like what I expected but it seems to work. I can run the LED anywhere between 5 and 70ma and the control loop is stable, for the moment I'm just doing a simple "bang bang" type control, if measured current < setpoint then output ++; etc but its sufficent, when i dropped the clock frequency to 8mhz it started to oscillate but I have some thoughts on how to fix that.
Interesting sidebar. I broke the laws of physics, V != IR. Well at least as far as my ability to measure amperage with my multimeter by measuring voltage drop across a 240 ohm resistor goes.
Vary the supply voltage, the AVR would vary the gate drive in response to a varying voltage across its .82 ohm sense resistor, but the voltage I measured across the 240 ohm "safety" resistor i had in series with the LED varied all over the shop.
That's enough from me, that's where we are up to, any questions I'll try and answer them, any suggestions I am all ears. :D
The plan now is to make a new prototype, using an attiny84A which is what I want to use in production, (3mm to a side, 20 pads, my god, the proto will be using the tsop not the vsqfn thankfully lol) and using a new dual N chan fet, rather than the pair of discrete ones I have currently, its right on the edge of what we can make but I want to be sure it will respond the same. I only have about half a volt of range before the fet saturates, so I'm a little wary about it all to be honest.
My dad has semi retired lately and looking for something to do he has been making wooden things to sell in wood galleries around the place.
He based it on this earlier one and has made some improvements ;->
http://www.candlepowerforums.com/vb...-a-wooden-keyring-torch-for-my-mum&highlight=
So he has been making these for a while now, and he was looking for something to pep them up, I of course opened my big mouth and volunteered to help him.
Now I'm designing a lipo based USB rechargable multi-mode multi-LED behemoth, and it still has to fit into the same package!.
How hard could it be I think, I've designed battery powered stuff with chargers and motors and all sorts of fanciness in the past, I should have known better lol.
Anyway I figured why not open source the design, you guys have helped me in the past ;->
So first some background.
His current torches have a pair of renata(swiss) CR2003 cells in them and rely on the bent leg under the button to run.
He is was doing it with a super wide nichia LED NSDW570GS which is great for lighting up an entire room, but lacks some throw so probably feels less bright for the punters.
Or a (horribly over driven) NSPW500GS-K1 which is blindingly bright when you are trying to light up the keyhole but is super throwy.
On to the new design.
After some playing around with the two LED's we decided we should put both into the package, as far as holding two torches and wandering around at night goes, it gives a really nice ambient light all around and lights up the path a distance in front of you to boot.
Obviously we want the most battery power that can fit in the package, Initially I figured we'd be able to fit in something like a 200mah cell, but that contoured shape really cuts into the available space for a prismatic cell and I wound up settling on this http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=23309 80mah lipo. For $1.12 its cheaper than the two coin cells! unfortunately It'll happily put out enough current to blow both LED's in a second (or much less) so some sort of control is needed.
For charging I have used the MCP73831 (or the 2 viariant, I can never remember) in the past to charge 10Ah worth of cells so I was keen to keep on using that.
For the topology initially I was planning on using a NCP5007 boost controller and running both LED's in series to avoid a buck/boost layout which is always a pain.
I even got to the point of a board layout.
The yellow boarder is is the extent I'm allowed to put components, its 17mm X 15mm outside that is where the board gets clamped.
I'm using kicad for the design work here btw, the newer versions are pretty shiny, the only thing missing is the parts libraries. They can be a bit spotty.
The huge thing going off to the left is a micro usb connector lol.
So this was all looking good until I went and costed it, turns out it would add around $15 to the retail of the torches by the time the shop takes their cut.
That and the two LED's don't match, the narrow one maxes out at like 20-30ma and the wide one wants 70ma.
Back to the drawing board.
I had always wanted to put a micro controller in so we could have it latch on and perhaps do other fancy things so having used AVR's in the past I looked at attinys.
Turns out you can get them starting at like 60 cents for ones with sufficient herbs to run multiple PWM channels and differential ADCs etc.
So I started following that up,
I had a close look at the forward voltage vs current spec and it turns out I can run one LED off a 3.6v cell and actually get most of the battery life out at full drive current.
Naturally, being battery powered I want to be efficient so I look at switch mode.
Turns out that unless I get into the MHZ range the inductors wind up being HUGE and expensive. For a laugh I look at doing it in a linear fashion.
Running the numbers, because the voltage drop is generally so small its actually not *terrible* worst case efficency, IE maximum battery voltage, minimum LED current its still something like 70%.
I'm onto a winner!
The plan is to run the fets in their linear region, sensing the current through a sense resistor and modulate the fet output with PWM through a RC filter.
I've never driven a fet in its linear region, avoided it like the plague lol so, prototype time.
I pick at atmega16u4, partly because I have one and partly so I can use the USB interface to program stuff with.
After many false starts we get the mill cutting PCB's again. (pcb2gcode)
And this my friends is the creation!
its rather rough ;->
however lessons learnt, you must connect ureg to something or otherwise feed ucap something.
Blew up the usb voltage regulator :-<
I got an ultralow quiescent current 3.3v regulator and put that on there, not heeding the manufacturers advice that it needed rather a large cap on its output in order to work.
After screwing around for a an hour I finally read the datasheet and put the cap on there, still nothing. Thankfully dad persisted and realised we were looking at the damn thing backwards.
End result, we have a USB programming connection, and an ugly looking board ;->
YAY!
And here's a schematic.
Anyway after the usual fits and starts we now have a working prototype, the output from the ADC with its 40x gain is nothing like what I expected but it seems to work. I can run the LED anywhere between 5 and 70ma and the control loop is stable, for the moment I'm just doing a simple "bang bang" type control, if measured current < setpoint then output ++; etc but its sufficent, when i dropped the clock frequency to 8mhz it started to oscillate but I have some thoughts on how to fix that.
Interesting sidebar. I broke the laws of physics, V != IR. Well at least as far as my ability to measure amperage with my multimeter by measuring voltage drop across a 240 ohm resistor goes.
Vary the supply voltage, the AVR would vary the gate drive in response to a varying voltage across its .82 ohm sense resistor, but the voltage I measured across the 240 ohm "safety" resistor i had in series with the LED varied all over the shop.
That's enough from me, that's where we are up to, any questions I'll try and answer them, any suggestions I am all ears. :D
The plan now is to make a new prototype, using an attiny84A which is what I want to use in production, (3mm to a side, 20 pads, my god, the proto will be using the tsop not the vsqfn thankfully lol) and using a new dual N chan fet, rather than the pair of discrete ones I have currently, its right on the edge of what we can make but I want to be sure it will respond the same. I only have about half a volt of range before the fet saturates, so I'm a little wary about it all to be honest.