# Hotwire Regulator Design Collaboration Project part 3



## Alan B (Jan 24, 2009)

*






The Programmable Hotwire Driver*, as it has come to be called, has spawned some application specific projects. Basic design continues in this thread, and specific implementation threads are linked at the bottom of this posting. The photo above is of Alan's [email protected] first prototype, designed to drop-in to a D [email protected] and occupy the space for the original switch.

*This Product is Available from the Order Thread:*
https://www.candlepowerforums.com/threads/231886

*Now on to this, the third section of the Design thread:*

(Material from the first post of the previous thread, edited):

Now that I've built a [email protected] I can see the value of a soft starting regulator for incandescent flashlights. But I don't see much availability. ...

Being the electronics and software engineer that I am makes me think of how to build a simple regulator. With today's microprocessors having PWM, ADCs, temperature detection and just about everything else (memory, clock, ram, etc) built in, it would seem to me that very few parts are required. I have done projects with AVR and PIC microprocessors. It is amazing what can be done with a single small low lead-count chip. (The design developed here uses only about a dozen parts).

Requirements:

Primary Features:

1) soft start
2) regulated RMS bulb voltage by PWM for high efficiency
3) provide battery overdischarge protection
4) provide overtemperature protection for the electronics
5) provide selectable voltage levels (programmable Vbulb)

(10/4/08, above items are coded and tested, the FET power driver is tested)

6) have a lock off sequence for safety - secret unlock sequence to prevent accidental turnon (or provide a 'normal' flashlight Vbulb mode that would run the bulb at a lower setting that is very safe, and keep the turbo mode for expert access)
7) provide a 'timeout' feature to dim and shutdown to limit runtimes when desired
8) make it user reprogrammable, with free software tools and simple/inexpensive PC interface
9) have some public open sourcecode so folks could play with the user interface and make customized versions

As of 1/2009 the above requirements have been accomplished

10) have a public pcb layout available so folks could roll their own small batch if needed
11) one or more folks can make the hardware (and sell it), over time if they become unavailable someone new can step in and make hardware that will work with the same or slightly modified software
12) be a simple enough design to allow a builder to make one without a pcb (DIY dead-bug style, etc)

Secondary Features (possibly developed later):

1) provide one button reprogramming in the field for voltage settings, etc
2) provide a minimum off timer to reduce bulb wear from over clicking friends
3) auto-detect battery type and set voltage protection
4) other ideas??

It does not take a lot of parts to do this. A good Power FET directly driven from an AVR or PIC micro PWM output, and a way to measure the actual battery voltage, plus some calculations to determine the effective (RMS) voltage and adjust smoothly to the desired value. Approximately three processor I/O pins are required:

1) pushbutton input (option, some designs don't need this)(need on-switch detection in some cases)
2) pwm out
3) battery voltage

-) bulb RMS voltage is calculated from battery V and duty cycle of PWM

This would place square wave current pulses into the filament, but the frequency can be selected to be high enough to avoid problems, but low enough to manage losses in the switching FET. The thermal inertia of the filament provides the filtering, so pulses must be short enough for the temperature to be essentially constant from pulse to pulse.
We now know that other earlier designs work this way. JimmyM's soft start is not a micro. AW's is PWM but not a regulator. Most others I find (AWR et al) are no longer available.

Anyone interested in something like this? I don't have the time to do the whole project, but I may be able to do some part of it. Perhaps it could be some kind of group project?

Any interest? Any important requirements or concerns about this simple approach?? Anyone want to work on this???

If you have any links to similar projects (past or present), post them in this thread so we can review them and give them credit.

If you have done similar work or have ideas, chime in and let us know!

-- Alan


*Today (1/24/2008) we start part 3 of the thread. 

Part 1 is here:*

https://www.candlepowerforums.com/threads/186291

*Part 2 is here:*

https://www.candlepowerforums.com/threads/209098

*Project Status (1/24/2009)*

Alan has a prototype drop-in "Sled" working in a D [email protected] JimmyM has a development PCB working (and he may have a couple available - contact him directly). JimyM is working on a version to fit under a KIU socket adapter. wgiles is working on a version to mount in a special SF M6 battery holder. (links at bottom of this post).

*Project Status Update (July 2009)*

Production Regulators have started shipping. See the order thread for more information:
https://www.candlepowerforums.com/threads/231886

*Schematic*

http://akbeng.com/flash/hwreg/hrdc1d.bmp

*Earlier Notes:*

*We have Code and Hardware Working:*







The above is an actual scope capture of the output of the CPU driving PWM to the FET gate (in blue), and the output of the FET (in red) while driving a WA1185 bulb on Alan's test [email protected] D Sled prototype PC Board.

We have prototype hardware running. Alan B's sled board, and wquiles' protoboard. At this point (10/4/2008) we are working on software and calibration, and have worked through a couple of minor problems. Alan built and tested the USBtinyISP programmer. This is a $22 kit for programming the micro. This will be useful for loading the software, changing the parameters, and trying out different versions of the software. Advanced users and builders will want a programmer to have complete control over the software in their flashlights.

Alan has developed software using the Atmel STK500 board. This board has the programming capability, a socket for the CPU, and an LED and switch that can be jumpered to the chip. Using this Alan has developed software that does most of the basic functions - variable levels, voltage regulation, temperature and low battery cutout, etc. This is still in work, but it is doing most of the important functions required for this project.

Prototypes of the hardware are working. JimmyM and Alan are both working on pc boards. Alan's board is made and working, and Jim's test board is designed but not cut yet.

We have a couple of user interfaces including VariLevel Ramped with optional double-click boost, and On/Off. We have soft start. We have RMS feedback regulation. 


*Next Step:*

The calibration problem appears to be solved, so it is about time to package this in a flashlight, and make some 'operational' software versions. The dynamic calibration needs to be finished up. Perhaps a multilevel interface option would be useful. Possibly one or more small PCBs designed to fit inside "C", "D" [email protected] or SF M6's. High Power bulb testing would be interesting. Will wants to work on a one button interface and a SF M6 version. Jim wants to try a "high power" version with a driver.


*Signup Sheet:*

Send me a pm if you want to be added to this list:

Hardware Design: mostly done, here on the forum, by Alan B, JimmyM and That_Guy; with lots of helpful input and encouragement by folks like LuxLuthor, and others.

Hardware Prototyping: Alan B, JimmyM and wquiles working on.

Application Specific versions - wquiles is working on the SF M6 version, and JimmyM is working on a D [email protected] version to fit under a KIU base. Alan is working on a drop-in version for the D [email protected] called the [email protected] (links at bottom of this post).

High Power Testing - Possibly Jim and LuxLuthor?

Software Development: The software is pretty far along at this point. Based on AVR-GCC in WinAVR and AVR Studio for this. All Free software tools. Thus far Software is by Alan B with input and feedback from lots of others. (JimmyM is developing a software variant to work with the similar Tiny84 chip).


*Test Programs: (these are done)*

* FP1: Toggle the FET Gate Output (very slow or 100 hz, 50% duty cycle)
* FP2: Electronic Pushbutton Switch (on/off)
* FP3: Always On, Fixed PWM, Soft Start
* FP4: Pushbutton, Fixed PWM, Soft Start
* FP5: Pushbutton, VariLevel PWM, Soft Start
* FP6: Always On, Regulated, Calibrated, Soft Start
* FP7: Pushbutton, Regulated, Calibrated, Soft Start
* FP8: Test Suite for ADC, PWM, Regulation Algorithms
* FP9: Flashlight Program with lots of features

More to come.


*Design File Area: (schematics, code, scope traces, data)*

http://akbeng.com/flash/hwreg/ 


*References:*

The Lightbrain 2002 DIY regulator is very similar to the design goals for this project:
http://lasertagparts.com/lightbrain/free_regulator.htm 

AWR HotDriver (soft start, linear):
http://www.cpfmarketplace.com/mp/showthread.php?t=107783

PIR1 PWM Regulator Thread:
https://www.candlepowerforums.com/threads/107211

PIR1 Regulator Manual:
http://greenengineering.se/PIR1/PIRmanual.pdf 

LVR (Willie Hunt) Lamp Voltage Regulator: 
http://www.cs.indiana.edu/~willie/lvr.html 

That_Guy Regulator (similar to LightBrain):
http://img169.imageshack.us/img169/5875/pwmregulatorff7.png
http://rapidshare.com/files/87979929/PWM_Regulator.zip.html

JimmyM JM-SST Soft Start:
https://www.candlepowerforums.com/threads/181866

AW Soft Start:
http://candlepowerforums.com/vb/showthread.php?t=166223

Kiu Bipin Socket:
https://www.candlepowerforums.com/threads/171607

(Destructive) Bulb Testing - lots of bulb data:
https://www.candlepowerforums.com/threads/179748

More Bulb Data (for the SF M6, but useful for others):
https://www.candlepowerforums.com/threads/204157

Atmel Tiny85 Microprocessor Info:
http://www.atmel.com/dyn/products/product_card.asp?part_id=3612

Atmel AVR ISP2 USB Programming Adapter:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=ATAVRISP2-ND

AvrFreaks on the Tiny85:
http://www.avrfreaks.net/index.php?module=Freaks Devices&func=displayDev&objectid=102

Low Cost USB programmer (tested, works):
http://www.ladyada.net/make/usbtinyisp/

AvrDude Programming Software (included in WinAVR):
http://www.ladyada.net/make/usbtinyisp/avrdude.html


*Application Projects based on this Project's Design:*

D [email protected] Drop-in by Alan B:
https://www.candlepowerforums.com/threads/218506

