Hotwire Regulator Design Collaboration Project

Status
Not open for further replies.

Alan B

Flashlight Enthusiast
Joined
Nov 19, 2007
Messages
1,964
Location
San Francisco Bay Area
Now that I've built a M@g85 I can see the value of a soft starting regulator for incan. But I don't see much availability. I see JimmyM and AW planning to do something soon. I see old stuff but not currently available. Did I miss any? Soft starting with a thermistor is nice, but not enough.

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 that I would like to see:

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)

(9/3/08, above items are coded and mostly tested, the FET power driver is not yet tested, though it has been analyzed)

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
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 seems to me that it would 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 voltage across the filament, plus some calculations to determine the effective (RMS) voltage and adjust smoothly to the desired value. Possibly a second ADC channel on the battery side to keep track of the battery voltage (if needed). Approximately three processor I/O pins are required:

1) pushbutton input
2) pwm out
3) battery voltage (loaded battery V is bulb peak V)
bulb RMS voltage (calculate from bulb peak 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.

I don't know if any of the existing available designs work precisely this way. JimmyM's soft start is not a micro. AW's is but I don't know much about the design. 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

Project Status: (9/13/2008)

We have a preliminary schematic. See the directory linked below. We have a sketch of a "Regulator Sled" that would slide into a D mag and replace the switch with the regulator PCB and a tactile momentary switch. There can be other electrical and mechanical designs, but this is what we have thus far.

We have Code Running:

080912%20stk500%20output.gif


The above is a scope capture of the output of the CPU outputting PWM to an LED on the STK500 development test board. It ramps smoothly between different voltage levels. It is not driving the FET in this test setup.

Next Step:

We need to prototype the hardware. At this point (9/13/2008) we are waiting for Jimmy, Will and Alan's prototypes to be constructed and tested. Alan built and tested a USBtinyISP programmer. This is a $22 kit for programming the micro in the flashlight. This will be useful for loading the software, changing the parameters, and trying out different versions of the software.

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 not yet complete. JimmyM and Alan are both working on some pc boards, but it may be a couple more weeks before this happens.

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.

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.


Test Programs: (these are done)

* DLY: Delay Test Program
*
* FP1: Toggle the FET Gate Output Test Program
* FP2: Electronic Pushbutton Switch Test Program
* FP3: PWM Test Program
* FP4: Ramped PWM with Soft Start Test Program
* FP5: Ramped Regulated Calibrated with Soft Start Test Program

More Later.


Design Files: (schematics and code)

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:
http://www.candlepowerforums.com/vb/showthread.php?t=107211

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

Willie Hunt Light Bulb 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:
http://www.candlepowerforums.com/vb/showthread.php?t=181866

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

Kiu Bipin Socket:
http://www.candlepowerforums.com/vb/showthread.php?t=171607

(Destructive) Bulb Testing - lots of bulb data:
http://www.candlepowerforums.com/vb/showthread.php?t=179748

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

Atmel AVR ISP 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
 
Last edited:
Re: Hotwire Regulators

Winny's PIR1 had a lot of these features. Soft start with programmable delay time, three regulated and programmable voltage levels, programmable low battery voltage warning and cutoff. You can program it with either a sequence of button presses or using a USB programmer and custom software. The bad news is that they are no longer in production but they occasionally come up for sale. That's how I picked one up a while back.
 
Re: Hotwire Regulators

Thanks for the tip. Here is the sales/info thread for Winny's PIR1:

http://www.candlepowerforums.com/vb/showthread.php?t=107211

This is possibly more complex than I was considering. Boil it down to really minimal. But much of the same idea.

Also mentioned was the LightBrain. It has a homebrew version here:

http://lasertagparts.com/lightbrain/free_regulator.htm

They seem to have quit making product in 2005.

I think something in between these two examples is what I'm thinking of.

-- Alan
 
Last edited:
Re: Hotwire Regulators

No offense to Winny, but I blew all three of my PIRs-- and I'm not clear how. One minute they're working, then suddenly they weren't. When they worked, they had the features you describe. They were freakin' AWESOME when they worked.

But back to your design: you do NOT want to "filter" the PWM. This isn't audio-- you can't see 1KHz blinking, assuming a filament could heat up and cool down that quickly, which of course it cannot.

The trick is the SW. You need to measure the input voltage, Then figure the right duty cycle to give an RMS equivalent voltage to the desired output. Repeat every second or so.

Unless someone wants to go crazy and take voltage drop during the "on" phase into account, that's pretty much it.

Pertinax

P.S. If anyone would like to try resurrecting some dead PIRs, make me an offer.
 
Re: Hotwire Regulators

No offense to Winny, but I blew all three of my PIRs-- and I'm not clear how. One minute they're working, then suddenly they weren't. When they worked, they had the features you describe. They were freakin' AWESOME when they worked.......
Yeah, mine's got a glitch too. It works fine until you tell it to turn off fully. Then it goes off and won't come back on until you cycle the power to the driver, then it works fine again. Winny gave me a possible cause, but it doesn't look like that's it. I've been meaning to disassemble it to check it more fully, but haven't done it yet. In the meantime, I'm just using a second tailcap switch to reset the driver.
 
Re: Hotwire Regulators

But back to your design: you do NOT want to "filter" the PWM. This isn't audio-- you can't see 1KHz blinking, assuming a filament could heat up and cool down that quickly, which of course it cannot.
The human eye may not see 1 kHz, but electronic circuitry certainly can. When you have a 1 kHz PWM drive to the load, the voltage is jumping up and down at 1 kHz. I think you have to filter that to provide a smooth feedback reference to measure when controlling the PWM duty cycle.
 
Re: Hotwire Regulators

The human eye may not see 1 kHz, but electronic circuitry certainly can. When you have a 1 kHz PWM drive to the load, the voltage is jumping up and down at 1 kHz. I think you have to filter that to provide a smooth feedback reference to measure when controlling the PWM duty cycle.

You are both right. We don't want to filter the power to the filament. We do want to get a measurement of the effective voltage to the filament. In thinking about this further, I can think of several ways to do this, but one thing to understand first is that the effective filament voltage is not the same as the average filament voltage. Power is E squared over R, so averaging the loaded supply voltage over the duty cycle does not give the effective voltage. For example, doubling the voltage and halving the duty cycle will keep average voltage the same, but power will double due to the E squared term of the power equation.

Measuring E under load could be done, but this would require synchronization between the voltage sampling and the PWM. Since there is a sag in the voltage under load, this could lead to sample timing issues, in addition to the complexity. So to keep it simple we want to use some kind of averaging, which is like the process that develops power in the filament.

I did a quick bit of algebra and came up with a correction factor for the average voltage to get to the effective voltage. I define the effective voltage as that DC voltage equivalent to the filament that would produce the same power in the filament as the average voltage we would read under PWM with a simple RC filter. It is the voltage we want to control to.

This correction factor turns out to be one over the square root of the duty cycle. So if we average the filament with a filter, ADC convert that value, and multiply by this correction factor we get an effective voltage value that we can feed back on. So the PWM duty cycle is adjusted upward during soft starting until this effective voltage reaches the user set desired filament voltage.

Do these other hotwire regulators work this way? Am I reinventing the PWM incan regulator here??

-- Alan
 
Last edited:
Re: Hotwire Regulators

the effective filament voltage is not the same as the average filament voltage. Power is E squared over R, so averaging the loaded supply voltage over the duty cycle does not give the effective voltage
The term that presents itself here of course, is RMS or root-mean-square voltage. This is the DC voltage that delivers the same power into a resistive load as an AC waveform. :)