SF M6 thread by wquiles:
https://www.candlepowerforums.com/threads/215806

D [email protected] under Kiu Base thread by JimmyM:
https://www.candlepowerforums.com/posts/2743186


eof


----------



## Alan B (Jan 24, 2009)

*Easy Calibration Setup*

Today I added a quadclick to 5.00 volt option to the interface. Then I used this to calibrate the ADC. 

The Procedure:

Load the CPU with the default software which calibrates based on the specs for the CPU and resistors.

Quadclick the flashlight to output 5.00 volts to the bulb output (where I have my meter plugged in).

Take the value that I read there (in this case 4.66V) and put that value into the software.

Compile and reload the CPU.

Quadclick to go to 5.00V and verify the reading is 5.00V.

It Works!

Now if an averaging meter is used we need to read battery voltage and average bulb voltage instead of the one reading, but I can put those into the program as another option. So the user does NOT need to do ANY calculations. Merely set the output to 5.00V and read it, and read the battery voltage, and put both numbers in. Compile and reload the chip. Calibrated.

I chose 5.00V since it should not hurt any bulbs if accidentally triggered with a bulb in. It is actually a good medium level for the [email protected] The feature can be removed after calibration if desired.

== Alan


----------



## SafetyBob (Jan 24, 2009)

Alan, great recap of the massive amount of work that has gone into this project. The sight of your prototype sled is also a work of art. It is obvious that we are quickly closing in on a completed sled and testing. That is great news. 

I will be wanting at least 2 of these for incan fun here in Oklahoma. 

Thanks to everyone who has contributed even in the smallest degree, it has made this a superior effort that will be very rewarding for all of us. 

Bob E.


----------



## Alan B (Jan 24, 2009)

SafetyBob said:


> Alan, great recap of the massive amount of work that has gone into this project. The sight of your prototype sled is also a work of art. It is obvious that we are quickly closing in on a completed sled and testing. That is great news.
> 
> I will be wanting at least 2 of these for incan fun here in Oklahoma.
> 
> ...



Thanks Bob. Interest noted in the feeler thread post #5.

A bit more recent status detail:

The [email protected] board prototype design #2 is in the mail and I should have it monday. Actually it is in the UPS.

I have been doing a lot on the software. Redid the UI (user interface) code and compressed the code, and cleaned a lot of old junk out of it. Added lockout, doubleclick to turbo, tripleclick to half voltage options.

The new Fluke 189 meter is really nice. Used it to calibrate the ADC a bit ago. Really nails it. I wanted to get a meter that would make it really easy to calibrate these since it looks like I will have a bunch to calibrate, and I want to farm that work out to my kids when there are a lot to do. It needs to be straightforward for that to be efficient and accurate.

When we calibrate it we can write down the pre-calibration voltage values so the user can use those values in the software if they need to reload the chip, and save them the step of recalibrating. It is not that hard to do a calibration, but it is an extra step if you are just trying to change an option in the software.

-- Alan


----------



## JimmyM (Jan 24, 2009)

I have an update regarding the FET compensation.
It makes little difference.
No-Compensation
Vin_____1157 bulb_______1157+64447
13.5V___12.07V_________11.97V
25V_____12.03V_________11.98V

With Compensation
Vin_____1157 bulb_______1157+64447
13.5V___12.06V_________12.02V
25V_____12.03V_________12.00V

So a few hundreths of a volt. Keep in mind that the 64447 @ 25V only has ~10.4 Peak amps.
A different bulb, with more peak amps may show greater value to compensation.
I do have a 64275 that should pull a lot of amps at high Vin.
I'll test and get back to you.

Nope. no real difference.


----------



## SafetyBob (Jan 24, 2009)

I don't know Jimmy, I really think I might be able to see that 0.03VDC drop when I make my double head 623 and switch from one light on to two......now what am I supposed to do? 

I'll tell you. JUMP FOR JOY!!!

That kind of regulation I did not think was possible in this kind of build. Period. That is frankly amazing. And I am glad your kids will get involved to. I hope you slip them a dollar or two for doing that. I hope they will follow your footsteps into the electrical world. 

Interface sounds even better than we had ever imagined even three weeks ago. 

Please keep us up on the testing of the sled. 

Bob E.


----------



## JimmyM (Jan 25, 2009)

SafetyBob said:


> I don't know Jimmy, I really think I might be able to see that 0.03VDC drop when I make my double head 623 and switch from one light on to two......now what am I supposed to do?
> 
> I'll tell you. JUMP FOR JOY!!!
> 
> ...


Thanks for the kudos on the regulation, but it's Alan's kids that will be pressed into slave labor. Er I mean, assistance, yes. Assistance. Must remember that for Social Services, if I'm ever subpoena'd.
All kidding aside, my 7 year old daughter loves to come down to the shop and "help out". Even if that means me and her hooking up a 1.5V motor to my 50V bench supply and ramping it up until we let the smoke out.


----------



## wquiles (Jan 25, 2009)

JimmyM said:


> All kidding aside, my 7 year old daughter loves to come down to the shop and "help out". Even if that means me and her hooking up a 1.5V motor to my 50V bench supply and ramping it up until we let the smoke out.


That sounds like fun :devil:

Will


----------



## Alan B (Jan 25, 2009)

JimmyM said:


> Thanks for the kudos on the regulation, but it's Alan's kids that will be pressed into slave labor. Er I mean, assistance, yes. Assistance. Must remember that for Social Services, if I'm ever subpoena'd.
> All kidding aside, my 7 year old daughter loves to come down to the shop and "help out". Even if that means me and her hooking up a 1.5V motor to my 50V bench supply and ramping it up until we let the smoke out.



My kids are both young adults and I do remunerate them for services in my small business. Mostly it is pulling parts, packing and shipping. This project could be an opportunity for them to learn some new skills as well as helping me and getting things done a bit faster.

-- Alan


----------



## smflorkey (Jan 25, 2009)

Previous-thread quote from JimmyM: " All of my variables are declared as globals. Perhaps I'll try moving them into the main section. However, I have a routine that I call to reads the ADCs and sets the result as a variable I then use that variable in the main code. Does this variable need to be a global?"

I haven't done embedded programming so I may be missing something important, but in the big stuff where memory doesn't matter I would make your routine return a value to its calling point in main(). Something like

int cool_routine(int Vref, int ADC, int keepFirst, int sample_count, int read_count);

then later in main()

result = cool_routine(Vref, ADC, keepFirst, sample_count, read_count)

or

newState = oldState + cool_routine(Vref,ADC,keep1,sampleC,readC) * k;

In this way your routine looks a lot like a global variable. The value it returns can be assigned to a local variable or simply used directly.

Hope that helps. I've been enjoying reading this story. I may have to build a big incan (in my Copious Spare Time) so I can make use of the technology you all have shared.


----------



## Alan B (Jan 25, 2009)

smflorkey said:


> ...
> 
> I haven't done embedded programming so I may be missing something important, but in the big stuff where memory doesn't matter I would make your routine return a value to its calling point in main(). ...



Welcome to the thread, smflorkey!

You might enjoy programming these little chips!!

Many things that we routinely do in larger computers consume more resources than we like in the small chips. You can do them but once you figure out how to save codespace and time you may want to do that. I probably take it to an extreme, but I have programmed little chips over a long period and I enjoy the challenge. The sourcecode doesn't look as pretty perhaps, but it takes on its own rugged beauty in the efficiency. These days I'm getting the preprocessor to do all the hard lifting and reduce everything possible to small integer constants since those fit well in the 8 bit CPU.

Some of the philosophy when resources are at a premium:

Function call parameters are expensive. They have to be pushed on the stack and popped off the stack later. They take a lot of stack space, and RAM is small in these CPUs. Use them when necessary but it is generally much cheaper in code and memory space to access a global. Even a simple function call without parameters can be expensive as a lot of registers may need to be preserved. If the function is just doing a couple of lines of code it may be better done inline, or us a macro to avoid repeating the sourcecode.

In many CPUs globals are cheaper than locals to access. This is apparently not the case in the Tiny85 with GCC as moving globals to local in main caused a savings in codespace. Have to test the compiler/CPU to determine the resource cost. Know what code costs in time and space. Try test programs. Look at the code generated. Know your tools.

Wordsize - byte, integer, float - Bigger costs a lot, and floats cost a lot more. Use what is required and not more.

It is amazing what can be fit into a 2K processor (1K instructions). We can go to an 8K part in this package if necessary! Using a larger chip and less careful code generally causes hard to find bugs and reliability problems. So start small and build carefully.

-- Alan


----------



## JimmyM (Jan 25, 2009)

smflorkey said:


> Previous-thread quote from JimmyM: " All of my variables are declared as globals. Perhaps I'll try moving them into the main section. However, I have a routine that I call to reads the ADCs and sets the result as a variable I then use that variable in the main code. Does this variable need to be a global?"
> 
> I haven't done embedded programming so I may be missing something important, but in the big stuff where memory doesn't matter I would make your routine return a value to its calling point in main(). Something like
> 
> ...


I've changed my variable definitions. where/how. Now all variables are defined/declared within the main() section except where they are needed in the subroutines.
When I need a value from the subroutine I use the subroutine to return a value instead of storing the result to a global variable.

So...

uint16_t adcval = 0;
uint16_t adcvariable = 0;

void readADC(uint8_t newadmux, uint8_t dumpfirst, uint8_t samples, uint8_t divisor)
{
adc code stuff
}

main()
{
readADC(0x03,1,2,1);
adcval = adcvariable;
}

Becomes...

void readADC(uint8_t newadmux, uint8_t dumpfirst, uint8_t samples, uint8_t divisor)
{
uint16_t adcvariable; 
adc code stuff
return(adcvariable)
}

main()
{
uint16_t adcval;

adcval = readADC(0x03,1,2,1);

}

Now I'm using 10.5% program space, 0.0% data. Before the total was closer to 20% total. This is on the Tiny84.


----------



## Starlight (Jan 25, 2009)

Alan, your Easy Calibration Setup is a great idea. It solves the meter problems for all of us. Well Done!


----------



## Alan B (Jan 25, 2009)

Starlight said:


> Alan, your Easy Calibration Setup is a great idea. It solves the meter problems for all of us. Well Done!



Thanks.

I made some quiescent current measurements with the Fluke 189. It is about 7mA without shutting down the CPU. My code that shuts down the CPU took it down to 3mA. I expected less idle current, so I need to do more work on that program.

Good to see some higher current testing, Jim. Also those local instead of global variables sure saved you a lot of codespace!

Tonite the battery in my prototype finally ran down on me so I got to see the low battery code for real. It worked pretty well, though as the battery gets lower it really cannot do much more than turn off or dim way down. There just isn't enough power to do more than come on very low or go off.

The FAQ is taking shape in the [email protected] D Feeler thread. That should answer a lot of questions in one place. It may be a little tricky to handle the variations because the answers are not the same for all three variants, so we'll have to think about that. Possibly break it into sections.

I have added code that takes a bulb type, battery chemistry and number of cells, and fills in the voltages. There is still a manual override, but this way the standard values are there and one can just select the factors. This is all done at compile time so no codespace in the chip is required. More work for the preprocessor.

-- Alan


----------



## Alan B (Jan 28, 2009)

Alan B said:


> Thanks.
> 
> I made some quiescent current measurements with the Fluke 189. It is about 7mA without shutting down the CPU. My code that shuts down the CPU took it down to 3mA. I expected less idle current, so I need to do more work on that program.
> 
> ...



I made a change to the code and dropped the off-current to 300 uA which would take 270 days to drain Eneloops. I'm not done yet, I may reduce that further, but it will probably take minor hardware adjustments to accomplish that. (such as changing resistors and changing a bit of code). If we double that value one more time then the self-discharge will probably be equal to the drain and there is not much benefit available beyond that. The tailcap lockout is always there, too...

JimmyM asked what was done to reduce the current - essentially it took a one bit change. The CPU sleep state was not optimal. I had set it to "idle", I changed it to "power down". I don't recall which bit it is, but the code is in FP9 except for this one bit change in a constant. The processor consumption in power down is about 1uA, and all the clocks are stopped. I turned off the ADC before sleeping already. I need to double check if the Vref generator needs to be turned off separately, that is another item that might still be on.

I'm considering using the 1.1V ADC range which will also reduce the current. I believe Jim already did that. We could also stray from the specifications for the ADC input impedance and raise it (which would lower the divider current), but it is difficult to evaluate the consequence of that. Since I'm only using 8 bits I can probably get away with a bit more than the 10 bit codes. Getting good 10 bits from these ADCs is difficult.

On another item, I wrote code to sample the ADC in the center of the PWM. I have not tested it yet. Jim has already done this, but he has a fiducial there to test or interrupt on, and the PWM mode my code is in does not. So I checked to see what it takes to do a delay to the center of the PWM (finding the edge was already coded). Interestingly enough, it takes an argument to the low level gcc library delay function that is four times the PWM value. Which is trivial to do since you just shift the PWM value two bits left and call the delay loop with that value. I'll probably test the code, but I have a different technique that I plan to use that samples the pulse in several places.

A bit more dieting on the code has it at 55% of the 2K part, so there is a lot of space for improvements, and the code has a lot of features in there now. I use it every day as a flashlight, and it has a nice user interface and a very impressive range from a few lumens to a thousand or so. At 2 volts the light output is similar to a [email protected] solitaire (though it is orange), and at 10.8 volts it is more than required for most purposes. The boot-up memory value is midway between low and high, or 6.4 volts ((2+10.8)/2) which is a very nice useable level as well. I do have code that allows the memory to survive reboots, but that is not turned on at the moment.

Also the lockout function is currently reset by rebooting, so I will probably have to fix that and store the lockout in the nonvolatile memory. Perhaps that should be another option, do folks want the lockout to stay locked when the tailcap is loosened and the CPU reboots? It would seem to be a good idea if the lockout is to be very robust.

-- Alan


----------



## Alan B (Jan 28, 2009)

I started working on a feature that I thought about a long time ago but never pursued. This relates to using the three Vref's of the ADC for three voltage ranges. The Vref's are 5.0, 2.56 and 1.1 volts. Switching between these ADC ranges gives a very nice set of three fullscale voltages. I just need to set up the code so everything compensates for the change, including the scaling, the ADC initialization, and the calibration.

I will probably set it up so that the calibration voltage changes as well. So on the low voltage range the cal voltage will be 5.00 volts, 10.00 on the midrange and 20.00 volts on the high range, subject to change as I get the code done.

So by changing the settings in the compiler there will be three voltage ranges. That way there won't be any resistor swaps.

Seems like a better choice for everyone.

-- Alan


----------



## wquiles (Jan 28, 2009)

That would be AWESOME!

As you know I have been using the VCC reference, and it was been working perfectly, so I have no doubth that what you are trying here will work well 

Will


----------



## LuxLuthor (Jan 29, 2009)

Alan B said:


> *Easy Calibration Setup*
> 
> Today I added a quadclick to 5.00 volt option to the interface. Then I used this to calibrate the ADC.
> 
> ...


 
*Holy Moly that is great!*



Alan B said:


> I made a change to the code and dropped the off-current to 300 uA which would take 270 days to drain Eneloops. I'm not done yet, I may reduce that further, but it will probably take minor hardware adjustments to accomplish that. (such as changing resistors and changing a bit of code). If we double that value one more time then the self-discharge will probably be equal to the drain and there is not much benefit available beyond that. The tailcap lockout is always there, too...
> 
> JimmyM asked what was done to reduce the current - essentially it took a one bit change. The CPU sleep state was not optimal. I had set it to "idle", I changed it to "power down". I don't recall which bit it is, but the code is in FP9 except for this one bit change in a constant. The processor consumption in power down is about 1uA, and all the clocks are stopped. I turned off the ADC before sleeping already. I need to double check if the Vref generator needs to be turned off separately, that is another item that might still be on.
> 
> ...



*Sweet Jesus!*



Alan B said:


> I started working on a feature that I thought about a long time ago but never pursued. This relates to using the three Vref's of the ADC for three voltage ranges. The Vref's are 5.0, 2.56 and 1.1 volts. Switching between these ADC ranges gives a very nice set of three fullscale voltages. I just need to set up the code so everything compensates for the change, including the scaling, the ADC initialization, and the calibration.
> 
> I will probably set it up so that the calibration voltage changes as well. So on the low voltage range the cal voltage will be 5.00 volts, 10.00 on the midrange and 20.00 volts on the high range, subject to change as I get the code done.
> 
> ...



*Dear Lord...have I died and gone to Heaven?*


----------



## wquiles (Jan 29, 2009)

+1 - These features/improvements in the firmware are great!!!!!

Will


----------



## Alan B (Feb 14, 2009)

I am building a P7 with a d2Flex and I could not help but notice the similarity between the controller design and the regulator here.

It uses the same Tiny85 CPU, and a FET PWM switch, and of course there is a control switch input, and a voltage regulator.

The FET is only good to around 3.4 amps at 70C, and 24V.

The d2Flex is fairly small at 0.8" diameter on a round board ([email protected] C size).

The pushbutton control switch input appears to be on the same pin my software already uses.

The FET gate output is on a different pin than I used, which would require some minor software changes. Probably about 4 lines of code would change.

The voltage input divider is missing. This would require two resistors be added.

The programming interface is by pads, so something would be required there. The easiest might be to wire a standard six pin programming plug and epoxy it on the board. There is quite a lot of room on the back side.

This regulator, modified and reprogrammed, should be just adequate for a [email protected] Keep the current below 3.4A and the voltage well below 24V, say 15-18V.

Jim's future small regulator will have a lot more voltage and current capability. But if someone wants to experiment now, this could be a quick way to start.

Now, I have not done this, so there may be a surprise or problem. It would require working with some small wires and modding a surface mount board, but the mods appear to be fairly simple. If someone wants to try this I am willing to give a bit of help.


----------



## Alan B (Feb 14, 2009)

Alan B said:


> I started working on a feature that I thought about a long time ago but never pursued. This relates to using the three Vref's of the ADC for three voltage ranges. The Vref's are 5.0, 2.56 and 1.1 volts. Switching between these ADC ranges gives a very nice set of three fullscale voltages. I just need to set up the code so everything compensates for the change, including the scaling, the ADC initialization, and the calibration.
> 
> I will probably set it up so that the calibration voltage changes as well. So on the low voltage range the cal voltage will be 5.00 volts, 10.00 on the midrange and 20.00 volts on the high range, subject to change as I get the code done.
> 
> ...



I have added a resistor and jumper so that two ranges of three voltages can be selected. The code is under development.

The ranges are

jumper in: 2,4,8S

jumper out: 3,6,*12S

nS is 4.2V per cell for n Li-Ion cells. Cell chemistry selection is separate, but the voltage ranges are designed in terms of this 4.2V unit, though they run slightly higher due to tolerances.

* NOTE that 12S requires high voltage parts for the regulator and FET.

This was mentioned in the other thread already, I just add it here for completeness.