One over the square root of the duty cycle, huh? That's a neat result. Could provide a use for an op-amp analog square root extractor, or maybe the idea of using a programmable micro-controller is not as off the wall as I originally thought it might be... :devil:

From my internet browsing, there are quite a few examples of analog PWM regulation circuits out there. Unfortunately, I have not understood exactly how they get the voltage/current feedback control part to work out.
 
Re: Hotwire Regulators

The human eye may not see 1 kHz, but electronic circuitry certainly can. When you have a 1 kHz PWM drive to the load, the voltage is jumping up and down at 1 kHz. I think you have to filter that to provide a smooth feedback reference to measure when controlling the PWM duty cycle.

That's precicely it. The square wave output needs to be sampled and filtered. You can't sample the entire current path like a SMPS. That would lead to large inductors and capacitors with associated resistance.
The PIR has problems measuring the battery voltage and calculating the required duty cycle. That's why he had to incorporate a couple of calibration factors. The battery voltage sags under load and the rapid switching introduces noise into the signal as well. You mentioned increasing the frequency. That would help reduce the size of the sampling components and ripple. But it increases heat. You really need to measure a filtered sample of the output voltage. I love the microcontroller idea. I just don't have the programming knowledge to implement your ideas.
I've just received some new components to begin regulator experimentation. However, the L14K softstarter is next in line for building.
 