----------



## JimmyM (Feb 14, 2009)

What FET is it using?


----------



## Alan B (Feb 15, 2009)

JimmyM said:


> What FET is it using?



There is a block diagram on the tech page that shows the FET designation:

http://www.taskled.com/techd2flex.html

RTQ045NO3 is what it looks like to me.


----------



## sylathnie (Apr 19, 2009)

I'd like to see more information about the requirements to convert Alan B's design to high voltage applications. I have limited electronics knowledge but I would be glad to learn what I can.

Thus far we have determined that [URL="http://www.newark.com/national-semic...-92/dp/92K6133"]http://www.newark.com/national-semic...-92/dp/92K6133 [/URL]would be a potential candidate for a replacement regulator. Please double check me on this. 

I'm a little confused as to how the requirements for the FET work out. Thus far I have:
Gate Voltage 5V
Source to Drain Voltage >51VDC
Resistance <5mOhm 
Rated for >40A
Through hole leads
TO220 Case

What other requirements do I need to look for?

Thanks folks!


----------



## Alan B (Apr 20, 2009)

sylathnie said:


> I'd like to see more information about the requirements to convert Alan B's design to high voltage applications. I have limited electronics knowledge but I would be glad to learn what I can.
> 
> Thus far we have determined that http://www.newark.com/national-semiconductor/lm2936z-5-0/v-reg-ldo-low-iq-5-0v-2936-to-92/dp/92K6133http://www.newark.com/national-semic...-92/dp/92K6133 would be a potential candidate for a replacement regulator. Please double check me on this.
> 
> ...



Sounds about right. Probably want 55V or 60V min, need some headroom there for the inductive kick from the filament. And the type is N channel enhancement mode Power FET.

The clearance is tight so some of the FET tab must be cut off. I recall that a TO220 in open air can dissipate about 2 watts, but we don't have airflow here and we don't have the whole tab, so I would think keeping it under 1 watt is prudent. That would be about 5.1 milli-ohms at 14 amps.

It might be possible to thermally couple the FET with the aluminum sled, but it must be electrically isolated and this is tricky to do in the tight volume available. I put my first one of these together today and it is tight.

The first aluminum sleds are back from the machinist. Photos in the interest thread...


----------



## Alan B (Apr 22, 2009)

Well, as seems to happen often in this business, the FET that I am using is not so available now and I am looking for a new choice.

I have also been converting the layout to surface mount, not sure if I will go this way but it might lower costs/effort a bit. However there is not enough room for a surface mount FET on this board with all the terminals, holes, and socket for the programming/switch, so the FET will probably be through-hole even if the board goes SMT.

I'm using a TO220 but there is insufficient height for the tab, so I have to cut that off. I found one package that has the tab already shortened, and that is a good thing here. It has 0.090 pin spacing and is a bit smaller than TO220.

At any rate, anyone found any great FETs for this? 3-5 milliohms, N channel, 40V or better, low cost, etc. ?


----------



## JimmyM (Apr 25, 2009)

Alan B said:


> At any rate, anyone found any great FETs for this? 3-5 milliohms, N channel, 40V or better, low cost, etc. ?


Have a look at these. Maybe one of them will do.
DigiKey P/Ns
497-6190-5-ND
IRLU3114ZPBF-ND


----------



## JimmyM (Apr 25, 2009)

sylathnie said:


> I'd like to see more information about the requirements to convert Alan B's design to high voltage applications. I have limited electronics knowledge but I would be glad to learn what I can.
> 
> Thus far we have determined that http://www.newark.com/national-semiconductor/lm2936z-5-0/v-reg-ldo-low-iq-5-0v-2936-to-92/dp/92K6133http://www.newark.com/national-semic...-92/dp/92K6133 would be a potential candidate for a replacement regulator. Please double check me on this.
> 
> ...


Try the Linear LT3014B. It's adjustable, so it requires 2 external resistors. But it's good up to 80V.


----------



## LuxLuthor (May 19, 2009)

JimmyM said:


> Try the Linear LT3014B. It's adjustable, so it requires 2 external resistors. But* it's good up to 80V.*



I can hear Ralphie's mother: "You'll shoot your eye out."


----------



## Alan B (May 19, 2009)

Thanks for the suggestions, Jim.

I have pretty much settled on the TO262, which is a TO220 with almost no tab. Very nice size package.

For the regulator we need something TO92 with no external parts to fit the PCB. There is a 60V version of the regulator I'm already using, but it seems to be hard to find. The only stock I see is in UK.

I found a 60V FET that looks great. Don't have the number handy here, have to dig it up again at some point. I might have purchased one, not sure.


----------



## JimmyM (May 19, 2009)

Alan B said:


> Thanks for the suggestions, Jim.
> 
> I have pretty much settled on the TO262, which is a TO220 with almost no tab. Very nice size package.
> 
> ...


Oh OK. I thought you meant all SMD. While redesigning the board for SMD I thought you were redesigning for the 60V version. So a TO92 case 5V regulator good to 60V. That's a narrow focus. No wonder you have a tough time finding them.
OK. Gotcha.


----------



## JimmyM (May 19, 2009)

I'm working on the low voltage safety shutdown in my D1.
I have the code to determine the shutdown condition...
when Vbat falls to 87.5% of Vlow it engages low volt shutdown.
When it does, PWM goes to 0, but I'd like to go a little further.
I'd like to try putting it to sleep. I don't need to monitor interrupts because it will re quire a power cycle to clear. So I thought I'd use the "Power-Down" sleep mode. I know you're using sleep modes in your design to minimize power consumption in "off" mode. Would you mind sharing the code?
I'm guessing so far...
MCUCR = _BV(SE); // Enables sleep Mode
MCUCR = _BV(SM1); // Enter sleep mode = Power-Down


----------



## Alan B (May 19, 2009)

```
/*
 *-------------------------------------------------------------------------*
 *                                                                         *
 *  This program is free software: you can redistribute it and/or modify   *
 *  it under the terms of the GNU General Public License as published by   *
 *  the Free Software Foundation, either version 3 of the License, or      *
 *  (at your option) any later version.                                    *
 *                                                                         *
 *  This program is distributed in the hope that it will be useful,        *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 *                                                                         *
 *-------------------------------------------------------------------------*
 */

#ifdef LOPWR
            // set to low power, prepare wakeup interrupt, go to sleep
            // button is on INT0 pin, use low level int, no clocks req'd
            // insure output is low. only run when PWM is off
            // disable brownout detection? (BOD not enabled)
            ADCSRA = 0;                // disable ADC to save power
            sleep_enable();            // prepare for sleep
            sei();                    // enable interrupts
            MCUCR = 0b00100000;      // int on INT0 low level, conserve power
            GIMSK = 0b01000000;      // INTO mask enable
            sleep_cpu();            // sleep, interrupt on button push

            sleep_disable();        // waking up
            cli();                    // disable interrupts
            init();                    // wake up, re-init, ADC on, etc
#endif
```


----------



## JimmyM (May 19, 2009)

Alan B said:


> ```
> /*
> *-------------------------------------------------------------------------*
> *                                                                         *
> ...


Are the sleep_cpu(), sleep_enable(), and sei() your defined functions?
If so, can you post the the details of those functions? 
Is your code posted anywhere so I don't have to bother with these questions?
Thanks, Alan.


----------



## Alan B (May 19, 2009)

They are in the AVR library. Look at the library documentation available in AVR Studio.


----------



## JimmyM (May 19, 2009)

Alan B said:


> They are in the AVR library. Look at the library documentation available in AVR Studio.


Ahh. OK. Thanks.

What AVR Studio and Winavr are you using?
I just upgraded to Studio 4.16SP1. Still using winavr 20090313


----------



## mpteach (May 19, 2009)

Why does it need to be 60V, Is that because of inductive kick from the filament? Could you use a diode to absorb that or would that hurt efficiency signifiantly?


----------



## Alan B (May 20, 2009)

JimmyM said:


> Ahh. OK. Thanks.
> 
> What AVR Studio and Winavr are you using?
> I just upgraded to Studio 4.16SP1. Still using winavr 20090313



avr studio 4.14 build 589
avr libc 1.6.4
winavr 20080610

My tools are pretty old. Probably need to upgrade. Soon.


----------



## Alan B (May 20, 2009)

mpteach said:


> Why does it need to be 60V, Is that because of inductive kick from the filament? Could you use a diode to absorb that or would that hurt efficiency signifiantly?



Some users want to use 52V (12S Li-Ion). The present parts are rated at 40V so we need to stay below that.

For most users the 40V parts are fine.

Diodes were investigated to reduce the inductive overshoot, they did not appear to help.


----------



## Alan B (May 20, 2009)

JimmyM said:


> Oh OK. I thought you meant all SMD. While redesigning the board for SMD I thought you were redesigning for the 60V version. So a TO92 case 5V regulator good to 60V. That's a narrow focus. No wonder you have a tough time finding them.
> OK. Gotcha.



There did not seem to be enough room to go fully SMD. The terminal is through-hole and mechanically things are based on that, and it bisects the PCB and constrains the parts locations. The SMD fuse took a lot of board space and would be hard to change, so I stayed with through-hole. Also the traces on one side only would not carry the current well. The jumper could have been SMD but through hole seems easier there, as did the rather tight programming plug. Probably not enough room for SMD there. So the board is mostly SMD. The micro, resistors and capacitors are SMD. The jumper, ISP connector, fuse, socket wire connections, battery and negative terminals are through-hole.


----------



## mpteach (May 20, 2009)

Alan B said:


> Some users want to use 52V (12S Li-Ion). The present parts are rated at 40V so we need to stay below that.
> 
> For most users the 40V parts are fine.
> 
> Diodes were investigated to reduce the inductive overshoot, they did not appear to help.



12S, thats a very long and skinny tube!

did you try a schottky diode? http://en.wikipedia.org/wiki/Flyback_diode#Design


----------



## Alan B (May 20, 2009)

mpteach said:


> 12S, thats a very long and skinny tube!
> 
> did you try a schottky diode? http://en.wikipedia.org/wiki/Flyback_diode#Design



wquiles did that testing, and possibly JimmyM as well. I believe a schottky diode was tried. It had zero effect as I recall. You can find the discussion and measurements earlier in one of the design threads.


----------



## JimmyM (May 20, 2009)

Yeah. I tried a Shottkey during development with no effect. The inductive kick is only about 1 uS and our design is very low frequency. The Avalanche energy capability of the FETs we're using is sufficient to handle the "kick".


----------



## Alan B (May 20, 2009)

mpteach said:


> 12S, thats a very long and skinny tube!



Actually not. Folks using 12S are generally using elephant type lights that have 3 or 4 cells alongside, so a 12S stack is only 4 or 3 cells in length. Four 18650 cells alongside makes a thick handle but three is not much thicker than a D [email protected] These are custom builds but available from several sources here on CPF.


----------



## sylathnie (May 20, 2009)

12S Body + Light





Hopefully it will be hosting a high voltage regulator soon! :twothumbs


----------



## mpteach (May 20, 2009)

What kind of lithium cells do you have it there?


----------



## sylathnie (May 22, 2009)

IMR 18650s from Ryobi One+ battery packs.


----------



## mpteach (May 22, 2009)

are the 18650 electrically in series but physcially parrelel? thats long but it doesnt look 650*12 long to me.


----------



## KiwiMark (May 22, 2009)

mpteach said:


> are the 18650 electrically in series but physcially parrelel? thats long but it doesnt look 650*12 long to me.



An Elephant II body with 12 cells would be around 3 cells long inside the battery compartment. The cells are arranged in a 2x2 arrangement - as you say electrically in series but physically parallel. I have an Elephant II with 8 cells, same deal just 2/3rds as long. The 12 cell version can be reduced to 8 cells or 4 cells very easily with a little unscrewing of the body extensions and the battery holder extensions.


----------



## mpteach (May 23, 2009)

Which is exactly why I didnt understand the need for lithium 12S or high voltages since i doubt anyone will ever stack 12 in a single row.


----------



## Alan B (May 23, 2009)

mpteach said:


> are the 18650 electrically in series but physcially parrelel? thats long but it doesnt look 650*12 long to me.



Yes, they are electrically in series which is useful for some of the high powered filaments. Several folks on this list have 12S voltages to deal with (about 52 volts). The four-alongside packaging may only be 3S in physical length but it is still 52V.

There are three parts that need to see this voltage. The FET, the voltage regulator and the input capacitor. The 50V capacitor is probably ok, but the 40V rating on the FET and voltage regulator are too overstressed.

I found some 60V FETs, and the voltage regulator is made in a 60V model, but finding it is not easy. Newark shows some stock in the UK but it is costly to ship from there unless you live there.

The regulator and FET are the same on both the through-hole version and the hybrid SMD version of the PCB. The capacitor did change to a SMD. It is a ceramic capacitor and the rating is so close that I don't expect it will have problems, but it could be changed to a higher voltage unit as well.


----------



## petrev (May 23, 2009)

Alan B said:


> Yes, they are electrically in series which is useful for some of the high powered filaments. Several folks on this list have 12S voltages to deal with (about 52 volts). The four-alongside packaging may only be 3S in physical length but it is still 52V.
> 
> There are three parts that need to see this voltage. The FET, the voltage regulator and the input capacitor. The 50V capacitor is probably ok, but the 40V rating on the FET and voltage regulator are too overstressed.
> 
> ...


 
Hi Alan

I order from Farnell (which is Newark in the UK) - Let me know the part codes and I can look them up and check availability. I can post whatever you need.

Cheers
Pete


----------



## Alan B (May 23, 2009)

petrev said:


> Hi Alan
> 
> I order from Farnell (which is Newark in the UK) - Let me know the part codes and I can look them up and check availability. I can post whatever you need.
> 
> ...



The part we're looking for is LM2936HV-5.0 in TO92 package. Looking at a data sheet again just now I'm not sure they even make that combination. I've seen the HV model at Farnells, but the surface mount package is too large for the regulator board.

What we need is a TO92 regulator, low quiescent current, 5.0V output, 60V input. Load current is small, 50mA is fine.


----------



## petrev (May 23, 2009)

Alan B said:


> The part we're looking for is LM2936HV-5.0 in TO92 package. Looking at a data sheet again just now I'm not sure they even make that combination. I've seen the HV model at Farnells, but the surface mount package is too large for the regulator board.
> 
> What we need is a TO92 regulator, low quiescent current, 5.0V output, 60V input. Load current is small, 50mA is fine.


 
Hi

Only one in UK Farnell is 
LM2936HVBMA-5.0/NOPBand that is 8-pin package and it is only available from US stock ? ? ?

Data sheet suggests HV-5.0 not available in TO92 
Cheers
Pete


----------



## Alan B (May 23, 2009)

I just did another Digikey search for any TO92 regulator over 40V and found NONE. So the High Voltage version of the regulator is apparently not going to be as easy as changing a couple of parts. It will probably require a new PCB layout to accept some other package, and that part of the board is pretty crowded, though the SMD relayout did free up some space. But realistically I can't work on that now with all the other things in my que.

I was misled by the data sheet which indicates a high voltage version. What they didn't make clear is that this high voltage version is apparently only available in a fairly large surface mount package that I can't easily use.

So what High Power is possible with the "Standard 40V Regulator":

40V Divided by 12 is 3.33V, so A123 18650's that are charged to 3.3V will likely do quite well. They pack quite a punch, too. Easily handle 10-12 amps. Put out close to 400-480 watts (40V 10A).

Alternately 11S A123 cells can be fully charged to 3.6V. They will produce 35V at 350 to 400 watts.

Next down is 10S LiMN charged to 4.0V. Again an easily 400-480W power source. Charging to 4.0V will increase the lifetime of the cells tremendously at the cost of some fully charged capacity loss.

At the full 4.2V the limit is 9S. With LiMN you would get about 32V under load for 300-380W.


----------



## mpteach (May 23, 2009)

What voltage do the high wattage bulbs need?


----------



## Alan B (May 23, 2009)

mpteach said:


> What voltage do the high wattage bulbs need?



About 36 volts. Here's a 400W setup:

https://www.candlepowerforums.com/threads/205841


----------



## sylathnie (May 23, 2009)

Alan B said:


> So the High Voltage version of the regulator is apparently not going to be as easy as changing a couple of parts.



:mecry::mecry::mecry:

Ouch. This is crippling to my plans for world domination via flashlight....

So anyone else have a high voltage soft starter in the works? :naughty:


----------



## JimmyM (Jun 7, 2009)

JimmyM said:


> Are the sleep_cpu(), sleep_enable(), and sei() your defined functions?
> If so, can you post the the details of those functions?
> Is your code posted anywhere so I don't have to bother with these questions?
> Thanks, Alan.



I've gotten the sleep to work.

```
OCR1A = 0;  // Sets PWM Duty to 0 (Zero)
ADCSRA = 0; // disable ADC to save power
            
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Sets sleep mode to Power-Down.
sleep_mode(); // Puts the AVR to sleep using above set mode.
```

Of course this won't work in a pushbutton interface since I haven't enabled any interrupts. But for the current mode of operation. When operating it uses 4.4mA. In power-down mode, it uses 0.12 mA


----------



## Alan B (Jun 7, 2009)

sylathnie said:


> :mecry::mecry::mecry:
> 
> Ouch. This is crippling to my plans for world domination via flashlight....
> 
> So anyone else have a high voltage soft starter in the works? :naughty:



I'm using the same FET that you are already using, and the regulator is spec'd to survive 60V. It might work now.

The specs on the regulator seem to say that it will not fail at 60V, but it is not spec'd to operate over 40V. It is rated at 50ma and we're using about 6ma so it may well be the case that it will work fine above 40V. I can't predict that.

You might decide to try it and let us know how it works.


----------



## Alan B (Jun 7, 2009)

JimmyM said:


> I've gotten the sleep to work.
> 
> ```
> OCR1A = 0;  // Sets PWM Duty to 0 (Zero)
> ...



It certainly saves some power.


----------



## JimmyM (Jun 7, 2009)

Alan B said:


> I'm using the same FET that you are already using, and the regulator is spec'd to survive 60V. It might work now.
> 
> The specs on the regulator seem to say that it will not fail at 60V, but it is not spec'd to operate over 40V. It is rated at 50ma and we're using about 6ma so it may well be the case that it will work fine above 40V. I can't predict that.
> 
> You might decide to try it and let us know how it works.


What about power dissipation at 6mA considering the voltage drop from 60V to 5V? That's only .33W. How is it rated in a 60C environment?


----------



## JimmyM (Jun 9, 2009)

Did you guys have scope caps of of the PWM output for a battery under load showing the voltage sag during the PWM On cycle?


----------



## Alan B (Jun 9, 2009)

JimmyM said:


> What about power dissipation at 6mA considering the voltage drop from 60V to 5V? That's only .33W. How is it rated in a 60C environment?



Hopefully the voltage under load is way below 60V, and the regulator should shed load before 60C.


----------



## Alan B (Jun 9, 2009)

JimmyM said:


> Did you guys have scope caps of of the PWM output for a battery under load showing the voltage sag during the PWM On cycle?



Will had some of that. Trying to average the supply voltage?


----------



## wquiles (Jun 9, 2009)

JimmyM said:


> Did you guys have scope caps of of the PWM output for a battery under load showing the voltage sag during the PWM On cycle?



Yes, I captured this behavior fairly well in the earlier thread Alan had, probably towards the end of 2008. I am work now, but I will try to find the older posts with the scope captures later tonight.


----------



## JimmyM (Jun 9, 2009)

Alan B said:


> Will had some of that. Trying to average the supply voltage?


Yeah. I'm trying to figure out what the correct sampling schema is. I already have a multiple reading/averaging routine. I can sample and average 2, 4, 8, 16, or even 32 readings. Depending on what I can find with respect to sag curves, some simulations suggest that sampling in the middle is good for the average, but to more closely approximate the RMS voltage of the sagging battery voltage it's better to begin sampling in the beginning and increase the number of samples based on the current PWM count. This appears to get within a couple thousandths/tenthousandths of calculated RMS value. Once at 100% duty, sampling in the middle doesn't matter. It's just that I can trigger the sample with the TOV1 flag. I already have that coded, so I might as well keep using it. Maybe I can switch to just triggering when BOTTOM or TOP is reached. This will reduce the amount of code. Which is nice.


----------



## Alan B (Jun 9, 2009)

I spent some time on this awhile back. It is interesting to think about and see what can be done. I'm not sure it is too important as the voltage is not super-critical. Perhaps more important is bad readings from the ADC. A single bad reading from the ADC is only going to change the output one PWM count, however, so even that is pretty weak.

One thing I played with is to read the ADC four times and sum it, making a 12 bit ADC value, and using that directly.

Another was to average a lot of 8 bit readings.