Re: Hotwire Regulators

The term that presents itself here of course, is RMS or root-mean-square voltage. This is the DC voltage that delivers the same power into a resistive load as an AC waveform. :)

One over the square root of the duty cycle, huh? That's a neat result. Could provide a use for an op-amp analog square root extractor, or maybe the idea of using a programmable micro-controller is not as off the wall as I originally thought it might be... :devil:

From my internet browsing, there are quite a few examples of analog PWM regulation circuits out there. Unfortunately, I have not understood exactly how they get the voltage/current feedback control part to work out.

RMS precisely. Forgot to mention that. Excellent observation!

Using a micro seems overkill, but when an 8 pin micro costs $2 in small quantities and reduces the system parts count and gives capabilities not otherwise practical, they're worth it. It makes the thing smaller, and reduces the number of parts and wiring. I would rather write software than wire up a bunch of op amps, myself. Especially if to build 100 of them. PCBs make the wiring easy but there is still the procurement, soldering, testing, alignment, troubleshooting, etc.

Another thought is to have a public PCB layout. Free software is available for PCB layout from at least one company, and they make PCBs quickly via internet upload of the design file. They aren't the cheapest place on the net, but they are quick and good quality and with a public PCB layout anyone can have a few boards made, and even customize them a bit if needed. For about $60 you get three boards, each 2.5 by 3.8 inches. Depending on the side of the actual regulator board, up to about six could be laid out on each of these three boards, so up to about 18 boards could be made in less than a week for under $60 (expresspcb.com). That's just over $3 each. Not bad for quick turnaround, small quantity, and free PCB software that anyone can play with. Alternately one person could do the PCB and hardware, and make a few bucks selling the basic hardware modules. Maybe a small donation per board sold to the forums here would be appropriate as the enabling technology to facilitate the collaboration.

I'm hoping here we can combine efforts of a few folks to get something that no one has time/skill combinations to do alone. Glad to see JimmyM posting here. If we can get one person doing hardware, and one or more doing software we can spread out the effort and perhaps get this thing off the ground. We can start out with simple software and basic hardware and get something useful. Then later it can be improved as needed, and the software re-loaded into the chip. Unlike some of the earlier parts the current parts that are reprogrammable are readily available inexpensively. So new "firmware" for your flashlight is possible. (And since they are off-net they are not subject to viri et al).

-- Alan
 
Re: Hotwire Regulators

I'd be happy to do some schematic to PCB design work. I can also prototype a few for proving. I use "PCB Artist" and winQcad. PCB artist's files can be uploaded to their site for Gerber file creation. WinQcad can generate the Gerber files locally.

The biggest hurdle here is converting a measured sample of a square wave to a DC voltage in a linear fasion. There are RMS converters, but the ones I've found are expensive. Something like $30+ volts.
 
Re: Hotwire Regulators

Just adding a uP to your existing soft start switch might be a good start. I've not looked at the soft start schematic, but it does not take many parts, perhaps fewer than the soft start already has. Actually, the LightBrain schematic is very close to what is needed. Links above.

What I'm proposing is to use an RC 'averaging' filter and the correction coefficient from the PWM duty cycle to calculate RMS voltage. Since the filament voltage is too high for the on-chip ADC the filter needs to both divide the voltage and provide enough averaging for a few cycles of PWM. This can be accomplished with two resistors and one capacitor from the filament voltage to the ADC input. The rest is software. No RMS chip needed.

Then multiply the measured average voltage by one over the square root of the duty cycle to get RMS. The PWM correction factor can probably be a table lookup, I don't think much precision is required, if the CPU is not well suited to doing that calculation directly.

I have used both PIC and AVR micros, lately I have been preferring AVRs. A quick look shows the Atmel ATTiny13 8 pin chip might be suitable. 6 I/O pins, PWM, onboard clock, 1K program flash mem, etc, etc. Here is the summary sheet:

http://www.atmel.com/dyn/resources/prod_documents/2535S.pdf

These microprocessor systems on a chip are about $1.29 at Digikey in ones, and about 0.81 in quantity 25!! :)

-- Alan
 
Last edited:
Re: Hotwire Regulators

I don't think much precision is required, if the CPU is not well suited to doing that calculation directly
There's a very fast approximate method for 1/sqrt(x) used by the games programming fraternity, that uses some bit twiddling followed by a single Newton update, that might be portable to a micro. I can find the reference if anyone's interested.
These microprocessor systems on a chip are about $1.29 at Digikey in ones, and about 0.81 in quantity 25!!
What do you need to program them, though? Might that not be the more expensive bit?
 
Last edited:
Re: Hotwire Regulators

The PWM design I have uses low-side switching to avoid using a charge pump/mosfet driver that would be required to use an N-channel mosfet on the high side. P channel MOSFETs don't have the low Rds(on) that N channel fets have. I have a PWM controller picked out that drives a P-channel FET, but I need to do some testing at high power. Heat sinking is at a premium unside a KIU base.

The RC network would just convert the squarewave to a sawtooth. As long as the sawtooths peak-to-peak voltage is within the tolerances of the ADC in the MC, then it should read a pseudo DC voltage. The sample circuit I'm thinking of using is more like the output stage of an SMPS. It should result in a more DC-like waveform. I'm looking into the ripple tolerance of the controller.
 
Re: Hotwire Regulators

There's a very fast approximate method for 1/sqrt(x) used by the games programming fraternity, that uses some bit twiddling followed by a single Newton update, that might be portable to a micro. I can find the reference if anyone's interested.
What do you need to program them, though? Might that not be the more expensive bit?

Programming software is free. That's one reason I prefer AVR to PIC, but there is now free software for both. On the larger parts GCC (the free GNU C Compiler) will work with the AVR, but on the smaller parts assembly is usually required.

The programming hardware is pretty simple and can be homebrewed, or a nice USB version purchased for $35:

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=ATAVRISP2-ND

-- Alan
 
Last edited:
Re: Hotwire Regulators

It JUST hit me. The PWM controller's error amplifier's output is brought out at one if the pins (compensation). There's no transient response to deal with. The load is constant. A sawtooth wave at the feedback pin might not be an issue, if the error amplifier has a RC load on it with a time constant several times the switching frequency.
This is good for my design, not necessarily good for the microcontroller design. Unless you want to consider using an external opamp and voltage reference.
 
Re: Hotwire Regulators

JimmyM, Good that you figured out something useful from this brainstorming. Lots of good ideas.

Earlier this evening I had a long response to your earlier post typed up and my computer video went away. Looks serious, so I'll have to work on that.

I counted 10 parts in the CPU design by LightBrain. That is a good target. I'm aiming for that neighborhood.

N channel FET is good for parts count and cost/performance, though the P channel devices are more reliable (tougher, have more safety factor for equal performance). N channel is easier to drive, so cost/parts count comes down. It does create a problem measuring average bulb voltage however.

I'm looking into the details of the micro to see if the ADC can be synchronized easily with the PWM. Then the voltage under load can be properly measured and RMS calculated. This will mean the RC filter won't be needed or wanted. Reduces the parts count to 9. I would add a gate drain resistor however as the micro comes up tri-state, and we wouldn't want that gate to float up and the FET go linear. That would likely blow the FET. Wonder if that's what's happening to the PIR1's. If this was happening I would expect they might come on partially bright and then either go full on (shorted FET) or off (open FET).