One I considered but did not do is to take four readings, one at each end and two in the center, and add (or average) them. A weighted average commonly used (simpson's rule).

Lots of ways to do it.


----------



## wquiles (Jun 9, 2009)

Jim,

In this old post, you can see the yellow/top trace, both with my bench PS and with real batteries, how the voltage sags once the FET switches on:
https://www.candlepowerforums.com/posts/2654685&postcount=39

In this post, towards the end, you can also see the voltage sagging while the FET is ON:
https://www.candlepowerforums.com/posts/2654777&postcount=42

I feel that if possible, sampling somewhere in the middle of the pulse (and actually I mean sampling a few times, and averaging, throwing away "unreasonable" values from the ADC) should yield a well behaved algorithm.

Will


----------



## JimmyM (Jun 9, 2009)

Alan B said:


> I spent some time on this awhile back. It is interesting to think about and see what can be done. I'm not sure it is too important as the voltage is not super-critical. Perhaps more important is bad readings from the ADC. A single bad reading from the ADC is only going to change the output one PWM count, however, so even that is pretty weak.
> 
> One thing I played with is to read the ADC four times and sum it, making a 12 bit ADC value, and using that directly.
> 
> ...


Since the voltage won't rise during the "on" period, my calculations show that if the samples are taken *only* in the middle, the AVR thinks the battery voltage is lower than the RMS value of the sagging voltage curve. Thus resulting in a higher actual output voltage. A mistake I made by testing with a regulated supply stiffened up with a capacitor. Calculations based on a few simulated sag curves show that my "mistake" will only cause a 0.2V variance based on heavily sagging cells. Sagging more than 1V per "on" cycle.
However, if sampling begins at the start of the PWM cycle and is repeated as long as necessary, the AVR always gets the impression that the battery voltage is a tiny bit higher than it really is. Only by the tiniest margin. Therefore, never resulting in an output that's higher than the AVR thinks it is. I don't think that 32 samples is any better than 4, but it's simple, codewise, to just sample x times then do a bit-shift divide. The duration of the ADC sample and calculation duration is nice and predictable.


----------



## JimmyM (Jun 9, 2009)

wquiles said:


> Jim,
> 
> In this old post, you can see the yellow/top trace, both with my bench PS and with real batteries, how the voltage sags once the FET switches on:
> https://www.candlepowerforums.com/posts/2654685&postcount=39
> ...


Boy, was my assumption wrong! I assumed that the voltage wouldn't rise during the on phase. However, it falls then recovers. I'll have to approximate this curve in my calculator.
That "dip" is only about 3 uS long by my estimation.


----------



## Alan B (Jun 9, 2009)

Here we have electronics meeting chemistry.


----------



## JimmyM (Jun 9, 2009)

I don't think the ADC sample will even commence before the 3uS dip is over. So sampling in the middle does give the best result in this example.
Hmmm. Based on these tests, the battery voltage simply drops under load (after the blip), but I can't see any sagging *during* the "on" cycle.
But, based on this scope cap, that pulse width is only ~0.43% (about 1 pwm count in an 8-bit PWM). So that pulse is diminishingly short.
I have to contact Lux to see if he has a battery pack I can borrow/buy/beg/barter etc. To perform a qualitative analysis if real RMS output.
Keep in mind that because my design is set via pot from observed values, it will be correct based in the actual load being the same as the setting load, IF the sampling schema is correct. If the sampling schema is horribly wrong, then all bets are off.
A few hundredths of a volt means nothing, however, petrev has popped a few bulbs. I want to make sure I do everything I can to quantify what's going on. If anything.


----------



## JimmyM (Jun 9, 2009)

Alan B said:


> Here we have electronics meeting chemistry.


Yeah. great!
I will figure this out.


----------



## LuxLuthor (Jun 9, 2009)

JimmyM said:


> I have to contact Lux to see if he has a battery pack I can borrow/buy/beg/barter etc. To perform a qualitative analysis if real RMS output.



Just to let you know I read these threads. I follow the basic concepts of what you are working on, even if I don't understand much of the specifics.

Let me know what pack(s) you need by PM or email. I have to get a few other packs done for people that asked.


----------



## Alan B (Jun 10, 2009)

One thing to keep in mind is that batteries will vary a lot between chemistries and conditions such as temperature, age, current demand, etc. So a good algorithm should work well in lots of conditions.


----------



## JimmyM (Jun 10, 2009)

Alan B said:


> One thing to keep in mind is that batteries will vary a lot between chemistries and conditions such as temperature, age, current demand, etc. So a good algorithm should work well in lots of conditions.


Exactly. I've contacted Lux for a loaner pack or 2. I'll do some more testing.


----------



## JimmyM (Jun 15, 2009)

Alan B said:


> Might as well try it and see. Watch the boundary conditions, that's where the problems generally crop up. Have you measured the performance of the 32 bit math?
> 
> Be careful with filling up the bits. Don't subtract full 32 bit unsigned values, for example. I got bit by the equivalent thing at 16 bits. Caused some weird bugs.
> 
> We could discuss this stuff on the design thread to reduce clutter here



The bit's _shouldn't_ fill. The maximum value the ADC can deliver is a 10-bit, squared = 20-bit. The pwmvalue is never more than 4095 (12-bits). So intutively, it should work. I will keep an eye out for odd behavior though. Thanks for the tip.

I haven't qualitatively measured the performance of 32-bit math. It is slower than 16-bit, but I have no issues with the timing of things. I've been using uint32_t variables from the beginning for adc^2, and vbulb^2, etc.


----------



## Alan B (Jun 15, 2009)

JimmyM said:


> The bit's _shouldn't_ fill. The maximum value the ADC can deliver is a 10-bit, squared = 20-bit. The pwmvalue is never more than 4095 (12-bits). So intutively, it should work. I will keep an eye out for odd behavior though. Thanks for the tip.
> 
> I haven't qualitatively measured the performance of 32-bit math. It is slower than 16-bit, but I have no issues with the timing of things. I've been using uint32_t variables from the beginning for adc^2, and vbulb^2, etc.



They won't fill, but if they're more than half full the leading bits will be set and you will be in the 'unsigned danger zone' where trouble can develop. If you subtract two unsigned values, and one is more than half full, and the other is small, the difference can exceed the capability of a 32 bit signed variable to correctly represent since it can only represent 31 bits plus sign.


----------



## Mr Happy (Jun 15, 2009)

Alan B said:


> They won't fill, but if they're more than half full the leading bits will be set and you will be in the 'unsigned danger zone' where trouble can develop. If you subtract two unsigned values, and one is more than half full, and the other is small, the difference can exceed the capability of a 32 bit signed variable to correctly represent since it can only represent 31 bits plus sign.


I think there is an ambiguity about what 'half full' means here. I, and perhaps Jim, tend to think of a 32 bit register as half full when the stored value contains 16 or more significant bits. On the other hand, I think you mean half full when it holds more than half the maximum value (i.e. more than 31 bits).

However, since 2^32 = 4,294,967,296 and half of this is 2,147,483,648, I doubt there is a problem on that score.


----------



## Alan B (Jun 15, 2009)

Good point. You are correct. But if you take a 10 bit ADC reading that represents over half the fullscale voltage range, square it, multiply it by a 12 bit PWM value that represents more than 50% duty cycle you will have 2**31 bits of result. So it is not hard to get there. Not that it is necessary to use this many bits, but it is possible.

Jim, I like the approach you are looking at with the 32 bit value. That is exactly what I'm doing with 16 bits, filling them all up and using the whole value when I can. You have to be careful to get it exactly right, but it should work well.

What are you doing with the 12 bit PWM? Did you configure for 12 bit PWM or do anything useful with the extra bits?


----------



## Alan B (Jun 16, 2009)

Jim, did you measure the time it takes to do a 16 by 16 multiply with 32 bit result? Or a 32 by 32 multiply?? Just curious how quick those are.


----------



## JimmyM (Jun 16, 2009)

Alan B said:


> Good point. You are correct. But if you take a 10 bit ADC reading that represents over half the fullscale voltage range, square it, multiply it by a 12 bit PWM value that represents more than 50% duty cycle you will have 2**31 bits of result. So it is not hard to get there. Not that it is necessary to use this many bits, but it is possible.
> 
> Jim, I like the approach you are looking at with the 32 bit value. That is exactly what I'm doing with 16 bits, filling them all up and using the whole value when I can. You have to be careful to get it exactly right, but it should work well.
> 
> What are you doing with the 12 bit PWM? Did you configure for 12 bit PWM or do anything useful with the extra bits?



First I switched my 10-bit regulation to multiply vbulbsq by 1024 ( << 10) instead of dividing vbatsq. That made things measureably better. I could sweep the input voltage slowly and routinely had variances less than 0.04V The theoretical minimum for 10-bit, but with dithering, it can get below that due to retaining significant digits by moving the division/multiplication. No matter where I left the voltage, the RMS output never varied more than 0.03V.
So I implemented 12-bit PWM at 244Hz and 122Hz. I multiplied vbulbsq by 4096 ( << 12). I'm still doing testing, but using Petrev as a guide, I set the regulator as close to 13.800 V as I could. My 2 set points could be 13.778 or 13.815. In preliminary testing, it's showing a variance from 13.812 to 13.824. Not too shabby. I'm sampling as many as 64 times and squaring->summing->averaging to get the RMS equivalent.
It seems to work nicely. To what end? I'm not sure. Mostly an academic exercise. I'll mess with it some more later.
The movement of the 10-bit multiplication seems to have a worthwhile improvement.


----------



## Alan B (Jun 16, 2009)

Interesting results.

How long does it take to do these 64 ADC read, square and add cycles? Just curious.


----------



## JimmyM (Jun 16, 2009)

Alan B said:


> Interesting results.
> 
> How long does it take to do these 64 ADC read, square and add cycles? Just curious.


A little over half of the 122Hz period. When I do 244Hz, I only do 32 samples.
The summing of the squares only makes a very small difference on paper, but it is the "correct" way to do it.


----------



## JimmyM (Jun 19, 2009)

I haven't had a lot of time to do much at the bench, but this much is clear.
Moving the bit-shift from vbatsqpwm as >> 10 (for 10-bit) to vbulbsq as << 10. Makes a big difference in how the software can react to a changing Vbat. I was losing too many significant bits by bit shifting the Vbatsq value.
This also allows me to implement 12-bit PWM which makes such a tiny improvement in output regulation as to be insignificant. But I'll probably do it anyway, just because I can.
I'll have to do some more experimentation with regard to 122Hz versus 244Hz.


----------



## Alan B (Jun 19, 2009)

Carrying the precision correctly makes a difference. It is a tradeoff but there is little point in calculating a precise value and then throwing the precision away before using the result.

I don't have time now but at some point will experiment with more precision. Getting really good 10 bit ADC readings is a bit harder since the CPU really needs to be shut down during the reading and the interrupts used to start it back up. Otherwise the readings are pretty noisy, so I've read. With enough averaging the noise is less important of course.

It is fun to play with the algorithms.

I see you have not done much with ifdefs yet. They are quite useful for turning on and off test code and features.


----------



## JimmyM (Jun 19, 2009)

Alan B said:


> Carrying the precision correctly makes a difference. It is a tradeoff but there is little point in calculating a precise value and then throwing the precision away before using the result.
> 
> I don't have time now but at some point will experiment with more precision. Getting really good 10 bit ADC readings is a bit harder since the CPU really needs to be shut down during the reading and the interrupts used to start it back up. Otherwise the readings are pretty noisy, so I've read. With enough averaging the noise is less important of course.
> 
> ...


My rev 2 uses a lot of #ifdefs for turning on/off things like diagnosic outputs, 122/244Hz mode, Softstart ramp speed parameters, blah, blah, blah.

I haven't looked into sleeping the CPU during an ADC read, but it's on the list.


----------



## Mr Happy (Jun 19, 2009)

Have you guys looked at fixed precision squaring so you can square an N bit value into an N bit result without overflow?

For instance, suppose you want to square a 16 bit unsigned integer and keep the result with 16 bits precision. You can proceed like this:

Divide the 16 bit word into two 8 bit halves, so you have

X = A|B

where X = A << 8 + B

Then X^2 >> 16 can be computed without loss of precision as

X^2 >> 16 = (B^2 >> 9 + AB) >> 7 + A^2

If you evaluate this in code it is important to compute the terms from left to right and accumulate them as you go to avoid rounding errors. For instance:

A = X >> 8;
B = X - (A << 8);
SQ = (B*B) >> 9;
SQ += A*B;
SQ >>= 7;
SQ += A*A;

Here's an example. Suppose you want to square 6055 and obtain the result 6055^2/65536 = 559

6055 = 23 * 256 + 167
167^2/512 = 54
54 + 23*167 = 3895
3895 / 128 = 30
30 + 23^2 = 559

Of course what's interesting about this is that 6055 has 13 significant bits of precision, while 559 has only 10 significant bits. This is where floating point arithmetic has advantages over fixed precision arithmetic.


----------



## Alan B (Jun 19, 2009)

Very clever. So far things have fit pretty well into 8, 16 or 32 bit integers without loss of precision. But that is good to keep in mind.

Thanks,


----------



## JimmyM (Jun 20, 2009)

That is some fancy bit bit wrangling. And, as such, is a bit above my pay grade. I'm pretty new to this. I'm leaning heavily on the GCC to compile things properly and the AVR to slog through the math for me.
I wish there was an AVR programming class I could take nearby. Tutorials are great, but they lack the interaction you would get with an instructor. I'm still learning a lot. But this was great. Thanks.


----------



## JimmyM (Jul 1, 2009)

Alan,
Are you using interrupts to handle your pushbutton or polling every time the program loops? Or using a timer interrupt to poll?


----------



## Alan B (Jul 1, 2009)

JimmyM said:


> Alan,
> Are you using interrupts to handle your pushbutton or polling every time the program loops? Or using a timer interrupt to poll?



Polling in the main loop. Look at the published FP9. It is changed some, but that is basically the same.


----------



## JimmyM (Jul 1, 2009)

Alan B said:


> Polling in the main loop. Look at the published FP9. It is changed some, but that is basically the same.


Yup. I looked at FP9 but was wondering if you had made changes to how you read the button since you're now using sleep mode.
I've got the basics working in test code. 
At power up, it immediately goes into sleep mode. PCINT interrupt on an input pin wakes it up and it goes into low level. Read and debounce a button using polling to switch output levels. Press-hold to shut off and go to sleep.
Works pretty well. Now I have to incorporate the button UI into the existing Rev2 code. "Ifdef"s will enable/disable the button UI in the code.


----------



## Alan B (Jul 1, 2009)

I wrote a nice reply and it got lost in a database error.

The pushbutton is sampled once per loop as before. The processing of the samples has changed but this is unrelated.

The sleep is triggered after the light is off for one second. The pushbutton interrupts the CPU back on, and the sampling works from there.

Simple and direct.


----------



## JimmyM (Jul 2, 2009)

Alan B said:


> I wrote a nice reply and it got lost in a database error.
> 
> The pushbutton is sampled once per loop as before. The processing of the samples has changed but this is unrelated.
> 
> ...


I've lost many a reply that way.

Thanks, I seem to have what I need working pretty well. Push-Hold reduces duty to 0 after 250 cycles, then upon release of the button, it goes to sleep. The next button push wakes it up and it enters "Low" mode. It seems to work pretty well.
Next I'll get it into the Rev2 code and call it rev3.


----------



## Alan B (Jul 2, 2009)

I sometimes select and copy the text, but not always.

I don't try to sleep the CPU when the light is on, the power savings is not significant then, and the increase in complexity is not warranted. The power savings is very important when the light is off.


----------



## JimmyM (Jul 2, 2009)

Alan B said:


> I sometimes select and copy the text, but not always.
> 
> I don't try to sleep the CPU when the light is on, the power savings is not significant then, and the increase in complexity is not warranted. The power savings is very important when the light is off.


I'm not sleeping the CPU while the light is on. It just goes to sleep immediately upon the application of power (batteries inserted). After that it only goes to sleep when the user will shut off the light or an overtemp/undervolt condition occurs.


----------



## Alan B (Aug 30, 2009)

Awfully quiet over here.

Quick status - Wave 3 of the drop-in regulators is about to ship.

A new Graphical based configuration program is in late beta. It uses WinAVR but doesn't need AVR Studio to work. It makes regulator code, loads it into the regulator and makes customized manuals at the push of a few buttons. The user can run the program and email me their config file for an easier install to their spec.

See the *Order Thread* for more info on all that:

https://www.candlepowerforums.com/threads/231886

The high voltage version has not been tested yet, though JimmyM's test of the 5V regulator did show that it should work if the FET is selected for higher voltage. Going to have to try that.


----------



## sylathnie (Aug 31, 2009)

High voltage????


----------



## Alan B (Aug 31, 2009)

sylathnie said:


> High voltage????



I plan to get a high voltage FET and make one HV unit. Then perhaps someone will test it... 

Next time I order parts from Digikey, I have the FET picked out...


----------



## sylathnie (Aug 31, 2009)

I just happen to have 12 very nice IMR 18650 cells ready to dump their juice into whatever you can provide. :naughty: (Technically I have 20 but no body that can hold all of them.) I also have a 50V 20A bench power supply for continuous and more controlled testing.


----------



## Alan B (Aug 31, 2009)

Sounds like you are the HV Beta Tester.:thumbsup:


----------



## sylathnie (Aug 31, 2009)

I also have 3 different 36V 400W bulbs for testing. Let's see how far we can push this thing.


----------



## Starlight (Sep 1, 2009)

I just want a board for my Larry12k. 40v input, 30v output, 25 amps. I can test it all you want.


----------



## JimmyM (Sep 1, 2009)

Starlight said:


> I just want a board for my Larry12k. 40v input, 30v output, 25 amps. I can test it all you want.


25A will cook the FET in pretty short order. Mine os good for ~13A continuous, Alan uses a bigger FET so his may be able to get away with more. But not 25A.


----------



## Starlight (Sep 1, 2009)

OK, which one if you is going to design a Larry12K board?


----------



## JimmyM (Sep 1, 2009)

Starlight said:


> OK, which one if you is going to design a Larry12K board?


do a search for JM-PhD-X1. I've got one in the conceptual phase. Of course I have an idea to add an "output booster" for the JM-PhD-D1.
We can discuss in the X1 thread.


----------



## Alan B (Sep 1, 2009)

Starlight said:


> I just want a board for my Larry12k. 40v input, 30v output, 25 amps. I can test it all you want.



If the application does not require fitting into the [email protected] D tube then it is not a difficult task.

The board I have for the D [email protected] has an off-board FET that can handle the current if a modest heatsink is applied (and it will take the TO-220 FET that has a hole for ease of heatsink mounting). The fuse would have to be bypassed, and it would be prudent to augment the ground side traces carrying the current. So it would be a fairly small hack on the existing board. I have promised in the past to dig up some prototype boards and this would be good for one of those. Are you up to building and hacking a board a bit? I could supply either a built board or a parts kit. You would have to work out a heatsink. How much room is available and can you dissipate 5 watts or more of heat from the FET?

Note that we may have other unpredicted problems at these current levels, but we won't know until we give it a try. These FETs are rated 40V 95A, but that is pushing all the limits.


----------



## Starlight (Sep 2, 2009)

Alan,
Size isn't a problem. There is lots of room inside these spotlights. I can solder and I can follow directions, but I'm not sure about working on the really small stuff. I'm willing to try anything you say.


----------



## Alan B (Sep 2, 2009)

What is the realistic runtime at 25A? Trying to size the heatsink.


----------



## Starlight (Sep 2, 2009)

6-8 minutes, but usually in runs not over 1 minute.


----------



## Alan B (Sep 2, 2009)

Starlight said:


> 6-8 minutes, but usually in runs not over 1 minute.



The FET will be dissipating about 4 watts, so a heatsink is indicated. The problem is how to get the heat out. The tab is electrically hot so it has to be insulated. If you can come up with a way to conduct the heat out, or minimize the runtime it should work.


----------



## Starlight (Sep 2, 2009)

Could we just spec an FET that is robust enough to take the heat? What about something like IRFS3006 or IRFS3107. I used them to make a soft start circuit for this light. If not, didn't you say that this FET would be mounted external to the board. I could probably get a heat sink or the FET through the case to the outside.


----------



## Alan B (Sep 2, 2009)

Starlight said:


> Could we just spec an FET that is robust enough to take the heat? What about something like IRFS3006 or IRFS3107. I used them to make a soft start circuit for this light. If not, didn't you say that this FET would be mounted external to the board. I could probably get a heat sink or the FET through the case to the outside.



It is a TO220 standing up from the board so you can get to it for heatsink. The leads could be soldered on longer. The trick is to electrically insulate the device, the tab is not ground.

Those FETs look good but they are optimized for higher gate voltage. Still they might work. You would have to figure out how to mount them and run wires to the board. If you can find something in a TO220 package it would drop right in.

4 watts is low enough that it will probably handle it for awhile anyway. Even a chunk of metal to increase the thermal mass would help and might be enough to get the job done. I just don't know how long it would go before it got hot. You can experiment and probably get away with it. I can't predict that accurately.

Soft starting does not stress them quite as much as PWM. We only have 5V of gate drive, also.


----------



## Starlight (Sep 2, 2009)

Which FET are you using? Is there only one that we are talking about to heatsink?


----------



## Alan B (Sep 2, 2009)

IRL1404. There are various packages, some are optimized for 5V gate.

Just one FET to heatsink. You can see it in the sled, though the ones in the photos have the tabs cut off, or are TO262 that come that way. I have some with tabs for easier heatsinking. I could leave the FET off and you can mount that if you need to.


----------



## Starlight (Sep 3, 2009)

If I need to mount the FET separate to the board, I can use any size. Would this one(IRLS3036TRL7PPCT-ND) hold up to heat enough better than the IRL1404 to make it worthwhile? Are the ones optimized for 5v, the logic level gate feature rather than standard?


----------



## Alan B (Sep 3, 2009)

Starlight said:


> If I need to mount the FET separate to the board, I can use any size. Would this one(IRLS3036TRL7PPCT-ND) hold up to heat enough better than the IRL1404 to make it worthwhile? Are the ones optimized for 5v, the logic level gate feature rather than standard?



The IRL1404 can handle hundreds of watts if it is properly heatsinked.

The others you mention are a bit lower forward resistance so they will get a little less warm (Heat = I squared times R). However this is somewhat offset by the gate drive. They are optimized for 10V. Looking at the curves 5V is not bad at lower currents, but it is reducing the advantage those parts have. In the end the resistance of the parts may be pretty similar at 5V drive. So the advantage goes nearly away.

Almost any heatsink at all on the IRL1404 will be enough.


----------



## Starlight (Sep 4, 2009)

Ok, I'm ready to try something. Let me know how much you want for the board and I will send paypal. We can switch this to email to keep from cluttering up this thread.


----------



## JimmyM (May 1, 2010)

Solution to reduce sleep mode power drain.
Very early in our design discussion we lamented the parasitic loss created by the sampling divider. We came to the conclusion that is was small enough to forget about. But I wanted to solve that problem.
Some quick math:
For Vref: 1.1V
Vbat 40V
Sample divider: 360K & 10K
That leaves us with 0.108 mA drain

For Vref: 2.56V
Vbat 40V
Sample divider: 150K & 10K
That leaves us with 0.25 mA drain

That might seem quite small, but it's pretty large compared to the AVR sleep mode current of ~0.0006 mA.

So I had an epiphany. I've been working with some small FETs with a Gate Threshold of just 1.8V.

If a small N-FET is placed between the Upper resistor of the divider and the ADC input, it will isolate the ADC and disconnect the sampling divider current path. Since the AVR is driving the gate with 5V and the drain leg is, at most 1.1 or 2.56V above ground, that leaves us with 3.9-2.49V between the Drain and Gate. Well above the 1.8V Gate threshold. I tested this last night and it works great.

Sampling divider parasitic losses can be reduced to the leakage current of the FET. In the case of the one I used, <1 uA (0.0001 mA). The added component is an addition to complexity, but since these can be had in tiny SC-70 packages, the impact on space is very small.


----------



## Alan B (May 2, 2010)

JimmyM said:


> Solution to reduce sleep mode power drain.
> Very early in our design discussion we lamented the parasitic loss created by the sampling divider. We came to the conclusion that is was small enough to forget about. But I wanted to solve that problem.
> Some quick math:
> For Vref: 1.1V
> ...


 
Great idea, Jim. You may recall I had a somewhat different approach with an opto-isolator, which I chose not to implement at the present time. Your idea is simpler, but it unfortunately won't work on my particular design since I use the 5V range as well as the lower voltage ranges in my autoranging.


----------



## JimmyM (May 2, 2010)

Alan B said:


> Great idea, Jim. You may recall I had a somewhat different approach with an opto-isolator, which I chose not to implement at the present time. Your idea is simpler, but it unfortunately won't work on my particular design since I use the 5V range as well as the lower voltage ranges in my autoranging.


Right. I had thought about your autoranging, but didn't realize you use the 5V (Vcc) Vref as well. Oh, well. Maybe future designs.


----------



## Alan B (May 2, 2010)

The current drain is pretty low already, most battery setups will handle many months to a few years of standby. I often loosen the tailcap to reduce it further, but charging once every few months is not a bad idea anyway. Heck, standard NiMH cells have more self drain than the regulator! Also other regulators that are very popular have more drain than mine.

What would be perfect for this function is a small surface mount opto with an FET output.


----------



## JimmyM (May 2, 2010)

Alan B said:


> The current drain is pretty low already, most battery setups will handle many months to a few years of standby. I often loosen the tailcap to reduce it further, but charging once every few months is not a bad idea anyway. Heck, standard NiMH cells have more self drain than the regulator! Also other regulators that are very popular have more drain than mine.
> 
> What would be perfect for this function is a small surface mount opto with an FET output.


I agree. It's pretty darned low to begin with. But it was always there in the back of my mind. The other night lying in bed it occurred to me.
An opto with an FET output would be perfect.
How about an opto isolated SSR.
Avago ASSR-301
In stock at Mouser:
ASSR-301


----------



## Alan B (May 2, 2010)

JimmyM said:


> I agree. It's pretty darned low to begin with. But it was always there in the back of my mind. The other night lying in bed it occurred to me.
> An opto with an FET output would be perfect.
> How about an opto isolated SSR.
> Avago ASSR-301
> ...



I suspect that most any opto-isolator would be fine, the current is so low.


----------