-- Alan
 
Re: Hotwire Regulators

I didn't see any mention of AWR's Hotdriver which has some other useful contributions to the project.
 
Re: Hotwire Regulators

N channel FET is good for parts count and cost/performance, though the P channel devices are more reliable (tougher, have more safety factor for equal performance). N channel is easier to drive, so cost/parts count comes down. It does create a problem measuring average bulb voltage however.
Please explain further. I'm not sure how you mean N-channel fets are easier to drive. For a regulator, we'd have to use it in the "high side". That requires a mosfet driver or some sort of gate drive charge pump to fully enhance the gate. In high side switching the P channel is easiest. Pull the gate to B+ to turn off, pull it to B- to turn on.
I thought the N channel MOSFETs were the more robust chips. Is there some info you could point me to so that I can learn.
And "Yes" a tri state gate spells doom for the FET.

Lux,
You too. Please explain further with regards to AWRs HD. It is a fantastic piece that has served the group very well. But what in his design can we use in a PWM design. Hey, why re-invent the wheel right?
Thanks.
 
Re: Hotwire Regulators

Please explain further. I'm not sure how you mean N-channel fets are easier to drive. For a regulator, we'd have to use it in the "high side". That requires a mosfet driver or some sort of gate drive charge pump to fully enhance the gate. In high side switching the P channel is easiest. Pull the gate to B+ to turn off, pull it to B- to turn on.
I thought the N channel MOSFETs were the more robust chips. Is there some info you could point me to so that I can learn.
And "Yes" a tri state gate spells doom for the FET.

Lux,
You too. Please explain further with regards to AWRs HD. It is a fantastic piece that has served the group very well. But what in his design can we use in a PWM design. Hey, why re-invent the wheel right?
Thanks.

I'm not sure why a regulator has to use the 'high side' switch. Perhaps you are thinking that way because detecting the filament voltage in a low side configuration is harder, but if the ADC is synchronized with the PWM the low side driver is not a problem, we can still measure bulb voltage under load and use PWM duty cycle to calculate RMS.

On P vs N channel devices I have a thick handbook. It is old, but I think a lot of the info is still good. The P channel devices have a lower density of current carriers, so they have to use a lot more semiconductor material to get the same impedance as the N channel devices. This makes P channel devics cost more (for the same low on-resistance) but they then have more thermal mass and are more robust. For a given amount of semiconductor material, the N channel devices have lower impedance and higher current capability, but for a given impedance level the P channel devices (with more semiconductor material) have more thermal mass. That's what I recall from that source, unless device physics have changed since it was printed.

I think we are saying the same thing regarding driving the FETs.

The N channel logic level devices can be connected directly to the microprocessor in a low side switching configuration, so the drive is easy and low in parts count, as in one resistor to drain the gate when the micro goes tristate. The P channel devices in a high side configuration have to be pulled down to drive them, which requires a driver since the micro pins cannot handle the high voltage, and you have to protect the P channel device gate from overvoltage. So it takes a few more parts. In the solar controllers I have designed it took three resistors, a zener, and another small FET to drive them. So the parts count would go up by 4 and be about 14 instead of 10 parts. Then the averaging circuit on the filament voltage would work so another cap would be needed so 15 parts. Five extra parts plus the higher cost of the P chanel devices would increase costs a bit.

Driving the N channel device in a high side configuration, as you are indicating, is difficult, requiring a higher voltage.

The other problem with P channel devices is they require 10 volts to saturate, while logic level N channel devices will saturate with 5 volts of gate drive. There may be similar P channel devices available but I have not seen them.

Hi LuxLuthor. I have not seen a schematic or technical details on the AWR driver, I did look, but the links have been broken. I was referring to it in the class of "unavailable" drivers mentioned in the first post. So I am not very aware of what might be useful there. If you can help with links that would be useful.

-- Alan
 
Status
Not open for further replies.
Top