# Hotwire Regulator Design Collaboration Project Part 2



## Alan B (Jan 13, 2008)

*Hotwire Regulator Design Collaboration Project part 2*

*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 third section of this design thread continues here:* https://www.candlepowerforums.com/posts/2803333

*Now on to this, the second half of the Design thread:*

(From the first post of the first thread, with changes

Now that I've built a [email protected] 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)

(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
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 (option, some designs don't need this)(need on-switch detection in some cases)
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


*Today (10/4/2008) we start part 2 of the thread. 

Part 1 is here:*

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

*Part 3 is here:*

https://www.candlepowerforums.com/posts/2803333


*Project Status: (10/4/2008)*

We have a schematic and two circuit boards have been designed. One has been produced and tested. 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.

*Project Status: (12/2008)*

wquiles and JimmyM have started application specific projects for derivative versions of what has come to be known as the PHD (Programmable Hotwire Driver) regulator, and have threads pertaining to the details. General and specific design discussions continue in this thread. Links to the new threads are at the bottom of this posting. JimmyM has released a development/test PC board.

*Project Status: (1/2009)*

Alan has built a prototype into a D [email protected] and is about to build and test the second generation PCB for the [email protected] There is an interest thread for that variant as well as JimmyM and wquiles versions.

*Schematic*

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


*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.

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.


*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: Functional Flashlight Control program with many 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 

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:
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 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


*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 (Oct 4, 2008)

Looks like we overflowed.

I updated the copy of the first post in this thread, the old thread is locked.

This is a pretty good breakpoint, things are working well now.

What do folks want to tackle next?

-- Alan


----------



## wquiles (Oct 4, 2008)

Good summary above Alan - nicely done 

As to what do to next, I want to measure a few more things, including the initial surge current peak. I did it last time by differentially measuring the voltage across a 0.01 precision 4-terminal resistor, but of course, I want to do this with a higher power bulb, probably my 1185 and with real batteries (I still don't want to base much on a PS, no mater how good it might be).

Alan, question: have you tried calibrating the ADC using the Vcc input instead of the internal 2.56Vref? I was looking at the specs on the 5V (Vcc) regulator, and they seem a lot tighter than those in the internal 2.56Vref.

Will


----------



## Alan B (Oct 4, 2008)

wquiles said:


> Good summary above Alan - nicely done
> 
> As to what do to next, I want to measure a few more things, including the initial surge current peak. I did it last time by differentially measuring the voltage across a 0.01 precision 4-terminal resistor, but of course, I want to do this with a higher power bulb, probably my 1185 and with real batteries (I still don't want to base much on a PS, no mater how good it might be).
> 
> ...


 
It would be nice to see current measurements. I agree on the battery testing. That is the real answer. 

I thought about using the 5V but have not tried it. There are a few downsides:

1) it would double the standby current if we maintain the same input impedance to the ADC

2) it would decrease our ESD protection for the ADC input by a factor of two

3) it would probably have more noise on it than the Vref (a guess)

Unless it is good enough to totally avoid calibration, then it isn't really a help. Not sure if it is that good. How good does it have to be? Perhaps plus or minus 0.05V at Vbulb?

I have run the 1185 bulb quite a bit with 10 NiMH C cells, it works quite nicely. Perhaps I can put together a beta flashlight code soon. I'm going to be pretty busy for the next 2 weeks so we'll see what I can get done. I really would like to cut some metal and mount a proto Msled in a [email protected], but not sure when I'll be able to do that.

How much room is there in the M6 physically for a PCB? Is it similar to C [email protected] KIU base? The diameter is large but space is at a premium. Perhaps a PCB with components around the outside and contacts in the center can be sandwiched between bulb springs and battery pack...

-- Alan


----------



## LuxLuthor (Oct 5, 2008)

Really excellent summary and list of resources, Alan. Getting so close now. Yes on doing what I can to help test. Fully willing to get the programming hardware/software, etc.

As far as the M6 (& other setups) room, it somewhat depends on the bulb setup & batteries. For example this DM51 shootout has a wide set of variables.


----------



## wquiles (Oct 5, 2008)

Alan,

The other thing we need to work on, unless you already have it implemented, is on an usable soft start in the 50-100mS range. For a light that needs to occasionally need to be used for signaling in an emergency, a 1+ second soft start is excessively long. After using the Willie Hunt LVR and the HDM6, I have to agree that the 50-100mS is the "right" target - anything longer takes away from any posible use as a signaling device. There might be other applications that needed the quicker startup, but if Willie Hunt selected 50mS for his LVR and for the Surefire A2, I have to trust his judgement that there is a good reason for it 

Will


----------



## wquiles (Oct 5, 2008)

LuxLuthor said:


> As far as the M6 (& other setups) room, it somewhat depends on the bulb setup & batteries. For example this DM51 shootout has a wide set of variables.



That is exactly why I wanted to tread the M6 as a separate sub-project - talk about options. Plus once you have a regulated soft-start solution such as the PhD, you can then venture into solutions with higher battery voltages that are not possible now due to risk of insta-flash. I am also expecting that the soft-start will allow the use of protected LiIon cells that don't work today due to the protection device triggering upon the initial current surge 

Will


----------



## wquiles (Oct 5, 2008)

Alan B said:


> It would be nice to see current measurements. I agree on the battery testing. That is the real answer.
> 
> I thought about using the 5V but have not tried it. There are a few downsides:
> 
> ...



I really think the Vcc regulation "could" be that good, and that it might allow us to forgo the calibration (or use a simpler procedure). At least I feel it might be good enough and make the PhD easier to use.

1) it would double the standby current if we maintain the same input impedance to the ADC
=> We could use the Tiny85's sleep function so current draw would still be insignificant while not in use. While in use, it would not mater, as the drain in the batteries would be at least one or more orders of magnitude larger.

2) it would decrease our ESD protection for the ADC input by a factor of two
=> All circuits we use in flashlights are ESD sensitive - we just have to be carefull.

3) it would probably have more noise on it than the Vref (a guess)
=> From what I measured on my scope, the Vcc was really clean, and did not have any movement/spikes while the FET was switching.

I will try to do more measurements on the Vcc line to gather more data. I just feel it is worth exploring before we require the use to do external calibration.

Will


----------



## Alan B (Oct 5, 2008)

wquiles said:


> I really think the Vcc regulation "could" be that good, and that it might allow us to forgo the calibration (or use a simpler procedure). At least I feel it might be good enough and make the PhD easier to use.
> 
> 1) it would double the standby current if we maintain the same input impedance to the ADC
> => We could use the Tiny85's sleep function so current draw would still be insignificant while not in use. While in use, it would not mater, as the drain in the batteries would be at least one or more orders of magnitude larger.
> ...


 
Note that the ADC scaling resistors use current all the time, and they use more than 10x the current of the sleeping CPU. It is not the CPU that is dominating the off current. If there is a 'master off' switch this does not occur. If we changed to the 1.1V Vref we could lower the off current so perhaps we should consider that as well.

Note that we are not locked into the 2.56V Vref, we can support both modes quite easily. In fact, using the R1=47K value with 5V Vcc Vref will put the ADC max voltage to about 25V.

Changing to the Vcc Vref is trivial to try, only two things need to be changed in the software. I will leave that as an exercise for others for the moment while I pursue some code cleanup and completion. Simplifying calibration is part of that, I need to finish the dynamic calibration. I believe calibration will be necessary, so making it easy is a requirement.

*Calibration*

Calibration is a process the BUILDER needs to complete to adjust for the actual component values used in the circuit - to compensate for the resistors and the CPU chip manufacturing variations. If the regulator is a kit, then the kit builder will need to calibrate it. If built by a vendor, the vendor will complete this calibration and the end user will not be burdened.

Here is an example simple calibration process: 

1) Measure battery voltage with a normal averaging DC Multimeter. In a precalculated chart look up the battery voltage and get the Average Calibration Value to adjust to.

2) Plug a resistor into the bulb socket (instead of a bulb), and connect the DC Multimeter across the resistor.

3) Adjust the calibration until the Multimeter reads the chart value.

-- Alan


----------



## Alan B (Oct 5, 2008)

wquiles said:


> Alan,
> 
> The other thing we need to work on, unless you already have it implemented, is on an usable soft start in the 50-100mS range. For a light that needs to occasionally need to be used for signaling in an emergency, a 1+ second soft start is excessively long. After using the Willie Hunt LVR and the HDM6, I have to agree that the 50-100mS is the "right" target - anything longer takes away from any posible use as a signaling device. There might be other applications that needed the quicker startup, but if Willie Hunt selected 50mS for his LVR and for the Surefire A2, I have to trust his judgement that there is a good reason for it
> 
> Will


 
I have this implemented, but not fully tested.

-- Alan


----------



## wquiles (Oct 5, 2008)

Thanks much Alan - I did not realized the 10x factor in current 

Let us know when your code is ready for the next round of testing :twothumbs

Question: What is the current plan for the external calibration: Is the calibration going to be implemented with an external pot, or via additional "+" and "-" push buttons? How will the builder put the PhD in and out of "calibration mode"? If using buttons, some multiple button combination, such as pressing the "+" and "-" at the same time?

Will


----------



## Alan B (Oct 5, 2008)

wquiles said:


> Thanks much Alan - I did not realized the 10x factor in current
> 
> Let us know when your code is ready for the next round of testing :twothumbs
> 
> ...


 
Let's review the current and see if I did that right. 25V/110K = 225uA. At 12V it is better if you are using 100K, but if using 47K it is about the same. If we go to 5V and maintain the same impedance to the ADC pins we have to double the current to achieve 5V across the 10K. 10K is the recommended impedance to feed the ADC. We can probably go higher, that would be something to try out and see how it affects regulation and noise. It should increase noise a bit, but it may not be too bad. Something to try.

My Msled has three pushbuttons on a separate plug-in board used for calibration and programming. I'll do that one first. UP cal, Down cal and Control buttons. Since that board gets removed for operation the cal buttons can be 'live' all the time, but it only makes sense to cal at VLO and VHI since anywhere else there's no reference to cal against, so I limit the cal operation to those moments when Vbulb is at VLO and VHI.

For the single button folks I was thinking about a jumper on the programming pins that would put it into the cal mode and output a cal value which would be VHI. In this mode each push-hold of the control button would change the cal factor in the opposite direction. So by tap-holding you could get any cal value. Then Idle the light for a few seconds to make sure the cal factor is saved in eeprom (saves when idle), then remove power, remove jumper.

The external pot cal is always possible. You can do that right now. Add the pot, adjust the program, and you're there. Screwdriver cal. Jim may want to put that on his test board as well, then that board has complete options.

How does that sound?

-- Alan


----------



## wquiles (Oct 5, 2008)

Alan B said:


> Let's review the current and see if I did that right. 25V/110K = 225uA. At 12V it is better if you are using 100K, but if using 47K it is about the same. If we go to 5V and maintain the same impedance to the ADC pins we have to double the current to achieve 5V across the 10K. 10K is the recommended impedance to feed the ADC. We can probably go higher, that would be something to try out and see how it affects regulation and noise. It should increase noise a bit, but it may not be too bad. Something to try.
> 
> My Msled has three pushbuttons on a separate plug-in board used for calibration and programming. I'll do that one first. UP cal, Down cal and Control buttons. Since that board gets removed for operation the cal buttons can be 'live' all the time, but it only makes sense to cal at VLO and VHI since anywhere else there's no reference to cal against, so I limit the cal operation to those moments when Vbulb is at VLO and VHI.
> 
> ...




OK, sounds like playing with Vref = Vcc could be a little interesting. If I decide to play with it, have to change the #define VREF from 2.56 to 5.0, and on the ADMUX register, I should delete both bits REFS2 and REGS1 to select Vcc - is that it?

That Msled of yours is cool with the extra buttons - nice going. As to the single button interface, yes, that would be outstanding. Using a single jumper to get it in that mode, and then using the single button to get any value. Brilliant, and safe, as once done, you remove the jumper, so during use there would be no problem getting into this mode by "accident" 

I would prefer the extra button or single jumper to program the calibration factor than the external pot, but that is just me. I guess boards can be built both ways depending on individual preferences 

Will


----------



## Alan B (Oct 5, 2008)

wquiles said:


> OK, sounds like playing with Vref = Vcc could be a little interesting. If I decide to play with it, have to change the #define VREF from 2.56 to 5.0, and on the ADMUX register, I should delete both bits REFS2 and REGS1 to select Vcc - is that it?
> 
> That Msled of yours is cool with the extra buttons - nice going. As to the single button interface, yes, that would be outstanding. Using a single jumper to get it in that mode, and then using the single button to get any value. Brilliant, and safe, as once done, you remove the jumper, so during use there would be no problem during operation
> 
> ...


 
On Vcc Vref, that sounds about right - I didn't check the bits, but that's where the change needs to be, and the define, as you noted. Put one of the test programs into ADC to PWM output mode and vary the supply voltage and correlate it with the PWM ontime to see what the ADC is getting. It should be about half the usual value.

On the cal pot - it can be provided for on the PCB and just jumpered out when not used.

-- Alan


----------



## wquiles (Oct 5, 2008)

Alan,

I changed those two statements to try using Vcc. Just to check the initial divergence, I am using Vcal=1.0. R1 is now 47K (from 100K) since I need a larger voltage at the ADC input. Using:
#define VRED 5.0,
#define VOLTAGES, 
#define SCOPETRIG, and 
#define INTEGRAL options.

At startup (voltage on Fluke): 0.180 Volts (low accuracy)
Press (volts on Fluke): 
1 0.324 Volts (larger, but still low accuracy)
2 1.69 Volts (here we go)
3 2.79 Volts 
4 3.77 Volts 
5 4.78 Volts 
6 5.75 Volts 
7 6.79 Volts 
8 7.77 Volts 
9 8.73 Volts 
10 9.73 Volts 
11 10.72 Volts
12 11.68 Volts
13 0.180 Volts (goes back to startup)

So it looks like it tracks just OK, and just like you expected, even using Vcc would require some calibration factor :shakehead

Not all lost - at least I learned a little bit more about the Tiny85's registers 

Will


----------



## wquiles (Oct 5, 2008)

I played with it some more (using Vcc as a ref), and it looks like I need VCAL equal to about 1.03

At startup (voltage on Fluke): 0.180 Volts (low accuracy)
Press (volts on Fluke): 
1 0.324 Volts (larger, but still low accuracy)
2 1.89 Volts (here we go)
3 2.92 Volts 
4 3.87 Volts 
5 5.01 Volts 
6 5.99 Volts 
7 6.99 Volts 
8 7.96 Volts 
9 8.97 Volts 
10 10.07 Volts 
11 11.06 Volts
12 12.02 Volts
13 0.180 Volts (goes back to startup)

So bottom line, from this very limited data sample, I "still" need a correction factor, but the value is smaller (1.03) than when using the internal 2.56V reference (1.115). Maybe not worth the trouble to change the ref, but it was fun to do 

Will


----------



## Alan B (Oct 5, 2008)

wquiles said:


> I played with it some more (using Vcc as a ref), and it looks like I need VCAL equal to about 1.03
> 
> ...
> So bottom line, from this very limited data sample, I "still" need a correction factor, but the value is smaller (1.03) than when using the internal 2.56V reference (1.115). Maybe not worth the trouble to change the ref, but it was fun to do
> ...


 
Excellent experiment and congratulations on your first "mod" to the software. I have done some work on the code but it is not complete nor have I tested it for more than compiler errors yet.

I would think that putting in the actual measured values for Vcc and the resistors should yield pretty close calibration.

-- Alan


----------



## Alan B (Oct 6, 2008)

Above is a recent photo of the [email protected] Prototype in Test. The Programming/Calibration daughterboard is plugged in and the three pushbuttons and programming jack are visible toward the left. The USBtinyISP programming cable is visible low center. 

-- Alan


----------



## wquiles (Oct 6, 2008)

Alan B said:


> Excellent experiment and congratulations on your first "mod" to the software. I have done some work on the code but it is not complete nor have I tested it for more than compiler errors yet.


Thank - I am getting more comfortable and adventurous with the Tiny85. But the biggest help is that you took the time to write good in-line documentation :thumbsup:





Alan B said:


> I would think that putting in the actual measured values for Vcc and the resistors should yield pretty close calibration.


I will try that tonight. It will be interesting to see how "close" we can get 





Alan B said:


> ...
> 
> Above is a recent photo of the [email protected] Prototype in Test. The Programming/Calibration daughterboard is plugged in and the three pushbuttons and programming jack are visible toward the left. The USBtinyISP programming cable is visible low center.


That looks "really" cool :twothumbs


----------



## wquiles (Oct 6, 2008)

Alan B said:


> I would think that putting in the actual measured values for Vcc and the resistors should yield pretty close calibration.



Here is the data using the actual Vcc and resistor values that I have:
Vcc=4.967Volts
R1=46.2K (instead of 47K)
R3=9.98K (instead of 10K)
Vcal = 1.0 (no adjustment - just for this experiment)

At startup (voltage on Fluke): 0.179 Volts (low accuracy)
Press (volts on Fluke): 
1 0.322 Volts (larger, but still low accuracy)
2 1.89 Volts (here we go)
3 2.92 Volts 
4 3.87 Volts 
5 4.86 Volts 
6 5.87 Volts 
7 6.89 Volts 
8 7.87 Volts 
9 8.97 Volts 
10 9.96 Volts 
11 10.93 Volts
12 11.93 Volts
13 0.180 Volts (goes back to startup)

Not right on the money, but not bad either. I imagine that with a tiny bump (Vcal = 1.01) we might be spot on again 

Will


----------



## Alan B (Oct 6, 2008)

wquiles said:


> Here is the data using the actual Vcc and resistor values that I have:
> Vcc=4.967Volts
> R1=46.2K (instead of 47K)
> R3=9.98K (instead of 10K)
> ...


 
That's pretty darn close! Not bad!!

Wonder if the 1.1 volt Vref is worth trying. It would lower the power consumption by a nice factor of 2.5 which would be nice.

-- Alan


----------



## geek4christ (Oct 6, 2008)

Man, this has been a fascinating thread to follow. I'm only just now starting to get into hotwires, and offer admiration and thanks to you all for putting the time and effort into this project. I can't wait to see this thing in a flashlight and (hopefully) get try it out for myself when I get a little more experience under my belt.

Oh, and Alan. I just remembered you saying earlier that you lost your clipboard contents...try this or this. Never lose them again :thumbsup:


----------



## Alan B (Oct 6, 2008)

geek4christ said:


> Man, this has been a fascinating thread to follow. I'm only just now starting to get into hotwires, and offer admiration and thanks to you all for putting the time and effort into this project. I can't wait to see this thing in a flashlight and (hopefully) get try it out for myself when I get a little more experience under my belt.
> 
> Oh, and Alan. I just remembered you saying earlier that you lost your clipboard contents...try this or this. Never lose them again :thumbsup:


 
Forrest:

Thanks for stopping by and welcome to hotwires. Hopefully we'll have some really good stuff to show very shortly. From here it is smooth sailing, I hope. 

Great tip on the clipboard software. Have to give that a try. Looks quite useful. I try to keep my computers a bit lean, but that might be well worth it.

-- Alan


----------



## geek4christ (Oct 6, 2008)

Thanks for the welcome, Alan.



Alan B said:


> I try to keep my computers a bit lean, but that might be well worth it.



In my experience, ditto is the less resource-hungry of those two. For some reason clipx wants to do more I/O than what seems necessary.


----------



## Alan B (Oct 7, 2008)

Alan B said:


> Above is a recent photo of the [email protected] Prototype in Test. The Programming/Calibration daughterboard is plugged in and the three pushbuttons and programming jack are visible toward the left. The USBtinyISP programming cable is visible low center.
> 
> -- Alan


 
I just updated the earlier photo with a better one, and here are a couple more:






A closeup of the [email protected] board.






Here with the production pushbutton installed (intended to fit into the [email protected] and be close to flush with the body), and the programming/calibration plug bottom center.

Above photos taken at small F stop for depth of field and flash to generate sufficient light. It makes the WA1185 bulb appear rather weak, it was fairly dim at the time. Exposure 1/60th at F36.

-- Alan


----------



## wquiles (Oct 7, 2008)

Very nice Alan


----------



## LuxLuthor (Oct 7, 2008)




----------



## JimmyM (Oct 7, 2008)

Nice work on the Msled and daughter board.
Where would you want the Cal Pot on the "experimental board"? Is there a type of form factor you'd like to use? Pin layout, etc. Or just put a simple 3 pad arrangement on the board to wire the cal pot in for experiments?
You guys are making great progress. I just found out my bonus is in the mail. I think I'll have to take a small portion of it and buy some AVR equipment. Maybe have a set of boards made. Once they're made, they're made. So let's get everything on them we can. I'd like to add pads for a FET driver that can be jumpered around, as well as see what the pin requirements are for proper test points (Digikey P/N 500K-ND, perhaps). It would make test lead connection a lot easier. The price of the boards is going to be pretty much the same even if we add some stuff.


----------



## AMD64Blondie (Oct 7, 2008)

Once you get some of these regulators into production.. I'd be one of the first to buy one. I love my Mag85,but I'm always nervous about running the batteries down too soon. This would solve all of my problems.(Still waiting to put my replacement WA1185 bulb in,as I don't have any latex gloves to protect the new bulb from my skin oils lying around.)


----------



## Alan B (Oct 7, 2008)

JimmyM said:


> Nice work on the Msled and daughter board.
> Where would you want the Cal Pot on the "experimental board"? Is there a type of form factor you'd like to use? Pin layout, etc. Or just put a simple 3 pad arrangement on the board to wire the cal pot in for experiments?
> You guys are making great progress. I just found out my bonus is in the mail. I think I'll have to take a small portion of it and buy some AVR equipment. Maybe have a set of boards made. Once they're made, they're made. So let's get everything on them we can. I'd like to add pads for a FET driver that can be jumpered around, as well as see what the pin requirements are for proper test points (Digikey P/N 500K-ND, perhaps). It would make test lead connection a lot easier. The price of the boards is going to be pretty much the same even if we add some stuff.


 
Jim:

Glad to hear you are getting a bonus. You've been working hard for it.

On the pot, use what you would like to put on production boards. Might as well get some experience with the choice.

Agreed on the driver. Won't hurt to have the option.

Those are nice test points. A bit pricey, but for a one-off test board, not a real problem. They would work fine. 

I kind of like the .025" square posts so I can plug jumpers on to them. Or clip probes on. 

The cheapest test point is a pair of holes with a resistor lead soldered in both into an upside down U. 

Any of the above would be ok with me. Maybe with the right choice of pad diameter it can be a user choice.

-- Alan


----------



## Alan B (Oct 7, 2008)

AMD64Blondie said:


> Once you get some of these regulators into production.. I'd be one of the first to buy one. I love my Mag85,but I'm always nervous about running the batteries down too soon. This would solve all of my problems.(Still waiting to put my replacement WA1185 bulb in,as I don't have any latex gloves to protect the new bulb from my skin oils lying around.)


 
Thanks for the comments.

I use a fresh facial tissue or paper towel, and if the bulb needs cleaning use some alcohol. 

Using this regulator with my [email protected] bulb is a lot of fun - getting multiple light levels, and watching it ramp up to soft start. I am looking forward to getting it into the flashlight instead of on the bench.

-- Alan


----------



## JimmyM (Oct 8, 2008)

Alan B said:


> Jim:
> 
> Glad to hear you are getting a bonus. You've been working hard for it.
> 
> ...


I found some cheaper ones. They're still the little loop type with a stand off. Maybe just some single position headers like the the ones used for the programming plug. I hadn't thought about the loop of wire approach. That's a good thought.
I'm not getting email notifications of these posts. I have subscribed for instant notifications, but nothing comes in.


----------



## wquiles (Oct 8, 2008)

JimmyM said:


> I'm not getting email notifications of these posts. I have subscribed for instant notifications, but nothing comes in.


I am noticing this on ALL of my subscribed threads as well.

By the way, congrats on the bonus


----------



## Alan B (Oct 8, 2008)

JimmyM said:


> I found some cheaper ones. They're still the little loop type with a stand off. Maybe just some single position headers like the the ones used for the programming plug. I hadn't thought about the loop of wire approach. That's a good thought.
> I'm not getting email notifications of these posts. I have subscribed for instant notifications, but nothing comes in.


 
Yes. Email is not working on the forum, according to Sasha/Greta the forums will move to a dedicated Godaddy server this weekend. So we will have some downtime. Marketplace is already there and it works better, so this should help in the longer term. See details at the "everyone click here" announcement at the top of the page.

I continue to do code cleanup but my time to work on this is limited, so the next release will probably be a few more days. This one should be 'flashlight alpha', something that could be used once the bugs are ironed out.

-- Alan


----------



## wquiles (Oct 8, 2008)

Alan B said:


> I continue to do code cleanup but my time to work on this is limited, so the next release will probably be a few more days. This one should be 'flashlight alpha', something that could be used once the bugs are ironed out.



Thanks Alan. I am really looking forward to test the next release. I will start setup for the current measurements, so that by the time we get your Alpha code, I will be ready as well :twothumbs

Will


----------



## Alan B (Oct 8, 2008)

wquiles said:


> Thanks Alan. I am really looking forward to test the next release. I will start setup for the current measurements, so that by the time we get your Alpha code, I will be ready as well :twothumbs
> 
> Will


 
Current measurements would be quite interesting to see, especially in terms of soft-start peaks, as well as quiescent off-current at the microamp level. May need a couple of different shunts to cover the range.

Since email announcements of changes to this thread are not working I created a desktop icon that opens a browser to the latest post in this thread directly:

http://candlepowerforums.com/vb/showthread.php?goto=newpost&t=209098

-- Alan


----------



## wquiles (Oct 9, 2008)

Nothing pretty or neat, but since I wanted to get better/nicer measurements I had to move away from the protoboard. This is closer to a real board, and I have lots of built-in test points for all of the important signals. The yellow wire on the very top is what will become the shunt to measure the current spikes going to the bulb. Miracles of miracles, after two hours working on this tonight, it fired up and worked perfectly the fist time around!. Next step is to add the 6-pin programming port which will be located between the red and green vertical wires, close to the 8-pin socket. The quarter is there just to give idea of the actual size - if we use SMT components, this could be fairly nice/small:






Will


----------



## Alan B (Oct 9, 2008)

Nice Job:thumbsup:

-- Alan


----------



## wquiles (Oct 9, 2008)

I mentioned earlier that I was seeing some "inductive looking" spikes. I though it was because of the protoboard, but now that I have a relatively small board with short traces, I am "still" seeing those spikes - in fact I can see them better now than before. 

I then though it could be related to the power supply, but when I try with real batteries, I still see the spikes:

Here is using the 13.6 PS:






and here using the 3x 18650 LiIon cells:






I still will work in shortening the cables from the battery to the board, but I am a little worried. 

Has anyone else seen these? They are pretty fast, so might be hard to capture, but you can see the spilkes here very clearly at 2uS/div. when the FET closes/turns OFF.

Will


----------



## Alan B (Oct 9, 2008)

I don't believe my USB scope can see those. I keep looking for a reason to get a better one :naughty:

I do have a 60 mhz Heathkit dual trace buried in the garage. Wonder if it still works.

Remind me what the traces are and the parameters of your test.

Any data on bulb inductance?

-- Alan


----------



## wquiles (Oct 9, 2008)

Alan B said:


> I don't believe my USB scope can see those. I keep looking for a reason to get a better one :naughty:
> 
> I do have a 60 mhz Heathkit dual trace buried in the garage. Wonder if it still works.
> 
> ...



No data on the bulb inductance - it is a standard automotive 12V bulb (this one rated at 12V 1Amp or so).

Yellow trace= Vbatt vs. GND (which is also Vbulb+
Blue trace = Vgate vs. GND (this is the trigger signal for the scope, set at 4.0V)
Purple trace = Vbulb- vs. GND
Red trace = Yellow trace - Purple trace = Voltage across the bulb

Will


----------



## wquiles (Oct 9, 2008)

I did more testing, but I decided to try a new bulb, a 4-5V incandescent. To my surprise, as soon as I connected it, it gave out a very brief but very bright output pulse, and then went down to very little or nothing. I tried like 10 times, but I could not always do it. Somehow, at startup, there was a wider output pulse that was not visible on the 12 volt bulb.

Here is the standard 12V bulb I am using (I can't see the pulse in this one):







and here is the smaller voltage bulb - very easy to see the pulse:






It took me many tries to get the scope right, but here is the actual capture of the elusive first pulse, right as the system is starting up - you can see that the "normal" tiny pulses follow as expected (this is at 20mS/div). Also note that at this resolution the spikes are not visible:






I then changed the scale in each of these shots so that you can see more detail, of course with lower resolution (this is at 10mS/div):






(this is at 4mS/div):






(this is at 2mS/div):






Here is the dimly lit bulb with the "normal" tiny pulses, before I pushed the button:






So at first pass, it looks like we "might" have a problem with instability as the Tiny85 wakes up or as the routine gets ready to output its first pulse.

Alan, can you try with a small voltage bulb (like a 2 or 3 cell Mag bulb) to see if your circuit will also show the brief, bright pulse of light upon starting?

Will


----------



## wquiles (Oct 9, 2008)

Alan,

As I noted above, I couldn't always see this on startup, but I was finally able to get it to happen repeatedly, "if" I wait long enough for the capacitors to fully discharge. Then it happens every time.

Maybe something with Vcc taking a little too long to come up and while it is coming up the Tiny85 starts doing "its thing" before the Vcc is stable? Also remember that I am using Vcc as my reference - this might also explain what is going on, if the algorithm makes a decision before the Capacitor for Vcc is fully charged. Could the solution be as simple as waiting a few mili-seconds before "starting" for good?

Makes me wonder if the internal 1.1V and 2.56V references also have a "setup" time?

Will


----------



## Alan B (Oct 9, 2008)

Will:

Precisely what kind of startup are you doing? Applying power to the micro?? Or pushing the button??

I presume this is on application of power. I have not tested that very much.

I have not enabled the chip's Brownout Detection circuitry. I suspect that might solve the problem.

-- Alan


----------



## Alan B (Oct 9, 2008)

Looking at the timing of this first pulse, I would guess that it is an initialization problem in the code. Have to review that in detail.

-- Alan


----------



## wquiles (Oct 9, 2008)

Alan B said:


> Will:
> 
> Precisely what kind of startup are you doing? Applying power to the micro?? Or pushing the button??
> 
> ...



Alan,

No button involved, just during first power application. Basically:

- use a low Voltage bulb (mine I used to DD with 4x AA NiMH cells)
- wait until caps are discharged (at least 30 seconds)
- setup scope to trigger once
- switch ON the power supply
- bulb grows VERY bright for a very short while
- bulb goes down quickly to a steady state level (barely see the red glow)






Will


----------



## Alan B (Oct 9, 2008)

The output being used to drive the FET is a complementary output (normally high). It looks to me from your excellent scope capture that the first cycle is high, which makes a lot of sense. Probably need to initialize it a bit differently to coerce the first cycle to be low or very short...

Try putting 

OCR1B = 255

right before the GTCCR = ... line and see if this problem goes away.

Thanks!

-- Alan


----------



## wquiles (Oct 9, 2008)

Alan,

Yup, that fixed it. Initializing the value to 255 so that the initial inverted output is zero works. I have tried several times tonight, and I can't get it to do it again - good job dude!

It is so cool to be able to run a flicker-free 4-5V bulb from a 13V PS without the bulb exploding!!!

Now, we need to go back and work on the FET=OFF glitches - they are pretty nasty  . I think I am going to experiment with a single fast diode across the bulb terminals to see if that helps.

Will


----------



## Alan B (Oct 10, 2008)

wquiles said:


> Alan,
> 
> Yup, that fixed it. Initializing the value to 255 so that the initial inverted output is zero works. I have tried several times tonight, and I can't get it to do it again - good job dude!
> 
> ...


 
Great :thumbsup:. I'll have to put that into the various codes, though it really only matters in the final code, the older test programs don't really matter much for that. I should have thought of that when I wrote the initialization, but at that time I was driving the STK500 which is upside down and so didn't have the problem. 

On the FET OFF Transient - It doesn't endanger the bulb, but might the FET or the regulator. The real question is what is the magnitude of this peak (in various conditions), and does it endanger the ratings of the regulator and FET. It certainly appears as though it could.

The other question is where is it coming from. It might be interesting to measure the inductance of some bulbs and see if it can account for it. The complicated coil within a coil winding of filaments might product some interesting inductance.

Incidentally, the clarity of your scope traces is really excellent and very helpful in sorting these phenomena out. As soon as I really looked at your capture of the starting flash I knew what the problem was, and that it was not my first guess which I made before really focussing on the information that was available in the scope. Similarly with the FET off-glitch, the clarity of the information is really excellent and helpful in quickly narrowing down the issues.

It really does appear to be filament inductance. I have not tried to put numbers on it, but that has other implications as well regarding the RMS power in the filament vs the frequency content of the PWM. :sick2:

As far as a diode helping, I don't see where to dump the energy. Normally the supply would be used, but clearly here the supply/battery is being driven by this spike, so that may not help - maybe it will, see below. The traditional absorber is an RC snubber across the switch (FET), and that may be a good tool tool here. Actually, the diode just might help. Worth a test at least. The snubber is faster, but using the energy in the filament may help with the problem I mentioned above - the energy that was soaked up and diverted by the inductance at the onset of the PWM pulse will get dumped into the filament at the end of the PWM pulse. Excellent.

For the inductive kickback to get to the battery it must couple through the FET drain-source capacitance, which is substantial. Interesting.

Also, the scope trace clearly shows the miller effect of the drain transition coupling internally to and slowing the gate transition. That is what will drive the dissipation of this FET and it shows us where the linear region is. Nice :thumbsup:

So it might make sense to look at snubber design and see what might be reasonable there. I wonder if other designs have done that?

-- Alan


----------



## wquiles (Oct 10, 2008)

Alan,

I will post pictures of the scope tonight, but a couple of additional data points from my testing last night:

- I though I was hearing a low buzz but I always ignored thinking it was some noise in my office. Last night I tried to listen better, and sure enough, the low buzz/humming noise "is" coming from the PhD board.

- I tried a resistor for a load (1K) instead of the bulb - not only the buzz/humming is gone, but the signals look almost perfect, and with no pulses as the FET turns off.

- I put back the bulb, and sure enough, I got the buzz back, and the pulses there again.

- I tried replacing the PS with the 3x18650 cells, and the pulses were there again if I used the bulb.

The amplitude is substantial - on a PS of 13.6V, the peaks seem to be at least 5-10 volts This is why I said earlier that these pulses do look rather "nasty". I will try to take additional measurements tonight.

Question: Have you tried placing the 68 Ohm resistor on the other side of the 100K resistor? I ask since that is how Willie Hunt drives his FET - I wonder if this would improve the switching behavior:
http://www.cs.indiana.edu/~willie/LVR3I.PDF

Will


----------



## Alan B (Oct 10, 2008)

wquiles said:


> Alan,
> 
> I will post pictures of the scope tonight, but a couple of additional data points from my testing last night:
> 
> ...


 
Interesting. That is good evidence that it is bulb inductance. 

I have heard the buzz on my WA1185. I think it was only at very very low settings, and it was not very loud, but it was audible.

I don't think moving the 68 ohm resistor on the other side of the 100k will matter. :thinking:

I do think the diode across the bulb is worth trying. I didn't at first, but the more I think about it that may be a good solution. That will redirect the inductive kick back into the filament. It should clean up the supply overshoot a lot. The energy in the inductance was taken from the bulb RMS, so if we return it to the bulb it will minimize the RMS error at the same time. All-around better.

Ideally it would be a schottky diode, but a power supply diode should be adequate for an initial test. Watch the direction of course, if put in backwards it will short the supply/battery through the FET and bad things may happen. 

I am building a new battery. LiFePO4. 4 cells in series. 31AH each. I will use it for general purpose stuff including powering Ham Radios, but it will also be used for this flashlight regulator testing and powering battery chargers used for RC and flashlight batteries. It should be a good example of a low impedance source, quite similar to A123 cells. I also have some A123 cells but have not set them up for use yet. Don't short these cells, though, they will get even. 

-- Alan


----------



## wquiles (Oct 10, 2008)

Alan B said:


> Interesting. That is good evidence that it is bulb inductance.
> 
> I have heard the buzz on my WA1185. I think it was only at very very low settings, and it was not very loud, but it was audible.
> 
> ...



I agree, it should be a schottky diode. I am pretty sure I have some at home - I will try tonight and let you know what happens.

Any word on when I can play with a more recent version of the firmware, even if not final?

Will


----------



## JimmyM (Oct 10, 2008)

wquiles said:


> Alan,
> 
> Yup, that fixed it. Initializing the value to 255 so that the initial inverted output is zero works. I have tried several times tonight, and I can't get it to do it again - good job dude!
> 
> ...


That diode is a great idea. A schotkey diode will dump the inductive pulse. If that's what it is. It sure looks inductive. Those 12V automotive bulbs do have a long filament...

Arrrrrgggghhhh. BONUS PLEASE GET HERE!!
I have a shopping cart at Digikey ready to go. As well as Tigerdirect.com. Hmmmm 22" LCD monitor for my bench PC.


----------



## Alan B (Oct 10, 2008)

wquiles said:


> I agree, it should be a schottky diode. I am pretty sure I have some at home - I will try tonight and let you know what happens.
> 
> Any word on when I can play with a more recent version of the firmware, even if not final?
> 
> Will


 
Maybe an Alpha tonite. 

If I do one, it will be mostly untested, though. I did some testing the other night and it wasn't starting the bulb on my PS unless I ramped the voltage up higher. I think it is just the power supply current limiting on the short pulses into a cold filament, but I didn't have time to fire up the scope to find out. So as long as our expectations are set for some bugs, we are about ready.

- - Alan


----------



## Alan B (Oct 10, 2008)

Remember that CPF may be moving to a new server tonite or this weekend.

Send me email if CPF is down and you need to.

The software will go into this directory and probably have a name with "alpha" on it:

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

-- Alan


----------



## Alan B (Oct 10, 2008)

Alan B said:


> Remember that CPF may be moving to a new server tonite or this weekend.
> 
> Send me email if CPF is down and you need to.
> 
> ...


 
The Alpha code is on the server. 

-- Alan


----------



## wquiles (Oct 10, 2008)

Alan B said:


> Maybe an Alpha tonite.
> 
> If I do one, it will be mostly untested, though. I did some testing the other night and it wasn't starting the bulb on my PS unless I ramped the voltage up higher. I think it is just the power supply current limiting on the short pulses into a cold filament, but I didn't have time to fire up the scope to find out. So as long as our expectations are set for some bugs, we are about ready.
> 
> - - Alan



Understood - thanks 





Alan B said:


> The Alpha code is on the server.
> 
> -- Alan



Got it downloaded. If CPF goes down, I will continue communicating with you via email 

Will


----------



## wquiles (Oct 11, 2008)

Good news and bad news.

Bad news, the schottky diode (50V 2A rating) did not work. I also tried a 6A Power Supply Rectifying diode - no go either.

Good news, I collected some interesting data on the "evil" pulses.

I found the schottky diodes I though I had, but they were surface mount:











I soldered to short legs so that I could use them:






Here is data on a 1K resistor as the load - note this is pretty much picture perfect shape on all waveforms (this is at startup, before any push buttons):






Here are the ugly pulses on the small 5V bulb (this is at startup, before any push buttons):






Same but with the schottky diode - basically no difference:






Here I am using the 100 Ohm 100Watt power resistor set to about 6 Ohms (notice this has some inductance, but also, that it puts a bigger load on the PS than the 1K resistor):







I kept playing with the system and swaping bulbs, and I noted that as the duty cycle increases, and the Vrms increases, that the spikes become "smaller" in magnitude!

To capture these better, I am now triggering on the negative slow of the gate voltage.

Here is the 12 volt bulb - at startup:






Here is the 12 volt bulb - after one press:






Here is the 12 volt bulb - after twp press:






Here is the 12 volt bulb - after three press:






Here is the 12 volt bulb - after four press:






Here is the 12 volt bulb - after five press:






Here is the 12 volt bulb - after six press:






Here is the 12 volt bulb - after seven press:






Here is the 12 volt bulb - after eight press:






Here is the 12 volt bulb - after nine press:








Now I changed back to the smaller 5V bulb. Note that the spikes are much larger!


Here is the 5 volt bulb - after startup:






Here is the 5 volt bulb - after one press:






Here is the 5 volt bulb - after two press:






Here is the 5 volt bulb - after three press:






Here is the 5 volt bulb - after four press:






Here is the 5 volt bulb - after five press:






So it looks like the bulb's inductance plays a key role, but also the current draw on the battery.

I will keep testing over the weekend - I still don't understand why neither the schottky diode nor the regular diode seemed to help 

Will


----------



## Alan B (Oct 11, 2008)

How was the diode connected?

-- Alan


----------



## Alan B (Oct 11, 2008)

Looks like CPF is about to go down.

See you on the other side!

-- Alan


----------



## Alan B (Oct 12, 2008)

And it is back a second time.

Good to be back.

Will, if you have an L C R meter it might be interesting to measure the L of a few filaments...

-- Alan


----------



## Alan B (Oct 12, 2008)

AHA, Just what I suspected. The few posts that were made (mine and Jim's) during the short uptime when the date/time was wrong are 'later' than they should be (by about 1 day), and will be 'pushed' ahead of the other posts until they are reached. Jim, we might edit them to reflect that...

-- Alan


----------



## wquiles (Oct 12, 2008)

I don't have an LCR meeting - I will see if somebody at work has one I can borrow. I did some testing today, but I blew one of my 1185 bulbs - only have one left 

The FET that I am using is the IRL1404Z in TO220.

Jim - which FET's do you use in your Analog PWM solution?

Will


----------



## wquiles (Oct 12, 2008)

My reply above is out of date/hour since your posts #65 and #66 appear to have been made a day from today 

Will


----------



## Alan B (Oct 12, 2008)

JimmyM said:


> Yup. Seems to be.
> That "nasty kick" should have responded to the diode. At least a little.
> Do you have an inductor lying around to try in place of the bulb? If the kick gets worse, it may give an indication of the scale of the inductive component were looking at. If 1 uH makes it 1000 times worse, then we're dealing with a tiny inductive value. What FET are you using? Does it have a body diode?


 
I believe the FET has a body diode.

-- Alan


----------



## Alan B (Oct 12, 2008)

wquiles said:


> I don't have an LCR meeting - I will see if somebody at work has one I can borrow. I did some testing today, but I blew one of my 1185 bulbs - only have one left
> 
> The FET that I am using is the IRL1404Z in TO220.
> 
> ...


 
Ouch on the bulb burnout. I've been careful and lucky so far. There is a maxpwm feature in there I set when I'm starting out to prevent it from getting too high, but that doesn't help much if the power supply is being varied to a high voltage. 

-- Alan


----------



## wquiles (Oct 12, 2008)

For several months now I "though" I had order extra LVRI kits from *js* for future projects (this was several years back), but I had simply lost them. Today, while cleaning up my home office area, I found the last two LVRI kits from Willie Hunt:












I am "very" well aware of how rare a find this is, so *before we go much further, NO, these are not for sale*. 

I will wire one up to use as a reference now that we are developing the PhD. It will be interesting to do back-and-forth between both boards, although these Willie Hunt's LVRI are pre-set to 6.8Vrms (perfect for the SureFire M6's MN21 bulb, which was the main goal for *js* when he invented/developed his highly regarded M6-R package).

Will


----------



## Alan B (Oct 12, 2008)

wquiles said:


> My reply above is out of date/hour since your posts #65 and #66 appear to have been made a day from today
> 
> Will


 
The posting number on those postings will change until their time has come.

Your post is fine, it is them that are wrong.

The forum is really quick. :thumbsup::twothumbs

-- Alan


----------



## wquiles (Oct 12, 2008)

Like I was sharing with Alan via email while CPF's was down, I "still" think that the problem might be related to the FET that we are using and/or how we are driving it.

By the way, for this LRVI solution, Willie Hunt selected the IRL8113 FET:
https://ec.irf.com/v6/en/US/adirect/ir?cmd=catProductDetailFrame&productID=IRL8113PBF


Will


----------



## Alan B (Oct 12, 2008)

wquiles said:


> Like I was sharing with Alan via email while CPF's was down, I "still" think that the problem might be related to the FET that we are using and/or how we are driving it.
> 
> By the way, for this LRVI solution, Willie Hunt selected the IRL8113 FET:
> https://ec.irf.com/v6/en/US/adirect/ir?cmd=catProductDetailFrame&productID=IRL8113PBF
> ...


 
I'm not sure how the FET could do this (transient). 

The IRL8113 FET looks pretty good also, but is only 30V and 7 milliohms. The fet we are using is 40V and 3 milliohms. :tinfoil:

-- Alan


----------



## wquiles (Oct 12, 2008)

Here is some data with various values of R5 (nominal 68 ohms):

R5=20 Ohms
FET=ON





FET=OFF







R5=68 Ohms
FET=ON





FET=OFF







R5=100 Ohms
FET=ON





FET=OFF






We can perhaps play some to get to an optimal value of R5 later on, but the larger R5, the more spread the energy and the lower the spikes. Of course, that also means the FET is on the linear region longer (not good for heat).

I am also considering swaping this FET for a different one, to see how results are affected.

Will


----------



## Alan B (Oct 13, 2008)

Will, can you hook up one of those W Hunt regulators and see if it has the same voltage spikes?

Jim, how about your softstart circuit? Does it have the spikes??

-- Alan


----------



## JimmyM (Oct 13, 2008)

Alan B said:


> Will, can you hook up one of those W Hunt regulators and see if it has the same voltage spikes?
> 
> Jim, how about your softstart circuit? Does it have the spikes??
> 
> -- Alan


It had some. But nothing I really took serious note of.
Plus, you said it dimished as duty cycle increased. My soft starter usually ramped to 85+% duty. It never spent much time at less than 5% duty.
Lux Luthor beat the hell out of one with a pair of 64623s in parallel (or was it 64458s).
Perhaps it isn't an issue for the FET. But, if it's causing voltage sampling problems, then it will have to be snubbed. My softstarter never cared what the input voltage was. It was just an RC curve based duty cycle ramp.


----------



## Alan B (Oct 13, 2008)

JimmyM said:


> It had some. But nothing I really took serious note of.
> Plus, you said it dimished as duty cycle increased. My soft starter usually ramped to 85+% duty. It never spent much time at less than 5% duty.
> Lux Luthor beat the hell out of one with a pair of 64623s in parallel (or was it 64458s).
> Perhaps it isn't an issue for the FET. But, if it's causing voltage sampling problems, then it will have to be snubbed. My softstarter never cared what the input voltage was. It was just an RC curve based duty cycle ramp.


 
Jim,

Good points. It is not a voltage sampling issue since the sample occurs before the PWM pulse ends. It won't see the peak.

The only issue I can think of is the breakdown voltages of the FET and regulator. Anyone up to running a SPICE model?

Can you make a softstart put out low pulsewidth for an extended time for a test? Just to observe and make measurements??

I'm expecting that this phenomenon is not new to this regulator, it has been present with others that use PWM. That may help tell us that it has not been a problem, or perhaps it was an unrecognized problem. 

The current parts have 40V ratings, giving lots of room, but for 30V parts it could be more problematic. Many of the surface mount parts have the lower rating. This phenomenon may drive the volrage rating of the circuit lower.

-- Alan


----------



## Alan B (Oct 13, 2008)

JimmyM said:


> Yup. Seems to be.
> That "nasty kick" should have responded to the diode. At least a little.
> Do you have an inductor lying around to try in place of the bulb? If the kick gets worse, it may give an indication of the scale of the inductive component were looking at. If 1 uH makes it 1000 times worse, then we're dealing with a tiny inductive value. What FET are you using? Does it have a body diode?


 
Some observations and thoughts:

If it is the inductance in the filament, it is in parallel with a low value of resistance. Unless it is the inductance from the wires on the bulb. Did it happen equally with short wires and long wires?? It went away with a resistor instead of a bulb... :thinking:

If you look at Will's earlier trace showing the filament voltage through differencing, it does not show the kick at all. This is interesting. It has been bothering me for some time. If the energy is coming from the filament, it needs to express a voltage there.

It almost makes me wonder if the 'inductance' is somehow in something external rather than being in the filament. It doesn't make sense to me yet. Is it coming from something external to the filament or even the circuit??

I wonder how this interacts with the protection circuit in the batteries? Have we tried unprotected batteries such as NiMH?

-- Alan


----------



## JimmyM (Oct 13, 2008)

Alan B said:


> Jim,
> 
> Good points. It is not a voltage sampling issue since the sample occurs before the PWM pulse ends. It won't see the peak.
> 
> ...


I'll see what I can do to make a low duty cycle softstarter. I think I still have one lying around somewhere. If not, I can knock one together pretty quickly. I'll see if I can get reliably short pulses and capture them on my scope.
Regarding the surface mount version... It shouldn't be a problem. The regulator you use (LM2936) can be replaced by a Linear LT3014/B (SOT-23) it's good to 60/80V input, and can pass 20mA. It's an adjustable regulator, but the external divider uses a 1.27M + 3.92M pair of resistors for 5V (510K + 4.53M for 12V) so parasitic loss is very small. Also, it could be used as a 12V regulator to drive the hell out of a gate using an FET driver (TPS2829) while supplying 12V to a fixed 5V regulator like the MIC5213 (SC70 pkg) to power the uP. So voltage ratings of components shouldn't be an issue.
Also, the TPS2829 comes in a version that includes a 20mA 11.4V regulator. It can handle 40V continuous input, so this chip could do double duty as a primary regulator and FET driver. MANY MANY nice tiny components out there.


----------



## JimmyM (Oct 13, 2008)

wquiles said:


> I am also considering swaping this FET for a different one, to see how results are affected.
> 
> Will


Try the IRF IRLU7843. It's rated at 30 Vdss and seems to work well at logic level gate voltages (3.2mOhm Rds(on) at a 4.5V gate.
I easily drive 64623s at 16V with this FET.


----------



## Alan B (Oct 13, 2008)

Seems to be back!!!

-- Alan

update:

note this post (and Jim's following post) was made on 10/12 but got a date of 10/13 due to the new server's configuration problem, so it will float ahead for a day until its time has passed...

-- Alan


----------



## JimmyM (Oct 13, 2008)

Yup. Seems to be.
That "nasty kick" should have responded to the diode. At least a little.
Do you have an inductor lying around to try in place of the bulb? If the kick gets worse, it may give an indication of the scale of the inductive component were looking at. If 1 uH makes it 1000 times worse, then we're dealing with a tiny inductive value. What FET are you using? Does it have a body diode?


----------



## jrmcferren (Oct 13, 2008)

I skimmed this thread, but a temporary stop-gap solution (or maybe even a permanent one) would be a capacitor across the bulb. It will make the on-off time of the startup a little longer, but maybe it will reduce the intensity of the pulse. With my limited electronics knowledge I know that L (inductance) can be canceled with C (capacitance). I have no ideas for a formula or anything, but it may be worth a try.


----------



## Alan B (Oct 13, 2008)

Okay, now we're past the time/date stamp problem, so things should flow a bit more smoothly.

Welcome to the thread jrmcferren!

Adding a cap across the filament might help stretch out energy from the pulse (though we didn't see a voltage change which is all the capacitor can react to), but it would also present a low impedance to the FET at turn-on that would make a current spike that the FET would have to deal with. If the cap was large enough it would probably blow the FET, as has been demonstrated before. :sigh:

The place with the largest voltage swing is the FET, a snubber (series RC network) there would absorb energy, but it is not clear that would reduce the transient on the supply line (it would help the transient on the FET drain).

Lots of tradeoffs!

-- Alan


----------



## JimmyM (Oct 13, 2008)

When initially investigating PWM I tried a cap across the bulb. It made the bulb brighter at a given duty cycle. We need a predictable relationship between duty cycle and RMS voltage. The cap would mess things up.


----------



## JimmyM (Oct 13, 2008)

I did some experimentation tonight. I couldn't reliably produce a very low duty cycle. ~10%. It gets down to ~10% then it jumps to a tiny pulse/spike. When in the adjustable range, the gate has rock solid square corners. I usually have the display set to vectors, but when I switch to dots, there are just horizontal lines separated with empty space. I have to use a gate driver because the comparator can't drive the gate very strongly. I do see a negative swing at turn off. About a volt or so. But it shuts off HARD. No roll-off of the gate or drain. Just BANG off.
I've captured some wave forms, but don't have a USB cable long enough to hook it to my PC. And I've lost/misplaced my camera. Duh.
But there's no gate roll-off at all.


----------



## Alan B (Oct 13, 2008)

JimmyM said:


> I did some experimentation tonight. I couldn't reliably produce a very low duty cycle. ~10%. It gets down to ~10% then it jumps to a tiny pulse/spike. When in the adjustable range, the gate has rock solid square corners. I usually have the display set to vectors, but when I switch to dots, there are just horizontal lines separated with empty space. I have to use a gate driver because the comparator can't drive the gate very strongly. I do see a negative swing at turn off. About a volt or so. But it shuts off HARD. No roll-off of the gate or drain. Just BANG off.
> I've captured some wave forms, but don't have a USB cable long enough to hook it to my PC. And I've lost/misplaced my camera. Duh.
> But there's no gate roll-off at all.


 
Jim,

What were the conditions of your test? Battery type, voltage, bulb type/voltage/current, frequency, etc.

Where was the kick? On the power line? On the drain terminal??

If there is an inductive kickback coming from the bulb it will have to dissipate through the drain-source capacitance and back through the supply. 

Turning the FET off harder makes this worse, as Will's measurements show. The energy in the inductor is dependent on current, and the voltage peak value will depend on the time taken to dissipate the energy, so reducing the time will increase the voltage spike amplitude.

If you want to simulate the softer drive a 150 ohm resistor from the gate driver to the gate (or 300 if you are using 10V drive) will about do it. Limit the drive current to 35mA if you want to simulate the micro driving. In no case has the FET warmed up, so the drive is apparently sufficient to keep losses low.

Will,

Is there any chance there is some inductance in the ground lead of your scope to the experiment? Anything else in the test environment??

-- Alan


----------



## JimmyM (Oct 13, 2008)

Alan B said:


> Jim,
> 
> What were the conditions of your test? Battery type, voltage, bulb type/voltage/current, frequency, etc.
> 
> ...


Oh, yeah. Details they would be handy huh.
I was using a variable power supply at 12.0 volts with a 75,000 uF cap to stiffen things a bit. Scope on the power leads showed a clean signal. Frequency was 230Hz. Bulb was a 12 volt auto motive bulb 1157. The gate-gnd was nice and sharp, no over-shoot in either direction. With the scope across the bulb, there was the turn off over-shoot. As soon as I get a camera or my PC hooked up, I'll get those wave forms posted.
Until I get my test board/uP set up, my data is really kind of inconclusive.


----------



## wquiles (Oct 13, 2008)

Guys,

Long day at work, followed by a business dinner, so I should probably be able to do more bench work tomorrow.

Last night I ordered a couple of FET's to try from Digikey (they already shipped them today!): 
- IRF3707
- IRF3709
- IRL8113 (the one used by Willie Hunt)

They are only 30V's, but designed for fast switching power supply designs (very low Capacitance/gate charge) and to switch on at 4.5V with very low Rds, so they might work differently in the PhD project.

Yes, my plan is to fire up one of the Willie Hunt LVR's tomorrow and get some scope captures using the 12V bulb I am using now.

Will


----------



## Alan B (Oct 14, 2008)

Will,

Thanks for your effort in this.

Changing the switching FETs will change the capacitance slightly, it will be interesting to see how much difference it makes.

There are a lot of other, possibly more interesting and important issues to check on the software. Perhaps we can make progress on some of them.

Unless this pulse threatens to reach component max ratings it is not too important.

-- Alan


----------



## JimmyM (Oct 14, 2008)

Perhaps, when I get my parts, I can look into the switching characteristics while you guys work on software issues.
I'll add a couple of the FETs that Will spec'd to my order.


----------



## Alan B (Oct 14, 2008)

JimmyM said:


> Perhaps, when I get my parts, I can look into the switching characteristics while you guys work on software issues.
> I'll add a couple of the FETs that Will spec'd to my order.


 
That might be a good way to go, if Will agrees.

Is your test board set up with jumpers to switch between direct drive and using a driver? Might be useful to really see the differences. Maybe a 3 pin 025 post row that the jumper can be plugged into either position on. Probably can leave the micro to driver all the time, just select the FET gate input?

-- Alan


----------



## JimmyM (Oct 14, 2008)

I have to revise the scematic for the driver option, but it would be as easy as removing the chip and jumpering the IC socket from input to output.
I have a couple of other ideas to implement as well. Basically, just adding provisions for additional components on the board and a few jumper positions.


----------



## Alan B (Oct 14, 2008)

JimmyM said:


> I have to revise the scematic for the driver option, but it would be as easy as removing the chip and jumpering the IC socket from input to output.
> I have a couple of other ideas to implement as well. Basically, just adding provisions for additional components on the board and a few jumper positions.


 
I'm just wondering if it would be interesting to make it possible to change jumpers without removing the driver chip. I can imagine wanting to compare with and without driver, and having to remove the chip would be annoying after a couple of iterations.. Just a thought..

Options are good on a test board 

-- Alan


----------



## JimmyM (Oct 14, 2008)

Sure. Anything is possible. I have to modify the schematic anyway. I would like to add 2 jumpers for it though. 1 on the FET gate side to select gate source (Driver or uP) and one on the driver input side to select uP gate destination (Driver or Gate). This way it would totally isolate the driver and remove ANY influence it may have by still being connected to the gate drive.
Yeah. Neat.


----------



## Alan B (Oct 14, 2008)

JimmyM said:


> Sure. Anything is possible. I have to modify the schematic anyway. I would like to add 2 jumpers for it though. 1 on the FET gate side to select gate source (Driver or uP) and one on the driver input side to select uP gate destination (Driver or Gate). This way it would totally isolate the driver and remove ANY influence it may have by still being connected to the gate drive.
> Yeah. Neat.


 
That's excellent. Waiting on this board is making it better! Will's breadboarding is helping improve it!

-- Alan


----------



## JimmyM (Oct 14, 2008)

Alan B said:


> That's excellent. Waiting on this board is making it better! Will's breadboarding is helping improve it!
> 
> -- Alan


Indeed. I'm kind of glad now that we haven't built them already. I'll add these various options.

1) Test points at B+, B-, Bulb+, Bulb-, FET(drain), V12, V5, FET-driver-in, Vgate, Across the Current sense shunts
2) Additional component position for a high voltage regulator (LT3014B) before 5V regulator to output 12V (for stronger gate drive). Including a bypass jumper.
3) Additional component position for a different 5V regulator. Use either component, just not both.
4) Additional component position for an FET driver with bypass jumpers and a 3 pin header/jumper to select Vcc for the Driver (12V buss or 5V buss)
5) Wire pads and drill holes for mounting a KIU socket on the boards as well as pads for external connection of a bulb socket.
6) Pads for current sense shunts between driver/uP and FET gate, and FET drain and B-.

This way, the user (you, me, Will) can configure for single regulator or dual regulator, FET driver or no FET driver, mount the bulb on the board or remotely, and use current sense shunts or bypass with a wire.
Sound about right?
I'll start updating the schematic tonight, hopefully. It will invariably become larger, but that's not necessarily a bad thing. Easier to work on. It's only 2" x 2" now.


----------



## wquiles (Oct 14, 2008)

JimmyM said:


> Indeed. I'm kind of glad now that we haven't built them already. I'll add these various options.
> 
> 1) Test points at B+, B-, Bulb+, Bulb-, FET(drain), V12, V5, FET-driver-in, Vgate, Across the Current sense shunts
> 2) Additional component position for a high voltage regulator (LT3014B) before 5V regulator to output 12V (for stronger gate drive). Including a bypass jumper.
> ...



Jimmy,

That is freaking awesome. Those are all the same test points that I am using today - sign me up! 

Earlier I though I could not use these, but the more bench work I put in, the more I realized now I "need" these boards NOW!. I will definitely buy boards along with you guys - how much money and when do you need it by?

Will


----------



## JimmyM (Oct 14, 2008)

wquiles said:


> Jimmy,
> 
> That is freaking awesome. Those are all the same test points that I am using today - sign me up!
> 
> ...


Let me get the schematic all done and see what the total cost is.
How many boards? 10? 25?
I'll just pass cost through and ship them when received.
I know you guys are pretty handy, but I'm wondering how well it would be received if I did partial assembly of some of the boards. Like test-points and pin headers/jumpers, and IC sockets. I can get better pricing at Digikey if I buy 10 of something versus 1. See what I mean? Or maybe I could just buy the parts and toss them in a bag with the board.
Thoughts, gents?
I'll be making an order to buy stuff for myself anyway.


----------



## Alan B (Oct 14, 2008)

I can use one. Quantity of build is your choice.

I would also take parts, they don't have to be pre-installed.

-- Alan


----------



## LuxLuthor (Oct 14, 2008)

Jimmy, I don't think this project is yet at my level of being able to make a significant contribution, but please let me know if I can help support your cost of those fabricated boards.


----------



## wquiles (Oct 14, 2008)

JimmyM said:


> Let me get the schematic all done and see what the total cost is.
> How many boards? 10? 25?
> I'll just pass cost through and ship them when received.
> I know you guys are pretty handy, but I'm wondering how well it would be received if I did partial assembly of some of the boards. Like test-points and pin headers/jumpers, and IC sockets. I can get better pricing at Digikey if I buy 10 of something versus 1. See what I mean? Or maybe I could just buy the parts and toss them in a bag with the board.
> ...



Jimmy,

I would say no more than 10 (probably we just need no more than 2 each) - realistically, it will likely be just the 3 of us using them, and then for a "production" board we would be using something a lot more customized/smaller/space efficient, and most likely SMT, so any more than a couple of boards each would likely not be very practical.

As to pre-assemble or not, go with what will give you best convenience to you - I have the gear to solder/build through-hole or SMT, so whatever you do, I will support 

Will


----------



## JimmyM (Oct 14, 2008)

LuxLuthor said:


> Jimmy, I don't think this project is yet at my level of being able to make a significant contribution, but please let me know if I can help support your cost of those fabricated boards.


A very kind offer. I may take you up on it. But, let's see just how much these babies cost first. I'm just about done with the schematic redesign.


----------



## JimmyM (Oct 14, 2008)

Arrrgh. Never mind.


----------



## wquiles (Oct 14, 2008)

Not much testing today with the LVR circuit from Willie Hunt, but I was able to get it running (note this LVR is hard-wired/programmed for 6.7-6.8 Vrms):































And although I will try to do more measurements, I did a quick one on the switching pulses on the LVR. Yes, there are still there, but they are smaller. In fact I had to change from 10V/div down to 5V/div to show the pulses on the +Bat side.

Here is for the FET turning OFF:






and here for the FET turning ON:






Here is a shot of the soft-start in action - note the LVR gets to a steady-state RMS within 5-6 pulses:






I will try to do some more testing tomorrow night since am traveling the rest of this week.

Will


----------



## Alan B (Oct 14, 2008)

JimmyM said:


> Arrrgh. Never mind.


 
Trouble with photo?

-- Alan


----------



## Alan B (Oct 15, 2008)

Nice, Will.

So this phenomena varies in magnitude, but is not unique to the new design. The turn-on and off look pretty soft there. Is ours quicker?

I wonder what the output capacitance of the FET is. Adding 5x or 10x that much capacitance across the battery would probably kill the battery side of the problem. Might not be all that large a cap. If you can, try say a 1uF bypass across the battery to ground sometime and see what it does to the spikes...

-- Alan


----------



## JimmyM (Oct 15, 2008)

Alan B said:


> Trouble with photo?
> 
> -- Alan


Yes.
I've got the board design done.

Current sense shunt positions for drain and gate. test points galore, and positions for 2 FETs. I couldn't help myself.
Positions for 2 bulb outputs and drill holes to mount a KIU ceramic socket on the board.
12V Regulator enable/disable jumper.
5V regulator source select jumper (battery or 12V buss). 5V buss source jumper (5V reg 1 or 5V reg 2), FET driver supply source jumper (5V/12V). Complete bypass of driver if desired.
One change to the scematic though. I moved the safety pull down resistor to go from ground to the gate instead of ground to the uP PWM output.
There are a lot of pin headers for jumpers. But also a lot of options.
Just by changing jumpers you can go from your scematic to a 12V/5V design using 2 surface mount regulators and an FET driver.


----------



## Alan B (Oct 15, 2008)

JimmyM said:


> Yes.
> I've got the board design done.
> 
> Current sense shunt positions for drain and gate. test points galore, and positions for 2 FETs. I couldn't help myself.
> ...


 
Really nice flexibility.

-- Alan


----------



## wquiles (Oct 15, 2008)

Alan B said:


> Nice, Will.
> 
> So this phenomena varies in magnitude, but is not unique to the new design. The turn-on and off look pretty soft there. Is ours quicker?



Willie Hunt used a 100 Ohm resistor to the gate, so if I look at the data that I already collected a couple of days ago at the same 1uS/Div scale when I had a 100 Ohms, we can compare them both:

Here is the PhD with R5=100 Ohms:
FET=ON:





Here is the LVR3i
FET=ON:





Here is the PhD with R5=100 Ohms:
FET=OFF:





Here is the LVR3i
FET=OFF:






Without making a super-scientific measurement, the LVR3i "looks" like it is significantly faster - probably about 2x faster. Also, the spikes on the Bat+ and Bulb- are also about half as big on the LVR3i, but this might not be 100% apples to apples as one is in steady-state and the other one isn't. Once the new FET's from DigiKey get here, I will see how the PhD does, but I still think that the FET we end up using will have "some" effect on this 

Will


----------



## Alan B (Oct 15, 2008)

I was thinking of the 68 ohm setup, not the 100 ohm. The gate capacitance of the FET is different, that and the resistance dominate this time, assuming the cpu output is not overloaded. This higher voltage FET has a higher capacitance gate. One of the tradeoffs that comes with higher voltage and low on-resistance.

There are a lot of new features in the software to test. How is the fast-start working, for example, and how low does the quiescent current get?

-- Alan


----------



## wquiles (Oct 15, 2008)

Alan B said:


> I was thinking of the 68 ohm setup, not the 100 ohm. The gate capacitance of the FET is different, that and the resistance dominate this time, assuming the cpu output is not overloaded. This higher voltage FET has a higher capacitance gate. One of the tradeoffs that comes with higher voltage and low on-resistance.
> 
> There are a lot of new features in the software to test. How is the fast-start working, for example, and how low does the quiescent current get?
> 
> -- Alan




Alan,

I will start testing the Alpha software when I come back from travel - hopefully this weekend. As to the data on the PhD with R5=68 Ohms, that I had collected, and in terms of voltage spikes it looks worst than with R5=100 Ohms. Here it is compared to the LVR, with everything at 1uS/Div, although note that the scale voltages are not identical.

Here is the PhD with R5=68 Ohms:
FET=ON:





Here is the LVR3i
FET=ON:





Here is the PhD with R5=68 Ohms:
FET=OFF:





Here is the LVR3i
FET=OFF:






Will


----------



## Alan B (Oct 15, 2008)

It seems to me that if we want to understand this we need to characterize it over a range of conditions and fit a model to it. I'm not sure it is worth the effort, though, unless it endangers the components. We need inductance measurements of the bulbs as well.

Changing to a 30V fet will change the capacitance, and this will change the spike, but it also reduces the voltage tolerance by a signficant amount. So there is a tradeoff there. 

We do need to characterize the spike sufficiently to derate the supply voltage rating appropriately. The voltage ratings of the components should not be exceeded at any time, and this spike is the worst point.

Will, earlier I think you mentioned that the phenomena is reduced at larger duty cycles. If this is the case, we may be able to improve the situation by setting a minimum pulsewidth.

I'm not sure why a shorter pulsewidth should change the transient, unless the inductance changes, but since this appears to be an air core inductor I would not expect it to change.

-- Alan


----------



## JimmyM (Oct 16, 2008)

I tried posting a picture, but pasting hte direct link to imageshack in the dialog box didn't work. I've got an updated PCB design that I think is qite nice. I'd like to share.
Any tips?


----------



## wquiles (Oct 16, 2008)

Alan B said:


> It seems to me that if we want to understand this we need to characterize it over a range of conditions and fit a model to it. I'm not sure it is worth the effort, though, unless it endangers the components. We need inductance measurements of the bulbs as well.
> 
> Changing to a 30V fet will change the capacitance, and this will change the spike, but it also reduces the voltage tolerance by a signficant amount. So there is a tradeoff there.
> 
> ...



I will gather more data this weekend. By the way, I am using your latest Alpha software 


Will


----------



## wquiles (Oct 16, 2008)

JimmyM said:


> I tried posting a picture, but pasting hte direct link to imageshack in the dialog box didn't work. I've got an updated PCB design that I think is qite nice. I'd like to share.
> Any tips?




I have my own web site. If you email me (wquiles [at] hotmail {dot} com) the pictures, I will host them for you 

Will


----------



## Alan B (Oct 17, 2008)

I'm away for the weekend at a Ham Radio convention, where I do have internet but will be unusually busy.

I also have a few websites so can host some files/photos if that is useful.

I suspect the right URL from flicker would also probably work, but it needs to be just to the photo to imbed, or to a link to click on.

-- Alan


----------



## JimmyM (Oct 17, 2008)

Thanks for the email address. Email sent.
I've got the board designed and sufficiently fiddled with.
It's a 2 oz, double sided board, 4" x 4". The high current paths are 6mm wide.
For 10 amps @ 25C ambient, 10C rise only requires 3.6mm wide track. I think we're good.
I've sent it off for fab. 10 of them for $225.
I'll be placing my order at Digikey within the hour.


----------



## wquiles (Oct 17, 2008)

Here you go Jimmy:


----------



## wquiles (Oct 17, 2008)

JimmyM said:


> Thanks for the email address. Email sent.
> I've got the board designed and sufficiently fiddled with.
> It's a 2 oz, double sided board, 4" x 4". The high current paths are 6mm wide.
> For 10 amps @ 25C ambient, 10C rise only requires 3.6mm wide track. I think we're good.
> ...



Thanks for doing this. Let me know your paypal - I will send you half ($115) right away 

Will


----------



## wquiles (Oct 18, 2008)

Jim, funds to help with the cost of the boards/parts sent 

Will


----------



## JimmyM (Oct 18, 2008)

Digikey has shipped. Wow. They're quick.
So I've got 10 boards and enough IC sockets, Pin headers, jumpers, test points, 10 uF electrolytic caps, and 0.1uF caps to satisfy them.
So when I send out the boards, I'll send along the above components as well.
You just need to add the other components as you desire.
I didn't modify the PCB design to exactly fit the pin spacing of these capacitors because I wanted to make it more generic.

Thanks, Will. I'll ship as soon as things arrive.

I've got some LT3014Bs left over from my JM-SSTs. If you want, I can send along a couple. You can't get these from Digikey. I had to order them from Linear. This way, if you want to test out the higher voltage FET drive, you can without having to make a special order just for the voltage reg. You'd just need to get the FET driver which is available from Digikey.


----------



## wquiles (Oct 18, 2008)

JimmyM said:


> I've got some LT3014Bs left over from my JM-SSTs. If you want, I can send along a couple. You can't get these from Digikey. I had to order them from Linear. This way, if you want to test out the higher voltage FET drive, you can without having to make a special order just for the voltage reg. You'd just need to get the FET driver which is available from Digikey.


Yes, that would be cool - thanks much Jim 

Will


----------



## JimmyM (Oct 18, 2008)

I also got color coded test points. Thought it would make things look more professional.
Damn, no pink. Perhaps it better that way.


----------



## wquiles (Oct 18, 2008)

JimmyM said:


> I also got color coded test points. Thought it would make things look more professional.
> Damn, no pink. Perhaps it better that way.



Very cool - definitely a nice touch 

Will


----------



## Alan B (Oct 19, 2008)

Great Progress!

-- Alan


----------



## JimmyM (Oct 21, 2008)

Boards have shipped. I ordered a 2 week turn around and got 4 day turn around. Of course I used ups ground to save costs. I would have capitalized the "ups", but every time i hit <shift> "p", Windows media player opens.


----------



## wquiles (Oct 21, 2008)

That is great news Jim - thanks for the update 

Will


----------



## JimmyM (Oct 21, 2008)

I'm not sure if there's a parameter for tuning the soft start time, but I think we need to be able to set a configurable softstart duration. As high as 500mS or so. The bulbs pushed super hard, can't take a 50mS softstart.


----------



## wquiles (Oct 21, 2008)

JimmyM said:


> I'm not sure if there's a parameter for tuning the soft start time, but I think we need to be able to set a configurable softstart duration. As high as 500mS or so. The bulbs pushed super hard, can't take a 50mS softstart.



You mean that you have been able to blow up bulbs by having "too short" soft start cycles? Have you been able to measure the inrush current via a shunt to see the problem? I wonder if there is a relationship to the power level of the bulb and the required duration for the soft start.

I am "really" looking forward to the new boards to be able to do this type of experiments 

Will


----------



## Alan B (Oct 22, 2008)

JimmyM said:


> I'm not sure if there's a parameter for tuning the soft start time, but I think we need to be able to set a configurable softstart duration. As high as 500mS or so. The bulbs pushed super hard, can't take a 50mS softstart.


 
Softstart is tunable.

Maybe Will can test it.

-- Alan


----------



## JimmyM (Oct 22, 2008)

Alan B said:


> Softstart is tunable.
> 
> Maybe Will can test it.
> 
> -- Alan


OK Cool. Looking forward to testing SOOOOOOON.



wquiles said:


> You mean that you have been able to blow up bulbs by having "too short" soft start cycles? Have you been able to measure the inrush current via a shunt to see the problem? I wonder if there is a relationship to the power level of the bulb and the required duration for the soft start.
> 
> I am "really" looking forward to the new boards to be able to do this type of experiments
> 
> Will


Sure, it will blow. The initial current is the same as it would be with a open-closed switch. It's just switching faster. So it's really a matter of current AND time. If the total "on" time accumulates too fast...


----------



## wquiles (Oct 22, 2008)

Alan B said:


> Softstart is tunable.
> Maybe Will can test it.



I will re-start soon. Right now I am having a computer problem in my main /server/workstation and I am in the process of restoring data from my daily backups. I did started testing however, and can already see the much faster soft start cycle (right now at about 100mS if I understood your code well). I have taken some pics, but I will not be able to post until my computer is "healthy" again 





JimmyM said:


> Sure, it will blow. The initial current is the same as it would be with a open-closed switch. It's just switching faster. So it's really a matter of current AND time. If the total "on" time accumulates too fast...


Good to know. So far for the "low" power bulbs that Alan and I are testing it does not make a huge difference to have very short soft-start times, but it is definitely good to know that we do have to worry about the more powerful bulbs - thanks 

Will


----------



## wquiles (Oct 22, 2008)

I will post more pics soon, but here are some teaser pics of the latest Alpha software (0.95) with the soft start in action bringing the voltage to a target voltage of 8.0 volts, with a supply voltage of 13.5volts:

(20mS/DIV)







(10mS/DIV)






(4mS/DIV)






(2mS/DIV)






(1mS/DIV)






Will


----------



## Alan B (Oct 23, 2008)

Nice, Will.

I see the glitch only on the first pulse there. Probably not enough samples to catch it consistently.

Soft start is quite adjustable, so no problem there.

The current is actually higher since we are using more voltage than the bulb is designed for. But this is a complicated relationship with resistance, inductance, temperature, and even magnetic fields moving things around a bit. 

-- Alan


----------



## wquiles (Oct 23, 2008)

Alan B said:


> Nice, Will.
> 
> I see the glitch only on the first pulse there. Probably not enough samples to catch it consistently.
> 
> ...



Yup, you have to sample quicker than this to "see"/capture the spikes. Instead of mS/div, you need to be in the uS/div to see them.

The current is higher, but of very short duration, so the bulb can't react fast enough to get enough heat to blow up the bulb's filament - that is the beauty of the PWM when used with incandescent lights 

Will


----------



## Alan B (Oct 23, 2008)

wquiles said:


> Yup, you have to sample quicker than this to "see"/capture the spikes. Instead of mS/div, you need to be in the uS/div to see them.
> 
> The current is higher, but of very short duration, so the bulb can't react fast enough to get enough heat to blow up the bulb's filament - that is the beauty of the PWM when used with incandescent lights
> 
> Will


 
In addition to the heat the magnetic fields are hammering the rather thin filament. In tubes with tight interelectrode spacing the bending from the inrush current can cause tube failure by shorting. Luckily we don't have that problem to contend with. It does make them sing a bit, though.

-- Alan


----------



## JimmyM (Oct 24, 2008)

Alan B said:


> It does make them sing a bit, though.
> 
> -- Alan


Yeah. that's pretty neat. When I was experimenting the the JM-SST, It hums while starting up, but was singing when I was testing other frequencies. At arounf 1 kHz, it's very noticable.


----------



## Alan B (Oct 24, 2008)

JimmyM said:


> Yeah. that's pretty neat. When I was experimenting the the JM-SST, It hums while starting up, but was singing when I was testing other frequencies. At arounf 1 kHz, it's very noticable.


 
In the RC business, the 'singing' of the motor windings is used to communicate with the motor controller. The motor "beeps". If you have no motor it cannot "beep", the motor is the transducer.

Perhaps we can use that technique. Then again, maybe not.

-- Alan


----------



## wquiles (Oct 24, 2008)

OK, I finally got to do some testing tonight. If you guys recall, I was able to blow up my 1185 bulb, even though the PhD appears to be working properly. Well, I tried tonight to see how the heck it happened, but this time instead of the 1185 bulb, I am using my 13V bulb (so it is safe), and I also had my storage scope running (I was testing the VLO and VHI features in v0.95 firmware).

Sure enough, I am now able to reproduce the problem very easily. Simply, from a steady state condition, turn off power (ON/OFF switch on PS), wait about 1/2 to 1 sec, and turn power back up - there will be a spike of full PS voltage on the bulb.

I tried to capture it here in photos, using both the Fluke and the Tek. VLO is set to 4.0, VHI is set to 6.8 (simulating SF M6 MN21 bulb RMS voltage), VBATT is set to 13.6, and I am still using VREF as VCC.

Here is the PhD at steady state, set to VHI (note this is almost dead on my VHI of 6.8 volts, still using VCAL = 1.0). It is important to note the background amount of light in the picture:






Here is after trying a couple of times. You can see in the first shot that the Scope shows almost 100% duty cycle, while on the other shot you can see the (slower to react) Fluke measuring about 11.6Vrms at the bulb. Note the background is MUCH brighter (in other words, forget the scope/Fluke - the output of the bulb is enough to show that somehow the PhD becomes unstable and it is definitely putting a much higher voltage at the bulb given its much brighter output):











I blew up my 1185 bulb while turning the PS ON and OFF, back with software 0.93 I think, so it is not something in the new firmware (v0.95). I wonder if we need to implement some brownout code/function to prevent these large, full-battery output swings?

Will


----------



## Alan B (Oct 25, 2008)

The brownout features on the CPU are not enabled yet.

I have too much else on my list right now to dig into that. Perhaps you want to give it a shot. Actually it is probably pretty simple. There may be implications in the power-down code, but that can be fixed later.

-- Alan


----------



## JimmyM (Oct 25, 2008)

This needs to work in "tail switch" mode. When power is just applied via tail switch or by mag switch when the circuitry has no connection to power at all.

Digikey delivered yesterday (with my STK500), the boards should be here early next week, and I just placed an order with Tiger Direct. He he he he.
22" LCD, wall mount, and some other bits.

I'm going to download the code from Alan's web site.

Are all of the test programs found in the "HotwireRegulatorAlpha.c" file?

I've got AVR Studio and WinAVR, but isn't there a update to allow use of the ATTiny uP in the STK500?
Alan also posted a "tutorial" or "how to" to get started, could someone point me to that post? I can't seem to find it in the postings. Thanks.

OK. I think I found it. How important is it that the 12V supply be 12V? I have a 13.8V fixed linear power supply. I don't want to have to go out and buy a 12V wall wart just for this.
Never mind. I found a 12V laptop style power supply rated at 60W. And the barrel connecot is an exact match. What LUCK!!

OK. So this post posed 2 questions. I answered them both. I suppose I'll leave it here just to show what a nitwit I can be.


----------



## Alan B (Oct 25, 2008)

JimmyM said:


> This needs to work in "tail switch" mode. When power is just applied via tail switch or by mag switch when the circuitry has no connection to power at all.
> 
> Digikey delivered yesterday (with my STK500), the boards should be here early next week, and I just placed an order with Tiger Direct. He he he he.
> 22" LCD, wall mount, and some other bits.
> ...


 
STK500 has onboard regulators, 12V voltage not critical. Also has polarity fixing bridge.

All the programs are in one file. You select by editing a define statement, well commented. That's the newest file. Need to do some cleanup there.

There's also a statement for inverting the output to work with the STK500 LED.

Don't recall a Tiny update.

Where is that STK intro, I should put a link to it in post 1.

-- Alan


----------



## JimmyM (Oct 25, 2008)

I've got the STK500 connected per your instructions and I can read the chip signature. So I'm getting there.

One thing though.
I may have made a dreadful error in the PCB design. The pin number assignments were done like a DIP device. Pin1 is still Pin1 in the design, but the placement of those pins in the PCB may be wrong
654
|||
---
|||
123

As viewed from above, can you define the pin numbering of the 6 pin header?
I'll need to do a little "fixing" of the boards when they arrive if I was wrong.

Also, the power switch on my STK500 doesn't seem to do anything.

I've done a little looking around and have found the below as the pin assignments for the Header.

246
|||
---
|||
135

Is this correct?


----------



## Alan B (Oct 25, 2008)

Jim:

Good start on reading the sig.

Sorry I didn't notice the pin numbering on the pcb prog jack. It is odd, as many jacks are. It is printed on your STK500 board, actually. Which you did not have when you did the PCB. It is also in the Atmel docs on AVR programming on their site, and on the web in many programmer documents.

Bad switch on STK?

-- Alan


----------



## JimmyM (Oct 25, 2008)

Arrrrrrrrggghhhhh! I KNEW, as soon as I sent out a board, I would find an error after I submitted it.
It's not THAT bad, though. At least I caught it.
After I receive them, I'll rewire the offending tracks on the bottom of the board before sending them out.
CRAP!


----------



## Alan B (Oct 25, 2008)

I hate it when that happens. Good it is only 10 boards.

-- Alan


----------



## JimmyM (Oct 25, 2008)

Alan B said:


> I hate it when that happens. Good it is only 10 boards.
> 
> -- Alan


It's 2 oz copper and fairly wide tracks. I should be able to fix things fairly easy. It's just such a P.I.T.A. Sounds like you know what it's like.
Any way. I'm looking forward to getting things working on my bench.


----------



## wquiles (Oct 25, 2008)

Alan B said:


> The brownout features on the CPU are not enabled yet.
> 
> I have too much else on my list right now to dig into that. Perhaps you want to give it a shot. Actually it is probably pretty simple. There may be implications in the power-down code, but that can be fixed later.
> 
> -- Alan






JimmyM said:


> This needs to work in "tail switch" mode. When power is just applied via tail switch or by mag switch when the circuitry has no connection to power at all.




Well, I enabled the brown-out detection (it was dissabled), and set it up for VCC=4.3Volts. Basically if the battery drops below this point (actually below 4.0 for the hysteresis) then it keeps the CPU in a reset mode - which prevents "stuff" from happening. Guess what, it works - now I can't get it to output those full Vbat swings in the output - at least I am no longer able to do it yet. I will keep playing with it, but this is encouraging as I only have one 1185 bulb left 

Will


----------



## wquiles (Oct 25, 2008)

JimmyM said:


> Arrrrrrrrggghhhhh! I KNEW, as soon as I sent out a board, I would find an error after I submitted it.
> It's not THAT bad, though. At least I caught it.
> After I receive them, I'll rewire the offending tracks on the bottom of the board before sending them out.
> CRAP!



I bought the 6-pin connector parts from Digikey and I had the flat cable, so I recently made an extra 6-pin programming cable from the STK500 to my target board, so making one with the "special" pinout to match these boards is not too bad. If this is the only problem with the boards, we are in fantastic shape as this one is easy to fix 

Will


----------



## Alan B (Oct 25, 2008)

wquiles said:


> Well, I enabled the brown-out detection (it was dissabled), and set it up for VCC=4.3Volts. Basically if the battery drops below this point (actually below 4.0 for the hysteresis) then it keeps the CPU in a reset mode - which prevents "stuff" from happening. Guess what, it works - now I can't get it to output those full Vbat swings in the output - at least I am no longer able to do it yet
> 
> Will


 
Perfect. As expected. Eventually we can put that in the source code so the fuses don't have to be manually fiddled.

-- Alan


----------



## Alan B (Oct 25, 2008)

wquiles said:


> I bought the 6-pin connector parts from Digikey and I had the flat cable, so I recently made an extra 6-pin programming cable from the STK500 to my target board, so making one with the "special" pinout to match these boards is not too bad. If this is the only problem with the boards, we are in fantastic shape as this one is easy to fix
> 
> Will


 
For myself, the nonstandard cable is not great, I'd hack the board. I have many programmers, and some have built in cabling. Save some problems down the road, most likely.

-- Alan


----------



## wquiles (Oct 26, 2008)

OK guys, I found that I can "still" make the PhD misbehave during power application/removal 

Basically, it is harder to do now that I have the brown-out code in place, but when running on steady state, if I go switch power OFF and then ON for approx. 1/2 a second, I can still get the problem to happen.

Here are two short videos that I took tonight and posted on youtube. Note that although briefly, it does get brighter, which is of course the problem:
http://www.youtube.com/watch?v=8iL2e9vk77I

http://www.youtube.com/watch?v=JHa9thtP0DI


And here are some still shots of the storage scope. Note that although the power is fluctuating, the pulses (blue trace) to the gate are still happening:

















It is almost as if the electrolitic caps are keeping the CPU running too long after power started going down? 

Or maybe, this is a problem only with the PS since it has big caps? I will try tomorrow with the battery pack to see if it behaves differently.

Will


----------



## Alan B (Oct 26, 2008)

The power supply is a pretty special case, the voltage does unusual things. Batteries may be much better behaved. Also, the low voltage shutoff code can be adjusted and made more agressive than it is in case that helps. There may be other brownout detection steps that need to be taken such as a brownout interrupt as well.

I'm not too worried about this, but it needs to be worked out.

Testing with batteries is a good idea. It may be a non-issue with them.

-- Alan


----------



## JimmyM (Oct 26, 2008)

Alan B said:


> For myself, the nonstandard cable is not great, I'd hack the board. I have many programmers, and some have built in cabling. Save some problems down the road, most likely.
> 
> -- Alan


I'm with Alan on this one. I had thought about it. But having to remember to use the right cable with this board is just a pain in the a**. I'd rather it be a pain in the a** for me just once instead of everyone else, every single time. Unless, of course, I hardwired cables onto the board.


----------



## Alan B (Oct 26, 2008)

Some programmers have the cable hardwired to them already, so fixing the board is the best option.

:shrug:

-- Alan


----------



## JimmyM (Oct 26, 2008)

OH, great. Now I've got options.
I've got the 6 pin headers already. So I'll fix one to see how it goes. If it's a giant pain, I'll look into the hardwired cable.


----------



## wquiles (Oct 26, 2008)

Alan B said:


> The power supply is a pretty special case, the voltage does unusual things. Batteries may be much better behaved. Also, the low voltage shutoff code can be adjusted and made more agressive than it is in case that helps. There may be other brownout detection steps that need to be taken such as a brownout interrupt as well.
> 
> I'm not too worried about this, but it needs to be worked out.
> 
> ...




Well guys, initial testing with batteries today seems to indicate this is a non issue. So far so good ... :twothumbs

Now, in terms of current usage, I took some measurements today and while the PhD is ON, but standby (bulb off), the circuit is using a very large 6.5mA according to my Fluke 189. I tried on both the 400mA and the 10A scales, and I get the same thing. Of course, this is not "sleep" mode, but it is worth nothing 

I also measured the current while the circuit was on (using the internal shunt in the Fluke 189 in the 10Amp scale), and as expected, we need an AC+DC RMS meter like the Fluke 189 for the current measurement as well. I was using one of my 6-7 bulbs, and on standard DC current I was measuring about 1Amp, while on true-rms AC+DC mode I was reading the expected 1.5-1.6Amps.

Will


----------



## Alan B (Oct 26, 2008)

wquiles said:


> Well guys, initial testing with batteries today seems to indicate this is a non issue. So far so good ... :twothumbs
> 
> Now, in terms of current usage, I took some measurements today and while the PhD is ON, but standby (bulb off), the circuit is using a very large 6.5mA according to my Fluke 189. I tried on both the 400mA and the 10A scales, and I get the same thing. Of course, this is not "sleep" mode, but it is worth nothing
> 
> ...


 
Will, if you enable the sleep mode it should drop after a few seconds to the lower level. The current will not be pulsing, so RMS should not be required for that measurement.

-- Alan


----------



## wquiles (Oct 28, 2008)

Cool - thanks. I will play some more with the new software when I return from travel (typing this from Mexico City).

Will


----------



## JimmyM (Oct 28, 2008)

Enjoy your travels, Will. The boards arrived today. I'm away working at the moment. I won't return until Tomorrow night or Thursday night. I can't wait to see them.


----------



## JimmyM (Oct 28, 2008)

I just finished a design for a 30mm round board for D cell Mags. It has...
a DPAK FET, 12V LDO gate drive regulator, 5V uP supply, FET driver, 1.27mm pitch programming header (properly connected this time), screw and bulb+ holes.
One this with this design though, it does not maintain power to the uP when off. All power is removed from the electronics and voltage sampling circuitry.
Pros: No power drain while off. Good for simple installation under a KIU base.
Cons: Just ON or OFF. Nothing fancy.

I could revise the design a little to keep power applied, and add a provision for a momentary button. In fact that's what I'll be working on next.


----------



## Alan B (Oct 28, 2008)

JimmyM said:


> I just finished a design for a 30mm round board for D cell Mags. It has...
> a DPAK FET, 12V LDO gate drive regulator, 5V uP supply, FET driver, 1.27mm pitch programming header (properly connected this time), screw and bulb+ holes.
> One this with this design though, it does not maintain power to the uP when off. All power is removed from the electronics and voltage sampling circuitry.
> Pros: No power drain while off. Good for simple installation under a KIU base.
> ...


 
Sounds nice, Jim. Wonder why doubling the hardware cost is required? (driver)(actually, more like triple the hw cost?)

-- Alan


----------



## JimmyM (Oct 29, 2008)

Alan B said:


> Sounds nice, Jim. Wonder why doubling the hardware cost is required? (driver)(actually, more like triple the hw cost?)
> 
> -- Alan


Ha ha ha. :sigh: Harder drive, less heat, switching load isolation for the uP. Added cost ~=$3.75. Plus, it's my hardware design. I've laways been one for overkill. It's served my designs well in the past. 600W JM-SST. The basics are all there. Just the gate drive has been enhanced.


----------



## wquiles (Oct 29, 2008)

JimmyM said:


> I just finished a design for a 30mm round board for D cell Mags. It has...
> a DPAK FET, 12V LDO gate drive regulator, 5V uP supply, FET driver, 1.27mm pitch programming header (properly connected this time), screw and bulb+ holes.
> One this with this design though, it does not maintain power to the uP when off. All power is removed from the electronics and voltage sampling circuitry.
> Pros: No power drain while off. Good for simple installation under a KIU base.
> ...



That is awesome Jim  That might be the same size factor and functionality that would work well in the SF M6 variant 

Will


----------



## JimmyM (Oct 29, 2008)

wquiles said:


> That is awesome Jim  That might be the same size factor and functionality that would work well in the SF M6 variant
> 
> Will


What diameter would fit?
I'm working on a double sided board with a single (5V) reg. I'm trying to see how small I can make it. The PITA is getting the programming header fitted. I was thinking about having a board with a 6 pin card edge connector. After assembly, programming, and testing, it could be cut off. Reprogramming would be a pain, but it would make it smaller. Then again, I could always build a rig to place pins on the 6 pins necessary for programming. That would eliminate a programming header entirely.


----------



## JimmyM (Oct 30, 2008)

OK. I'm home now. Boards look nice. I can't wait until my next design needs to be built.


----------



## wquiles (Oct 31, 2008)

JimmyM said:


> What diameter would fit?
> I'm working on a double sided board with a single (5V) reg. I'm trying to see how small I can make it. The PITA is getting the programming header fitted. I was thinking about having a board with a 6 pin card edge connector. After assembly, programming, and testing, it could be cut off. Reprogramming would be a pain, but it would make it smaller. Then again, I could always build a rig to place pins on the 6 pins necessary for programming. That would eliminate a programming header entirely.



OK, I am back in the good US of A !!!

Since the ID of the M6 is larger than the ID of the "D" Mag, your current size should fit "as is", at least diameter-wise. The challenge with the M6 is the OL of the battery pack/driver solution, so height might be the critical factor, depending on what cells are used, etc., so perhaps something "thin" and long like the LVR might fit better depending on the actual battery pack chosen. Here is the LVR from Willie Hunt:







Here is how the driver fits alongside the battery pack:
















For example, 6x17500 does "not" physically fit without the new easy-to-swap tailcup (see bellow) - SF M6 factory/OEM battery pack on the left for reference:






Here is the shorter tailcap insert, such as the one I did for the HDM6 project:
















Another possible rechargable solution that "does" fit is when using 3x17670 cells (of course would need a regulator of some sort due to the higher series voltage) - SF M6 factory/OEM battery pack on the right for reference:






When I start a thread specifically on the PhD-M6, we will go over all of this again, to see what folks need/want 

Will


----------



## Alan B (Oct 31, 2008)

JimmyM said:


> I just finished a design for a 30mm round board for D cell Mags. It has...
> a DPAK FET, 12V LDO gate drive regulator, 5V uP supply, FET driver, 1.27mm pitch programming header (properly connected this time), screw and bulb+ holes.
> One this with this design though, it does not maintain power to the uP when off. All power is removed from the electronics and voltage sampling circuitry.
> Pros: No power drain while off. Good for simple installation under a KIU base.
> ...



Both options here are good (power always on with pushbutton control, power off/on via switch. Different software will be required, but we already have a lot of options covered.

-- Alan


----------



## JimmyM (Oct 31, 2008)

wquiles said:


> OK, I am back in the good US of A !!!
> 
> 
> Will


Welcome back.
I see what you mean about the diameter vs length. The long thin design looks great. Also incorporating one into the 3x17670 pack looks really good.


----------



## JimmyM (Nov 5, 2008)

I was hoping to get some work done on the PhD test boards, but got called away on business. I won't be able to do anything until this weekend. Sorry, guys.
On the upside, I did get some work done finishing my workspace while my dad was visiting last weekend.


----------



## wquiles (Nov 5, 2008)

Thanks for the update Jim 

I am definitely looking forward to continuing testing with the new boards 

Will


----------



## JimmyM (Nov 10, 2008)

OK. I botched one board (kind of). It will work, but I have to do a little more fiddling. I modded another just fine and mounted the 6 pin header and IC socket. I can connect it to the STK500 and read the chip signature. I was able to modify 7 boards in total. I should be able to do the other 3 tonight. They don't look as "hacked together" as I thought they would.
But the programming does work.


----------



## Alan B (Nov 10, 2008)

JimmyM said:


> OK. I botched one board (kind of). It will work, but I have to do a little more fiddling. I modded another just fine and mounted the 6 pin header and IC socket. I can connect it to the STK500 and read the chip signature. I was able to modify 7 boards in total. I should be able to do the other 3 tonight. They don't look as "hacked together" as I thought they would.
> But the programming does work.



Good Progress, Jim :twothumbs

-- Alan


----------



## LuxLuthor (Nov 10, 2008)

:candle:


----------



## Alan B (Nov 10, 2008)

LuxLuthor said:


> :candle:



I wonder if we should get a board set up for LuxLuthor to do testing with various bulbs?

We could set up the software to ramp very slowly so one version could be used with different voltage bulbs. An averaging DC voltmeter and a preprinted chart could ease the conversion to RMS values and back. A simple test setup for bulbs??

Lux, what kind of electronics test gear do you have at hand??

-- Alan


----------



## JimmyM (Nov 10, 2008)

OK boards and component kits are ready to ship.
Components consist of:
Test points
IC sockets
Pin headers
Jumpers
2 x 0.1uF caps
1 x 10 uF cap

It doesn't have:
Resistors (everyone has those)
AVR
FET driver
12V regulator
5V regulators
Current sense shunts
FETs

PM me with your shipping addresses and I'll ASAP.
Shipping is per your request and I'll just add shipping to the total.
The price per board + components is $35 USD
Will, you've paid up-front, and then some (thank you again, very much), so you're all set.

Lux, if you're interested, and you don't already have one, I can include a Tiny45 with your kit. It looks like Will and Alan are OK with AVRs.


----------



## wquiles (Nov 10, 2008)

JimmyM said:


> OK boards and component kits are ready to ship.
> Components consist of:
> Test points
> IC sockets
> ...



Great update - thanks much Jim 

Will


----------



## Alan B (Nov 10, 2008)

JimmyM said:


> OK boards and component kits are ready to ship.
> Components consist of:
> Test points
> IC sockets
> ...



Jim, you want ppal or ??

-- Alan


----------



## LuxLuthor (Nov 10, 2008)

JimmyM said:


> OK boards and component kits are ready to ship.
> Components consist of:
> Test points
> IC sockets
> ...



I have a Fluke 179, but can get other equipment (within reason) that would be helpful. Jimmy, whichever (Tiny/AVR) you recommend is fine. I'll send a PM now.


----------



## JimmyM (Nov 11, 2008)

Alan B said:


> Jim, you want ppal or ??
> 
> -- Alan


Oh yeah. Duh. Sorry.
pp= [email protected]


----------



## Alan B (Nov 11, 2008)

JimmyM said:


> Oh yeah. Duh. Sorry.
> pp= ...



PM sent. Jim, you may want to distort the email address to reduce spam pickup.

-- Alan


----------



## JimmyM (Nov 11, 2008)

Alan B said:


> PM sent. Jim, you may want to distort the email address to reduce spam pickup.
> 
> -- Alan


It's funny you mention that. But, I get 200ish spam emails a day. My spam filter catches all but 1, maybe 2, a day.


----------



## Alan B (Nov 11, 2008)

JimmyM said:


> It's funny you mention that. But, I get 200ish spam emails a day. My spam filter catches all but 1, maybe 2, a day.



That's a good spam filter. It helps to make it hard for the address spiders to find the address, but it doesn't stop it, just reduces it a bit.

Back on topic, what programmer should LuxLuthor get? I've been using several different ones. The little USBTinyISP kit unit has a command line interface, the others work with Atmel Studio's GUI. There's a way to make the TinyISP work with Studio but it requires a more complicated software install, I have not tried that. It is a kit requiring soldering.

http://www.adafruit.com/index.php?main_page=product_info&cPath=16&products_id=46

The Dragon board is fragile, and the STK500 board is rather large and somewhat fragile. The boards are suitable for workbench use. The TinyISP is suitable for taking to the field. It is small and enclosed. There are many other solutions out there as well. All these work with windows. Linux is possible but more complicated.

-- Alan


----------



## JimmyM (Nov 11, 2008)

Alan B said:


> That's a good spam filter. It helps to make it hard for the address spiders to find the address, but it doesn't stop it, just reduces it a bit.
> 
> Back on topic, what programmer should LuxLuthor get? I've been using several different ones. The little USBTinyISP kit unit has a command line interface, the others work with Atmel Studio's GUI. There's a way to make the TinyISP work with Studio but it requires a more complicated software install, I have not tried that. It is a kit requiring soldering.
> 
> ...


I purchased both the AVRISP MkII and the STK500 from Digikey.
Once the PhD Proto board is built and powreed up, he should only need the AVRISP MkII. The AVR Studio recognizes it and it's not all that expensive. But here's the bonus. When you buy it at Digikey, they send you an email to order FREE AVRs compatible with the device you purchased. For the STK500 I could only choose from DIP devices. But with the AVRISP MkII I could choose from DIP and SOIC devices. I believe I got 4 chips as samples with each device.
I'd recommend the AVRISP MkII (Digikey PN ATAVRISP2-ND). AT $34 + shipping, it's not expensive at all AND you get free chips!
FREE CHIPS... NACHO LIBRE!!!!


----------



## Alan B (Nov 11, 2008)

JimmyM said:


> I purchased both the AVRISP MkII and the STK500 from Digikey.
> Once the PhD Proto board is built and powreed up, he should only need the AVRISP MkII. The AVR Studio recognizes it and it's not all that expensive. But here's the bonus. When you buy it at Digikey, they send you an email to order FREE AVRs compatible with the device you purchased. For the STK500 I could only choose from DIP devices. But with the AVRISP MkII I could choose from DIP and SOIC devices. I believe I got 4 chips as samples with each device.
> I'd recommend the AVRISP MkII (Digikey PN ATAVRISP2-ND). AT $34 + shipping, it's not expensive at all AND you get free chips!
> FREE CHIPS... NACHO LIBRE!!!!



Great, Jim. I didn't know you had both. I got a couple of sample chips with my STK500 but not with the AVRISP MkII.

The AVRISP MkII is a good choice. It is enclosed, USB, and has a six pin cable/plug for programming. The cost is reasonable, and it is "the real thing" from Atmel, so it should be compatible for a long time, and work nicely with all the software tools they produce.

The Downsides of the AVRISP MkII is that it does not have the option to power the circuit being programmed (occasionally useful), and it does not have a 10 pin programming cable. We don't need a 10 pin programming cable on this project, but many projects/boards out there do use the 10 pin (older) standard. I did find an adapter PCB from Sparkfun that could be used to solve this problem if needed.

The USBTinyISP has a jumper to select "power the target", or "don't power the target". This allows programming/testing a board that has no power, which can be useful. Again, not required, but can be useful.

The AVRISP integrates with AVR Studio nicely. A couple of clicks are all that are required to program a chip, and it is graphical. The TinyISP uses AvrDude, a command line program. It is a little less convenient to set up, but once done it takes a click and two keystrokes to program a chip. There is a way to connect it to AvrStudio graphically but I have not done so.

The TinyISP is somewhat smaller than the AVRISP. The TinyISP is a kit requiring simple through-hole soldering and minor assembly. It has both 6 and 10 pin programming cables, plus a jumper to select powering the target CPU or not. The AVRISP is built and tested. They are both USB. The TinyISP is $22, so a little lower cost.

Both great choices.

I wonder if any of this will change now that MicroChip (the PIC folks) are buying Atmel? One thing that MicroChip does is to have free samples of CPUs. So for small projects we might be able to use samples. Doesn't matter much since these CPUs are so inexpensive anyway.

-- Alan


----------



## JimmyM (Nov 11, 2008)

Alan B said:


> The USBTinyISP has a jumper to select "power the target", or "don't power the target". This allows programming/testing a board that has no power, which can be useful. Again, not required, but can be useful.
> -- Alan


That is a nice option. I'll be building out a proto board tonight and testing the AVRISP.
Your package went out today. Board and components shipped via USPS Priority Mail. Shipping was $6.50.


----------



## Alan B (Nov 11, 2008)

JimmyM said:


> That is a nice option. I'll be building out a proto board tonight and testing the AVRISP.
> Your package went out today. Board and components shipped via USPS Priority Mail. Shipping was $6.50.



Pp sent. 

Great on the prototype test board build. 

Thanks, Alan


----------



## JimmyM (Nov 11, 2008)

Update: I finished assembling my board.
13.2V input.
11.5V to the "12V" buss.
4.97V to the AVR.

Signature can be read using the AVRISP connected by USB with power applied to the board.

Following your instructions found here...
http://candlepowerforums.com/vb/showthread.php?p=2630454&highlight=signature#post2630454
I was able to flash the AVR in the PhD Proto board.

Now if I can just find a suitable pushbutton lying around here somewhere. Arrrrggghhh.


----------



## wquiles (Nov 11, 2008)

Nice going Jim - you are almost there 

Will


----------



## JimmyM (Nov 12, 2008)

IMPORTANT NOTE:
The Symbol of the TO-92 case regulator (LM2936) is BACKWARDS.
When placing the chip. Insert it with the flat of the package opposite of the way the board marking suggests.
I removed mine and turned it 180 degrees and it works very nicely.


----------



## JimmyM (Nov 12, 2008)

Regarding power supplies.
I'm seeing a LOT of "ringing" at the battery input. It's only barely noticable at the AVR Vcc. But it's very pronounced at the gate shut-off.
This si what FP8 looks like on powerup. No button presses. Redline=FET gate, Yellow=AVR Vcc.
5V/Div, 25uS






This is What it looks like with the FET driver.


----------



## wquiles (Nov 12, 2008)

JimmyM said:


> IMPORTANT NOTE:
> The Symbol of the TO-92 case regulator (LM2936) is BACKWARDS.
> When placing the chip. Insert it with the flat of the package opposite of the way the board marking suggests.
> I removed mine and turned it 180 degrees and it works very nicely.



Thanks for the heads-up!





JimmyM said:


> Regarding power supplies.
> I'm seeing a LOT of "ringing" at the battery input. It's only barely noticable at the AVR Vcc. But it's very pronounced at the gate shut-off.
> This si what FP8 looks like on powerup. No button presses. Redline=FET gate, Yellow=AVR Vcc.
> 5V/Div, 25uS
> ...



Cool - that driver sure makes a difference 

Will


----------



## JimmyM (Nov 12, 2008)

I've changed some components a little.
I added a 0.1 uF cap right at the pins of the AVR to clean up some noise.

I added a 22 uF cap in addition to C5,C6,C7 12V buss looksed strange, even without driving the FET Driver. I'll have to investigate that. I used the same regulator LT3014B for the JM-SSTs with no problems using a 1uF cap. Perhaps a bad 12V regulator. But the 22 uF cap worked for now.

Below are caps of the gate (Yellow) and AVR Vcc pin (Red). 5V/Div, 2.5 uS/Div, 0 presses.
Top is with FET driver on 12V, below it is just the AVR driving the gate.


----------



## JimmyM (Nov 12, 2008)

Another one.
0 presses
5V/div, 2.5uS/div.
Load is a 12V automotive 1157 bulb (both filaments)
Here's a comparison of AVR output versus Gate voltage.
Red=Gate voltage
Yellow=AVR output

With the Driver running at 5V with a 10 Ohm gate resistor







WITHOUT the driver and a 68 Ohm gate resistor.






Here's one, same as just above but no load.






Again, but with a 2.2 Ohm resistor as load


----------



## wquiles (Nov 12, 2008)

Nice captures Jim 

Can't wait to get my own boards to join the "party" 

Will


----------



## JimmyM (Nov 12, 2008)

wquiles said:


> Nice captures Jim
> 
> Can't wait to get my own boards to join the "party"
> 
> Will


Did you PM me your shipping address?


----------



## wquiles (Nov 12, 2008)

JimmyM said:


> Did you PM me your shipping address?



I was on my Paypal to you, but I will send you an email with it 

Will


----------



## LuxLuthor (Nov 13, 2008)

I'll likely get the AVRISP MkII, as I would mostly be using it for this project, and have made contact with Jimmy. I'll be a good "intermediary" guinea pig for the general CPF gang...if I can figure out how to get it working for all my bulbs, I can teach it to others. This project is surely worth the extra effort!


----------



## JimmyM (Nov 13, 2008)

wquiles said:


> I was on my Paypal to you, but I will send you an email with it
> 
> Will


Duh. SHould have looked. Thanks.


----------



## JimmyM (Nov 14, 2008)

JimmyM said:


> I added a 22 uF cap in addition to C5,C6,C7 12V buss looked strange, even without driving the FET Driver. I'll have to investigate that. I used the same regulator, LT3014B, for the JM-SSTs with no problems using a 1uF cap. Perhaps a bad 12V regulator. But the 22 uF cap worked for now.


As it turns out I have a bad 3014B. I built and tested another board and it's perfectly stable with just the onboard 3 x 1uF ceramic SMD chips. Also, it was stable without the additional filter cap at the AVR.


----------



## wquiles (Nov 14, 2008)

JimmyM said:


> As it turns out I have a bad 3014B. I built and tested another board and it's perfectly stable with just the onboard 3 x 1uF ceramic SMD chips. Also, it was stable without the additional filter cap at the AVR.



Good to know that it is working well with the smaller SMD parts 

Will


----------



## JimmyM (Nov 15, 2008)

I've been making little updates to the PCB design as I go. I fixed the programming header routing, I added an SMD pad under the AVR for a filter cap if necessary, I added a provision to select a 47K or 100K resistor as the upper sampling divider. I also added a provision to select either the LT3014B or an LM7812 as the 12V regulator. The LM7812 is too large for production units, but it allows a cheaper alternative for testing. The LT3014B is not available from Digikey. 
I just want to keep the design as "current" as possible based on testing results. Advanced CIrcuits (the folks that made the proto boards) has an option to have just a single board made for $33 each. If anyone wants an updated board, I can have one made for $33+shipping. The boards I had made before were 10 for $210+shipping. So the updated boards are more expensive, but it's an option for those that want one. 
The higher gate drive voltage and FET driver do make quite a difference in the gate voltage curve. If using the 5V or 12V gate drive, adding an FET driver will add only about $1.29 in cost. The package of the MIC4416 is an SOT143 (3mm x 2.4mm including legs). So it's quite small.


----------



## LuxLuthor (Nov 15, 2008)

Jimmy, the two you are sending me are from first batch, correct? I also have the AVRISP MkII coming. Once I figure this much out (including what you said abut gate drive voltage and FET driver), I'm sure I would want more. Is it the similar cheaper price for quantity of 10? 

After talking to Jimmy, I can start testing actual lux with various bulbs using my former destructive testing setup, vs. PS delivered voltage to PhD, vs. battery power to PhD.

Alan, is the file on your site "HotwireRegulatorAlpha.c" the most current version you are all using with AVR?


----------



## JimmyM (Nov 15, 2008)

LuxLuthor said:


> Jimmy, the two you are sending me are from first batch, correct? I also have the AVRISP MkII coming. Once I figure this much out (including what you said abut gate drive voltage and FET driver), I'm sure I would want more. Is it the similar cheaper price for quantity of 10?
> 
> After talking to Jimmy, I can start testing actual lux with various bulbs using my former destructive testing setup, vs. PS delivered voltage to PhD, vs. battery power to PhD.
> 
> Alan, is the file on your site "HotwireRegulatorAlpha.c" the most current version you are all using with AVR?



There isn't a second batch yet. Just the ones I have and am sending out. Lux, you are getting one fully populated baord with all the chips/bits, etc. The second board is just the empty board with the standard parts kit.
The populated board has the 47K resistor for the upper half of the sampling divider that Alan is using now. As well as a 1 Ohm resistor for the Gate current sence resistor. Before assembly was complete, I measured the resistance of the gate sense resistor (compensating for leads) and wrote it on the board. (0.98 Ohm). The only thing I didn't do on your board was the main current sense shunt. You have a shunt that you can solder in wires for.

PS. The board you have is completely reconfigurable for 5V gate drive or 12V (actuaqlly 11.2V) gate drive. You have all but the 100K versus 47K option and the 3014B/7812 option. But the One board already has the 3014B installed. So you don't need the 3014B. If you choose to enable the 12V regulator and set the 5V source to 12V instead of Vbat, you set up can do 40V with the FET installed. Be carefull near 40V though.
The 6mm wide, 2oz tracks should be good for ~15A with a 10 deg C rise.

Lux should be able to test the crap out of several bulbs.
One great interest of mine is the life of a bulb that survives 10 hours at 15VDC versus the life of a bulb driven at 15VRMS (25V, etc peak)


----------



## wquiles (Nov 16, 2008)

LuxLuthor said:


> Alan, is the file on your site "HotwireRegulatorAlpha.c" the most current version you are all using with AVR?



The latest that I have is version 0.95 from October 2008.

It is quite powerful and versatile. Basically, you use the #define statements to enable "sections of code to compile and execute. This allows for testing of individual sections, which is nice. Alan also has the "older" codes as well, which start with FP1, to the latest which is FP9 - which is the one I am testing with. I must say that although I would tune up a little bit the behavior, I like the one-button interface that Alan has right now 

Will


----------



## Alan B (Nov 17, 2008)

wquiles said:


> The latest that I have is version 0.95 from October 2008.
> 
> It is quite powerful and versatile. Basically, you use the #define statements to enable "sections of code to compile and execute. This allows for testing of individual sections, which is nice. Alan also has the "older" codes as well, which start with FP1, to the latest which is FP9 - which is the one I am testing with. I must say that although I would tune up a little bit the behavior, I like the one-button interface that Alan has right now
> 
> Will



LuxLuthor, I did not notice your question earlier. Thanks to Will for picking that up. Yes, that is the latest, no work has been done on it for quite some time. There are quite a few features there that have not been fully beta tested yet, though I did at least some testing of each of them at some point.

-- Alan


----------



## winny (Nov 17, 2008)

LuxLuthor was kind enough to point me to this thread, so...

Long time no see everyone! :wave: It's been three years since I designed my first beta-PIR now and much have happened since I see which is fun. 

Since then, I have almost completed my MSc in EE and I now work for a Swedish amplifier company developing multi-kW power supplies and rig sound and light for concerts and parties with a student union organization which takes up *all* my available time. It's very much fun though...

I still have plans for a PIR 1.1, so when I eventually finish school, I just might build it. In the mean time, I use LEDs and still think "Pathetic compared to incan!" when I turn it on high...

Got to get back to work now!


----------



## JimmyM (Nov 17, 2008)

Thanks to, Lux, Indeed. Glad to see you poking your head in here.
Please feel free to add commentary, etc if you like.


----------



## Alan B (Nov 17, 2008)

winny said:


> LuxLuthor was kind enough to point me to this thread, so...
> 
> Long time no see everyone! :wave: It's been three years since I designed my first beta-PIR now and much have happened since I see which is fun.
> 
> ...



Thanks for stopping by, Winny! Hopefully when you have some time you can make some comments here. :twothumbs

The new SSC P7 LED's are starting to get pretty impressive, 3 of them can make 2500 lumens :naughty:. But we know the incans can go a bit farther, right up to .

-- Alan


----------



## LuxLuthor (Nov 17, 2008)

wquiles/Alan, thanks for confirming latest software.

Jimmy, got the two boards...they are so purdy!!!!!!!! Really nice! Thanks!

Winny, your PIR work was inspirational. If you have the time, any feedback would be wonderful!


----------



## JimmyM (Nov 18, 2008)

LuxLuthor said:


> Jimmy, got the two boards...they are so purdy!!!!!!!! Really nice! Thanks!


Glad you like 'em.


----------



## wquiles (Nov 18, 2008)

Jim - got the boards as well - thanks much 

Will


----------



## Alan B (Nov 18, 2008)

JimmyM said:


> Glad you like 'em.



Jim, board received. Now to find some time..

Thanks

-- Alan


----------



## JimmyM (Nov 18, 2008)

Tell me about it! I'm away for work again Wed-Fri.
I'd like to start messing around with FP7 and FP8 this weekend.
I'm going to try some real world battery/bulb voltages.
5761 on 3 or 4 A123s/eMolis
1185 on 4 A123s.
Things like that. Bulb/Battery voltage combinations that will work this design in the more likely duty cycle range.


----------



## Alan B (Nov 18, 2008)

JimmyM said:


> Tell me about it! I'm away for work again Wed-Fri.
> I'd like to start messing around with FP7 and FP8 this weekend.
> I'm going to try some real world battery/bulb voltages.
> 5761 on 3 or 4 A123s/eMolis
> ...



That's tough. Really hard to be away. Course you could take a small test setup along..

Sounds like a good plan, get some familiarity with the code/hardware.

-- Alan


----------



## JimmyM (Nov 19, 2008)

Alan B said:


> That's tough. Really hard to be away. Course you could take a small test setup along..
> -- Alan



TSA Agent: What is this?
Jim: Oh, that's just so I can build flashlight regulators.
TSA Agent: Come with me sir. Are you familiar with the term "Body cavity search"?


----------



## Alan B (Nov 19, 2008)

JimmyM said:


> TSA Agent: What is this?
> Jim: Oh, that's just so I can build flashlight regulators.
> TSA Agent: Come with me sir. Are you familiar with the term "Body cavity search"?



Put it in the "checked luggage", not carryon.

-- Alan


----------



## JimmyM (Nov 19, 2008)

Alan B said:


> Put it in the "checked luggage", not carryon.
> 
> -- Alan


C'mon, Alan. That would make sense. You can't expect me to think that clearly this early in the morning. My, GOD, man.


----------



## wquiles (Nov 19, 2008)

You guys are too funny in the morning :twothumbs

I am traveling today again - of course my PhD setup is staying at home 

Will


----------



## JimmyM (Nov 20, 2008)

I found a neat Programmer that has 6 and 10 pin programming plugs and is cheaper than the STK500.
http://www.sparkfun.com/commerce/product_info.php?products_id=8702


----------



## Alan B (Nov 20, 2008)

JimmyM said:


> I found a neat Programmer that has 6 and 10 pin programming plugs and is cheaper than the STK500.
> http://www.sparkfun.com/commerce/product_info.php?products_id=8702



I didn't mention that one before since it wasn't outstanding, but it looks fine. It is nice that it works directly with AVR Studio with no drivers, and that it has both 6 and 10 pin plugs. If someone tries it hopefully they will report here.

-- Alan


----------



## JimmyM (Nov 20, 2008)

What AVRs have a greater than 8bit PWM?
All of the Atmel product tables just list the number of PWM channels. Some only have 8 bit timers while some have 16 bit timers. Is that an indicator?


----------



## Alan B (Nov 20, 2008)

JimmyM said:


> What AVRs have a greater than 8bit PWM?
> All of the Atmel product tables just list the number of PWM channels. Some only have 8 bit timers while some have 16 bit timers. Is that an indicator?



I think most of them have more than 8 bits, 10 bits is common. Have to dig deeper into the datasheet, it seems to be omitted from the tables. One problem is more bits requires a much higher frequency to make it work. So there is a limit to what is practical.

-- Alan


----------



## JimmyM (Nov 20, 2008)

I found the ATTiny84. It's a 14 Pin DIP (Fine for experimenting) , but it also comes in a QFN20 package which is only 4 mm square overall.
Even the 8 pin SOIC is 5.25 x 8 mm overall. So it's actually better for production designs.
From the documentation... It will do 16MHz at 4.5-5.5V
Features
- High Performance, Low Power AVR® 8-Bit Microcontroller
- Advanced RISC Architecture
- 120 Powerful Instructions - Most Single Clock Cycle Execution
- 32 x 8 General Purpose Working Registers
- Fully Static Operation
- Non-volatile Program and Data Memories
- 2/4/8K Byte of In-System Programmable Program Memory Flash (ATtiny24/44/84)
Endurance: 10,000 Write/Erase Cycles
- 128/256/512 Bytes In-System Programmable EEPROM (ATtiny24/44/84)
Endurance: 100,000 Write/Erase Cycles
- 128/256/512 Bytes Internal SRAM (ATtiny24/44/84)
- Programming Lock for Self-Programming Flash Program and EEPROM Data
Security
- Peripheral Features
- Two Timer/Counters, 8- and 16-bit counters with two PWM Channels on both
- 10-bit ADC
---8 single-ended channels
---12 differential ADC channel pairs with programmable gain (1x, 20x)
Temperature Measurement
- Programmable Watchdog Timer with Separate On-chip Oscillator
- On-chip Analog Comparator
- Universal Serial Interface
- Special Microcontroller Features
- debugWIRE On-chip Debug System
- In-System Programmable via SPI Port
- External and Internal Interrupt Sources
- Pin Change Interrupt on 12 pins
- Low Power Idle, ADC Noise Reduction, Standby and Power-down Modes
- Enhanced Power-on Reset Circuit
- Programmable Brown-out Detection Circuit
- Internal Calibrated Oscillator
- On-chip Temperature Sensor
- I/O and Packages
- 14-pin SOIC, 20-pin QFN/MLF: Twelve Programmable I/O Lines
- Operating Voltage:
- 2.7 - 5.5V for ATtiny24/44/84
- Speed Grade
- ATtiny24/44/84: 0 - 8 MHz @ 2.7 - 5.5V, 0 - 16 MHz @ 4.5 - 5.5V


----------



## Alan B (Nov 20, 2008)

JimmyM said:


> I found the ATTiny84. It's a 14 Pin DIP (Fine for experimenting) , but it also comes in a QFN20 package which is only 4 mm square overall.
> Even the 8 pin SOIC is 5.25 x 8 mm overall. So it's actually better for production designs.
> From the documentation...



That is a good chip. I have seen it before, but have not reviewed it carefully. There are many aspects to uP selection, but it is probably ok. That 4mm package might be a bit difficult to work with. Have to make sure the clocks are compatible, the low power mode, brownout, etc, etc. It probably is okay, but there might be some surprises. Costs go up a bit with the number of pins, both in buying the part and installation / testing / rework. Finer pitch parts also drive up costs a little.

Is the 8 bit pwm a problem, or the 8 bit SOIC too large?? One goal we had was to keep it very simple and low pin-count. 14 pins is a lot more than required for the application. Every pin and connection increases cost a little and reduces reliability a little. So I hesitate to add unnecessary stuff. Supporting several CPUs is possible, but will add a lot of dimensions to testing and possibly more complexity to the source code switches.

I have been looking at Xbee RF neworking. Now that would be useful. We could control the flashlight and upload new firmware using a USB wireless interface. Just kidding. Maybe. 

-- Alan


----------



## wquiles (Nov 20, 2008)

Alan B said:


> Is the 8 bit pwm a problem, or the 8 bit SOIC too large?? One goal we had was to keep it very simple and low pin-count. 14 pins is a lot more than required for the application. Every pin and connection increases cost a little and reduces reliability a little. So I hesitate to add unnecessary stuff. Supporting several CPUs is possible, but will add a lot of dimensions to testing and possibly more complexity to the source code switches.


I am with you on this. After testing this Tiny85 that we have been using, along with the latest software from you, I have to agree that the Tiny85 is "plenty" for our PhD project 

Will


----------



## JimmyM (Nov 21, 2008)

Alan B said:


> That is a good chip. I have seen it before, but have not reviewed it carefully. There are many aspects to uP selection, but it is probably ok. That 4mm package might be a bit difficult to work with. Have to make sure the clocks are compatible, the low power mode, brownout, etc, etc. It probably is okay, but there might be some surprises. Costs go up a bit with the number of pins, both in buying the part and installation / testing / rework. Finer pitch parts also drive up costs a little.
> 
> Is the 8 bit pwm a problem, or the 8 bit SOIC too large?? One goal we had was to keep it very simple and low pin-count. 14 pins is a lot more than required for the application. Every pin and connection increases cost a little and reduces reliability a little. So I hesitate to add unnecessary stuff. Supporting several CPUs is possible, but will add a lot of dimensions to testing and possibly more complexity to the source code switches.
> 
> ...


OK. I was just thinking about capability and size. I thought that a smaller chip capable of >8 bit PWM would be better. Assembly really isn't a huge problem. The SOIC8 chip is OK. I think smaller is better though. Unless we're actually using those extra pins, etc. It doesn't add any additional complexity. The Tiny84 is about $0.60 more expensive. No big deal.
I would like to see a smaller (fewer pins) interface for programming though.


----------



## JimmyM (Nov 21, 2008)

Sorry to reply to my own post, but... I will anyway.
What about a 5 pin Mini or Micro USB connector utilizing the shell as the 6th conductor? Would that work? It would make in system programming a lot more easily done for unit that is mounted in a flashlight,


----------



## Alan B (Nov 21, 2008)

JimmyM said:


> Sorry to reply to my own post, but... I will anyway.
> What about a 5 pin Mini or Micro USB connector utilizing the shell as the 6th conductor? Would that work? It would make in system programming a lot more easily done for unit that is mounted in a flashlight,



Possibly. It would have to be designed to be either actually USB programmed (possible, but more work), or at least be designed to not fry anything when someone does plug it into a real USB by mistake.

I think a smaller pitch 3m style connector might be good for starters, and perhaps the next generation might be "real" USB, so no programmer needed at all. The USB would probably be a "standard serial" interface and not require a driver. There would need to be a loader that would talk to the flashlight. This is all possible but time consuming to work out. One problem with real USB is that a crystal clock would probably be required, so a micro with lots more pins is needed, plus the crystal itself. More codespace is also required in the cpu, probably double what the flashlight requires. I think it is all do-able, but we need to walk before we fly.

For small boards and production type programming an array of pads on the board, and a special plug fixture that contacts the pads is probably the way to go. Customers would not need to program these as they would come pre-programmed. Flexibility can be provided in a one-button interface if needed. The array of pads might be the standard 3x2 sized for a small pitch 3m style connector, but the connector would not be loaded normally. A user that wanted to program it would either load the connector or get a spring-loaded connector like the manufacturing unit.

-- Alan


----------



## JimmyM (Nov 21, 2008)

Alan B said:


> Possibly. It would have to be designed to be either actually USB programmed (possible, but more work), or at least be designed to not fry anything when someone does plug it into a real USB by mistake.


Oh, yeah. That probably WOULD happen.


Alan B said:


> I think a smaller pitch 3m style connector might be good for starters, and perhaps the next generation might be "real" USB, so no programmer needed at all. The USB would probably be a "standard serial" interface and not require a driver. There would need to be a loader that would talk to the flashlight. This is all possible but time consuming to work out. One problem with real USB is that a crystal clock would probably be required, so a micro with lots more pins is needed, plus the crystal itself. More codespace is also required in the cpu, probably double what the flashlight requires. I think it is all do-able, but we need to walk before we fly.


Absolutely. Waaaay too complicated for now.


Alan B said:


> For small boards and production type programming an array of pads on the board, and a special plug fixture that contacts the pads is probably the way to go. Customers would not need to program these as they would come pre-programmed. Flexibility can be provided in a one-button interface if needed. The array of pads might be the standard 3x2 sized for a small pitch 3m style connector, but the connector would not be loaded normally. A user that wanted to program it would either load the connector or get a spring-loaded connector like the manufacturing unit.
> -- Alan


I found a 1.27mm pitch connector like the 6 pin connector on the proto boards, just half the size. Winny left some holes on his PIR that a custom plug made from a pin header would plug into for programming. That's a thought too.


----------



## JimmyM (Nov 24, 2008)

OK. I've been fiddling a bit with FP9. Things seem to work well.
One little thing. BLAST seems to have a higher RMS voltage than ramping to VHI. I'll have to make more measurements to be sure. The FET driver at 5V couldn't produce a "squarer" wave.
I started with Vbat at ~10.8V and went down to ~9.0V (3 x A123).
Variables were
VLO 6.0
VHI 7.1
VCAL 1.03
(All measurements made with a Fluke 189 in VDC(AC+DC) mode)
@ 10.82V, VLO(out)=5.81Vrms, VHI(out)=7.11
@ 9.80V, VLO(out)=5.93Vrms, VHI(out)=7.12
@ 8.85V, VLO(out)=5.96Vrms, VHI(out)=7.08

This works very nicely.
The deviation from programmed values seems negligable


----------



## Alan B (Nov 24, 2008)

JimmyM said:


> OK. I've been fiddling a bit with FP9. Things seem to work well.
> One little thing. BLAST seems to have a higher RMS voltage than ramping to VHI. I'll have to make more measurements to be sure. The FET driver at 5V couldn't produce a "squarer" wave.
> I started with Vbat at ~10.8V and went down to ~9.0V (3 x A123).
> Variables were
> ...



Nice Job :twothumbs

-- Alan


----------



## JimmyM (Nov 25, 2008)

Alan B said:


> Nice Job :twothumbs
> 
> -- Alan


No. Not me... YOU! Nice Job!!!!
I'm still deciphering what's a user variable and what's a system value/parameter is, etc. But things are becoming a little less opaque now.
So, since the PWM and regulation seems to work pretty well, are we just working on UI now? or do we have finer details to work out?
As we've talked about before, there are limits to what the user can do with this.
Maximum Vbat/Vbulb ratio of 2:1. (12V batt driving 6V bulb = 25% Duty)
That really sums it up. Once we get away from the rediculously small duty cycles, things work very well.
So, what left is there to accomplish? Is there anything we should be testing?
My next testing is going to be in the area of power. I'm going to use a couple of big bulbs and do a little testing of the FETs power handling. I have a couple of FETs I'd like to try.


----------



## wquiles (Nov 25, 2008)

Yep, nice work Alan - the software is working pretty good 

I will be building my board today and test some more on the FET area using the other FETs that I have - I still want to understand better if those "ugly" pulses are a real problem or not. I also need to do a little bit more testing on the GUI timing 

Will


----------



## JimmyM (Nov 25, 2008)

What about the automatic calibration routine? Do any of the FP programs have that feature enabled? If so, how is it invoked?


----------



## Alan B (Nov 25, 2008)

JimmyM said:


> What about the automatic calibration routine? Do any of the FP programs have that feature enabled? If so, how is it invoked?



If I recall correctly (IIRC) that was not done. There is a software calibration adjustment with two extra pushbuttons. I'm not sure about the testing status of that. Seems like I tested it some time ago but have not recently.

-- Alan


----------



## JimmyM (Nov 25, 2008)

Going back to my previous post regarding the ATTiny84...
I'm really quite interested in trying that chip. It's size is quite attractive.
It comes in a 14 Pin DIP for use in the STK500.
But, If you'd be willing to test things out a with some programming, I'll see if I can put together a 14Pin to 8Pin adapter for our Proto boards. We wouldn't need any more pins than we have now. Correct?
It's just that the smaller size of the 20QFN package will make more designs possible in the future. 16-bit PWM is just a side benefit because the 8-bit seems to work fairly well.


----------



## JimmyM (Nov 25, 2008)

Alan B said:


> If I recall correctly (IIRC) that was not done. There is a software calibration adjustment with two extra pushbuttons. I'm not sure about the testing status of that. Seems like I tested it some time ago but have not recently.
> 
> -- Alan


Yeah. I saw that, but since I don't have the extra 2 buttons connected and didn't want to start rewiring things, I thought I would leave that alone.
Basically, though, the theory is that the software would use the Vbat input value and calculate it's own VCAL value based on the ADC reading and store it in memory?
Other than for use in an internal calibration, why do we need to put in VBATT? I see you use it in the PWM ramp, I'm not quite sure why the ramp isn't just a fixed slope ramp though.


----------



## Alan B (Nov 25, 2008)

JimmyM said:


> Yeah. I saw that, but since I don't have the extra 2 buttons connected and didn't want to start rewiring things, I thought I would leave that alone.
> Basically, though, the theory is that the software would use the Vbat input value and calculate it's own VCAL value based on the ADC reading and store it in memory?
> Other than for use in an internal calibration, why do we need to put in VBATT? I see you use it in the PWM ramp, I'm not quite sure why the ramp isn't just a fixed slope ramp though.



Somehow the ADC needs to know what bit value is what voltage. So you have to either put in a fixed voltage and tell the CPU to calibrate itself, or you have to tell it to adjust its calibration while you watch something to see that it is correct. 

You could choose a fixed calibration voltage (such as 12.0 volts), and apply that along with a "calibrate jumper". Or you use two pushbuttons and adjust it till it is correct. The problem with a calibrate voltage is more folks have a voltmeter than have a fixed accurate power supply AND a voltmeter. So the voltmeter only seemed like the better way to go. We can do both, more code to write/maintain. And you still have to mess with a jumper.

We could do a single pushbutton calibration setup with a second button, or we could do a cal jumper and use the single button, but the two button setup is simpler and no jumper required.

-- Alan


----------



## JimmyM (Nov 25, 2008)

I see now. The programmatic cal is fine with me then. The 2 button arrangement just means more stuff to hang off the board. I'd rather assemble the board, apply an exact measured voltage then adjust the VCAL in software for desired output. Adjusting that one number should compensate for resistors not being exactly 100K, 47K, 10K, etc and any variances in the Vref.
That's cool.
You're pretty smuckin' fart. :thumbsup:


----------



## Alan B (Nov 25, 2008)

JimmyM said:


> ...
> Other than for use in an internal calibration, why do we need to put in VBATT? I see you use it in the PWM ramp, I'm not quite sure why the ramp isn't just a fixed slope ramp though.



VBATT is not being used for internal calibration.

The calculation to determine the PWM required for precise fast ramping is rather complicated, so I did not want to do it in the microprocessor. By providing the nominal battery voltage the C preprocessor can precalculate the PWM values needed for precise fast ramping and pass them to the micro as constants.

This could be done at runtime in the micro but would require floating point, or some careful work to get it right in fixed point. We can put floating point into the micro, but nothing else requires it, so it is not in there now.

When I was developing this the equations started out more complicated, they don't look too difficult now as I simplified them. They could be done in fixed point in the micro with a little work. Or we could go back to slower on-ramping which avoided the whole issue 

-- Alan


----------



## Alan B (Nov 25, 2008)

JimmyM said:


> I see now. The programmatic cal is fine with me then. The 2 button arrangement just means more stuff to hang off the board. I'd rather assemble the board, apply an exact measured voltage then adjust the VCAL in software for desired output. Adjusting that one number should compensate for resistors not being exactly 100K, 47K, 10K, etc and any variances in the Vref.
> ... :thumbsup:



The one cal factor takes all those items into account, it is just a conversion from counts to volts. 

The two pushbuttons would only be required during calibration, and they connect via the programming pins. So you program the chip, then cal the chip, then remove the cal cable/buttons and close it up. The cal is maintained across reprogramming (via the coefficient eemem), so loading a new software version does not lose the cal.

-- Alan


----------



## JimmyM (Nov 25, 2008)

Alan B said:


> The one cal factor takes all those items into account, it is just a conversion from counts to volts.
> 
> The two pushbuttons would only be required during calibration, and they connect via the programming pins. So you program the chip, then cal the chip, then remove the cal cable/buttons and close it up. The cal is maintained across reprogramming (via the coefficient eemem), so loading a new software version does not lose the cal.
> 
> -- Alan


Oh that's right. I forgot that the cal buttons connected at the programming header. Sweet!
That's what's nice about a bad memory. Even old news is NEW news!


----------



## wquiles (Nov 26, 2008)

Jim,

It took me a little bit to figure it out since your more flexible schematic is different than the one for the "basic" PhD board, but "IT IS ALIVE !"























For the current shunt, I am using a precision 0.01 Ohms 4-terminal shunt:











For the resistors going to the GATE, I am using removable parts so that I can experiment that works well with the new FET I am using (IRL8113 - same as in Willie Hunt's LVR):






And then, back in my office:






I will try to collect some data tomorrow 

Again, GREAT job on the board - this project now looks more professional !!!

Will


----------



## JimmyM (Nov 26, 2008)

Nicely done. I like the little sockets you used for the resistors. What are those?

Edit: ARRRGH. I should have made the Battery anb bulb connections with centers for banana jacks!!!!!!
Oh well. Rev 2 right.


----------



## Alan B (Nov 26, 2008)

JimmyM said:


> Nicely done. I like the little sockets you used for the resistors. What are those?



They appear to be machine socket pins cut from an IC socket? :twothumbs

-- Alan


----------



## JimmyM (Nov 26, 2008)

They do appear to be exatly that. Nice touch. I was thinking about the swap-ability of some of the components. But that solution didn't come to mind. Maybe I'll beuild a second board for myself.


----------



## wquiles (Nov 26, 2008)

I am using these:


----------



## Mr Happy (Nov 26, 2008)

wquiles said:


> I am using these:


...and those are (?) if we may ask?

They do look interesting. They are maybe test sockets for PCB's?


----------



## wquiles (Nov 26, 2008)

JimmyM said:


> Nicely done. I like the little sockets you used for the resistors. What are those?
> 
> Edit: ARRRGH. I should have made the Battery anb bulb connections with centers for banana jacks!!!!!!
> Oh well. Rev 2 right.



Yes, a little bit wider separation and a little larger hole for the banana connector would have been perfect. For rev 2, it would be great to have a test point on the BULB- (same as drain on the FET). Right now we only have a test point on the BULB+, which is the same as Bat+.

Will


----------



## wquiles (Nov 26, 2008)

Mr Happy said:


> ...and those are (?) if we may ask?
> 
> They do look interesting. They are maybe test sockets for PCB's?



Actually, I don't know what they are. These were among the parts I salvaged when a company close to us closed up their engineering lab.

Will


----------



## Alan B (Nov 27, 2008)

Mr Happy said:


> ...and those are (?) if we may ask?
> 
> They do look interesting. They are maybe test sockets for PCB's?



Actually they are strip sockets. We used them for ICs. They snap-off or are cut off to any length and can be mounted at any spacing in two rows for ICs. Of course they also work for SIP resistors, etc. They are quite useful and cheaper to inventory than a bunch of different sized IC sockets.

They are also used for sub PCBs to plug into a main board. Lots of uses.

-- Alan


----------



## LuxLuthor (Nov 27, 2008)

Will thanks for those close up pictures. It really helps see various setups in use.


----------



## MatajumotorS (Nov 27, 2008)

Hi, i am new for this project, i have assambled some test platform. Mostly i had programmed in Assambler, and maby did not read all posts so excuse me for some sillie or answered questions. 
I got everything working, but I am little confused about Voltage values. 
The VbulbMEAN is clear for me. But for what purpuse is VbulbRMS used? Is it good, when using RMS DC Voltmeter? 

Else problem, when the ADC voltage reach some point, output goes off, i have read about overvoltage protection, but i dont understand something..

Resistors are 100k to VDD and 10K to GND. 
Settings are:
#define VLO 12 // bulb low setting, in RMS volts
#define VHI 17.2 // bulb high setting, in RMS volts
#define VBATT 24.0 // nominal battery voltage, in volts (with value 20 - same results)

It happens like this:
@ 20V power up and jump to VHI
increase voltage, and @ 22V it jums to VLO and stays there until decrease voltage and increase the output by presiing the button.
If to try increasing the output @22V - it is like prottection decreasing it with some interval (0,5.. 1sec)


Please enlight me  :candle:

Finded answer to issue with turn off: 
As Alan B wrote: ''it turns off because the ADC is running out of range '' in my case - 2,28V


----------



## wquiles (Nov 27, 2008)

MatajumotorS said:


> Hi, i am new for this project, i have assambled some test platform. Mostly i had programmed in Assambler, and maby did not read all posts so excuse me for some sillie or answered questions.
> I got everything working, but I am little confused about Voltage values.
> The VbulbMEAN is clear for me. But for what purpuse is VbulbRMS used? Is it good, when using RMS DC Voltmeter?
> Else problem, when the ADC voltage reach some point, output goes off, i have read about overvoltage protection, but i dont understand something..
> Please enlight me  :candle:



Unlike LED's, who can react to voltage going on and off almost instantly, the filament in an incandescent light "can't" react quickly enough to the PWM voltage. So basically when the voltage goes away, the voltage in the filament starts to decrease, but it does not go to zero - when the voltage comes back ON, the voltage in the filament starts to raise, but never quite gets to Vbatt+. So although the voltage is swinging from Vbatt- (zero volts) to Vbatt+, the bulb is actually seeing an "average" voltage that to the bulb is actually fairly constant - this "average" voltage that the bulb is seing is the VbulbRMS, and it is the actual voltage that we have to control in the software control loop.

The problem is that most all RMS voltmeters can't reliable measure the PWM's square wave signal, specially since the duty cycle is not the "typical" 50% ON/OFF. Only a few voltmeters can read this signal properly (Fluke 189 being one of them), so it makes it a little bit harder to measure/verify what is the VbulbRMS voltage that the bulb is actually seeing.

Willie Hunt (now working for Surefire) was one of the original pioneers in using PWM in portable flashlights. He actually explains how to measure VbulbRMS by using a "normal" RMS voltmeter:

text provided by Willie Hunt:
**********************
THIS IS THE ROOT OF YOUR PROBLEM:

> I'm using a cheap DVM to measure voltage at the load.
> With the dummy load reading 2.85 volts, when I substituted a 6 watt 6
> volt bulb instead, the bulb burned brighly briefly, then blew out. I
> did not have a chance to read the bulb voltage... I was hooking up the
> volt meter as the bulb blew.

> Am I measuring things improperly? Why is the measured voltage
> varying so very much with variation of input voltage that SHOULD be
> within the range of the regulator circuit?

Think about what you are measuring and what your DVM does. You are
measuring a PWM rectangular waveform with a meter that gives you the
average DC voltage component. Now, think about what the bulb does.
It is averaging the power waveform, which is proportional to the DC
coupled true RMS. Even I don't have a DC coupled true RMS voltmeter,
thus I set all the regulators using the duty cycle measurement on my
Tek 2440 scope. I assumed that you would understand true RMS
concepts, and thus know how to set the duty cycle. Sorry, I often
assume too much.


Here's a bit of math:

t=end
/
DVM average = | v dt
/
t=0
t=end
/
DC coupled true RMS = square root( | v^2 dt )
/
t=0

t=end
/
Bulb power = | v * i dt
/
t=0

given that the waveform switches fast enough we can use the average
bulb resistance R because it changes so little over the cycle:

t=end
/
Bulb power = | v^2 / R dt
/
t=0

Thus

Bulb power = (DC coupled true RMS)^2 / R

That's why RMS is useful.

Let's take the 25% duty cycle at 12 volt in for example:

DVM average = 25% of 12 volts = 3 volts

True RMS = sqrt( 25% of 12^2 ) = sqrt( 0.25 * 144 ) = 6 volts

Assuming a 6 volt, 1 amp, thus 6 ohm bulb we get:

V = iR thus 12 = i * 6 so i = 2

Bulb power = 25% of v * i = 0.25 * 12 * 2 = 6 watts

notice that the peak power (v*i) is 24 watts!

Also, bulb power = RMS^2 / R = 6^2/6 = 6 watts.




Isn't math great!

So, the moral of this story is that the DVM is useless for measuring
the output directly. However, if you know that your DVM averages
correctly you can use it on the input, and the ouput and then
calculate the RMS voltage as sqrt( input * output), because you know
the shape of the waveform. This sqrt( in * out) will lose accuracy if
the voltage source sags, because the average input voltage will
measure higher than the peak bulb voltage when the bulb is on.
Alkaline batteries sags greatly, whereas NiCad's sags little, but only
a "stiff" bench lab supply will provide accurate results.

Willie

**********************


----------



## wquiles (Nov 27, 2008)

Alan B said:


> Actually they are strip sockets. We used them for ICs. They snap-off or are cut off to any length and can be mounted at any spacing in two rows for ICs. Of course they also work for SIP resistors, etc. They are quite useful and cheaper to inventory than a bunch of different sized IC sockets.
> 
> They are also used for sub PCBs to plug into a main board. Lots of uses.
> 
> -- Alan


Thanks Alan. I have used them for many years, but never knew what the heck they were called 




LuxLuthor said:


> Will thanks for those close up pictures. It really helps see various setups in use.


My pleasure - glad it helps 

Will


----------



## Alan B (Nov 27, 2008)

MatajumotorS said:


> Hi, i am new for this project, i have assambled some test platform. Mostly i had programmed in Assambler, and maby did not read all posts so excuse me for some sillie or answered questions.
> I got everything working, but I am little confused about Voltage values.
> The VbulbMEAN is clear for me. But for what purpuse is VbulbRMS used? Is it good, when using RMS DC Voltmeter?
> 
> ...



Welcome to the group. Good job on getting a prototype working!

If I remember correctly the software is set up with protection when the ADC gets near full counts to reduce to VLO to protect the bulb.

You may need to increase the 100K resistor to get more voltage range on the ADC. Try 120K, and be sure to change the value in the software as well.

-- Alan


----------



## MatajumotorS (Nov 27, 2008)

wquiles said:


> Unlike LED's, who can react to voltage going on and off almost instantly, the filament in an incandescent light "can't" react quickly enough to the PWM voltage. So basically when the voltage goes away, the voltage in the filament starts to decrease, but it does not go to zero - when the voltage comes back ON, the voltage in the filament starts to raise, but never quite gets to Vbatt+. So although the voltage is swinging from Vbatt- (zero volts) to Vbatt+, the bulb is actually seeing an "average" voltage that to the bulb is actually fairly constant - this "average" voltage that the bulb is seing is the VbulbRMS, and it is the actual voltage that we have to control in the software control loop.


 
Thanks for explanation! Now i can continue to studdy the code







Alan B said:


> Welcome to the group. Good job on getting a prototype working!
> 
> If I remember correctly the software is set up with protection when the ADC gets near full counts to reduce to VLO to protect the bulb.
> 
> ...


 
Thaks! Yes, i did find that routine in the program, i printed the whole program to read, while going home =] (1hr by train).
Still mutch to understand.


----------



## JimmyM (Dec 4, 2008)

Alan B said:


> Actually they are strip sockets. We used them for ICs. They snap-off or are cut off to any length and can be mounted at any spacing in two rows for ICs. Of course they also work for SIP resistors, etc. They are quite useful and cheaper to inventory than a bunch of different sized IC sockets.
> 
> They are also used for sub PCBs to plug into a main board. Lots of uses.
> 
> -- Alan


Thanks for the "Strip sockets" rosetta stone. I found some online from a company called Mill-Max.
I ordered some samples.
Below is a pic of them. I got some surface mount ones that can mount on end or lying down.
The gold ones are simple through hole ones that can be mounted in a small hole via its pin, or a larger hole by inserting the whole body.
The pic was taken with my new toy. a 200x, 1.3 MP USB "microscope".
It's pretty neat.




Here is a shot of the upper voltage divider resistor. I switched from a 100K to a 47K.*



*


----------



## wquiles (Dec 4, 2008)

Nice find - cool pics.

On my testing I am noticing a little variation on the button times - some times I need a shorter press, sometimes a longer press. Anyone else notice this?

Will


----------



## Alan B (Dec 4, 2008)

wquiles said:


> Nice find - cool pics.
> 
> On my testing I am noticing a little variation on the button times - some times I need a shorter press, sometimes a longer press. Anyone else notice this?
> 
> Will



So far I have not noticed this. What is the experience you are having?

I have thought that one of those USB microscopes would be useful. I do not have that yet, but I do have a new Nikon D90 DSLR with 12 megapixels and a 60mm macro lens that will do 1:1 on a 60% sensor. Can't get to 200x but can get a pretty good view of small stuff.

-- Alan


----------



## JimmyM (Dec 4, 2008)

Alan B said:


> So far I have not noticed this. What is the experience you are having?
> 
> I have thought that one of those USB microscopes would be useful. I do not have that yet, but I do have a new Nikon D90 DSLR with 12 megapixels and a 60mm macro lens that will do 1:1 on a 60% sensor. Can't get to 200x but can get a pretty good view of small stuff.
> 
> -- Alan


D90. Nice piece of kit. You see... my digital camera is a Canon A590. Just a lower end point and shoot. We mostly just take snapshots of the kids, etc. I think it does 8 MP. It doesn't have the versatility of the D90. Those pics above were taken from about 2" away. When I put the nose of it up near the board. I can easily read the text on 0603 resistors and see the texture of the solder joints. In preview mode, it shows live video at a decent resolution, but can take snapshots at 1.3 MP resolution.


----------



## wquiles (Dec 4, 2008)

Alan B said:


> So far I have not noticed this. What is the experience you are having?


It just does always react to the same press of the button - as if the timing used to measure the duration were varying a little bit. Maybe the control loop is looking for a little too brief button durations? Kind of hard to put in words since it is an ergonomic issue :sigh:




Alan B said:


> I have thought that one of those USB microscopes would be useful. I do not have that yet, but I do have a new Nikon D90 DSLR with 12 megapixels and a 60mm macro lens that will do 1:1 on a 60% sensor. Can't get to 200x but can get a pretty good view of small stuff.


Awesome setup 


Will


----------



## LuxLuthor (Dec 5, 2008)

JimmyM said:


> D90. Nice piece of kit. You see... my digital camera is a Canon A590. Just a lower end point and shoot. We mostly just take snapshots of the kids, etc. I think it does 8 MP. It doesn't have the versatility of the D90. Those pics above were taken from about 2" away. When I put the nose of it up near the board. I can easily read the text on 0603 resistors and see the texture of the solder joints. In preview mode, it shows live video at a decent resolution, but can take snapshots at 1.3 MP resolution.



Which did you get? I was looking at those Dino-Lite 1.3 mp versions like here.

Also, those ImageShack thumbs you posted above go to this page when I click on them. The thumbs seem pretty hazy/limited focus.


----------



## JimmyM (Dec 5, 2008)

LuxLuthor said:


> Which did you get? I was looking at those Dino-Lite 1.3 mp versions like here.
> 
> Also, those ImageShack thumbs you posted above go to this page when I click on them. The thumbs seem pretty hazy/limited focus.


That Dinolite one looks exactly like the one I got. But NOT for $329. MY GOD. I paid about $50 on ebay. There are 0.3MP ones (Intel Play QX3), and the 1.3MP ones (Like the Dino lite). Search eBay for item number 320321698799. It doesn't come with the measuring software though. I just put it in preview mode and it's a live video camera. Once I have what I want in focus, etc, I do a snapshot of it using an onscreen menu. The video resolution is OK. but the snapshots can be just about any resolution you want.

Those images were loading just fine last night. I wonder what happened.


----------



## Bimmerboy (Dec 5, 2008)

Alan B said:


> they are strip sockets. We used them for ICs.
> 
> ...
> 
> Lots of uses.


Great little things. I use 'em to connect drivers to laser diodes instead of soldering onto the legs.



JimmyM said:


> a company called Mill-Max.


High quality stuff. Almost contacted them a ways back for a sample strip of their SIP sockets, but happened to find what was said to be an equal quality product (Samtek) at a local warehouse first. I only wanted non-ROHS, so both companies get a :thumbsup: in my book.


----------



## wquiles (Dec 7, 2008)

Alan,

I want to play a little with a second input button - was was again the left over pin (pins) that I could use?

I set them up using the PORTB and DDRB statements, right?

Will


----------



## Alan B (Dec 8, 2008)

wquiles said:


> Alan,
> 
> I want to play a little with a second input button - was was again the left over pin (pins) that I could use?
> 
> ...



The VARICAL calibrate up and down use the extra pins, so you can use the same code (just don't enable the VARICAL calibration at the same time). Some of the ISP pins are re-used (I think that is on one of the schematics I put on the web).

I need to finish the hotwire regulator mounting setup and get this installed in my D mag. But this weekend I was too busy making 16 antenna launchers, so nothing much else was worked on...

What are your plans for the extra pins?

-- Alan


----------



## wquiles (Dec 8, 2008)

Alan B said:


> The VARICAL calibrate up and down use the extra pins, so you can use the same code (just don't enable the VARICAL calibration at the same time). Some of the ISP pins are re-used (I think that is on one of the schematics I put on the web).
> 
> I need to finish the hotwire regulator mounting setup and get this installed in my D mag. But this weekend I was too busy making 16 antenna launchers, so nothing much else was worked on...
> 
> ...



Alan,

Thanks much - this will help with the extra input pin. I have not yet tested that portion of the code, but I will look at the code this week.

What if I want to use one of those extra pins as an output instead (like to drive a small LED for status/mode/etc.? Can I use the second extra pin for an output? Same register, just change direction and initialize to high/low accordingly?

I am still working out the details in my head, but I am still thinking about how to leverage this work for my "pet project", the SF M6, and I am thinking on a way to do bulb selection and status by using this extra input and output pin.

Will


----------



## Alan B (Dec 9, 2008)

wquiles said:


> Alan,
> 
> Thanks much - this will help with the extra input pin. I have not yet tested that portion of the code, but I will look at the code this week.
> 
> ...



Yes, you can configure and use a pin as output. That's why we like these micros, they are very flexible.

-- Alan


----------



## wquiles (Dec 12, 2008)

Now that I have been looking at the code for the extra button and perhaps an LED status signal, I think that this might be a good time to start a new thread for the PhD-M6 variant - I want to see what owners of the M6 feel about different possible battery/bulb combos. 

Please feel free to continue collaboration on both threads as many things can be shared 

Will


----------



## Alan B (Dec 16, 2008)

wquiles said:


> Now that I have been looking at the code for the extra button and perhaps an LED status signal, I think that this might be a good time to start a new thread for the PhD-M6 variant - I want to see what owners of the M6 feel about different possible battery/bulb combos.
> 
> Please feel free to continue collaboration on both threads as many things can be shared
> 
> Will



Sounds good! Might put a link to the new thread here.

-- Alan


----------



## JimmyM (Dec 16, 2008)

I think I'd like to try the same thing, except with the Mag D body.
I'll start a thread and post a link here.
Alan, maybe you could edit the first post in this thread to include a "derivative work" section.
Does that sound good?

EDIT: Feeler/development thread can be found HERE


----------



## wquiles (Dec 16, 2008)

Yep, awesome idea Jim - in fact I still feel that there are vastly more folks interested in a Mag-specific solution than on a SF-M6 solution, so there should be plenty of interest 

Will


----------



## wquiles (Dec 16, 2008)

Alan,

I was testing some more today, and came up with a quick question for you. The algorithm assumes that there is a bulb always connected to the circuit, and that when the FET turns ON/OFF this creates an RMS voltage at the bulb based on the duty cycle. But what happens if during the regulation process the bulb dies (which is typically an open circuit)? Like for example the flashlight is dropped and the bulb brakes?

My guess from looking at the code, is that nothing would change, so I went ahead and tried, by just removing the bulb, and sure enough nothing changed - the PhD keep working like nothing happened.

Given this, I think it would be good to have an automatic bulb detector in place to basically stop the PWM in recognition that there is no bulb in there. Perhaps the way to detect this could be to compare the Vbat loaded to the Vbat unloaded. Specifically, under normal operating conditions, a true battery will always "dip" some amount during the ON cycle (compared to the resting voltage during the OFF cycle), so if the Vbat unloaded = Vbat loaded, we probably have an error condition, blown bulb, etc.. Of course given that we have finite steps in the PWM and in the ADC, we probably can't make just an "absolute" comparison, but perhaps look at the error being "too small" as an indication that the bulb is not there of simply blown.

What do you think? Any other ideas you might have to do bulb detection?

Will


----------



## JimmyM (Dec 17, 2008)

wquiles said:


> Alan,
> 
> I was testing some more today, and came up with a quick question for you. The algorithm assumes that there is a bulb always connected to the circuit, and that when the FET turns ON/OFF this creates an RMS voltage at the bulb based on the duty cycle. But what happens if during the regulation process the bulb dies (which is typically an open circuit)? Like for example the flashlight is dropped and the bulb brakes?
> 
> ...


It's funny you mention a blown bulb. That happened to me tonight. I popped a 64458 (19.9 VRMS on a 25V source). The scope showed no difference. In fact it would have auto corrected itself for the now non-sagging voltage. FP7 doesn't have a PWM syncronized ADC reading. The PWM waveform was essiantially unchanged.

Is it a problem if the PhD just goes on it's merry way regulating things as if a bulb were there?


----------



## Alan B (Dec 17, 2008)

wquiles said:


> Alan,
> 
> I was testing some more today, and came up with a quick question for you. The algorithm assumes that there is a bulb always connected to the circuit, and that when the FET turns ON/OFF this creates an RMS voltage at the bulb based on the duty cycle. But what happens if during the regulation process the bulb dies (which is typically an open circuit)? Like for example the flashlight is dropped and the bulb brakes?
> 
> ...



Reliably detecting a blown bulb might be difficult. Stiff batteries or low power bulbs will not give much to detect. 

I suppose the reason you might want to do that is to shut off and preserve the batteries instead of consuming some power generating the waveform and keeping the CPU awake. Another way might be to add an "on" timeout, but that could be undesirable in other ways. 

-- Alan


----------



## LuxLuthor (Dec 17, 2008)

I had another question that is somewhat related to this subject. 

When I was taking measurements of AW's D Driver without bulb on low/medium/high with my Fluke 179 that does true RMS, I was wondering why I got *the readings highlighted in Dark Red* *in this post*.


----------



## Alan B (Dec 17, 2008)

LuxLuthor said:


> I had another question that is somewhat related to this subject.
> 
> When I was taking measurements of AW's D Driver without bulb on low/medium/high with my Fluke 179 that does true RMS, I was wondering why I got *the readings highlighted in Dark Red* *in this post*.



I documented the formulas in the sourcecode comments, so it is easier to find them there than in the long discussions:

VbulbRMS = VbattDC * sqrt(Duty_cycle)

I didn't check this against your values, but if you first subtract the voltage lost due to the resistance, and use the remaining voltage as VbattDC in the equation, and assuming that the AW figures are for percent duty cycle, convert them to fractional duty cycle (so 30% is 0.30) and then apply the square root and multiply, this should produce something that tracks with your measured VbulbRMS.

Let us know how close it comes out. 

As far as the question (later in the thread) about fitting the parts into a flashlight, my circuit board is already small enough, and Jim's will be smaller, so that is no problem. The real challenge is making access to the circuit to program it, or adjust it.

-- Alan


----------



## LuxLuthor (Dec 17, 2008)

Alan, I was wondering about the results I got in dark red (without bulb) for AW's Low/Medium/High which he says is 30/60/100%...in particular the Medium setting.

Battery pack external to light measures *12.42V*

Then when pack inside light, readings in empty bipin slots measure: *12.35V / 12.44V / 12.42V* on its *Low/Med/High *settings

The 60% 12.44V is higher than 12.42V battery pack removed from light, without a bulb and closed circuit, I just found this curious. It is reproduceable.


----------



## Alan B (Dec 17, 2008)

LuxLuthor said:


> Alan, I was wondering about the results I got in dark red (without bulb) for AW's Low/Medium/High which he says is 30/60/100%...in particular the Medium setting.
> 
> Battery pack external to light measures *12.42V*
> 
> ...



That is curious. The unloaded voltage is distributed across the meter and the FET, The meter is such a high impedance that the FET leakage causes Vbatt to come through for the most part. Then the capacitance of the meter and leads vs the FET will divide the AC part. The medium setting has the greatest AC component , so perhaps the meter is responding to that.

To get meaningful numbers put a resistor across the meter. 1K ohms will probably do it.

-- Alan


----------



## JimmyM (Dec 17, 2008)

Alan B said:


> That is curious. The unloaded voltage is distributed across the meter and the FET, The meter is such a high impedance that the FET leakage causes Vbatt to come through for the most part. Then the capacitance of the meter and leads vs the FET will divide the AC part. The medium setting has the greatest AC component , so perhaps the meter is responding to that.
> 
> To get meaningful numbers put a resistor across the meter. 1K ohms will probably do it.
> 
> -- Alan



Remember the FET has capacitance. If there is no bulb to drain that by pulling the voltage up while the FET is OFF, the voltage stays low (We use low-side switching). I've seen it in my own designs.
The wave form I was monitoring when my bulb blew was the gate voltage, not bulb voltage. I'm sure I would have experienced the same thing had I been monitoring bulb voltage.


----------



## wquiles (Dec 17, 2008)

Alan B said:


> Reliably detecting a blown bulb might be difficult. Stiff batteries or low power bulbs will not give much to detect.
> 
> I suppose the reason you might want to do that is to shut off and preserve the batteries instead of consuming some power generating the waveform and keeping the CPU awake. Another way might be to add an "on" timeout, but that could be undesirable in other ways.
> 
> -- Alan



Good point - what to do with lower power bulbs. We don't want to exclude them altogether.

OK, I think I just came up with another possible method - hear me out:
- We monitor the voltage at the Drain pin of the FET.
- Turn OFF the FET, and measure this voltage through the ADC (say with a large series resistor so that we can't load the ADC input).
- If the voltage of the Drain is not a solid Vbatt, then there must be no bulb, as only through the bulb would the Drain's voltage raise to Vbatt. In other words, with no bulb, the Drain of the FET can't get to Vbatt since there is no electrical connection to Vbatt (normally a healthy bulb).

What do you think?

Will


----------



## Alan B (Dec 17, 2008)

wquiles said:


> Good point - what to do with lower power bulbs. We don't want to exclude them altogether.
> 
> OK, I think I just came up with another possible method - hear me out:
> - We monitor the voltage at the Drain pin of the FET.
> ...



Interesting idea. That should work if there is no pullup resistor. Floating the FET drain might allow a voltage that is not good for the FET, so putting a pullup across the bulb is good to protect the FET and will make this idea not work. Some of my schematics show this pullup, some do not.

Is it worth doing? A timer would be easier and require no parts. I didn't check, do we have another ADC pin available at this point?? This use is probably not compatible with the ISP pins, and those are the only ones available.

One solution is to take the batteries out if the bulb is blown. How often is this an issue?

Another is to put a run limit timer in. That would be easy, about 4 lines of code. Turn off after an hour? The blown bulb on-drain is quite low, so an hour would not consume much battery power, and then it would go off. Set the timer for even several hours. What is the max runtime that makes sense? This also protects against leaving the light set very dim for a long time. What is the max time one would want the light to be on in 'dim' mode? The timeout could even be related to the brightness level, but this gets a bit more complicated.

-- Alan


----------



## wquiles (Dec 17, 2008)

Alan B said:


> Interesting idea. That should work if there is no pullup resistor. Floating the FET drain might allow a voltage that is not good for the FET, so putting a pullup across the bulb is good to protect the FET and will make this idea not work. Some of my schematics show this pullup, some do not.
> 
> Is it worth doing? A timer would be easier and require no parts. I didn't check, do we have another ADC pin available at this point?? This use is probably not compatible with the ISP pins, and those are the only ones available.
> 
> ...



This might not be an issue in the originally intended Mag host, but I think we might need something like this for the PhD-M6 project. 

For the M6, there is no separate battery vs. the driver - it is all a single unit/module that gets removed from the body, and there is no separate switch either. The battery inside the unit/module is not even exposed, as only the two bulb contacts are available externally, one always connected to one side of the bulb, and the other contact is connected to the other side of the bulb through the body and tailcap (when the tailcap is finally closed). 

What this means is that for the M6, since the bulb is always connected to the body and one side of the battery "module", the tailcap can't be used like a switch - the tailcap simply closes the electrical circuit to the bulb while the battery is always connected to the driver. 

If there is no automatic bulb detection circuit (to sense that the tailcap has been closed), there is no way to implement a soft start either as the driver is already running. This is one of the many reasons I will be making several, substantial changes to the software/firmware - the M6 is truly a different animal :naughty:

Willie Hunt implemented this "automatic bulb detection", and his LVR works exactly as I described here above in the M6 (as part of Jim's M6-R pack), so somehow his LVR "knows" that the bulb is now connected, and it knows to only start the soft start at this point. By looking at the LVR schematic, it looks like Willie seems to have implemented something similar - so maybe I am not that much off the path to a workable solution. 

Or maybe the solution will be wiring the PhD-M6 differently than the M6-R. Maybe we don't need a full ADC input to know - I just have to experiment some more over the holidays to see what works and what does not. Either way I have 100% confidence we can make it work 

Please let me know what you think 

Will


----------



## JimmyM (Dec 17, 2008)

WOW. And you guys accuse me of complicating things by adding an FET driver! 
Personally, I don't see much of a need for this. It would be easier to add a little led somewhere connected to the PWM output of the Tiny85. That would indicate if the output is running. No changes to programming or anything else really.
If you want additional inputs/outputs, go with the Tiny84. I've mentioned this before, but I'll pitch it again. for any designs that will actually be made in any numbers, the size of the QFN20 chip is a plus.


----------



## JimmyM (Dec 17, 2008)

wquiles said:


> For the M6, there is no separate battery vs. the driver - it is all a single unit/module that gets removed from the body, and there is no separate switch either. The battery inside the unit/module is not even exposed, as only the two bulb contacts are available externally, one always connected to one side of the bulb, and the other contact is connected to the other side of the bulb through the body and tailcap (when the tailcap is finally closed).
> Will


How do you turn it on and off. Is there a switch in the tailcap?


----------



## Alan B (Dec 17, 2008)

OK. The constraints are changing. 

Rather than making apparently random suggestions for design changes, it would be more efficient to outline the requirements for the new design and consider alternatives in a larger perspective.

If the regulator is to be embedded in the battery pack, are there only two external terminals, or are there three? If we are in a tailswitch type setup the third terminal could pick up the intersection of the lamp and the tailswitch by contacting the inside of the body. There are designs that can work either way.

-- Alan


----------



## wquiles (Dec 17, 2008)

JimmyM said:


> How do you turn it on and off. Is there a switch in the tailcap?



The tailcap "is" the switch - it just connects one end of the battery to the body to close the circuit. In a Mag, this connection is always present 

Will


----------



## JimmyM (Dec 17, 2008)

So you tighten the tailcap to turn it on. Correct?
I think these M6 specific issues should be further discussed in Will's M6 thread. We'll be able to focus on things there without deviating too much from this thread's design discussion.


----------



## wquiles (Dec 17, 2008)

Alan B said:


> OK. The constraints are changing.
> 
> Rather than making apparently random suggestions for design changes, it would be more efficient to outline the requirements for the new design and consider alternatives in a larger perspective.
> 
> ...



Alan,

My apologies if these seemed like random questions. I always had the M6 as my goal from day one, so I am always thinking about it - I should had been more clear when I started the question above regarding how to do bulb detection. 

I will stop asking questions here in your thread, to keep it more focused to the Mag host. Sorry about that 

Will


----------



## wquiles (Dec 17, 2008)

JimmyM said:


> So you tighten the tailcap to turn it on. Correct?
> I think these M6 specific issues should be further discussed in Will's M6 thread. We'll be able to focus on things there without deviating too much from this thread's design discussion.



Yes - tighten the tailcap to turn it on, and one side of the bulb is always in contact with the body.

And yes, agreed on keeping M6-related/specific questions outside this thread. Sorry about all of the confusion I created 

Will


----------



## JimmyM (Dec 17, 2008)

wquiles said:


> Alan,
> 
> My apologies if these seemed like random questions. I always had the M6 as my goal from day one, so I am always thinking about it - I should had been more clear when I started the question above regarding how to do bulb detection.
> 
> ...


Sorry, Will. I meant that this thread is for the general discussion and design of the base project itself. I started a thread to discuss a Mag based variant. I'd like to, if I could keep very specific designs out of this thread because your M6 stuff and my Mag stuff will be too scattered amongst the general PhD discussion that pertains to all designs based on this project. A separate M6 thread would be more focused. I dunno. Does that make sense? Or am I just nuts.


----------



## wquiles (Dec 17, 2008)

JimmyM said:


> Sorry, Will. I meant that this thread is for the general discussion and design of the base project itself. I started a thread to discuss a Mag based variant. I'd like to, if I could keep very specific designs out of this thread because your M6 stuff and my Mag stuff will be too scattered amongst the general PhD discussion that pertains to all designs based on this project. A separate M6 thread would be more focused. I dunno. Does that make sense? Or am I just nuts.



No worries dude, and yes, it makes perfect sense. I already have the PhD-M6 thread going, to I will ask these questions in that thread instead. Hopefully you and Alan will check that thread now and then and chip in with ideas/suggestions/etc.. The goal of course is to leverage as much as possible the various projects where it makes sense 

Will


----------



## Alan B (Dec 17, 2008)

Will, no need to apologize. We can discuss anything in this thread pertaining to the regulator that we choose to. I get the feeling that the depth of these discussions drives away some folks, so perhaps the deep technical stuff should stay in this thread, and the more user-oriented details should go in the other threads. That will necessarily complicate this thread some, if that is even possible. But it will keep folks interested in the other threads without getting lost in the tech, unless they want it, and then it would be here. As long as we reference what situation we are talking about it should not be too confusing. We could use the subtitle to differentiate subtopics.

Will, you didn't answer my question regarding the configuration - ie can the pack pick up the body of the light, a tap between the bulb and the switch, or is it going to have to detect current? A contact to the body would help a lot, but it must have non-anodized material to sample voltage. Then it could tell between on and off, and blown bulbs.

-- Alan


----------



## wquiles (Dec 17, 2008)

Alan B said:


> Will, no need to apologize. We can discuss anything in this thread pertaining to the regulator that we choose to. I get the feeling that the depth of these discussions drives away some folks, so perhaps the deep technical stuff should stay in this thread, and the more user-oriented details should go in the other threads. That will necessarily complicate this thread some, if that is even possible. But it will keep folks interested in the other threads without getting lost in the tech, unless they want it, and then it would be here. As long as we reference what situation we are talking about it should not be too confusing. We could use the subtitle to differentiate subtopics.
> 
> Will, you didn't answer my question regarding the configuration - ie can the pack pick up the body of the light, a tap between the bulb and the switch, or is it going to have to detect current? A contact to the body would help a lot, but it must have non-anodized material to sample voltage. Then it could tell between on and off, and blown bulbs.
> 
> -- Alan



OK, thanks Alan.

In the M6, at least on factory/OEM form, there is no middle/body contact. One side of the bulb is constantly touching the body (lets call it side A), and the other side of the bulb (side B) touches the battery pack if/when inserted into the body. The battery pack contacts one side of the bulb (side B), and the other end of the battery pack touches the inside of the tailcap. Then you tighten the tailcap, the circuit is then closed, and current then flows form the tailcap to the body, and through the body back to side A of the bulb. Once very nice thing about this, being that bulbs have no "+" or "-" is that you can insert the battery pack either way - it is symmetrical. 

Now, on the HDM6, AWR implemented a wire connection to the middle of the body. I have two of these early packs, and I have had some problems with that wire loosing contact with frequent removal of the pack, and sometimes the light would not work until I re-bend the contact out some - definitely a weak point reliability-wise, so I am trying to stay away from any solution that requires this extra contact if at all possible.

Will


----------



## Alan B (Dec 17, 2008)

wquiles said:


> OK, thanks Alan.
> 
> In the M6, at least on factory/OEM form, there is no middle/body contact. One side of the bulb is constantly touching the body (lets call it side A), and the other side of the bulb (side B) touches the battery pack if/when inserted into the body. The battery pack contacts one side of the bulb (side B), and the other end of the battery pack touches the inside of the tailcap. Then you tighten the tailcap, the circuit is then closed, and current then flows form the tailcap to the body, and through the body back to side A of the bulb. Once very nice thing about this, being that bulbs have no "+" or "-" is that you can insert the battery pack either way - it is symmetrical.
> 
> ...



Okay. That is reasonable. I have a sketch of a circuit that addresses this, have to go now but we can discuss it later.

-- Alan


----------



## JimmyM (Dec 17, 2008)

I've just been doing some testing with a 64623 bulb.
Conditions are FP7, 15.6V source, and 14V setpoint.
The ADC is not synced with the PWM so I'd like to see about adding ADC Sync to FP6 and 7.
Any way.
I was measuring the gate (red) and ADC input (yellow)in my scope. Below are the results.





Really noisy ADC


----------



## JimmyM (Dec 17, 2008)

Alan,
How can I add ADC Sync to the FP7 and FP6 routines?
I may have figured it out.
I took this section from FP8
----if (pwm > 0 && pwm < 255) // sync to PWM cycle
{
while (PINB & _BV(PB3)) /**/; // wait for PWM off
while (!(PINB & _BV(PB3))) /**/; // wait for PWM on
}

ADCSRA |= _BV(ADSC); // start conversion Vbatt
while (ADCSRA & _BV(ADSC)) /**/; // wait till done
adc = ADCH; // read result

// get last ADC reading at end of PWM cycle

while (pwm > 0 && pwm < 255 && PINB & _BV(PB3)) // while PWM cycle is on
{
adc = ADCH; // store previous ADC result

ADCSRA |= _BV(ADSC); // start conversion Vbatt
while (ADCSRA & _BV(ADSC)) /**/; // wait till done
}
----
and copied it into FP7 in place of this code...
----
ADCSRA |= _BV(ADSC); // start conversion battery V
while (ADCSRA & _BV(ADSC)) /**/; // wait till done
adc = ADCH;
----


----------



## Alan B (Dec 17, 2008)

JimmyM said:


> Alan,
> How can I add ADC Sync to the FP7 and FP6 routines?
> I may have figured it out.
> I took this section from FP8
> ...



Well, does it work?

-- Alan


----------



## Alan B (Dec 17, 2008)

Another question is where to sync the ADC, one can make arguments that any one spot is wrong, so having it random causes an 'averaging' that might be argued to be good.

Is there a reason that unsynced ADC is causing a problem?

-- Alan


----------



## donn_ (Dec 17, 2008)

> But it will keep folks interested in the other threads without getting lost in the tech, _*unless they want it*_, and then it would be here.



Some of us want it! I'm using it as a learning guide. The downside is I end up spending a lot of time in Google, researching the stuff you guys take for granted. The upside is I'm learning a little bit every day.

Keep up the good work!


----------



## Alan B (Dec 17, 2008)

donn_ said:


> Some of us want it! I'm using it as a learning guide. The downside is I end up spending a lot of time in Google, researching the stuff you guys take for granted. The upside is I'm learning a little bit every day.
> 
> Keep up the good work!



Hi, donn_. Glad to hear you are finding it useful. It has been a learning exercise for all of us, and focused us on a specific useful bit of technology that should benefit a lot of folks going forward. 

Sorry about the time it takes. Quite a bit of time for all of us. Probably a better investment than watching TV.

Besides, I wanted a couple of regulators for myself, anyway 

-- Alan


----------



## donn_ (Dec 17, 2008)

Alan B said:


> Hi, donn_. Glad to hear you are finding it useful. It has been a learning exercise for all of us, and focused us on a specific useful bit of technology that should benefit a lot of folks going forward.
> 
> Sorry about the time it takes. Quite a bit of time for all of us. Probably a better investment than watching TV.
> 
> ...



Please..don't worry about the time. It's winter here, and I'm a gardener. I have way too much time on my hands, and there's rarely anything as interesting on TV. I can spend my day listening to right-wing talk radio and reading about FETs and such.

Imagine my surprise to learn they have nothing to do with cheese!


----------



## JimmyM (Dec 17, 2008)

Alan B said:


> Well, does it work?
> 
> -- Alan


It compiles and loads just fine. And the regulator operates as it did before. I'm not sure how differently it should act. The voltage doesn't really sag all that much. But it at least works.


----------



## Alan B (Dec 17, 2008)

JimmyM said:


> It compiles and loads just fine. And the regulator operates as it did before. I'm not sure how differently it should act. The voltage doesn't really sag all that much. But it at least works.



Good. Sampling the voltage at the start of the PWM cycle gives too high a reading, and sampling at the end gives a low reading, the correct answer is in between. Sampling randomly produces an "average" that might be nearer the truth, but it is not perfect. If the battery impedance is low it doesn't matter much at all.

-- Alan


----------



## wquiles (Dec 17, 2008)

Alan B said:


> Good. Sampling the voltage at the start of the PWM cycle gives too high a reading, and sampling at the end gives a low reading, the correct answer is in between. Sampling randomly produces an "average" that might be nearer the truth, but it is not perfect. If the battery impedance is low it doesn't matter much at all.
> 
> -- Alan



From the scope samples I took earlier, I agree. Somewhere in the "middle" of the ON cycle would be best - that being said, the ON pulse varies in width (narrower first, then becoming wider near the end of the battery life), so in the middle is actually a variable point in time 

I think that if we start from the narowest pulse that we will see, and then pick the middle of that pulse to use the ADC, regardless of later pulses that will be longer, at least will give us a consistent and predictable place to know when the actual ADC sampling takes place.

Just an idea ...

Will


----------



## JimmyM (Dec 18, 2008)

Well. We know the PWM value, we know the frequency.
Follow my math and please check it for me.
254Hz ~= 0.003937 (1 / 254)
if you split that into 255 sections
you get 1.5439e-5 seconds. 
if you multiply that number times the PWM value you get the pulse duration.
Divide that by 2 and you get the middle of the pulse.
So PWM*7.7196e-6 = ADC read delay.
Right?


----------



## JimmyM (Dec 18, 2008)

Alan,
You mentioned a "voltage request" pot idea. That's starting to make a lot more sense as I think about it. Is there an available pin on the Tiny85 that could monitor a pot that went from VCC of uC to GND and the wiper was connected to an ADC input? A pair of "scale" values could be programmed, say 6 and 30. The uC would read the ADC of the request pot and scale it's 0-Vcc input from 6 to 30 output volts. This "scaled" value would take the place of VBULB.
Does that sound reasonable? Can we use Vcc as the Vref for the second ADC? That way the pot value would always be between 0 and Vref.
SCALELO = 6.0
SCALEHI = 30.0
MAXADC = 5.0
MINADC = 0.0

VBULB=SCALELO + (((SCALEHI - SCALELO)/(MAXADC-MINADC))*ADCReadValue)

This would require more programming than hardware. Hardware would consist of 1 pot. The programming would be up to you.
You can do it. I KNOW you can. This would be the "holy grail" of simple field programmability without the risk of overloading the ADC for the battery voltage.


----------



## wquiles (Dec 18, 2008)

JimmyM said:


> Alan,
> You mentioned a "voltage request" pot idea. That's starting to make a lot more sense as I think about it. Is there an available pin on the Tiny85 that could monitor a pot that went from VCC of uC to GND and the wiper was connected to an ADC input? A pair of "scale" values could be programmed, say 6 and 30. The uC would read the ADC of the request pot and scale it's 0-Vcc input from 6 to 30 output volts. This "scaled" value would take the place of VBULB.
> Does that sound reasonable? Can we use Vcc as the Vref for the second ADC? That way the pot value would always be between 0 and Vref.
> SCALELO = 6.0
> ...



Reasonable? I think it is freaking brilliant - use a linear input, like a volume control to set the Vbulb - sounds great!. The only challenge would be that you would need a second ADC port for the POT (since the Tiny85's would be used to monitor the battery and provide regulation). 

Another possible way to do this without a second ADC would be to have a switch that would connect the pot to the ADC input (again, assuming there is only one ADC available) during a "setup" stage, and then you switch it back to the "normal" position. Or perhaps we could use one of the two pins left and internally route that signal to the ADC? I though I read something like that in the documentation - or maybe I am on drugs? 

Will


----------



## Alan B (Dec 18, 2008)

wquiles said:


> Reasonable? I think it is freaking brilliant - use a linear input, like a volume control to set the Vbulb - sounds great!. The only challenge would be that you would need a second ADC port for the POT (since the Tiny85's would be used to monitor the battery and provide regulation).
> 
> ...
> 
> Will



I wouldn't go so far as to call it "brilliant", but it is a possible interface option. There are four ADC channels in the Tiny85, and to answer Jim's question, it can be scaled to Vcc, so that makes it really simple to wire up. The question is what else those 3 ADC pins are being used for, and the power consumption of this pot. I didn't check to see where those pins are, but if any of them are on the ISP pins and we make the impedance high enough to not interfere with ISP use then they could just stay there. That probably means a pot with a series resistor on the wiper to guarantee minimum impedance is high enough to not bother the ISP. Another possibility is to always set the pot to midrange during ISP programming and forget the wiper resistor.

Somebody take a look at the Tiny data sheet and see where the other three ADC inputs are, and lets review the pins for best choice.

This still leaves other coefficients in the code, just the one parameter will be done via the pot... Maybe more.. Hmmm.. Never mind... Just the one parameter for now..

Jim, you can write code, too! This will be a copy of code that is already there, not hard to do.

On the ADC timing, I didn't check the math but that is the right idea. That is still pretty early in the ADC cycle, but you can do it. Just detect the start and then do a small delay and then read the ADC.

-- Alan


----------



## Alan B (Dec 18, 2008)

JimmyM said:


> Alan,
> You mentioned a "voltage request" pot idea. That's starting to make a lot more sense as I think about it. Is there an available pin on the Tiny85 that could monitor a pot that went from VCC of uC to GND and the wiper was connected to an ADC input? A pair of "scale" values could be programmed, say 6 and 30. The uC would read the ADC of the request pot and scale it's 0-Vcc input from 6 to 30 output volts. This "scaled" value would take the place of VBULB.
> Does that sound reasonable? Can we use Vcc as the Vref for the second ADC? That way the pot value would always be between 0 and Vref.
> SCALELO = 6.0
> ...



Jim, this is the hard way to do it. Remember, the micro code works in ADC and PWM counts, not volts. So there is no sense of volts. This makes it easier since the pot will also be in ADC counts, so it is already in the units needed. The voltage goal needs to be in ADC counts. So there is little if any conversion needed. This does not set a minimum value and rescale, but that is probably not required, and could be done if desired. But in some sense there is no need since all that can be controlled to is one ADC count, so the resolution of the pot is the same already without scaling. Hope that makes sense...

Another thing that might make sense here is to only read the voltage adjust pot when a jumper on an ISP pin is detected, and then write the value to the eememory. Then a noisy pot would not matter, once the adjustment was made the pot would be superfluous. So the jumper would lock it in against accidental changes, but be easy to re-do when desired.

-- Alan


----------



## JimmyM (Dec 18, 2008)

Alan B said:


> I wouldn't go so far as to call it "brilliant",


Thanks for keeping me humble.



Alan B said:


> There are four ADC channels in the Tiny85, and to answer Jim's question, it can be scaled to Vcc, so that makes it really simple to wire up. The question is what else those 3 ADC pins are being used for, and the power consumption of this pot. I didn't check to see where those pins are, but if any of them are on the ISP pins and we make the impedance high enough to not interfere with ISP use then they could just stay there. That probably means a pot with a series resistor on the wiper to guarantee minimum impedance is high enough to not bother the ISP. Another possibility is to always set the pot to midrange during ISP programming and forget the wiper resistor.
> 
> Somebody take a look at the Tiny data sheet and see where the other three ADC inputs are, and lets review the pins for best choice.


ADC0 = is our RESET pin for programming. If we pull this low, wouldn't it cause the uC to RESET?
ADC1 = SCK pin for programming. This might do. a 1M pot with a 100K wiper resistor?
ADC2 = Is our battery voltage ADC
ADC3 = OC1B pin, our PWM output.




Alan B said:


> This still leaves other coefficients in the code, just the one parameter will be done via the pot... Maybe more.. Hmmm.. Never mind... Just the one parameter for now..
> 
> Jim, you can write code, too! This will be a copy of code that is already there, not hard to do.



I'll give it a shot. I need to get a good book or 2, but I'll give it a shot.



Alan B said:


> On the ADC timing, I didn't check the math but that is the right idea. That is still pretty early in the ADC cycle, but you can do it. Just detect the start and then do a small delay and then read the ADC.
> 
> -- Alan


I'll see what I can come up with. This will be my first foray into AVR programming.


----------



## JimmyM (Dec 18, 2008)

Alan B said:


> Jim, this is the hard way to do it. Remember, the micro code works in ADC and PWM counts, not volts. So there is no sense of volts. This makes it easier since the pot will also be in ADC counts, so it is already in the units needed. The voltage goal needs to be in ADC counts. So there is little if any conversion needed. This does not set a minimum value and rescale, but that is probably not required, and could be done if desired. But in some sense there is no need since all that can be controlled to is one ADC count, so the resolution of the pot is the same already without scaling. Hope that makes sense...
> 
> Another thing that might make sense here is to only read the voltage adjust pot when a jumper on an ISP pin is detected, and then write the value to the eememory. Then a noisy pot would not matter, once the adjustment was made the pot would be superfluous. So the jumper would lock it in against accidental changes, but be easy to re-do when desired.
> 
> -- Alan


I kind of understand. The VBULB is set in programming code to a voltage value, but you convert it to ADC counts in code. The same would be done here I imagine. I'm guessing that the "ADC counts" means that it is the 10-bit number assigned to a voltage at the ADC compared to Vref(2.56V in our Vbatt ADC's case).

If the pot were read only when a jumper was set, then the voltage could not be adjusted during operation. This would be desirable to let the user turn it on, then adjust the pot for desired voltage. The same rules apply to any other pot, noise is bad, design for less noise.

I think I'm going to get a Tiny84 and try my hand at converting the code to work on that chip. It's smaller and allows for more I/O pins. I hope you don't mind me asking for some help with the code. It's pretty much your fault that I like AVRs now. You reap what you sow.


----------



## JimmyM (Dec 20, 2008)

Alan,
I've been at work trying to port your Tiny85 code to the Tiny84. Some of it seems straight forward.
I'm going to use PB1 instead of PB2 for the Pushbutton.
I'll be using PA5/OC1B instead of PB2/OC1B for the PWM output.
The Timer 1 on the Tiny84 can do 16 bit PWM.
There is no longer a "PWM" it's now called WGM (Waveform Generation Mode)
Also, there is no GTCCR register, just TCCR0A/B and TCCR1A/B.
Until I get a book or something, I'm pretty lost.
I've pared down your original code to just contain the code for FP7.

My pin "usage" if the Tiny84.
PB3 = RESET (programming header)
PA6 = MOSI (programming header)
PA5 = MISO (programming header) and PWM output
PA4 = USCK (programming header) and Pushbutton
PA3 = ADC3 "request voltage" pot wiper
PA2 = ADC2 battery voltage divider

Would you mind too much having a look at it when you get a chance?
I can email it to you.


----------



## Alan B (Dec 20, 2008)

You can email it. Make sure the pin assignemtns, etc are all documente in the sourcecode. Also put questions into the sourcecode that you are trying to figure out, etc. Make it a fairly self-contained document.

-- Alan


----------



## JimmyM (Dec 20, 2008)

OK. Thanks.


----------



## JimmyM (Dec 20, 2008)

Did we already cover "Where did you learn about AVRs". These 2 threads date back a ways. I know that AVRFreaks exists, and it has a TON of information. But i'm a little put off by all of the "Hey I'm not gonna do your job for you. look here". and "here" is the noob section that has a ton of info from everywhere, but it's too disorganized.
I just haven't seen a tutorial like "This is how you set up PWM and this is what each of the pars of the definition do". I've seen ones for "make an LED blink" and use a pushbutton. It's a start, but it's the first step in a journey of a 1000 miles.
Is there a book or books you could suggest?
Thanks again. And to think I was skeptical at first.


----------



## JimmyM (Dec 20, 2008)

WOW. Look at all my replies.
I see now what you're doing with the ADC bits. You're using an 8-bit ADC to coincide with the 8-bit PWM. The Tiny84 can do 10-bit "FAST PWM". Maybe I'll just use your implementation, using ADC and PWM counts except use 10-bit. That will give better resolution when using a 100K upper voltage divider.
Is that indeed what you're doing? So then all of those 65535s will become 1023s.
I've been doing some more reading at AVRFreaks. There's a tutorial in ADCs and another one on Timers. I've also found some postings on PWM implementation.
I have to look into what the lower limit is for "FAST PWM" frequency, if there is one.


----------



## Alan B (Dec 20, 2008)

Jim:

I generally find the manufacturer's spec sheet (book?) on the CPU to be the most useful resource on things like the PWM, ADC, etc. 

I'm not really taking advantage of the ADC word size being the same as the PWM word size. In fact, I tested with 10 bit ADC and found it was not really helpful, so backed it out to keep things simple.

The regulation routine I use most just counts the PWM up or down by one count at a time, the ADC reading is used to decide if the voltage is high or low, and adjust accordingly. Can't get much simpler than that.

Of course Will wanted the ramping to occur faster, so then I set it up to compute a faster rate for ramping when the error term was large, and things are a bit more complicated after that, but this is not really required. It just takes more finesse to go fast and do it properly.

Back to the data sheets, they tend to make sense once one finds the proper passage and rereads it a few times, or more, as required. At some point you just have to set up a simple test and put the scope on it and see what it does. After all, the microprocessor is really just a bunch of fairly simple logic, gates and registers, so when you start to look at a low level it is not complex.

Books don't tend to keep up with this technology, but if you can find one it might help at a higher level. There are not many AVR books out there.

-- Alan


----------



## Alan B (Dec 21, 2008)

Jim et al:

I just reviewed the package that you sent, and I think there are some comments to make that belong in the thread.

Changing CPUs can be a minor thing, or a major thing, depending on how the hardware changes affect the software. In this case the Tiny84 has significantly different hardware in the PWM and there are far reaching implications.

The way to approach a CPU change like this is probably to start at FP1 and work up. Jumping in at FP7 is likely to make a frustrating setup that doesn't work in several ways, and no easy way to understand why.

I should put in the comments some info about the standard macros such as _BV which changes a bit position number to a bit mask value. 

One problem with using more than an 8 bit ADC is that squaring the value won't fit into 16 bits, so this makes things get complicated fast.

There are other implications with changing bits such as the one Jim noted about the ramp rate. Using 16 bit instead of 8 bit PWM causes the ramp to go 256 times slower. So you end up having to move more than one count at a time, which kind of defeats the purpose. Also the clock has to be 256 times higher frequency which consumes more power, etc. The fast start code in the later version takes care of this with some added complexity by using larger steps when the error is large.

-- Alan


----------



## JimmyM (Dec 21, 2008)

If we used the full 10-bit ADC and used the 10-bit PWM mode, the 2 values would then coincide, as did the 8 bit values. The 10-bit ADC would be better with respect to broadening the Vbatt range while maintaining decent resolution. The 10-bit PWM would just be implemented to keep in step with the 10-bit ADC.
I have a lot of learning to do. That's pretty clear, but I thought that your experience would place the FP7 farther up the learning curve. The softstart could be done in chunks of 4 which would place it in the same area as the 8-bit PWM, until the regulation point is reached. Since the step size would be the same as it was with the 8-bit PWM, it couldn't over-run the regulation point by any more than the 8-bit did. then it would use the full resolution of the 10-bit PWM during the pwm increment/decrement loop.


----------



## Alan B (Dec 21, 2008)

JimmyM said:


> If we used the full 10-bit ADC and used the 10-bit PWM mode, the 2 values would then coincide, as did the 8 bit values. The 10-bit ADC would be better with respect to broadening the Vbatt range while maintaining decent resolution. The 10-bit PWM would just be implemented to keep in step with the 10-bit ADC.
> I have a lot of learning to do. That's pretty clear, but I thought that your experience would place the FP7 farther up the learning curve. The softstart could be done in chunks of 4 which would place it in the same area as the 8-bit PWM, until the regulation point is reached. Since the step size would be the same as it was with the 8-bit PWM, it couldn't over-run the regulation point by any more than the 8-bit did. then it would use the full resolution of the 10-bit PWM during the pwm increment/decrement loop.



Jim,

Your logic regarding the 10 bit PWM increment/decrement by 4 should be okay. We are essentially doing that in the later fast-start code, but based on the magnitude of the error rather than a boolean. So it will not overshoot.

If 10 bit ADC values are used, then squaring them will produce a 20 bit result. 16 bit arithmetic is insufficient to handle this, so the math has to be changed to floating point or longer precision integers. This can be done, however it significantly slows down the processor and makes the binary file much larger. The bottom bits of the ADC are more noisy and the clock rates are probably too high now so the ADC process will need to be slowed down, and the bottom bits will be noisier than the bottom bits of the 8 bit value. So the dynamic range will increase at the cost of noise and slower readings. If the voltage input is set at say 25 volts and a 6 volt battery is used then the top two bits are never used. It is perhaps better to rescale to 6V than to extend the precision by adding two noisy bits that slow down the system.

When the ADC gets to full scale the regulator can no longer regulate since it does not know what Vbatt is, so it needs to do something, like shutting off, or limiting the PWM to some safe value based on some assumptions about the possible voltages.

If you make more than one change at a time it can be impossible to debug. Changing the processor is a huge change by itself, so doing that requires going back to smaller pieces and building back up.

One approach would be to make ONLY the MINIMUM changes to the code required by the new CPU. Get that working. Then work individually on other improvements. Make the new CPU work just exactly like the old one did first, then make other changes.

Probably the easiest way to do what you are proposing is to just go floating point. That will slow down the CPU a lot, and take a lot more code space. You will have to convert ADC to floating point and floating point to PWM values. It will make things a lot easier to think about and to work on. I did floating point testing and there are examples in the file.

One thing I did was to try ideas out like this in the Python simulator. It is much easier to try them out there and see how they perform. I tried most of the things you are considering (10 bit ADC and PWM) and didn't see a great deal of improvement in most of the operating area, but it is a good exercise to test and see, and there is improvement possible in some areas. You can do ten tests in Python faster than one in the micro.

-- Alan


----------



## Alan B (Dec 21, 2008)

I have updated the first post in this thread, and added links to the Application Specific projects.

-- Alan


----------



## Alan B (Dec 21, 2008)

Alan B said:


> Okay. That is reasonable. I have a sketch of a circuit that addresses this (the M6 variant), have to go now but we can discuss it later.
> 
> -- Alan



Will, sorry for the delay getting back to this. I did make a new schematic which I need to upload, but it looks quite viable with small changes to the existing design.

Basically the pushbutton input is not required, but instead a sample of the voltage at the output of the FET is taken and fed into the CPU using that pin. This is used to generate an interrupt when the micro is asleep in the off state (and the switch turns on, raising the voltage across the open FET and input to the CPU), and it can be used to tell if the switch is on or off by opening the FET and sampling the level (it goes high if the switch is closed, stays low if not). The software will require several mods to work this way, but it should not be difficult.

-- Alan


----------



## Alan B (Dec 21, 2008)

Alan B said:


> Will, sorry for the delay getting back to this. I did make a new schematic which I need to upload, but it looks quite viable with small changes to the existing design.
> 
> Basically the pushbutton input is not required, but instead a sample of the voltage at the output of the FET is taken and fed into the CPU using that pin. This is used to generate an interrupt when the micro is asleep in the off state (and the switch turns on, raising the voltage across the open FET and input to the CPU), and it can be used to tell if the switch is on or off by opening the FET and sampling the level (it goes high if the switch is closed, stays low if not). The software will require several mods to work this way, but it should not be difficult.
> 
> -- Alan



Will, I just reread your design thread and updated the schematic a bit. It now has a four position dip switch that has one switch to power the regulator. This allows a charged pack to avoid any drain, the regulator is not active at all until this switch is closed.

This leaves three positions, and there are two bits left. One could get fancier, but it is easy to get six selections from these three switches. This is accomplished by using the first two switches from the two bits to ground, and the third switch to connect the two bits together. This does not quite get to 8 possible values since when the cross-connecting switch is closed the micro cannot discern which of the two remaining switches is closed, but it can tell the case where neither of them vs one of them is closed. Hence 6 total values.

Alternately more values can be read by using resistors and making essentially a DAC with the switches, and reading the voltage in with an ADC. This can be done by rearranging things a bit if six is not enough values. Enough on that unless it is really necessary.

This regulator will have to go in the tailswitch end of the battery pack since the FET needs to connect directly between battery minus and the rest of the circuit. It also needs a tap from battery plus, but very little current flows in this. This also facilitates a charging jack at the base if desired.

-- Alan


----------



## JimmyM (Dec 21, 2008)

Alan B said:


> Jim,
> 
> Your logic regarding the 10 bit PWM increment/decrement by 4 should be okay. We are essentially doing that in the later fast-start code, but based on the magnitude of the error rather than a boolean. So it will not overshoot.
> 
> ...


I'm going to begin at the beginning, like you said. Get the basics working on the new procesor, then get fancy. It will be fun to fiddle. I have some ideas with respect to the program layout. I see above that you and Will are thinking along the same lines as I am with the "request voltage" pot. Except you would use an ADC to decode the desired output voltage based on specific ADC input voltages.

I see what you mean about 10-bit math and squaring. Using a 16-bit floating value would drop the least sicnificant bits, but still not perfect.

I'll let you know how it goes.


----------



## wquiles (Dec 21, 2008)

Alan B said:


> Will, sorry for the delay getting back to this. I did make a new schematic which I need to upload, but it looks quite viable with small changes to the existing design.
> 
> Basically the pushbutton input is not required, but instead a sample of the voltage at the output of the FET is taken and fed into the CPU using that pin. This is used to generate an interrupt when the micro is asleep in the off state (and the switch turns on, raising the voltage across the open FET and input to the CPU), and it can be used to tell if the switch is on or off by opening the FET and sampling the level (it goes high if the switch is closed, stays low if not). The software will require several mods to work this way, but it should not be difficult.
> 
> -- Alan







Alan B said:


> Will, I just reread your design thread and updated the schematic a bit. It now has a four position dip switch that has one switch to power the regulator. This allows a charged pack to avoid any drain, the regulator is not active at all until this switch is closed.
> 
> This leaves three positions, and there are two bits left. One could get fancier, but it is easy to get six selections from these three switches. This is accomplished by using the first two switches from the two bits to ground, and the third switch to connect the two bits together. This does not quite get to 8 possible values since when the cross-connecting switch is closed the micro cannot discern which of the two remaining switches is closed, but it can tell the case where neither of them vs one of them is closed. Hence 6 total values.
> 
> ...




Thanks much Alan. Your idea for the bulb detection sounds neat - I look forward to trying it out. As for voltage/bulb selections, to start 4 values is plenty, but it is nice to know that we can use up to 6 without much problems 

Since we have to create a new "-" for the bulb, it works out nicely if we have the PhD-M6 in the tailcap side, so I agree with you. One of the guys in the PhD-M6 thread has a good idea for the pack, based on an FM holder, so we should be able to make this work 

Will


----------



## Alan B (Dec 21, 2008)

wquiles said:


> Thanks much Alan. Your idea for the bulb detection sounds neat - I look forward to trying it out. As for voltage/bulb selections, to start 4 values is plenty, but it is nice to know that we can use up to 6 without much problems
> 
> Since we have to create a new "-" for the bulb, it works out nicely if we have the PhD-M6 in the tailcap side, so I agree with you. One of the guys in the PhD-M6 thread has a good idea for the pack, based on an FM holder, so we should be able to make this work
> 
> Will



New Schematic Posted for Battery Pack PHD Regulator with on-off switch and six level selection switch input to CPU.

http://www.akbeng.com/flash/hwreg/phd1e.gif

If the programming jack is made at least somewhat accessible the reprogramming feature is also available, open the selection switches and program away!

-- Alan


----------



## Alan B (Dec 21, 2008)

wquiles said:


> Thanks much Alan. Your idea for the bulb detection sounds neat - I look forward to trying it out. As for voltage/bulb selections, to start 4 values is plenty, but it is nice to know that we can use up to 6 without much problems
> 
> Since we have to create a new "-" for the bulb, it works out nicely if we have the PhD-M6 in the tailcap side, so I agree with you. One of the guys in the PhD-M6 thread has a good idea for the pack, based on an FM holder, so we should be able to make this work
> 
> Will



Note that doing switch detection this way also detects blown bulbs - same as the switch open, so it shuts down. The only issue is when running out of regulation (so the FET is fully on all the time) - the power to the bulb will have to be interrupted periodically to see if it is still there and on. While the FET is closed there is no data available, so it will have to open the FET and sample the voltage. This should be done perhaps ten times per second to reliably catch the turnoff, but it does not have to be open for long, so there will be no visible effect from this sampling.

It might be interesting to think about user interfaces for this arrangement. Seems like 2 or 3 levels might be useful.

-- Alan


----------



## wquiles (Dec 21, 2008)

Alan B said:


> New Schematic Posted for Battery Pack PHD Regulator with on-off switch and six level selection switch input to CPU.
> 
> http://www.akbeng.com/flash/hwreg/phd1e.gif
> 
> ...


Excellent - thanks much Alan 




Alan B said:


> Note that doing switch detection this way also detects blown bulbs - same as the switch open, so it shuts down. The only issue is when running out of regulation (so the FET is fully on all the time) - the power to the bulb will have to be interrupted periodically to see if it is still there and on. While the FET is closed there is no data available, so it will have to open the FET and sample the voltage. This should be done perhaps ten times per second to reliably catch the turnoff, but it does not have to be open for long, so there will be no visible effect from this sampling.
> 
> It might be interesting to think about user interfaces for this arrangement. Seems like 2 or 3 levels might be useful.
> 
> -- Alan


Gotcha - excellent idea about checking while on DD mode :twothumbs

Will


----------



## JimmyM (Jan 2, 2009)

I just placed an order at Digikey for some development parts. A couple of Tiny84s in 14DIP for breadboarding and one in 20QFN for layout purposes. As well as some pushbuttons, LEDs, pots etc.
As soon as I get them and breadboard it to the point where I can start turning LEDs on and off, I'll start trying to duplicate your FP1-FP7 programs step by step. I think my goal, for now is to attain a program like FP6 and another like FP7. I want to write the code so that there are sections of code that can be enabled at compile time like you did.
For things like another output to turn a device on or off, or to output a sequence of flashes to an external LED for status, enable another ADC for a request POT for low volt shutdown, enable an input to accept a signal from a Li-Ion protection IC, etc. I know I'm getting ambitious, but hey. I might as well try to come up with ideas for how to use the extra I/O ports.


----------



## Alan B (Jan 2, 2009)

JimmyM said:


> I just placed an order at Digikey for some development parts. A couple of Tiny84s in 14DIP for breadboarding and one in 20QFN for layout purposes. As well as some pushbuttons, LEDs, pots etc.
> As soon as I get them and breadboard it to the point where I can start turning LEDs on and off, I'll start trying to duplicate your FP1-FP7 programs step by step. I think my goal, for now is to attain a program like FP6 and another like FP7. I want to write the code so that there are sections of code that can be enabled at compile time like you did.
> For things like another output to turn a device on or off, or to output a sequence of flashes to an external LED for status, enable another ADC for a request POT for low volt shutdown, enable an input to accept a signal from a Li-Ion protection IC, etc. I know I'm getting ambitious, but hey. I might as well try to come up with ideas for how to use the extra I/O ports.



That is a good approach. Get the basics working and then add features carefully. Some steps are going to be troublesome, but you can always back up and take a half-step.

Lots of possible uses for more bits.

How are you going to solder the surface mount part? Does the part in the center also need to be soldered? 

That part doesn't look well suited to hand soldering. We use some BGA parts at work (Ball Grid Array). Have to send those out for installation.The pins are underneath.

-- Alan


----------



## Alan B (Jan 2, 2009)

JimmyM said:


> ..., enable another ADC for a request POT for low volt shutdown, enable an input to accept a signal from a Li-Ion protection IC, etc. ..



Why bother with a Li-Ion protection IC? It only requires a couple lines of code to do that. Need to think in terms of Software not Hardware.

-- Alan


----------



## JimmyM (Jan 2, 2009)

Alan B said:


> That is a good approach. Get the basics working and then add features carefully. Some steps are going to be troublesome, but you can always back up and take a half-step.
> 
> Lots of possible uses for more bits.
> 
> ...


The 20QFN can be hand soldered since the leads do present themselves at the edge. I just made the pad footpront extend a tiny amount beyond the legs. I'd use solder paste, but I should be able to solder them with a small conical point on my iron. The center pad should have a corresponding pad on the board. There are 2 ways to do it. Reflow soldering with solder paste and a toaster oven, or using thermal vias and heating them from underneath to reflow the solder paste between the chip and the board.
I may try reflowing the whole board after paste and component placement. I can order paste stencils from the same company I order the boards from, but I think I'll try just using a small swab. I have some that were given to me, they have a very small end.



Alan B said:


> Why bother with a Li-Ion protection IC? It only requires a couple lines of code to do that. Need to think in terms of Software not Hardware.
> 
> -- Alan


The chips I was thinking about have per cell monitoring for 2-4 cells, and 5-10 cells.
EDIT: The 5-10 cell model I found (TI bq77PL900) can do up to 10 cells, has a 60V maximum input and has a built in 5V/25mA LDO that can power an external microcontroller. Instead on driving external FETs, those outputs could signal the Tiny84/85. They can even talk to each other if you want. This would really be for the Uber Regulator for guys with 10 cell Li-Ion packs and those big lantern style lights, but it's something to keep in mind.

Something else I've been thinking about would be pack voltage curve monitoring. If the uC could monitor the curve, it might be able to use that to determine when the pack is in the final throes of discharge. If the voltage falls x% in y program cycles, initiate the low voltage protocol. Something along those lines. Most cells, especially, Li-Ion, fall off pretty quickly at the end. The protocol would reset itself after power cycling.


----------



## Alan B (Jan 2, 2009)

One problem with per-cell monitoring is all the wiring. Probably have to build it into a custom battery pack like the RC folks do. Gets messy.

The per cell monitoring is required in the high drain applications like RC. They drain a battery in 5 or 10 minutes. Most flashlights aren't quite that hungry.

Looks like a challenge to hand solder those CPU chips. They produce so little heat the center pad is probably not required thermally, is it required electrically?

I've heard the toaster oven/heat gun technique is excellent but have not done it myself. Probably best to just have the boards professionally loaded. it is surprisingly inexpensive when done in quantity.

This package is probably not a good choice for a "kit" that the user puts together themselves.

-- Alan


----------



## JimmyM (Jan 2, 2009)

Alan B said:


> One problem with per-cell monitoring is all the wiring. Probably have to build it into a custom battery pack like the RC folks do. Gets messy.
> 
> The per cell monitoring is required in the high drain applications like RC. They drain a battery in 5 or 10 minutes. Most flashlights aren't quite that hungry.


I think many here would be quick to disagree. Especially with unprotected cells. They would definitely have to beuilt into a pack design. For sure.


Alan B said:


> Looks like a challenge to hand solder those CPU chips. They produce so little heat the center pad is probably not required thermally, is it required electrically?


It says it should be soldered to ground (Pin 8).


Alan B said:


> I've heard the toaster oven/heat gun technique is excellent but have not done it myself. Probably best to just have the boards professionally loaded. it is surprisingly inexpensive when done in quantity.


 I had been thinking about that, but wanted to look into the quantities.


Alan B said:


> This package is probably not a good choice for a "kit" that the user puts together themselves.


Oh, God. Definitely NOT. The through hole version is about the most 95% of CPFers would be willing to deal with.


----------



## donn_ (Jan 2, 2009)

I've got to believe we can find a competent assembler who, for reasonable remuneration, will put together anything you can come up with.


----------



## Alan B (Jan 2, 2009)

JimmyM said:


> I think many here would be quick to disagree. Especially with unprotected cells. They would definitely have to beuilt into a pack design. For sure.
> 
> It says it should be soldered to ground (Pin 8).
> 
> Oh, God. Definitely NOT. The through hole version is about the most 95% of CPFers would be willing to deal with.



Most per cell monitoring that I have seen is for charging applications. Even the heavy discharging RC folks don't usually monitor per-cell discharges.

If the center pad must be grounded, that is a problem for hand soldering. I see they do recommend that. Darn.

How many folks are interested in through-hole kits?

I put together my KIU socket yesterday and re-assembled my [email protected] Now that I know where it focuses properly I can make final measurements for the [email protected] and perhaps cut some aluminum for a prototype. The circuit board that I have been testing seems to be error free, only the one diode had to be changed and that does not affect the board. The programming plug in board may be a bit shorter than I'd like but that is minor.

-- Alan


----------



## JimmyM (Jan 2, 2009)

donn_ said:


> I've got to believe we can find a competent assembler who, for reasonable remuneration, will put together anything you can come up with.


The folks that fabbed the boards for the PhD-prototype said they can do assembly. So I'll be getting a quote from them for the assembly at the same time I order the boards.
P.S. I love the word "remuneration". It's one of those "fine print" words they use in infomercials so some folks don't know the spokes-person had been paid.


----------



## JimmyM (Jan 2, 2009)

Alan B said:


> Most per cell monitoring that I have seen is for charging applications. Even the heavy discharging RC folks don't usually monitor per-cell discharges.
> -- Alan


True. true.

What do you think about my "discharge slope" idea for low voltage cut off?


----------



## Alan B (Jan 2, 2009)

JimmyM said:


> ...
> 
> What do you think about my "discharge slope" idea for low voltage cut off?



It is a good idea. I have had similar thoughts. I suspect that it needs to be tuned to the battery and bulb in use. It might be easy for a specific setup but hard for a generic application.

-- Alan


----------



## JimmyM (Jan 2, 2009)

Alan B said:


> It is a good idea. I have had similar thoughts. I suspect that it needs to be tuned to the battery and bulb in use. It might be easy for a specific setup but hard for a generic application.
> 
> -- Alan


Maybe for a specific bulb and cell "type". If the cell count were fixed, then the low volt cutoff would be a simple programmed value. So it might be a good option for a certain range of bulbs (3-4 Amps, or 5-6 Amps), etc and a type of cell. A123s or eMoli, etc. Well, once I get the software working, I'll start adding the fancy stuff.


----------



## JimmyM (Jan 2, 2009)

I just can't wait to get the chips and parts from Digikey.


----------



## Alan B (Jan 3, 2009)

Well, today I chucked up a piece of 6061-T6 and let the chips fly. Turning and boring is now done on the first prototype [email protected]

Next I need to set up the Mill and make more chips. Maybe, just maybe I'll have a working [email protected] regulator in the next few days... 

-- Alan


----------



## wquiles (Jan 3, 2009)

Alan B said:


> Well, today I chucked up a piece of 6061-T6 and let the chips fly. Turning and boring is now done on the first prototype [email protected]
> 
> Next I need to set up the Mill and make more chips. Maybe, just maybe I'll have a working [email protected] regulator in the next few days...
> 
> ...



Very nice Alan 

Will


----------



## Alan B (Jan 4, 2009)

Alan B said:


> Well, today I chucked up a piece of 6061-T6 and let the chips fly. Turning and boring is now done on the first prototype [email protected]
> 
> Next I need to set up the Mill and make more chips. Maybe, just maybe I'll have a working [email protected] regulator in the next few days...
> 
> -- Alan



Well, the turning went pretty fast but the milling is a stretch for my mini-mill. This is going to take awhile. Need a more efficient mechanical design or an NC mill.

-- Alan


----------



## Alan B (Jan 7, 2009)

OK. I have redesigned the mechanical and the PCBoard to make it easier to build this thing because my earlier design was not practical for my tooling. Now the question is should I just build a couple for myself, or a few more? My plan is sufficiently different from others that it might be worthwhile to make a few, though I don't have a lot of time for this.

I started a separate feeler thread to keep this topic on the design, and discussions about making some in the appropriate forum:

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

-- Alan


----------



## JimmyM (Jan 7, 2009)

Alan,
Is it possible to trigger the ADC read via an interrupt?
I've been reading the Tiny84/85 documentation.
If we use Phase Correct PWM and read the ADC every time the TOVn interrupt flag is set, we are assured to read the ADC value in the middle of the PWM ON pulse. That's good right?


----------



## Alan B (Jan 7, 2009)

JimmyM said:


> Alan,
> Is it possible to trigger the ADC read via an interrupt?
> I've been reading the Tiny84/85 documentation.
> If we use Phase Correct PWM and read the ADC every time the TOVn interrupt flag is set, we are assured to read the ADC value in the middle of the PWM ON pulse. That's good right?



I'd have to look into it. I'm not sure the phase correct PWM will work properly for the Tiny85 design pinout that I was using. Seems to me there was some problem with it.

I think the ADC can be triggered on certain interrupts, probably not all.

The center of the PWM cycle may not be the optimum place to read the ADC, but it is one good place. It might be better to read it at both ends and make a trapezoidal interpolation. Probably need to model some real waveforms to see.

-- Alan


----------



## JimmyM (Jan 10, 2009)

I have an update regarding the development for the Tiny84.
I have 10-bit PWM running at 244Hz.

I read the battery voltage on ADC3 with the internal 1.1V Vref and I read the request voltage on ADC2 with Vcc as the Vref both using the full 10-bits.
The Tiny84 doesn't have the 2.56V Vref, Just 1.1 and Vcc. So I can use a 360K upper resistor for the battery voltage divider and a 10K for the bottom. A nice side effect is a reduction in "waste" current.
With that arrangement, I can get ~0.04V resolution

It works very nicely thus far.
Next to do...
1) Syncing the ADC3 read with PWM ON.
2) Start introducing the various calculations for regulation.
3) Add programmable soft start ramp.
4) Add code for reading pushbuttons. While not necessay for the JM-PhD-D1, it will be for later versions.

This shouldn't be too bad.


----------



## Alan B (Jan 10, 2009)

JimmyM said:


> I have an update regarding the development for the Tiny84.
> I have 10-bit PWM running at 244Hz.
> 
> I read the battery voltage on ADC3 with the internal 1.1V Vref and I read the request voltage on ADC2 with Vcc as the Vref both using the full 10-bits.
> ...



Jim, Excellent progress! There sure are a lot of little differences between the CPUs. Perhaps we should consider changing to the 1.1Vref on all versions of the code, would make things a bit easier to follow, and keep the resistor sets the same. 

Is the Tiny84 running at the same clock rate (8 mhz as I recall)?

Today I found a commercially made terminal to connect to the screw that brings in B+, and I had to move most of the components on the PCB to make it fit. I made several new PCB components and it looks really good. Before I was going to make a connector from a brass block but this will be a lot easier to do. Also the FET is now in a position where I could mount it under the PCB to the Sled for heatsinking if that was ever needed.

A few days ago I found a supplier that has what appears to be the bipin sockets that are used for these bulbs. I checked the local hardware store and they have quite a few bulbs that might work but no sockets. There are quite a few 6 and 12 volt bipin bulbs for lighting carried at the hardware store. I hadn't really seen all of them before, it seems to be an expanding market.

I've still got that chunk of milled aluminum - the Sled prototype - clamped in the mill. Maybe after dinner I'll work on that a bit, or on preparing the next regulator board to mount on it.

-- Alan


----------



## Mr Happy (Jan 10, 2009)

Alan B said:


> There are quite a few 6 and 12 volt bipin bulbs for lighting carried at the hardware store. I hadn't really seen all of them before, it seems to be an expanding market.


Really? I've seen no other than 12 V bulbs myself. The home lighting halogens tend to be rated with a 2000 hour life, so they could be over driven quite a lot to make them very bright with a 20 hour life. I'd rather be able to drive a 6 V bulb at 9 V rather than a 12 V bulb at 18 V. One drawback is that home lighting bulbs do not have very precise filament placement, unlike projector bulbs. I picked out half a dozen 20 W bulbs before I found one with a reasonably well-shaped filament.


----------



## Alan B (Jan 10, 2009)

Mr Happy said:


> Really? I've seen no other than 12 V bulbs myself. The home lighting halogens tend to be rated with a 2000 hour life, so they could be over driven quite a lot to make them very bright with a 20 hour life. I'd rather be able to drive a 6 V bulb at 9 V rather than a 12 V bulb at 18 V. One drawback is that home lighting bulbs do not have very precise filament placement, unlike projector bulbs. I picked out half a dozen 20 W bulbs before I found one with a reasonably well-shaped filament.



I wasn't thinking so much of using them in flashlights as using them for test. The 12V bulbs would be good even if the parameters were wrong they would not  on a 12V test supply, and the 6V would be interesting to overdrive a bit. Some of them have pins that are a bit fat so are hard on the sockets. There are also quite a few with built in reflectors. Might make a good floodlight flashlight. It seems like most of my uses for flashlights are more toward the floody side. Throwers are fun, but don't get used much for me.

-- Alan


----------



## JimmyM (Jan 10, 2009)

Alan B said:


> Jim, Excellent progress! There sure are a lot of little differences between the CPUs. Perhaps we should consider changing to the 1.1Vref on all versions of the code, would make things a bit easier to follow, and keep the resistor sets the same.
> 
> Is the Tiny84 running at the same clock rate (8 mhz as I recall)?


It, by default, uses the 8MHz oscillator as the clock source. The clock prescale divider = 1 allows the CPU to run at 8MHz. But to get the PWM frequency I need, I had to step down to a 4MHz CPU clock by using the clock divider = 2. It can run up to 20MHz by external crystal.


Alan B said:


> Today I found a commercially made terminal to connect to the screw that brings in B+, and I had to move most of the components on the PCB to make it fit. I made several new PCB components and it looks really good. Before I was going to make a connector from a brass block but this will be a lot easier to do. Also the FET is now in a position where I could mount it under the PCB to the Sled for heatsinking if that was ever needed.


I would mount it on the back of the board and heat sink it there anyway! Why not? You've got a giant chunk of aluminum there, why not use it.


Alan B said:


> A few days ago I found a supplier that has what appears to be the bipin sockets that are used for these bulbs. I checked the local hardware store and they have quite a few bulbs that might work but no sockets. There are quite a few 6 and 12 volt bipin bulbs for lighting carried at the hardware store. I hadn't really seen all of them before, it seems to be an expanding market.
> 
> I've still got that chunk of milled aluminum - the Sled prototype - clamped in the mill. Maybe after dinner I'll work on that a bit, or on preparing the next regulator board to mount on it.
> 
> -- Alan


----------



## JimmyM (Jan 10, 2009)

I bought 3 14DIP Tiny84s. It would appear as though I "bricked" one. Initially, I could read the chip signature and all was goodness and light. I went to set the BOD to 4.3V and it all went south. Afterwards the AVRISP MkII light flashed orange and gave errors about RESET pin pull-ups. If I swap chips, the different chip works great.
Do you know what I can do to un-brick it?


----------



## Alan B (Jan 10, 2009)

JimmyM said:


> I bought 3 14DIP Tiny84s. It would appear as though I "bricked" one. Initially, I could read the chip signature and all was goodness and light. I went to set the BOD to 4.3V and it all went south. Afterwards the AVRISP MkII light flashed orange and gave errors about RESET pin pull-ups. If I swap chips, the different chip works great.
> Do you know what I can do to un-brick it?



Seems to me that if some of the programming fuses get set in certain ways it will no longer be able to program with "low voltage serial programming", or it requires an external clock which is not present. In that case you have to use "high voltage serial programming" or some other mode, depending on the particulars of the CPU chip. This can be done with the STK500 board by following a procedure in the manual. It requires some jumpers etc. I did it once to recover a chip. I don't think the AVRISP can do it.

-- Alan


----------



## Alan B (Jan 11, 2009)

On a related note, I picked up a precision voltage reference on eBay. 5.000V, 0.01%. A guy builds them and auctions one every week for $24.50. This one is a PC board with a 9V battery holder underneath and is very small. It even includes a battery.

Actually there are a couple of folks who make similar ones, this one is smaller and appears to be better made. Anyway, it is a good idea to check those meters for calibration. Some are pretty bad. My Exceltech is right on according to this reference, it reads either 5.00 or 4.99V on this source. 

Lux, do you cal check your meters? Making bulb measurements for life, etc, it would be good to know how accurate the readings actually are. 

This one is what I got:

ebay item number 280299727669

If you are patient you can get one for 24.50, I had to wait about a month for some higher bidders to get theirs, then I got mine. The seller measures the actual voltage with a precision meter and gives you better numbers cold and warmed up, so you can get more precision. It is better than any meter I own.

There is an even better one available from Geller Labs.

http://www.gellerlabs.com/SVR Series.htm

It is not very expensive but is a bit larger and requires a power supply or some batteries to run it, so it is a bit more of a project. If you put a good power supply on it you can get 0.0005% (5 PPM) accuracy.

-- Alan


----------



## wquiles (Jan 11, 2009)

JimmyM said:


> I have an update regarding the development for the Tiny84.
> I have 10-bit PWM running at 244Hz.
> 
> I read the battery voltage on ADC3 with the internal 1.1V Vref and I read the request voltage on ADC2 with Vcc as the Vref both using the full 10-bits.
> ...



That is awesome progress Jim - way to go !!!

At this rate, since you are so far along, I might just use the same processor for the PhD-M6 to share on the PWB layout size/packages that you have for it 

Will


----------



## wquiles (Jan 11, 2009)

Alan B said:


> On a related note, I picked up a precision voltage reference on eBay. 5.000V, 0.01%. A guy builds them and auctions one every week for $24.50. This one is a PC board with a 9V battery holder underneath and is very small. It even includes a battery.
> 
> Actually there are a couple of folks who make similar ones, this one is smaller and appears to be better made. Anyway, it is a good idea to check those meters for calibration. Some are pretty bad. My Exceltech is right on according to this reference, it reads either 5.00 or 4.99V on this source.
> 
> ...



Great tip Alan - I need to get one of these to check the accuracy of my own meters 

Will


----------



## JimmyM (Jan 11, 2009)

Alan B said:


> On a related note, I picked up a precision voltage reference on eBay. 5.000V, 0.01%. A guy builds them and auctions one every week for $24.50. This one is a PC board with a 9V battery holder underneath and is very small. It even includes a battery.
> 
> Actually there are a couple of folks who make similar ones, this one is smaller and appears to be better made. Anyway, it is a good idea to check those meters for calibration. Some are pretty bad. My Exceltech is right on according to this reference, it reads either 5.00 or 4.99V on this source.
> 
> ...


Those are neat little toys. I'm not sure I really need one. My Fluke is one if the best portable DMMs available. It has a basic DC accuracy of 0.025%. I think for my purposes it should be OK. Even if it was off, I'd have to send it off to Fluke for recalibration.


----------



## JimmyM (Jan 11, 2009)

Alan B said:


> Seems to me that if some of the programming fuses get set in certain ways it will no longer be able to program with "low voltage serial programming", or it requires an external clock which is not present. In that case you have to use "high voltage serial programming" or some other mode, depending on the particulars of the CPU chip. This can be done with the STK500 board by following a procedure in the manual. It requires some jumpers etc. I did it once to recover a chip. I don't think the AVRISP can do it.
> 
> -- Alan


The only problem there is that the STK500 would require and accessory board to accept the Tiny84. Unless I can just jumper from the STK500 to the breadboard where the Tiny84 is mounted.


----------



## JimmyM (Jan 11, 2009)

wquiles said:


> That is awesome progress Jim - way to go !!!
> 
> At this rate, since you are so far along, I might just use the same processor for the PhD-M6 to share on the PWB layout size/packages that you have for it
> 
> Will


Thanks, Will. I'm going to see how much I can get done today. Your design is such that power on and power off is accomplished by making and breaking the main current path via the rear tail cap. Correct? If so, most of the JM-PhD-D1 code should work for your design.


----------



## Alan B (Jan 11, 2009)

JimmyM said:


> The only problem there is that the STK500 would require and accessory board to accept the Tiny84. Unless I can just jumper from the STK500 to the breadboard where the Tiny84 is mounted.



Jumpers should do it. Also the Dragon board can probably do it. Unless you brick a few of them it may not be worth recovering them. Label them and set them aside for later. 

-- Alan


----------



## JimmyM (Jan 11, 2009)

Alan B said:


> Jumpers should do it. Also the Dragon board can probably do it. Unless you brick a few of them it may not be worth recovering them. Label them and set them aside for later.
> 
> -- Alan


I only bricked one. I have 2 more. One I'm using and an extra. I might try setting the Brownout Detection on the extra and see what happens. I checked that the BOD setting (4.3V) is definitely below the Vcc I'm using (5.002V).
I'll look into high voltage programming with the STK500.
Thanks for the tip.


----------



## Alan B (Jan 11, 2009)

JimmyM said:


> I only bricked one. I have 2 more. One I'm using and an extra. I might try setting the Brownout Detection on the extra and see what happens. I checked that the BOD setting (4.3V) is definitely below the Vcc I'm using (5.002V).
> I'll look into high voltage programming with the STK500.
> Thanks for the tip.



I try to avoid changing fuses from factory default if possible. Many can be overridden in software so there's no need to change them. If you are going to change one fuse, check ALL of them and make sure every one is right before flashing the fuses. One wrong one (like selecting external clock) can sink you.

I think you can safely leave the BOD (brownout detection for those reading the mail) till last.

I just checked my third DVM with the voltage reference. All read 4.99/5.00 so far. Even the old Heathkit DVM that I can calibrate. I calibrated that one when I built it many years ago against an HP 6 digit DVM and I guess it has held. I have not found any of the $3 DVMs yet to try. Those will probably be different but it will be interesting to see. Most DVMs call for calibration every year or two, but if you can check them you can tell if it is required or not. Most DVMs hold cal quite well but you can not tell without a reference source. I figured for under $30 it might be worth knowing, especially for things like expensive hotwire bulbs that are quite voltage sensitive. Clearly my 3 meters have not needed it. However, the more accurate a meter is, the more it needs calibration. The more precision it has the more sensitive it is to changes in the parts.

Well, I'm not finding a box of parts for my regulator build today. Wonder where they crawled off to. Perhaps the runaway socks took them hostage.:candle:

-- Alan


----------



## Alan B (Jan 11, 2009)

Alan B said:


> Well, I'm not finding a box of parts for my regulator build today. Wonder where they crawled off to. Perhaps the runaway socks took them hostage.:candle:
> 
> -- Alan



Found 'em! Now back to the shop!

-- Alan


----------



## JimmyM (Jan 11, 2009)

Alan B said:


> I try to avoid changing fuses from factory default if possible. Many can be overridden in software so there's no need to change them. If you are going to change one fuse, check ALL of them and make sure every one is right before flashing the fuses. One wrong one (like selecting external clock) can sink you.
> 
> I think you can safely leave the BOD (brownout detection for those reading the mail) till last.
> 
> -- Alan


Maybe I set a clock source fuse, or something I didn't intend on setting. Oh, well.


----------



## Alan B (Jan 11, 2009)

Question - on the D [email protected], how important is the support of the internal ring to the switch? I notice that folks leave it out when they install KIU bases. I have been trying to keep it in for support. In my prototype it is going to have to come out (or lose some battery compartment space) due to the way I machined the Sled. I wonder how much difference it really makes, how well the cone screw locks in the dropin?

I have drilled the Sled and fitted it into the [email protected] body. Off to the hardware store for a tap for the cone screw, forgot that the other day. Then four holes to tap. Hope I don't break that 4-40 tap..

-- Alan


----------



## LuxLuthor (Jan 12, 2009)

Alan, I'm kind of in the same boat with my Fluke 179 which says it has DC-V accuracy of 0.09% and I think I would have to send it to Fluke for calibrating...although that EBay device does look nice.

The retaining ring in Mag D get's routinely tossed with all the KIU, AW's, etc. While the setscrew may not be the most secure arrangement, I have not had a problem with switch movement using the setscrew without the retaining clip.

I also have used the cone set screws and 4-40 tap which has been holding up well for quite a few threadings.


----------



## Alan B (Jan 12, 2009)

LuxLuthor said:


> Alan, I'm kind of in the same boat with my Fluke 179 which says it has DC-V accuracy of 0.09% and I think I would have to send it to Fluke for calibrating...although that EBay device does look nice.
> 
> The retaining ring in Mag D get's routinely tossed with all the KIU, AW's, etc. While the setscrew may not be the most secure arrangement, I have not had a problem with switch movement using the setscrew without the retaining clip.
> 
> I also have used the cone set screws and 4-40 tap which has been holding up well for quite a few threadings.



The 4-40 tap survived, though it did torque a bit. One question is to use US or Metric fasteners in the final [email protected]

The spec on a meter is for when it is calibrated. The calibration interval is generally one to two years. After that there is no guarantee the accuracy is in spec. It may be, or not. Checking it on a reference is a lot cheaper than periodically sending it in for recalibration. Only send it in when it needs it, which hopefully is never. 

On the [email protected], I need to lower the switch height and provide better support for the switch cover. It is installed in a [email protected] body tube, though I need to get some half inch standoffs to finish it.

-- Alan


----------



## JimmyM (Jan 12, 2009)

A little update from the Tiny84 front...
I have the the ADC read triggered in the middle of the PWM ON phase. The code Alan has in the Tiny85 reads in the very beginning. I think that the battery voltage may not have time to settle if the ADC sample and hold is taken right at the beginning. However, to complete the conversion within the ON phase, I have a little if-else to read at the PWM ON (like you do if duty drops below a certain point.

if(pwmval >0 and pwmval <100)
{ wait for PWM ON }
else
{ wait for middle of PWM }

readADC(0x82); // battery voltage
readADC(0x03); // request voltage

This way, even at low duty cycles the battery voltage ADC conversion will happen during the ON phase.

Now I'm working on doing the math.

Alan,
I've sent you an email regarding this. I can send you the code for the selective ADC read if you want, but it will only work with Phase correct PWM, not Fast PWM.


----------



## Alan B (Jan 12, 2009)

Jim,

I have codes that read the ADC at the beginning, end, randomly and a couple other ideas I tried out. The question is where is best. The middle is hard to do, while the end is pretty easy. The beginning is clearly not the best time with the transients going on there. Sometimes random turns out better than a specific time, and it is easy. It will be quite interesting when your version is working to evaluate it from a black box perspective, just how well does the regulation work. 

One problem in evaluating these methods is that the differences in many cases are quite small. So it is hard to tell (and not so important).

-- Alan


----------



## wquiles (Jan 12, 2009)

JimmyM said:


> A little update from the Tiny84 front...
> I have the the ADC read triggered in the middle of the PWM ON phase. The code Alan has in the Tiny85 reads in the very beginning. I think that the battery voltage may not have time to settle if the ADC sample and hold is taken right at the beginning. However, to complete the conversion within the ON phase, I have a little if-else to read at the PWM ON (like you do if duty drops below a certain point.
> 
> if(pwmval >0 and pwmval <100)
> ...



Great progress 

Will


----------



## JimmyM (Jan 12, 2009)

Alan B said:


> The middle is hard to do, while the end is pretty easy.
> -- Alan


Actually the middle is just as easy as the beginning.
You just wait for the TOV1 flag in the TIFR1 register. If you're using Fast PWM, this won't work. It actually happens a little after the middle, but it's darn close.

I'll have to get the math working for regulation first.
Then we'll see if it's all worth it or not.


----------



## Alan B (Jan 12, 2009)

I have not looked into that recently.

Why would the middle be better than the end? 

-- Alan


----------



## Alan B (Jan 12, 2009)

Prototype regulator is in a [email protected] D and working. Pictures up soon.

-- Alan


----------



## Alan B (Jan 12, 2009)

Pictures here:

https://www.candlepowerforums.com/posts/2784342&postcount=49

-- Alan


----------



## JimmyM (Jan 13, 2009)

Alan B said:


> I have not looked into that recently.
> 
> Why would the middle be better than the end?
> 
> -- Alan


My theory is that at the start the voltage is high due to the off cycle preceeding it. The end is the lowest the voltage will be during the ON cycle. The middle is the middle. Neither high, nor low.


----------



## Alan B (Jan 13, 2009)

JimmyM said:


> My theory is that at the start the voltage is high due to the off cycle preceeding it. The end is the lowest the voltage will be during the ON cycle. The middle is the middle. Neither high, nor low.



If the batteries are in good shape it probably doesn't matter much where it is sampled. If the batteries are sagging badly then it is probably time to shut down. 

Sampling in the middle is a fine idea. I'm not too thrilled about running the CPU at half speed to get the PWM frequency right, though.

Another way to determine sampling is to check the counter. The CPU is running adequately fast to do that. Probably takes no longer than sampling TOV1. Calculating the value to look for only has to be done once per cycle.

-- Alan


----------



## JimmyM (Jan 13, 2009)

Alan B said:


> If the batteries are in good shape it probably doesn't matter much where it is sampled. If the batteries are sagging badly then it is probably time to shut down.
> 
> Sampling in the middle is a fine idea. I'm not too thrilled about running the CPU at half speed to get the PWM frequency right, though.
> 
> ...


Once the regulation math has been worked out I'll have better data regarding speed. I've added a couple of lines of code that set another pin high when the adc conversion starts, and it sets it low when the ADC conversion ends. Both conversions start and finish within the PWM on cycle down to ~10% duty at 4MHz clock.
If I switch to 8 bit operation I can raise the clock frequency to 8MHz and change the PWM divider to get 245 Hz. So, a comparable PWM frequency is available if I want to go to 8-bit. This still uses Phase correct PWM since the dividers are different in the Tiny84.
I'll be using the high/low pin as a second input for my scope to show the timing of things. Honestly though, if the 4MHz/10-bit set up takes 2 or 3 PWM cycles... I don't care. I think it's better to have the increased resolution and wait 8 or 12 mS for a PWM duty cycle update. It would be nice to have everything I want and do it within a PWM cycle, but in reality, I think it's irrelevant. 12mS is less than a blink of an eye.
But... that's just one man's opinion. Of course I could always add a 20MHz resonator and kick things up a notch!


----------



## Alan B (Jan 13, 2009)

JimmyM said:


> Once the regulation math has been worked out I'll have better data regarding speed. I've added a couple of lines of code that set another pin high when the adc conversion starts, and it sets it low when the ADC conversion ends. Both conversions start and finish within the PWM on cycle down to ~10% duty at 4MHz clock.
> If I switch to 8 bit operation I can raise the clock frequency to 8MHz and change the PWM divider to get 245 Hz. So, a comparable PWM frequency is available if I want to go to 8-bit. This still uses Phase correct PWM since the dividers are different in the Tiny84.
> I'll be using the high/low pin as a second input for my scope to show the timing of things. Honestly though, if the 4MHz/10-bit set up takes 2 or 3 PWM cycles... I don't care. I think it's better to have the increased resolution and wait 8 or 12 mS for a PWM duty cycle update. It would be nice to have everything I want and do it within a PWM cycle, but in reality, I think it's irrelevant. 12mS is less than a blink of an eye.
> But... that's just one man's opinion. Of course I could always add a 20MHz resonator and kick things up a notch!



One thing that happens when you go fast is that you get extra resolution, eg changing 8 bit PWM every cycle is the same as 10 bit PWM adjusted every fourth cycle, since the 8 bit PWM can 'dither' producing extra resolution. This is commonly employed to increase resolution. In one iteration of my code I read the ADC up to 160 times per PWM cycle.

Try it and see. I suspect at the end of the day the differences are not visible in the light output of the flashlight. One thing we probably need to do is hook up a light sensor to the scope and look at the actual "output" intensity vs time to see what artifacts are actually there.

Jim, are you going to make another test board? Might be nice to have DIP sockets for both Tiny84 and 85 (one at a time), etc.

I looked at my PCB and fitting in a 14 DIP would be tough. Could be done, but probably would not be worth it. Even on the 85 I have more pins than I need.

I'm starting to think about the next version of the UI. I want to change a few things...

-- Alan


----------



## wquiles (Jan 13, 2009)

JimmyM said:


> Once the regulation math has been worked out I'll have better data regarding speed. I've added a couple of lines of code that set another pin high when the adc conversion starts, and it sets it low when the ADC conversion ends. Both conversions start and finish within the PWM on cycle down to ~10% duty at 4MHz clock.
> If I switch to 8 bit operation I can raise the clock frequency to 8MHz and change the PWM divider to get 245 Hz. So, a comparable PWM frequency is available if I want to go to 8-bit. This still uses Phase correct PWM since the dividers are different in the Tiny84.
> I'll be using the high/low pin as a second input for my scope to show the timing of things. Honestly though, if the 4MHz/10-bit set up takes 2 or 3 PWM cycles... I don't care. I think it's better to have the increased resolution and wait 8 or 12 mS for a PWM duty cycle update. It would be nice to have everything I want and do it within a PWM cycle, but in reality, I think it's irrelevant. 12mS is less than a blink of an eye.
> But... that's just one man's opinion. Of course I could always add a 20MHz resonator and kick things up a notch!



The other point about "speed", is the time it takes the PhD to go through the soft start period. I still propose that we try to have the soft-start last between 50-100mS, based on experience with the LVR from Willie in *js*'s M6-R, the SF A2 (LVR from Willie in there as well), and the HDM5 from AWR. What is your current goal?

Will


----------



## wquiles (Jan 13, 2009)

Alan B said:


> One thing that happens when you go fast is that you get extra resolution, eg changing 8 bit PWM every cycle is the same as 10 bit PWM adjusted every fourth cycle, since the 8 bit PWM can 'dither' producing extra resolution. This is commonly employed to increase resolution. In one iteration of my code I read the ADC up to 160 times per PWM cycle.
> 
> Try it and see. I suspect at the end of the day the differences are not visible in the light output of the flashlight. One thing we probably need to do is hook up a light sensor to the scope and look at the actual "output" intensity vs time to see what artifacts are actually there.
> 
> ...



For what is worth, I agree with you 100% on this. In fact, that was the first thing I noted when looking at your initial code several months back. I noted that you were "only" using 8-bits, until I realized that it was more than plenty for the job at hand, so I never said a thing about it - the human eye can't tell the difference at those levels 

Will


----------



## JimmyM (Jan 13, 2009)

Alan B said:


> One thing that happens when you go fast is that you get extra resolution, eg changing 8 bit PWM every cycle is the same as 10 bit PWM adjusted every fourth cycle, since the 8 bit PWM can 'dither' producing extra resolution. This is commonly employed to increase resolution. In one iteration of my code I read the ADC up to 160 times per PWM cycle.


It can. But you're waiting for the on cycle, then starting a single conversion. I can't see in you're code where you're sampling several times per cycle.


Alan B said:


> Try it and see. I suspect at the end of the day the differences are not visible in the light output of the flashlight. One thing we probably need to do is hook up a light sensor to the scope and look at the actual "output" intensity vs time to see what artifacts are actually there.


Maybe you're right, but I still want to try to use the extended bit capabilities of the Tiny84. Why are you using 8-bits instead of 6-bits? Because it's the best the Tiny85 can do. The Tiny84 can do 10-bit ADC AND PWM. If I can get it to work, all the better. Plus, I have plans for higher voltages that can benefit from 10-bit ADC.
A 40 Volt light like the Blitz would only have 0.15V resolution. If I can get 0.04V resolution, I'll take it.


Alan B said:


> Jim, are you going to make another test board? Might be nice to have DIP sockets for both Tiny84 and 85 (one at a time), etc.
> 
> I looked at my PCB and fitting in a 14 DIP would be tough. Could be done, but probably would not be worth it. Even on the 85 I have more pins than I need.
> 
> ...


I probably won't be making a new development board.


----------



## Alan B (Jan 13, 2009)

JimmyM said:


> It can. But you're waiting for the on cycle, then starting a single conversion. I can't see in you're code where you're sampling several times per cycle.
> 
> Maybe you're right, but I still want to try to use the extended bit capabilities of the Tiny84. Why are you using 8-bits instead of 6-bits? Because it's the best the Tiny85 can do. The Tiny84 can do 10-bit ADC AND PWM. If I can get it to work, all the better. Plus, I have plans for higher voltages that can benefit from 10-bit ADC.
> A 40 Volt light like the Blitz would only have 0.15V resolution. If I can get 0.04V resolution, I'll take it.
> ...



First of all, I don't want to discourage you from trying this. It is certainly interesting to test out ideas. I tried a lot of things that didn't work out as well. You have to decide what you feel is important.

On the code, I have many versions of the code. Too many to fully debug and publish. Many have been discarded.

The Tiny85 will do 10 bit ADC. I have done it. It gets noisy (the 10th bit is questionable). It slows waay down to read it properly (you must put the CPU to sleep, etc) and to do the math takes about four times longer. If you want better precision the correct way to proceed is probably to use a 12 bit external ADC.

One simple way to analyze this is to calculate what a single bit error in the ADC does to bulb power. I have a calculation here for a 24V 250W bulb. Being off in voltage by 1/256 (8 bit ADC) causes less than 2 watts of error out of 250 watts. If the ADC is scaled for twice the voltage then the least bit gets larger, so then it would be 4 watts of error.

The one advantage of more ADC bits would be if a small part of a large voltage range was being used. For example if the full voltage was 50V and only 6V were in use. Then more bits would be more important.

Engineering is about tradeoffs. Better is the enemy of good enough.

-- Alan


----------



## JimmyM (Jan 13, 2009)

Alan B said:


> First of all, I don't want to discourage you from trying this. It is certainly interesting to test out ideas. I tried a lot of things that didn't work out as well. You have to decide what you feel is important.
> 
> On the code, I have many versions of the code. Too many to fully debug and publish. Many have been discarded.
> 
> ...


I'm going to try full 10 bit with floating math and see what happens. The alternative is 8-bit the way you've done it. But I HAVE to try it.
The plus I see with 8-bit is the way you're implemented the regulation control is that dithering will kick in every pulse. So, on average, we really have 9-bit PWM.


----------



## JimmyM (Jan 13, 2009)

Tonight I worked in regulation...
I started with Alan's code and implemented something very similar in the Tiny84. First I tried using the Request Voltage ADC to calculate a voltage value between 5 and 40V based on the ADC counts, then feed that value into Alan's existing equation to convert VBULB into ADC units. I'd have to double check, but the relationship wasn't 1:1. But to get it to work, since I had to compute VreqADC-to-volts-to-VbulbADC, the code balooned to 53% of the Tiny84's 8k. But it worked. It held regulation regardless of input voltage, and the request pot was adjustable on-the-fly. So I figured... let's try using the Request ADC counts directly. The output went to 100%. But I adjusted the Request Pot and got a voltage at less than 100% duty. And it holds at that point as input voltage rises and falls.
Since I went to 8-bit PWM I was able to back to the 8MHz clock and still use Phase correct PWM. This allows me to trigger the ADC read in the middle of the pulse.
One thing though, Alan... I have to use an ADC clock of 125kHz. Between 50 and 200 kHz, per the documentation. How is it that you can use a higher ADC clock? I'm using the ADLAR bit and reading only the ADCH register, like you.


----------



## Alan B (Jan 14, 2009)

JimmyM said:


> Tonight I worked in regulation...
> I started with Alan's code and implemented something very similar in the Tiny84. First I tried using the Request Voltage ADC to calculate a voltage value between 5 and 40V based on the ADC counts, then feed that value into Alan's existing equation to convert VBULB into ADC units. I'd have to double check, but the relationship wasn't 1:1. But to get it to work, since I had to compute VreqADC-to-volts-to-VbulbADC, the code balooned to 53% of the Tiny84's 8k. But it worked. It held regulation regardless of input voltage, and the request pot was adjustable on-the-fly. So I figured... let's try using the Request ADC counts directly. The output went to 100%. But I adjusted the Request Pot and got a voltage at less than 100% duty. And it holds at that point as input voltage rises and falls.
> Since I went to 8-bit PWM I was able to back to the 8MHz clock and still use Phase correct PWM. This allows me to trigger the ADC read in the middle of the pulse.
> One thing though, Alan... I have to use an ADC clock of 125kHz. Between 50 and 200 kHz, per the documentation. How is it that you can use a higher ADC clock? I'm using the ADLAR bit and reading only the ADCH register, like you.



The Tiny85 documentation says that at 8 bits the clock rate can be up to 1 mhz. Probably don't need to go that fast, was trying many readings per PWM cycle when I sped that up. As slow as you can is probably best for the ADC. I should make that a tunable parameter rather than fixing it so it could be tested more easily.

-- Alan


----------



## Alan B (Jan 14, 2009)

JimmyM said:


> Tonight I worked in regulation...
> I started with Alan's code and implemented something very similar in the Tiny84. First I tried using the Request Voltage ADC to calculate a voltage value between 5 and 40V based on the ADC counts, then feed that value into...



I just wanted to add that I'm impressed with the progress Jim is making in this project, first the hardware and now the software. I know it is a major step, and a significant investment in time and funds.

Will has also committed significant effort and funds toward these projects.

Both of them deserve recognition.

Good Work! :thumbsup:

-- Alan


----------



## JimmyM (Jan 14, 2009)

Alan B said:


> The Tiny85 documentation says that at 8 bits the clock rate can be up to 1 mhz. Probably don't need to go that fast, was trying many readings per PWM cycle when I sped that up. As slow as you can is probably best for the ADC. I should make that a tunable parameter rather than fixing it so it could be tested more easily.
> 
> -- Alan


I need to experiment a little. When I went to 250kHz things went funny, but that was using 10-bit. Also, I'm using a 330K upper resistor. At higher frequencies the S&H cap may not charge fully, but then again, that was all at 10-bits. I'm going to try changing dividers with the 8 bit settings and see what happens. I don't know what I'm worrying about, down to ~9% duty, I can do both ADC conversions (both complete) within the PWM on phase when triggering at TOV1. At that point I switch to triggering the adc at the PWM on edge.
I'll fiddle with ADC clocks a bit tomorrow, but then it's on to implementing 10-bit stuff. This should be interesting.
I'll try using 8-bit ADC with 9 or 10-bit PWM just for giggles.
Maybe I'll try using 10-bit ADC with 10-bit PWM.
I'll figure something out that will make the code size explode again.
Right now I'm using 2% of the data space on the Tiny84. When the code size blew up, it went to 53%. Good LORD! long math takes up space. Everything still got triggered within the PWM period though.


----------



## JimmyM (Jan 14, 2009)

Alan B said:


> I just wanted to add that I'm impressed with the progress Jim is making in this project, first the hardware and now the software. I know it is a major step, and a significant investment in time and funds.
> 
> Will has also committed significant effort and funds toward these projects.
> 
> ...


Thanks, Alan. Much appreciated. You have made me a convert. I love AVRs now. I'm just thinking about things I've done in the past that would have been more easily and better done with an AVR. That Tiny13A looks real cute. <1mA @ 1.8V @ <1MHz. I've done lots of stuff in the past that could have used some logic, but didn't necessessarily need speed.
Now I have to work on interrupts and debouncing.


----------



## JimmyM (Jan 14, 2009)

Ever on the lookout for a neat bit to make a project possible, better, smaller, more flexible. I have found a tiny linear regulator to run our AVRs. When I say tiny I mean teeny tiny.
It's rated for 40Vin (45V max), guaranteed 50mA output, 90uA quiescent current under full load.
It's an SMD device really only suitable for reflow soldering, but it's 3mm square and 0.8mm high. This could find it's way onto a regulator for a C cell Mag.
This combined with the FDD8444 FET would yield a regulator capable up to 40V (pending testing at high voltages and currents). I'll be doing that later.


----------



## wquiles (Jan 14, 2009)

Alan B said:


> I just wanted to add that I'm impressed with the progress Jim is making in this project, first the hardware and now the software. I know it is a major step, and a significant investment in time and funds.
> 
> Will has also committed significant effort and funds toward these projects.
> 
> ...



Thanks much Alan, but it was "you" who got both Jim and I started, so thanks much to you for your helping hand and your willingness to help/answer our questions :twothumbs

Will


----------



## Alan B (Jan 14, 2009)

JimmyM said:


> Ever on the lookout for a neat bit to make a project possible, better, smaller, more flexible. I have found a tiny linear regulator to run our AVRs. When I say tiny I mean teeny tiny.
> It's rated for 40Vin (45V max), guaranteed 50mA output, 90uA quiescent current under full load.
> It's an SMD device really only suitable for reflow soldering, but it's 3mm square and 0.8mm high. This could find it's way onto a regulator for a C cell Mag.
> This combined with the FDD8444 FET would yield a regulator capable up to 40V (pending testing at high voltages and currents). I'll be doing that later.



Have to get a stereo microscope to work on those.

-- Alan


----------



## JimmyM (Jan 14, 2009)

Alan B said:


> Have to get a stereo microscope to work on those.
> 
> -- Alan


Yeah. No kidding! But sometimes you gotta go SMALL.
I'm really hot on the idea of a C cell regulator now. I've got a 23mm diameter round board that has everything needed on one side. There's even room for 2 standoffs. The onboard (SC-70 package) 5V regulator can ony handle 24V. This little baby will push that to 40V. I got samples from Maxim. They are tiny.
I'm going to have to get a toaster oven to do the reflow.

I'd like to run some ideas past you, machine-shop-wise, after the dust has settled from your Mag-Sled.


----------



## Alan B (Jan 14, 2009)

JimmyM said:


> Yeah. No kidding! But sometimes you gotta go SMALL.
> I'm really hot on the idea of a C cell regulator now. I've got a 23mm diameter round board that has everything needed on one side. There's even room for 2 standoffs. The onboard (SC-70 package) 5V regulator can ony handle 24V. This little baby will push that to 40V. I got samples from Maxim. They are tiny.
> I'm going to have to get a toaster oven to do the reflow.
> 
> I'd like to run some ideas past you, machine-shop-wise, after the dust has settled from your Mag-Sled.



Sure. There is a lot of interest in the C [email protected]

-- Alan


----------



## Alan B (Jan 15, 2009)

*Bulb Inductive Kickback*

The FET is likely robust enough to handle this kick. It has avalanche energy ratings that can be checked. I'm not too worried about that.

The other component at risk is the voltage regulator. It is somewhat protected by the avalanche voltage of the FET, but that is not enough. The regulator is further protected by the series R (Jim's suggestion) and the input side bypass capacitor. We can even adjust those values a bit to improve protection if needed.

Will and Jim, you made some measurements of the duration and voltage of this kick. What were those values? I'd like to do some calculations with those and see what the regulator's risks are and if anything needs to be adjusted.

Thanks, 

-- Alan


----------



## JimmyM (Jan 15, 2009)

Alan B said:


> *Bulb Inductive Kickback*
> 
> Will and Jim, you made some measurements of the duration and voltage of this kick. What were those values? I'd like to do some calculations with those and see what the regulator's risks are and if anything needs to be adjusted.
> 
> ...


My testing showed a duration of about 1 uS.


----------



## Alan B (Jan 15, 2009)

JimmyM said:


> My testing showed a duration of about 1 uS.



The time constant of the regulator input is longer than 3 uS. It would be interesting if you measured the spike at the input of the regulator directly. It should be pretty small there.

We may not have a problem at all. We could also go up 10x on the capacitor pretty easily...

Knowing all this will help us to set the voltage rating. Hopefully we can get to 8S (33.6V) on 40V parts...

-- Alan


----------



## JimmyM (Jan 15, 2009)

Alan B said:


> The time constant of the regulator input is longer than 3 uS. It would be interesting if you measured the spike at the input of the regulator directly. It should be pretty small there.
> 
> We may not have a problem at all. We could also go up 10x on the capacitor pretty easily...
> 
> ...


When I figure out my 10-bit dilemma, I'll pull out the PhD proto board and take some measurments.
But since the supply for the linear regulator is before the bulb, the "spike" would be a negative spike, not positive. The inductive kick of the bulb can't be raising voltage on both sides of the bulb.


----------



## wquiles (Jan 15, 2009)

Alan B said:


> *Bulb Inductive Kickback*
> 
> Will and Jim, you made some measurements of the duration and voltage of this kick. What were those values? I'd like to do some calculations with those and see what the regulator's risks are and if anything needs to be adjusted.
> 
> ...



I also saw approx. a 1uS duration on the pulses.

In posts #39 and #58 I have lots of screen captures of the "evil" inductive kickback. That was back when I was trying diodes and different values to see if I could bring it down:
https://www.candlepowerforums.com/threads/209098&page=2

I saw these in my initial Radio Shack board, but saw them again with Jim's development board. I also saw them with both the power supply and with the 3x LiIon 18650 pack 

Will


----------



## Alan B (Jan 16, 2009)

JimmyM said:


> ...
> But since the supply for the linear regulator is before the bulb, the "spike" would be a negative spike, not positive. The inductive kick of the bulb can't be raising voltage on both sides of the bulb.



It appears to be raising battery+.

This effect is actually pretty interesting (and Will made great pictures). It generates a positive transient on the battery plus, and then a little later as the FET impedance increases it generates a positive transient on the FET.

In any case it appears to be safe for both the FET and the regulator. I would like to see the waveform on the regulator supply pin just to see if it fits expectations, it should be a lot less than the battery+ transient.

-- Alan


----------



## JimmyM (Jan 16, 2009)

Alan B said:


> It appears to be raising battery+.
> 
> This effect is actually pretty interesting (and Will made great pictures). It generates a positive transient on the battery plus, and then a little later as the FET impedance increases it generates a positive transient on the FET.
> 
> ...


Are your measurements being taken via battery or power supply? I can see a power supply having a transiernt overshoot when load is suddenly removed.
Would a battery do the same?


----------



## Alan B (Jan 16, 2009)

JimmyM said:


> Are your measurements being taken via battery or power supply? I can see a power supply having a transiernt overshoot when load is suddenly removed.
> Would a battery do the same?



Will's measurements showed it both ways.

It seems to make sense. The collapsing field in the filament tries to replace the disappearing current flow, acting as a power source. Initially the FET's impedance is much lower than the batteries, so the voltage resulting from this current appears as a transient driving the battery plus upwards. Then as the FET impedance starts to get higher (and the output capacitance of the FET becomes charged) the voltage shifts to the FET. As the energy in the field dissipates the FET transient dies out. So it makes two transients, first at the battery plus, then at the FET plus.

-- Alan


----------



## JimmyM (Jan 16, 2009)

I've got it! (Actually WE'VE got it. Alan explained some of his code for the 8-bit version to me last night, and I've got it working. 10-bit ADCs (averages 4 readings for Vbat to reduce noise). Request voltage ADC is very quiet, so I'm just taking 1 sample. Preliminary testing shows that an ADC frequency of 250kHz isn't a problem. results at 125kHz match those of 250kHz.
I'm reading the battery voltage midway through the PWM on cycle, unless the duty falls too low (<10%), then I read at the beginning of the cycle so that Vbat readings are taken during the ON phase.
An adjustable rate soft start. It works fantastically. Also, with Alan's tip regarding "quick" division, the code size for all this is only Program 8.2% Full), Data 5.1% Full). This is AWESOME.
The regulation is stellar. it holds regulation within a hundredth of a volt sweeping from 20V down to 10V Vbat with a set point of 8.64. Actually, it rarely wanders from 8.64.


----------



## wquiles (Jan 16, 2009)

AWESOME - great news dude :thumbsup:

Using the Tiny84 and its small package is now a complete reality for both of our projects, thanks to you and Alan's great efforts 

Will


----------



## Alan B (Jan 16, 2009)

JimmyM said:


> I've got it! (Actually WE"VE got ot. Alan explained some of his code for the 8-bit version to me last night, and I've got it working. 10-bit ADCs (averages 4 readings for Vbat to reduce noise). Request voltage ADC is very quiet, so I'm just taking 1 sample. Preliminary testing shows that an ADC frequency of 250kHz isn't a problem. results at 125kHz match those of 250kHz.
> I'm reading the battery voltage midway through the PWM on cycle, unless the duty falls too low (<10%), then I read at the beginning of the cycle so that Vbat readings are taken during the ON phase.
> An adjustable rate soft start. It works fantastically. Also, with Alan's tip regarding "quick" division, the code size for all this is only Program8.2% Full), Data5.1% Full). This is AWESOME.
> The regulation is stellar. it holds regulation within a hundredth of a volt sweeping from 20V down to 10V Vbat with a set point of 8.64. Actually, it rarely wanders from 8.64.



Excellent. Good codesize. Wonder why the data size is so large. Not much data in that code.

-- Alan


----------



## Alan B (Jan 16, 2009)

So the Fluke 179 does the RMS right, as I recall? Is that the "one to get"??

Thanks, Alan


----------



## donn_ (Jan 16, 2009)

Yes it does:


----------



## Alan B (Jan 16, 2009)

This project has sure gotten expensive.

-- Alan


----------



## LED_astray (Jan 16, 2009)

Alan B said:


> So the Fluke 179 does the RMS right, as I recall? Is that the "one to get"??
> 
> Thanks, Alan



The Fluke 115 does "True RMS". It, or similar models from the 114-117 family, go on sale for $115-120 at Fry's periodically. IIRC- the 179 is much more than that.

If I ever knew, I've forgotten the subtleties of RMS measurements. From earlier discussions in this thread, I learned the "crest factor" is important measuring PWM values. At that time I looked up the 115 and it was about twice the values of the better meters you, JimmyM, or wquiles were using. (6, not 3?) At that time I understood measurements at the very narrow pulse end wouldn't be accurate....


----------



## wquiles (Jan 16, 2009)

donn_ said:


> Yes it does:





LED_astray said:


> The Fluke 115 does "True RMS". It, or similar models from the 114-117 family, go on sale for $115-120 at Fry's periodically. IIRC- the 179 is much more than that.
> 
> If I ever knew, I've forgotten the subtleties of RMS measurements. From earlier discussions in this thread, I learned the "crest factor" is important measuring PWM values. At that time I looked up the 115 and it was about twice the values of the better meters you, JimmyM, or wquiles were using. (6, not 3?) At that time I understood measurements at the very narrow pulse end wouldn't be accurate....





Actually, we have to be careful here. Almost all Flukes will give you an RMS reading and are called true RMS meeters. The problem is that they can't read the RMS value of a signal that is not at 50% duty cycle (in other words, these meters will only read Vrms accurately on a 60Hz AC signal or similar). For the varying duty cycle that we have here with PWM, you need a "special" RMS meter, such as the Fluke 189, which has a special "AC+DC" mode that "can" accurately read Vrms on our PWM signal. Even then, we are limited by the ratio of the ON/OFF cycles, so not even my Fluke 189 will read values properly for when the PWM was in the few percent (I have shown in this thread this problem where the first, second voltage step is not accurate, but all other ones are).

Here in this pic you can clearly see my Fluke 189 in this special AC+DC mode:






Will


----------



## Alan B (Jan 16, 2009)

Anyone know if the Fluke 179 works correctly on this? I thought Jim was using one.

The 189 is sure a nice meter. Will has all the good toys! (I mean TOOLS).

-- Alan


----------



## JimmyM (Jan 16, 2009)

Alan B said:


> Anyone know if the Fluke 179 works correctly on this? I thought Jim was using one.
> 
> The 189 is sure a nice meter. Will has all the good toys! (I mean TOOLS).
> 
> -- Alan


I have the 189. But the 179 is it's little brother. The 189 just has data logging capabilities built in.
They've discontinued the 189. Not sure about the 179. I see a few on eBay.
The new 189 replacements models are the 287/289. Full graphic display, very expensive.
Head over to eBay and grab a 179.


----------



## Alan B (Jan 16, 2009)

JimmyM said:


> I have the 189. But the 179 is it's little brother. The 189 just has data logging capabilities built in.
> They've discontinued the 189. Not sure about the 179. I see a few on eBay.
> The new 189 replacements models are the 287/289. Full graphic display, very expensive.
> Head over to eBay and grab a 179.



Does the 179 read out the PWM correctly and accurately then? Has it been tested in this use?? LuxLuthor seemed to have issues with his in this use.

Thanks,

-- Alan


----------



## JimmyM (Jan 16, 2009)

Alan B said:


> Excellent. Good codesize. Wonder why the data size is so large. Not much data in that code.
> 
> -- Alan


Probably because I'm using uint32_t data types? I thought it was quite tidy. When I was trying to use floats, it balooned to 53%!
The relatively small code size will allow me to use the Tiny24 for many designs. It will still allow for future code expansion.
Although I don't have any interface for the design I'm working on, I'd love to get a peek at the code for your interface. I've been doing a lot of reading about debouncing. But much of the debouncing insanity can be solved by the use of a snap action switch. Like the tactile feedback switches you're using. Their bouncing time is very short from what I've read.
I think I'll be working on a real interface for the Lantern style lights. LED feedback, up/down rockers, lots of stuff. I found the neatest thing today. ScreenKeys! RGB backlit, graphical display, pushbutton. They're $50 each, but think of the stuff you could do!!! Your low battery warning could flash it red with a neat icon. Or select modes before turning the light on. It could display state of charge for each of the cells while charging.
It's really too much to think about now, but ooooo to dream.


----------



## JimmyM (Jan 16, 2009)

Alan B said:


> Does the 179 read out the PWM correctly and accurately then? Has it been tested in this use?? LuxLuthor seemed to have issues with his in this use.
> 
> Thanks,
> 
> -- Alan


I'm not sure. Let's get Lux in here. All I can do is tell you about my 189.


----------



## Alan B (Jan 16, 2009)

JimmyM said:


> Probably because I'm using uint32_t data types? I thought it was quite tidy. When I was trying to use floats, it balooned to 53%!
> The relatively small code size will allow me to use the Tiny24 for many designs. It will still allow for future code expansion.
> Although I don't have any interface for the design I'm working on, I'd love to get a peek at the code for your interface. I've been doing a lot of reading about debouncing. But much of the debouncing insanity can be solved by the use of a snap action switch. Like the tactile feedback switches you're using. Their bouncing time is very short from what I've read.
> I think I'll be working on a real interface for the Lantern style lights. LED feedback, up/down rockers, lots of stuff. I found the neatest thing today. ScreenKeys! RGB backlit, graphical display, pushbutton. They're $50 each, but think of the stuff you could do!!! Your low battery warning could flash it red with a neat icon. Or select modes before turning the light on. It could display state of charge for each of the cells while charging.
> It's really too much to think about now, but ooooo to dream.



You might run out of data space on the small chip, it also shrinks by 4x as I recall.

One thing that should help is to declare different variables different sizes. Very few need to be 32 bit.

Also, there is a special float library for the AVR that is much smaller, so make sure you put that into the library path. You may find that AVR floats are similar to or even smaller than 32 bit ints. Using the right size helps a lot too. When you mix them the compiler converts to the larger type. Values that don't need to be over 255 can be unsigned bytes, and almost everything else can be 16 bit, aside from the product/sum values that need to be 32 bit.

I have heard about LCD pushbuttons. Very neat.

The next thing I'm going to do on the interface is to add "blink" for the low voltage cutout. It goes off for a short time and returns at a lower power level. If the battery can handle that it stays on, if voltage gets too low it blinks again, lowering the level again etc.

I think I'll get a Fluke 189, they are still available new and it appears to be a good choice. Wonder if anyone has used the IR interface. Might be handy. I need to set up the calibration process to be easy for my son or daughter to do so I can farm out some of the work.

I do have pushbutton debounce in the code. Isn't it in FP9? I have done it several ways, but basically the buttons have to be pushed for several passes through the loop before they react.

-- Alan


----------



## JimmyM (Jan 16, 2009)

Alan B said:


> You might run out of data space on the small chip, it also shrinks by 4x as I recall.


8.2% + 5.1% = 13.3% of 8K, that would be ~= 53.2% of 2K. For some designs, that 46% remaining is plenty. There's always the Tiny44.

What's your code up to?



Alan B said:


> One thing that should help is to declare different variables different sizes. Very few need to be 32 bit.
> 
> Also, there is a special float library for the AVR that is much smaller, so make sure you put that into the library path. You may find that AVR floats are similar to or even smaller than 32 bit ints. Using the right size helps a lot too. When you mix them the compiler converts to the larger type. Values that don't need to be over 255 can be unsigned bytes, and almost everything else can be 16 bit, aside from the product/sum values that need to be 32 bit.


I didn't need to use floats, thanks to that divide by 1024 trick, but that library is good to know about. I'll take a look at using the "minimum" variable type sizees to keep things trim. I only use 2 uint32_t variables. For the squared 10-bit values.


Alan B said:


> I have heard about LCD pushbuttons. Very neat.
> 
> The next thing I'm going to do on the interface is to add "blink" for the low voltage cutout. It goes off for a short time and returns at a lower power level. If the battery can handle that it stays on, if voltage gets too low it blinks again, lowering the level again etc.
> 
> I think I'll get a Fluke 189, they are still available new and it appears to be a good choice. Wonder if anyone has used the IR interface. Might be handy. I need to set up the calibration process to be easy for my son or daughter to do so I can farm out some of the work.


You can't go wrong with the 189. Great meter.
I've used the IR interface to connect to my PC. The 189 kit I bought had the FlukeView Forms software, the extended battery pack, test leads, case, etc. I like the extended battery pack. 4 C cells. Great run time for a bench used meter. I would like to get some more test leads though. I'd also like to get another one, or a 287. This IS an expensive hobby.


Alan B said:


> I do have pushbutton debounce in the code. Isn't it in FP9? I have done it several ways, but basically the buttons have to be pushed for several passes through the loop before they react.
> 
> -- Alan


I was wondering if you had begun using a different style or using interrupts, what have you.


----------



## JimmyM (Jan 16, 2009)

WinAVR has a "new" release. 12052008. I had been using the from June.


----------



## Alan B (Jan 16, 2009)

JimmyM said:


> 8.2% + 5.1% = 13.3% of 8K, that would be ~= 53.2% of 2K. For some designs, that 46% remaining is plenty. There's always the Tiny44.
> 
> What's your code up to?
> 
> ...



The size of my code is all over the map depending on the options turned on. With almost everything on it is about 50-60% of the Tiny25. I need to do some thinning on it, though, it is a bit pudgy. That includes low power, ramping UI, low voltage blink, overtemperature, etc.

The 189 is on order.

I think the only interrupt I'm using is for the low power shutdown wakeup. It looks like FP9 with extra sections added, various junk that I tried and have not thrown away yet, etc. Too many options and too much old code. When I publish a new version I strip it down as much as I can otherwise it would be totally confusing. Right now I'm changing the UI a bit so there is more redundant code in there than usual.

-- Alan


----------



## Alan B (Jan 16, 2009)

JimmyM said:


> WinAVR has a "new" release. 12052008. I had been using the from June.



Anything important change?

Last thing I need right now is to break it. I'm taking it to the San Jose CPF gathering tomorrow, so don't want to break it right now.

-- Alan


----------



## JimmyM (Jan 16, 2009)

Alan B said:


> Anything important change?
> 
> Last thing I need right now is to break it. I'm taking it to the San Jose CPF gathering tomorrow, so don't want to break it right now.
> 
> -- Alan


It installs itself into a new directory and adds the path to the Windows PATH. That's how AVRStudio finds it. If something goes screwy, just change your Windows PATH and AVRStudio will use the older version. I've been using it today with no problems.


----------



## LED_astray (Jan 16, 2009)

wquiles said:


> Actually, we have to be careful here. Almost all Flukes will give you an RMS reading and are called true RMS meeters. The problem is that they can't read the RMS value of a signal that is not at 50% duty cycle (in other words, these meters will only read Vrms accurately on a 60Hz AC signal or similar). For the varying duty cycle that we have here with PWM, you need a "special" RMS meter, such as the Fluke 189, which has a special "AC+DC" mode that "can" accurately read Vrms on our PWM signal. Even then, we are limited by the ratio of the ON/OFF cycles, so not even my Fluke 189 will read values properly for when the PWM was in the few percent (I have shown in this thread this problem where the first, second voltage step is not accurate, but all other ones are)....



Do any of you know the "keyword" Fluke uses for this feature?

I just went to the Fluke site and, other than accuracy I don't see any difference between the 179 & the 115 for basic measurements. (They do have slightly different feature lists.) The 189 isn't listed.

Ah, I may have figured out what to search for. The 289 says it can measure RMS for "AC+DC". The others say only "AC". (Hence the 179 probably can't measure what you're talking about.)

Yuck, I can't rationally justify the money I spent on the 115 for the little use I get from it....


----------



## Alan B (Jan 16, 2009)

LED_astray said:


> Do any of you know the "keyword" Fluke uses for this feature?
> 
> I just went to the Fluke site and, other than accuracy I don't see any difference between the 179 & the 115 for basic measurements. (They do have slightly different feature lists.) The 189 isn't listed.
> 
> ...



Will's earlier photos clearly show the AC+DC RMS mode for this measurement.

Measuring average and doing a calculation works as long as the waveform is square (no drooping, etc). So unloaded (without bulb) you can get good readings with most any DC DMM. I wanted the true RMS for testing and calibrating a number of regulators, but folks don't really need to have that.

-- Alan


----------



## wquiles (Jan 16, 2009)

LED_astray said:


> Do any of you know the "keyword" Fluke uses for this feature?
> 
> I just went to the Fluke site and, other than accuracy I don't see any difference between the 179 & the 115 for basic measurements. (They do have slightly different feature lists.) The 189 isn't listed.
> 
> ...



That is it: the "AC+DC" is the key feature that you need to directly measure the Vrms on the PWM signal from the PhD. Without it, you can't directly measure it. 

Now, please note that you can calculate the Vrms value by using a normal RMS meter by following Willie Hunt's explanation:


text provided by Willie Hunt:
**********************
THIS IS THE ROOT OF YOUR PROBLEM:

> I'm using a cheap DVM to measure voltage at the load. 
> With the dummy load reading 2.85 volts, when I substituted a 6 watt 6 
> volt bulb instead, the bulb burned brighly briefly, then blew out. I 
> did not have a chance to read the bulb voltage... I was hooking up the 
> volt meter as the bulb blew. 

> Am I measuring things improperly? Why is the measured voltage 
> varying so very much with variation of input voltage that SHOULD be 
> within the range of the regulator circuit?

Think about what you are measuring and what your DVM does. You are
measuring a PWM rectangular waveform with a meter that gives you the
average DC voltage component. Now, think about what the bulb does.
It is averaging the power waveform, which is proportional to the DC
coupled true RMS. Even I don't have a DC coupled true RMS voltmeter,
thus I set all the regulators using the duty cycle measurement on my
Tek 2440 scope. I assumed that you would understand true RMS
concepts, and thus know how to set the duty cycle. Sorry, I often
assume too much.


Here's a bit of math:

t=end
/
DVM average = | v dt
/
t=0
t=end
/
DC coupled true RMS = square root( | v^2 dt )
/
t=0

t=end
/
Bulb power = | v * i dt
/
t=0

given that the waveform switches fast enough we can use the average
bulb resistance R because it changes so little over the cycle:

t=end
/
Bulb power = | v^2 / R dt
/
t=0

Thus

Bulb power = (DC coupled true RMS)^2 / R

That's why RMS is useful.

Let's take the 25% duty cycle at 12 volt in for example:

DVM average = 25% of 12 volts = 3 volts

True RMS = sqrt( 25% of 12^2 ) = sqrt( 0.25 * 144 ) = 6 volts

Assuming a 6 volt, 1 amp, thus 6 ohm bulb we get:

V = iR thus 12 = i * 6 so i = 2

Bulb power = 25% of v * i = 0.25 * 12 * 2 = 6 watts

notice that the peak power (v*i) is 24 watts!

Also, bulb power = RMS^2 / R = 6^2/6 = 6 watts.




Isn't math great! 

So, the moral of this story is that the DVM is useless for measuring
the output directly. However, if you know that your DVM averages
correctly you can use it on the input, and the ouput and then
calculate the RMS voltage as sqrt( input * output), because you know
the shape of the waveform. This sqrt( in * out) will lose accuracy if
the voltage source sags, because the average input voltage will
measure higher than the peak bulb voltage when the bulb is on.
Alkaline batteries sags greatly, whereas NiCad's sags little, but only
a "stiff" bench lab supply will provide accurate results.

Willie

**********************


----------



## LED_astray (Jan 16, 2009)

Thanks, I'm starting to understand (I think.)

Froogle suggests any Fluke with that capability runs around $500. That's a little disappointing. (I guess I'll be buying programmed switches or doing math. Maybe both.)


----------



## Alan B (Jan 16, 2009)

LED_astray said:


> Thanks, I'm starting to understand (I think.)
> 
> Froogle suggests any Fluke with that capability runs around $500. That's a little disappointing. (I guess I'll be buying programmed switches or doing math. Maybe both.)



New Fluke 189's on eBay are under $300.

There are other ways to calibrate as well. If you have a variable supply and a scope or logic probe or AC meter or even a capacitor coupled LED you can see when the regulator transitions from PWM to DC as you adjust the DC supply, which it does right at the point the DC value equals the RMS value. So a variable supply is a replacement for an AC+DC RMS meter.

-- Alan


----------



## LuxLuthor (Jan 17, 2009)

Yes, this is true about the 179 not having this "AC+DC" capability. Will, I have read your quote from Willie Hunt, but I'm not 100% sure how his


> calculate the RMS voltage as sqrt( input * output)


 should be used to deal with this Fluke 179 as it applies to PWM settings.

I think working this out will benefit a number of others, so if you don't mind can you use the numbers I got from my question Alan referred to in post #276 of this thread? It referenced my observations in this thread (attention to my dark red readings). It related to Fluke 179 RMS measurements of AW's multilevel D Driver (30/60/100% duty cycle) at bipin holes with & without bulb.

I didn't understand Alan's answer, and I didn't want to look stupid, so I just "let it be."  I followed his advice in post #277 but nothing made sense to me. 

Alan's Post #277 *PWM 30% Low Setting:*10.97V x sqrt(0.3)
10.97V x .548 = *6.01V *​*PWM 60% Med Setting:*10.97V x sqrt(0.6) = *8.5V*​====================================

If I try to use Willie Hunt's formula starting with Vbat=12.42V
*PWM 30% Low Setting:*sqrt(12.42V x 3.88V)
sqrt(48.19)
*6.94V*​*PWM 60% Med Setting:*sqrt(12.42V x 6.79V)
sqrt(84.33)
*9.18V*​*PWM 100% High Setting:*sqrt(12.42V x 10.97V)
sqrt(136.25)
*11.67V*​I'm not sure what I am supposed to be figuring out with both methods. Be gentile. 

Alan, I do have a variable PS. Can you explain more clearly what you meant in your last post about what/how to use it?


----------



## Alan B (Jan 17, 2009)

My apologies for not being clear, LuxLuthor.

I would suggest NOT using the RMS mode of a meter that does not have AC+DC RMS. It is just too confusing to figure out what the results mean. Measuring the output of a PWM regulator with no load or too much load also creates measurement problems and should be avoided.

*Using an Averaging Meter*

For the averaging meter method to work the waveform must not sag in voltage. It must be clean and consist of two instantaneous values, zero and the supply voltage with a quick clean transition in between. This requires the load to be light and/or the power source to be stiff. The best way to accomplish this is to use a resistor and avoid drawing a lot of power so the batteries/power supply don't sag or overshoot. A 1K resistor and a reasonably stiff battery or power supply should work well. The power supply voltage must be greater than the desired RMS voltage. Then the following relationships hold:

/* Formulae (from the source code)
*
* 1) VbattDC^2 * Duty_cycle = VbulbRMS^2
*
* 2) VbulbRMS = VbattDC * sqrt(Duty_cycle)
*
* 3) Duty_cycle = VbulbRMS^2 / VbattDC^2
*
* 4) VbulbMEAN = VbattDC * Duty_cycle
*
* 5) VbulbRMS = sqrt(VbattDC * VbulbMEAN)
*
* 6) VbulbMEAN = VbulbRMS^2 / VbattDC
*/

Equations 5 and 6 are the most useful and allow one to calculate what the RMS is based on an average measurement (5), or what the average should be to get a desired RMS (6). Mean is the technical term for average.

*Using a Variable Power Supply*

When the power supply voltage drops below the desired RMS output voltage the PWM will stop and the output will become DC as the system drops out of regulation and becomes direct drive. So if you adjust the power supply carefully to this transition point then the DC voltage equals the RMS voltage. Set your meter on AC reading the output. When PWM starts the AC meter will jump way up to volts of AC. Adjust the supply down just to the point that the AC reading drops to near zero, so PWM has just stopped. The supply will then be just below the RMS value and you can switch to DC and read it. If you want to set for a certain RMS value start by setting the power supply there with the DC meter, and then adjust the regulator until it is just at the edge of starting PWM switching at that supply voltage.

-- Alan


----------



## wquiles (Jan 17, 2009)

LuxLuthor said:


> Yes, this is true about the 179 not having this "AC+DC" capability. Will, I have read your quote from Willie Hunt, but I'm not 100% sure how his should be used to deal with this Fluke 179 as it applies to PWM settings.
> 
> I think working this out will benefit a number of others, so if you don't mind can you use the numbers I got from my question Alan referred to in post #276 of this thread? It referenced my observations in this thread (attention to my dark red readings). It related to Fluke 179 RMS measurements of AW's multilevel D Driver (30/60/100% duty cycle) at bipin holes with & without bulb.
> 
> ...



Lux,

Here in post #1, you can see me following Willie's steps while using a standard RMS meter (I did not have my AC+DC Fluke until 2 years later). Look at the yellow stickie notes - I am recording the two voltages per Willie, and then calculating the equivalent "true" RMS value:
http://candlepowerforums.com/vb/showthread.php?t=125451


First using a 100 Ohm load:








And then using the actual MN15 bulb. Note how the my Fluke 87 with "true RMS" gives you the wrong value of 4.72 volts, when the real value is about 7.4 volts!:







Will


----------



## LuxLuthor (Jan 17, 2009)

LOL! I just went from being optimistically stupid to hopelessly befuddled. I'm going to go take my dog for a walk and come back later, read your two responses again and M6-R LVR3i thread until I at least understand where I am lost. 

Is it possible to use my practical measurements from that Mag 1331 to make sense of this, or are you saying that other thread's measurements are totally worthless ? I'm trying to bridge the theoretical to the practical that I understand thus far...so my thinking is stuck in that example.


----------



## Alan B (Jan 18, 2009)

LuxLuthor said:


> LOL! I just went from being optimistically stupid to hopelessly befuddled. I'm going to go take my dog for a walk and come back later, read your two responses again and M6-R LVR3i thread until I at least understand where I am lost.
> 
> Is it possible to use my practical measurements from that Mag 1331 to make sense of this, or are you saying that other thread's measurements are totally worthless ? I'm trying to bridge the theoretical to the practical that I understand thus far...so my thinking is stuck in that example.



My apologies LuxLuthor, I was probably answering the wrong question. I was answering "how to do it" rather than "how to interpret these results".

I suspect the Fluke 179 and other AC RMS meters are measuring the RMS value of the AC coupled waveform. So rather than a sequence of values of either 0 or +Battery they are getting +something and -something where the difference between the readings is battery voltage. They then square each of those values, add them up, divide by the number of values (mean) and take the square root of that. What they are missing then is the DC average voltage that was blocked by the capacitor. So perhaps if you measure the AC RMS and the DC Mean (average) and add them together that might be the AC+DC RMS answer that we are looking for.

I do not think we can do it from the AC RMS reading alone, because the DC blocking capacitor has discarded data, so we don't have all the information. We could possibly calculate what the DC Mean should have been and try using that together with your measurements and see if that works.

-- Alan


----------



## JimmyM (Jan 18, 2009)

Alan, I was looking more closely at your Tiny85 code. Specifically, how you implemented PWM. Why did you choose to use !OC1B? If you used OC0A, you would still have been able to get 245 Hz at 8MHz clock.
Just curious.


----------



## Alan B (Jan 18, 2009)

JimmyM said:


> Alan, I was looking more closely at your Tiny85 code. Specifically, how you implemented PWM. Why did you choose to use !OC1B? If you used OC0A, you would still have been able to get 245 Hz at 8MHz clock.
> Just curious.



It has been some time since I did those tradeoffs, but as I recall the pin I chose was the only one that could do PWM that was NOT part of the ISP. I did not want to blow bulbs while programming. Also I wanted an open pin for the ADC so I would not have voltage dividers on the ISP jack. So I had some constraints to work with. The larger pin count part has more options but is harder to solder. 

Last night at the CPF San Jose gathering I met Wayne who makes LED regulators. He told me how he solders those parts. I don't want to delay my project, but someday I'll get set up for it. The first thing you should get (if you don't already have one) is a stereo microscope. It is vital to be able to clearly see what you are doing otherwise the results are random.

It would be good to review the pinout again, I suppose. It is not too late yet to change it, but as I recall there were constraints that nailed just about every pin. And clearly the pins can be made to work the way they are chosen.

The present code is getting 245hz PWM at 8 mhz clock. As for center detection of the voltage during the PWM cycle, I can do that but have not coded it. I did code some time back a setup that samples all the way through the PWM cycle, well over 100 samples per cycle as I recall. That should be the most accurate, but until I get a good meter and really wring it out I won't know how much difference it really makes. Many of these "improvements" are not worth their complexity, but it is interesting to try them.

Incidentally I really like the new Atme AVR ISP MKII USB that I got recently. The older programmer worked just fine, but this one is fewer clicks and less trouble to set up. For me it doesn't matter so much, but for other users it will be fundamentally simpler to set up and program the regulator.

-- Alan


----------



## JimmyM (Jan 18, 2009)

Alan B said:


> It has been some time since I did those tradeoffs, but as I recall the pin I chose was the only one that could do PWM that was NOT part of the ISP. I did not want to blow bulbs while programming. Also I wanted an open pin for the ADC so I would not have voltage dividers on the ISP jack. So I had some constraints to work with. The larger pin count part has more options but is harder to solder.


My PWM output is on one of the ISP lines. I do get bulb flicker while programming, but it hasn't been a problem.


Alan B said:


> Last night at the CPF San Jose gathering I met Wayne who makes LED regulators. He told me how he solders those parts. I don't want to delay my project, but someday I'll get set up for it. The first thing you should get (if you don't already have one) is a stereo microscope. It is vital to be able to clearly see what you are doing otherwise the results are random.


I've soldered SC-70 devices (0.65mm pitch) without any problems. But they have gullwing pins. The QFN devices have no pins. So they have to be reflowed. I'll be ordering solder paste and borrowing a toaster oven. Basically it's pretty simple. Preheat the board to 150C, then crank the heat until it reaches ~230C. Then shut it off and open the door.


Alan B said:


> It would be good to review the pinout again, I suppose. It is not too late yet to change it, but as I recall there were constraints that nailed just about every pin. And clearly the pins can be made to work the way they are chosen.
> 
> The present code is getting 245hz PWM at 8 mhz clock. As for center detection of the voltage during the PWM cycle, I can do that but have not coded it. I did code some time back a setup that samples all the way through the PWM cycle, well over 100 samples per cycle as I recall. That should be the most accurate, but until I get a good meter and really wring it out I won't know how much difference it really makes. Many of these "improvements" are not worth their complexity, but it is interesting to try them.


Oh I know. There are a hundred ways to skin a cat. Since your design works, there's no real reason to change it. I just wanted to peek inside your thoughts. There are plenty of things that get by me.
I've been working today on regulation stability while introducing a large resistance into the line (to cause a big voltage drop while under load). Neat stuff. I've pretty much settled on 4 ADC reads for Vbat beginning at midpoint, with averaging. I may try triggering the Vbat readings at PWM ON, do a couple of ADC reads to delay the 4 averaged readings.
I'm getting +/- 0.04V repeatability though. That's a good figure, but I'm trying fiddle with the timing so that everything is nice and consistant regardless of voltage sag under load.


Alan B said:


> Incidentally I really like the new Atme AVR ISP MKII USB that I got recently. The older programmer worked just fine, but this one is fewer clicks and less trouble to set up. For me it doesn't matter so much, but for other users it will be fundamentally simpler to set up and program the regulator.
> -- Alan


That's the one I got. I really like it. It can't power the device being programmed, but that's not too big a deal.


----------



## Mr Happy (Jan 18, 2009)

JimmyM said:


> I've soldered SC-70 devices (0.65mm pitch) without any problems. But they have gullwing pins. The QFN devices have no pins. So they have to be reflowed. I'll be ordering solder paste and borrowing a toaster oven. Basically it's pretty simple. Preheat the board to 150C, then crank the heat until it reaches ~230C. Then shut it off and open the door.


I understand the alternative to a toaster oven is a hot air solder station. Apparently there are decent ones to be had for under $200.

The hot air gun gives you a lot more flexibility than an oven, and you get a good temperature controlled iron into the bargain. Ovens are good for doing a whole large board at once, but it is a one shot deal. If something doesn't go right, you need another tool to fix it.


----------



## Alan B (Jan 18, 2009)

Mr Happy said:


> I understand the alternative to a toaster oven is a hot air solder station. Apparently there are decent ones to be had for under $200.
> 
> The hot air gun gives you a lot more flexibility than an oven, and you get a good temperature controlled iron into the bargain. Ovens are good for doing a whole large board at once, but it is a one shot deal. If something doesn't go right, you need another tool to fix it.



That was another tool that Wayne uses, the hot air soldering station.

Lots of discussion on this also in Ham Radio building with surface mount. Also modding toaster ovens for better temperature control, etc. Quite a project in itself.

-- Alan


----------



## JimmyM (Jan 18, 2009)

Mr Happy said:


> I understand the alternative to a toaster oven is a hot air solder station. Apparently there are decent ones to be had for under $200.
> 
> The hot air gun gives you a lot more flexibility than an oven, and you get a good temperature controlled iron into the bargain. Ovens are good for doing a whole large board at once, but it is a one shot deal. If something doesn't go right, you need another tool to fix it.


Those hot air systems are great for soldering things with a bunch of leads. I'm not sure how well they work for leadless packages or BGAs. The air can't get underneath. The solder paste is sticky. Once the compenents are set they won't move if you move the board around a little. I've got 2 leadless packages to play with. The Tiny84 and a neat little MAX15007 regulator I may use on my JM-PhD-D1. I'll tank etch a test board with both packages on it, the into the toaster oven it goes.
I'll then use those mounted components for testing.


----------



## mpteach (Jan 18, 2009)

Adding a temp sensor should be fairly trivial but how about an interface for reverse clicky fingerprint reader? You don't want just anyone hittin the red button.


----------



## Alan B (Jan 18, 2009)

mpteach said:


> Adding a temp sensor should be fairly trivial but how about an interface for reverse clicky fingerprint reader? You don't want just anyone hittin the red button.



Temp Sensor - check, done

Fingerprint Reader - on the list

-- Alan


----------



## mpteach (Jan 18, 2009)

The phd could also use an integrated 2megapixel beamshot camera also for facial recognition and facial expression recognition of to go turbo when another hard anodized object enters a predetermined radius.

Edit luxmeter for cpf duels and a speaker to tell me when its getting low and to make lightsaber sounds. I don't beleive this chip could handle a connection to the cpf PHd App store though.

Edit2: an egg timer for when youre hotwire cooking!


----------



## Mr Happy (Jan 18, 2009)

JimmyM said:


> Those hot air systems are great for soldering things with a bunch of leads. I'm not sure how well they work for leadless packages or BGAs. The air can't get underneath.


They work fine, apparently. With BGA you heat the whole component up to reflow temperature from above. You don't need to be timid. Here's a nice demo: http://www.youtube.com/watch?v=JB1InDsWCjQ


----------



## mpteach (Jan 18, 2009)

One guy soldered his boards with his kitchen skillet and a thermometer. The board were solid aluminum core though which conducted the heat evenly.


----------



## mpteach (Jan 18, 2009)

Remember with RMS Math that power is propotional to duty cycle ie 50% duty cycle is half the power. Power is proprtional to the square of voltage though so 70.7%V (sqrt2)is half the power. So coming up with an equivilent dc voltage requires square root. Increase the voltage by 1.41x and run a .5 duty cycle and the power is the equivilent.


----------



## mpteach (Jan 18, 2009)

Vin^2 * Dutycycle is proportional to the power, to get rms readin your take the square root of that Vin^2*Dutycycle. Averaging DC meters give you only Vin*Dutycycle.


----------



## Alan B (Jan 18, 2009)

mpteach said:


> Remember with RMS Math that power is ....



That's true. Welcome to the thread.


Well, I did work on the code today, and made the memory mode work again. I found an interaction between the memory mode and the low power option. Probably did not test them together before.

It would appear that when the processor comes out of power down via the pushbutton interrupt it reboots. It is not supposed to, according to Atmel documentation, but this may be an issue in the GCC libraries, or some interaction with my code. So I stored the memorized level in ee memory for now, this solves that issue.

I also did some measurements of the sizes of various options. The low power option is huge, about 22.7% of the Tiny25's memory. There are only a few lines of code in this option, but it calls a couple of functions and macros from the AVR GCC library. I will have to look into that since I don't believe anything like that is actually required to do the job. Basically you have to prepare the CPU for the interrupt and then go to sleep, and then wake up and resume operations. So I'll probably end up coding that directly inline.

I made some current measurements. Without power down the draw was about 5 milliamps. With it the drain was under 1 mA, too small to measure on that meter. Have to do it again when the Fluke 189 arrives. Or set up a resistor in series and measure voltage across it to make a bigger reading.

I tested with three of the KD D size Li-Ion cells the other day. Worked fine. I did not leave them in since the spring is really putting more pressure on them than I'd like. I need a shorter spring for the [email protected] With those the runtime should be more than double the AA NiMH. About 4.5 AH instead of 1.8AH. Over an hour full power runtime, and stay in regulation longer due to the higher voltage. Not bad for a [email protected]

It might be fun to set up a quad bore 3D for 3x4AA for this. Unfortunately that is not a low cost setup to try. It would be able to go higher in voltage and stay in regulation longer.

I also noticed something interesting. I have started loosening the tailcap to "lock out" the light when I don't want it to get turned on by accident. I thought this was also saving the less than one milliamp that it is drawing when off. However when I connected the programmer I found that the CPU is powered and could be programmed. Removing the tailcap prevented programming since this programmer does not power the target CPU. So the leakage of the tailcap is not enough to light the filament, but it is enough to power the CPU. So it is useful as an "on lockout" but not to save the microamps...

So, we have a nice interface and working memory at this point.

Ramping up and down (sets memory)
Double click to max from off
Click on/off to memory value
Overtemperature shutdown
Low battery blink/redux
Fast soft-start

and we also have battery powered desktop programming...







-- Alan


----------



## Mr Happy (Jan 18, 2009)

Alan B said:


> It might be fun to set up a quad bore 3D for 3x4AA for this. Unfortunately that is not a low cost setup to try. It would be able to go higher in voltage and stay in regulation longer.


The need for boring seems to vary with the cells and maybe Mag samples. I find I can fit 4 Eneloops side by side in my Mag without boring, but not 4 of the Kodak pre-charged. The main issue seems to be constructing the battery holder, which needs some workshop facilities.



> I also noticed something interesting. I have started loosening the tailcap to "lock out" the light when I don't want it to get turned on by accident. I thought this was also saving the less than one milliamp that it is drawing when off. However when I connected the programmer I found that the CPU is powered and could be programmed. Removing the tailcap prevented programming since this programmer does not power the target CPU. So the leakage of the tailcap is not enough to light the filament, but it is enough to power the CPU. So it is useful as an "on lockout" but not to save the microamps...


This lockout feature is also variable. I find my Mag will light at full brightness even when the tailcap is hanging on by a single thread. There is no lockout facility from loosening the tailcap at all.


----------



## mpteach (Jan 18, 2009)

For comparison whats the drain of a typical protected Li-ion cells circuit and cells self discharge?


----------



## Alan B (Jan 18, 2009)

Mr Happy said:


> The need for boring seems to vary with the cells and maybe Mag samples. I find I can fit 4 Eneloops side by side in my Mag without boring, but not 4 of the Kodak pre-charged. The main issue seems to be constructing the battery holder, which needs some workshop facilities.
> 
> This lockout feature is also variable. I find my Mag will light at full brightness even when the tailcap is hanging on by a single thread. There is no lockout facility from loosening the tailcap at all.





mpteach said:


> For comparison whats the drain of a typical protected Li-ion cells circuit and cells self discharge?



The older mags also were much larger, and I have one, but it is much different inside and my metalwork won't fit so I don't think I'll use that one for now.

FiveMega makes some nice holders, and possibly some others as well if one wants to buy them.

The lockout is, as you say, variable. It depends on anodizing in the threads which wears out especially if not lubricated. [email protected] seem to come dry so a little use will take the anodizing out. I tried a couple of tailcaps in this [email protected] and one of them locks out in any position. The other locks out a half turn or so then comes back into contact further out, so the lockout only works in the right part of the threads. I suppose we could send out just the tailcap for hard anodizing, that would do it. It is a nice feature, I would prefer to have it especially on high power incandescents that might be in my briefcase.

Self discharge of the Li-Ion cells is really low, so it is just the drain of the protection circuit. I don't know what that is, and I'm sure it varies, but it is a whole lot less than a milliamp. All the CPU controlled lights have some drain unless there is a switch completely shutting them off. I'm making it as low as practical.

-- Alan


----------



## Mr Happy (Jan 18, 2009)

Alan B said:


> The older mags also were much larger, and I have one, but it is much different inside and my metalwork won't fit so I don't think I'll use that one for now.


My Mag is a new one, but the Eneloops still fit quite comfortably inside it. I wonder if there is variation between samples?

I've never felt compelled to lubricate the threads on a light. I feel the whole purpose is to make good electrical contact and lubrication counters that objective.


----------



## mpteach (Jan 18, 2009)

If the protection circuit is so much lower maybe you could add a lower power circuit to cut power to the microprocessor and monitor the button? A flip flop cuircuit of some type?


----------



## mpteach (Jan 18, 2009)

For your breifcase you could make a lock mode where you have to tap the button several times then hold it for a second to unlock. A physical lockout might be more reliable though or maybe not.


----------



## Alan B (Jan 18, 2009)

Mr Happy said:


> My Mag is a new one, but the Eneloops still fit quite comfortably inside it. I wonder if there is variation between samples?
> 
> I've never felt compelled to lubricate the threads on a light. I feel the whole purpose is to make good electrical contact and lubrication counters that objective.



The variation is more in the batteries. The new [email protected] are very precise. Or a lot of aftermarket stuff would not fit. The batteries are all over the map.

The [email protected] threads are anodized and not good for electrical contact. There is a shoulder at the end of the tube that the tailcap seats against that makes the electrical contact.

Lube generally does not prevent contact in stationary applications. It does control oxidation which in many metals is a poor conductor, most contact cleaner contains lubricant. Most lights seem to be lubed from the factory. Lubing the [email protected] threads makes them a lot nicer to move, they grate pretty badly with the stock finish.

But they work either way,

-- Alan


----------



## Alan B (Jan 19, 2009)

mpteach said:


> If the protection circuit is so much lower maybe you could add a lower power circuit to cut power to the microprocessor and monitor the button? A flip flop cuircuit of some type?





mpteach said:


> For your breifcase you could make a lock mode where you have to tap the button several times then hold it for a second to unlock. A physical lockout might be more reliable though or maybe not.



The micro power is quite low when powered down, in fact the voltage monitor resistive divider current is larger and the FET switch leakage is not insignificant either.

Software lockouts are certainly possible but mechanical ones are more trustworthy.

-- Alan


----------



## Alan B (Jan 19, 2009)

Wide Output Range

This evening I set the low voltage to 2.0V on the regulator output. The high voltage is set to 10.8 for the WA1185 bulb. The range of output is pretty amazing. At 2.0V on this bulb the output is similar to a [email protected] Solitaire, but of course it has a lot more red/orange (and the pattern is a lot better than a Solitaire as well). So it is excellent for preserving night vision and not disturbing folks or being seen too far away. It could be quite useful at times, especially in the house, tent or around the RV so as to not disturb the neighboring campers. All the while having the big output just a double-click away.

I'm working on a redesign of the user interface to allow getting straight to low mode without going to a higher level so it would be possible to use it in the situation that a lot of light is not desirable, even for a short burst.

The runtime of 3x3AA cells at this low level should be more than 30 times as long as on full power, so about 12 hours on a charge, more on Li-Ions or 3x4AAs.

-- Alan


----------



## Mr Happy (Jan 19, 2009)

Check the design of the bulb though. If it is a halogen bulb, it may have a very short life on low output...


----------



## Alan B (Jan 19, 2009)

Mr Happy said:


> Check the design of the bulb though. If it is a halogen bulb, it may have a very short life on low output...



I have read about that being a problem with early Halogen bulbs, and that newer ones have a much wider range of voltages that they can operate at. I suspect, like you, that 2.0V is too low for this bulb to have a long life, as the tungsten will not redeposit properly on the filament at the lower temperatures. Exactly how short the life might be is an open question. At least the WA1185's are not expensive bulbs. Unfortunately manufacturer's specs are not detailed on the minimum voltages for long bulb life.

The WA1185 bulb is quite small, smaller than a PR bulb, so the temperature is higher than a larger bulb. This is one reason it is so white on high power (and why it is only a 50 hour bulb at normal ratings). So it is perhaps a better candidate than larger bulbs for extra lower power operation.

-- Alan


----------



## Alan B (Jan 19, 2009)

Quad Voltage Interface Proposal

This is the interface I'm thinking about implementing next:

clickoff -> on (goes to low on click then at release goes to memory level)
on -> off (goes off at release)
turbo -> memory level​double clickalways goes to turbo (does not affect memory)​pressoff -> goes to low, resets memory to low
on -> ramps memory till released, reverses direction each press
turbo -> goes to memory level, then ramps​click then pressoff -> goes to afterburner, light goes off when released
on -> goes to low​selectable voltage levels (4) w/ examples for WA1185 volts, bulb life hours, bulb lumens
2.0V (?h) (2?BL)low end of memory range
9.6V (50h)(800BL) high end of memory range
11.0V (10h) (1200BL) turbo can be higher than high, can stay in this mode
11.6V (5h) (1400BL) afterburner can be higher than turbo, won't stay in this mode​-- Alan


----------



## mpteach (Jan 19, 2009)

I know you're sick of my ideas but how about adding an accelerometer chip so you could convince people you have the worlds brightest "shake" powered light LOL.


----------



## Alan B (Jan 19, 2009)

mpteach said:


> I know you're sick of my ideas but how about adding an accelerometer chip so you could convince people you have the worlds brightest "shake" powered light LOL.



Right. That goes on the "probably not" list.

A better use of such a transducer would be to detect the light being dropped and shut down the filament before it hits, possibly saving the bulb. But at this point in the design cycle I doubt if folks want to delay it for such a change.

I have been getting some parts and making final adjustments to the physical PC Board and Metalwork for proper fit. The terminal and shoulder washers look good. It uses a #6 screw for the battery plus.

I have updated the proposed interface a couple posts back with small changes and example bulb lumens and bulb life for the Welch Allyn 1185.

-- Alan


----------



## mpteach (Jan 19, 2009)

It would be funny " see you shake the light and it charges Heh I thought a drop shutoff before but didnt think the bulb could cool down much in the fraction of a second before impact it can't park the bulb like a harddrive head or deploy an airbag.


----------



## mpteach (Jan 19, 2009)

Do you have any code to keep stats on bulb life and bulb use?


----------



## Alan B (Jan 19, 2009)

mpteach said:


> Do you have any code to keep stats on bulb life and bulb use?



Not at this time. Could do that, would require reading out on the computer. Perhaps later.

-- Alan


----------



## Alan B (Jan 19, 2009)

JimmyM said:


> My PWM output is on one of the ISP lines. I do get bulb flicker while programming, but it hasn't been a problem.
> ...
> I've been working today on regulation stability while introducing a large resistance into the line (to cause a big voltage drop while under load). Neat stuff. I've pretty much settled on 4 ADC reads for Vbat beginning at midpoint, with averaging. I may try triggering the Vbat readings at PWM ON, do a couple of ADC reads to delay the 4 averaged readings.
> I'm getting +/- 0.04V repeatability though. That's a good figure, but I'm trying fiddle with the timing so that everything is nice and consistant regardless of voltage sag under load.
> ...



Jim,

I wanted to avoid driving the bulb while programming since I didn't know if it would flash the bulb. Just my conservatism. So I picked a different pin and then checked to see if I could get the program to work with it. It does require a subtract since the pin I used is a complemented PWM output, but it worked out okay.

I have ADC code using a quad read of the ADC. That is a good way to go. It gives you 12 bits from 10 ADC bits, so you can do the control with 12 bits!

I just realized that Simpson's rule would probably be a good way to measure the battery voltage. Read it four times, once at each end and twice in the middle and average that. Pretty simple and better than just ends or middle, etc. On the first read take it twice, skipping the first one so the reading is just a little into the pulse and skips the on-transient. Then twice in the middle, and then again at the end just before the PWM goes off. Add them up and you have a 12 bit value if the individual readings were 10 bits each. That might be worth a try.

Great that you are getting the repeatability. I need to check mine when I get the new meter.

Also should measure the total resistance. Have you tried to do that? I suppose the best way to do that is put large current through and measure actual voltage drop. The FET is not much, most will probably come from traces and so on.

I'm looking at a different way of decoding the UI again. I've changed that a couple of times and to do the new UI I want to do it is time to upgrade it to an event stream/state machine. No interrupts, but much different code than it is now.

-- Alan


----------



## Alan B (Jan 19, 2009)

LuxLuthor said:


> Yes, this is true about the 179 not having this "AC+DC" capability. Will, I have read your quote from Willie Hunt, but I'm not 100% sure how his should be used to deal with this Fluke 179 as it applies to PWM settings.
> 
> I think working this out will benefit a number of others, so if you don't mind can you use the numbers I got from my question Alan referred to in post #276 of this thread? It referenced my observations in this thread (attention to my dark red readings). It related to Fluke 179 RMS measurements of AW's multilevel D Driver (30/60/100% duty cycle) at bipin holes with & without bulb.
> 
> ...




LuxLuthor,

One question - is the AW driver rating of 30/60% for voltage, percent of time on, or power? Percent of what??

-- Alan


----------



## LuxLuthor (Jan 20, 2009)

I asked AW about this, and he said "the 30/60/100% setting is duty cycle power on time. The voltage measurement taken by a meter is sampling readings of RMS ( root mean square ) since the power on curve won't be linear. You will get a much better picture if you can measure it with a scope."

Unfortunately, I don't have a scope.


----------



## Alan B (Jan 20, 2009)

LuxLuthor said:


> I asked AW about this, and he said "the 30/60/100% setting is duty cycle power on time. The voltage measurement taken by a meter is sampling readings of RMS ( root mean square ) since the power on curve won't be linear. You will get a much better picture if you can measure it with a scope."
> 
> Unfortunately, I don't have a scope.





LuxLuthor said:


> Yes, this is true about the 179 not having this "AC+DC" capability. Will, I have read your quote from Willie Hunt, but I'm not 100% sure how his should be used to deal with this Fluke 179 as it applies to PWM settings.
> 
> I think working this out will benefit a number of others, so if you don't mind can you use the numbers I got from my question Alan referred to in post #276 of this thread? It referenced my observations in this thread (attention to my dark red readings). It related to Fluke 179 RMS measurements of AW's multilevel D Driver (30/60/100% duty cycle) at bipin holes with & without bulb.
> 
> ...



OK LuxLuthor. Then the calculation that you did (equation 2) is correct for a battery voltage under load of 10.97V. The reading of an RMS AC+DC DVM should be 6.01 and 8.5V. The Fluke 179, as I understand it, is not an AC+DC RMS DVM, so the AC RMS scale of the meter will ignore the DC component and give you the RMS reading of the AC only. This is not useful, so this range should not be used. Instead we must use the regular averaging DC range. We must convert the RMS readings to average (mean) DC readings:

* 1) VbattDC^2 * Duty_cycle = VbulbRMS^2
* 2) VbulbRMS = VbattDC * sqrt(Duty_cycle)
* 3) Duty_cycle = VbulbRMS^2 / VbattDC^2
* 4) VbulbMEAN = VbattDC * Duty_cycle
* 5) VbulbRMS = sqrt(VbattDC * VbulbMEAN)
* 6) VbulbMEAN = VbulbRMS^2 / VbattDC

To do this use equation 4:

for 30%: 10.97 * 0.30 = 3.29V average (6.01V RMS)

for 60%: 10.97 * 0.60 = 6.58V average (8.50V RMS)

To see these values place a light load on the soft start (such as 1k ohms) and connect the DC DVM across the resistor leads.


----------



## JimmyM (Jan 20, 2009)

I think I've found out what's causing some of the voltage deviation in my regulator design. Alan, I believe you mentioned before about FET resistance.
For instance, the 64623 I was testing with.
Set for 12V (8.8 amps DC) with a 15.6V input puts a peak FET load of 11.44A which creates a 0.037V drop across the 3.2mOhm FET.
Which can be corrected by adding an extra PWM count. Some bulbs could place over a 30A load on the FET requiring an additional 3 PWM counts to correct.
I'll be doing some experimenting later this week. I'm going to try adding another ADC input to read the voltage at the FET drain. The inaccuracy may have been caused by the FET drop, not noise in the Vbatt ADC readings. If there's no difference I won't bother.


----------



## wquiles (Jan 20, 2009)

Good catch Jim. At these levels, being off my one PWM count does not seem that bad 

Will


----------



## Alan B (Jan 21, 2009)

Loaded the new compiler this evening. 20081205 version of WinAvr. Code size seems the same.

I'm trying to figure out why making one function call costs 18% of the memory size. The function is already there and already called elsewhere, but perhaps calling it a second time trips the optimizer. Seems like too much waste, though.

Also noticed a lot of pushing on the stack at the start of main, need to figure out how to get rid of that. Don't think we're ever going to return from main so should not need all that stack activity. It is almost 2% of the CPU program memory, rather silly. I think it is the way main is defined that affects that.

After that perhaps I can get back to the new Event/State UI design.

You can compensate for the FET drop easily enough. Hopefully that is a small enough effect that it will not be noticeable. 30 millivolts should not be visible. The correct way to compensate for this is to subtract the Vdrain ADC from the Vbatt ADC. This second ADC voltage divider adds to the battery drain.

-- Alan


----------



## Alan B (Jan 21, 2009)

Tried the various optimizer settings on the compiler. Surprisingly enough 03 produced quite a bit smaller code than the default Os. Not sure if the code works right since I did not try running it yet.

Os optimizes for size, O3 for speed.

-- Alan


----------



## JimmyM (Jan 21, 2009)

Alan B said:


> You can compensate for the FET drop easily enough. Hopefully that is a small enough effect that it will not be noticeable. 30 millivolts should not be visible. The correct way to compensate for this is to subtract the Vdrain ADC from the Vbatt ADC. This second ADC voltage divider adds to the battery drain.
> 
> -- Alan


It will, yes. But since I'm using the 1.1V Vref, I'm using 360K & 10K resistors already. It's less than a milliamp each (about 0.1 mA). It's more about theory right now. If I use a differential pair of ADCs it should compensate for FET drop. It will look like the Vbat is lower by the amount of the FET drain and thus increase duty to compensate. I'm just curious really. I'm trying to develop as "perfect" as possible with respect to regulation. I know Perfect is the enemy of good enough. But, I just have to try it out.


----------



## mpteach (Jan 21, 2009)

Will this high impedence driver board be protected from the effects of condensation?


----------



## Alan B (Jan 21, 2009)

mpteach said:


> Will this high impedence driver board be protected from the effects of condensation?



Not planning to conformal coat it. Should be fairly sealed inside a [email protected] tube. There is probably a little space if you want to put a dessicant pack in there.

There is a pulldown on the FET gate, so the impedance is clamped.

-- Alan


----------



## donn_ (Jan 21, 2009)

There will be condensation, especially in climates like mine (marine). As long as the tube isn't airtight (and it isn't) the only problem I'll have is salt deposits from moist salt air. The residual heat at the head end of the tube will take care of the moisture, but will leave the salt.

I'll probably look for some sort of spray coating which will minimize the salt issue.


----------



## mpteach (Jan 21, 2009)

That's good news because you wouldn't want to assemble the light or change batteries in a warm humid house the thro a hotwire in your bag and put it in a very cold car and have it turn on by itself and start meling stuff.


----------



## Alan B (Jan 21, 2009)

mpteach said:


> That's good news because you wouldn't want to assemble the light or change batteries in a warm humid house the thro a hotwire in your bag and put it in a very cold car and have it turn on by itself and start meling stuff.



I have taken to loosening the tailcap a half turn or so. On most lights that breaks contact enough to prevent turn-on. It does require good anodize on the threads.

I would have to check but to turn on the light would take a pretty low impedance, the pullups in the CPU are turned on to detect the switch closure.

-- Alan


----------



## Alan B (Jan 21, 2009)

donn_ said:


> There will be condensation, especially in climates like mine (marine). As long as the tube isn't airtight (and it isn't) the only problem I'll have is salt deposits from moist salt air. The residual heat at the head end of the tube will take care of the moisture, but will leave the salt.
> 
> I'll probably look for some sort of spray coating which will minimize the salt issue.



The boards can be coated. Have to protect the plug/socket/contact surfaces. There are sprays designed for this.

-- Alan


----------



## JimmyM (Jan 21, 2009)

mpteach said:


> Will this high impedence driver board be protected from the effects of condensation?


Like Alan says... There are sprays designed for this. The board, of course, has the green solder mask to protect the traces. I suppose I could look into a sptay coating after assembly. The pots I've chosen for mine are multi-turn sealed units.


----------



## JimmyM (Jan 21, 2009)

I'm traveling on business this week. I'm itching to get back to the bench and fiddle. ARRRRGGGGHHHHHH!.


----------



## Alan B (Jan 21, 2009)

JimmyM said:


> I'm traveling on business this week. I'm itching to get back to the bench and fiddle. ARRRRGGGGHHHHHH!.



My switch is sealed. The plug and jack are gold plated. The CPU can be soldered or plugged into a good socket. Have to keep the spray out of the sockets and off the plugs and other contact areas, but it could be done.

You need to make your development system more portable. Mine is quite portable now. If I use the other programmer I don't even need power to the target, but no way to test with a bulb unless power is available. But with the sled mounted in the [email protected] it is a very portable software development system.

-- Alan


----------



## JimmyM (Jan 21, 2009)

Alan B said:


> My switch is sealed. The plug and jack are gold plated. The CPU can be soldered or plugged into a good socket. Have to keep the spray out of the sockets and off the plugs and other contact areas, but it could be done.
> 
> You need to make your development system more portable. Mine is quite portable now. If I use the other programmer I don't even need power to the target, but no way to test with a bulb unless power is available. But with the sled mounted in the [email protected] it is a very portable software development system.
> 
> -- Alan


I need to experiment with hardware as well. So I need my breadboard and other components. My hardware design is evolving here and there. Oh well. I suppose I have to put up with the job that pays for my hobby.


----------



## Alan B (Jan 21, 2009)

JimmyM said:


> I need to experiment with hardware as well. So I need my breadboard and other components. My hardware design is evolving here and there. Oh well. I suppose I have to put up with the job that pays for my hobby.



Of course, on both. However there is plenty to try on the software side as well, especially with UI development.

I wrote some code (not tested yet) that scans the pushbuttons and creates an event stream, and a basic UI that operates on the stream of events. I like this approach. Hope it does not generate a lot of code bytes.

I'm still playing with UI protocols. I want to be able to access high, low and memory directly from off.

Probably the best way to do this is:
click to go to memory level...
double click to high
press to low​-- Alan


----------



## Roland (Jan 22, 2009)

High should always be default or reached first.
When you need high you usually need it easy and fast.

Low is for fiddling around.
Then you have enough time to double click, ramp down etc. or to shield off the light and go to a low setting.

so:
click to high


----------



## mpteach (Jan 22, 2009)

Some people prefer high first some low first.


----------



## Calina (Jan 22, 2009)

I prefer both and that is exactly what my L2D does: I can turn it on either high or low (I know, it's a LED light). Most of the time I start it on low.


----------



## JimmyM (Jan 22, 2009)

Alan B said:


> Of course, on both. However there is plenty to try on the software side as well, especially with UI development.
> 
> I wrote some code (not tested yet) that scans the pushbuttons and creates an event stream, and a basic UI that operates on the stream of events. I like this approach. Hope it does not generate a lot of code bytes.
> 
> ...


 With all the UI dev you're doing, that cool that you can take it anywhere.

I'm doing a bunch of things with "mode" variables. Different if statements set a "mode" variable to different values depending on what different conditions occur. Mode 1=normal (can be used with startup flag to alter the pwmval step.), mode 2= low voltage condition, mode 3 = over temperature. Then different sections do different things based on what mode the regulator is in.


----------



## Alan B (Jan 22, 2009)

Roland said:


> High should always be default or reached first.
> When you need high you usually need it easy and fast.
> 
> Low is for fiddling around.
> ...



I will provide flexibility in the programming setup so folks can choose variations like this.

-- Alan


----------



## Roland (Jan 22, 2009)

Alan B said:


> I will provide flexibility in the programming setup so folks can choose variations like this.
> 
> -- Alan



:thumbsup:


----------



## Alan B (Jan 22, 2009)

JimmyM said:


> With all the UI dev you're doing, that cool that you can take it anywhere.
> 
> I'm doing a bunch of things with "mode" variables. Different if statements set a "mode" variable to different values depending on what different conditions occur. Mode 1=normal (can be used with startup flag to alter the pwmval step.), mode 2= low voltage condition, mode 3 = over temperature. Then different sections do different things based on what mode the regulator is in.



Modes allow a lot of different (and potentially confusing) things to happen. In UI design there has been a trend away from "modes". For example, the "vi" editor is "modal", so you are in "insert" mode or not. Folks get confused by modes and remembering what mode things are in.

So for the most part I'm steering away from "modes". Clearly some modes are obvious, such as on vs off, but even that can be a problem if the light is on a low setting, or the operator is in a hurry or under pressure, so the mode can get in the way. For example I'm trying to make "go to high" the same whether the light is on or off since that is one that might be needed in a hurry. Therefore "double click" always means "go to high" regardless of the current mode.

One other problem I'm having at the moment is keeping the memory over the power savings sleep. Variables such as mode are being reset to reboot values every time the light times out/wakes back up, so anything to be kept must be put in nonvolatile memory before shutting down and retrieved later. This should not happen as RAM is kept over a powerdown, but so far I have not been successful at avoiding a reboot during the restart. The modes you mention don't need to be remembered as they can be rediscovered easily enough.

Also, measuring the temperature doesn't need to be done every cycle (and it wastes time to do so), and user ramping cannot be done every cycle as it goes too fast (though 10 bits will slow that to about the right rate).

-- Alan


----------



## Alan B (Jan 22, 2009)

Fluke 189 arrived. Wow. Beautiful meter. 50,000 counts, AD+DC RMS, perfect for my 5V precision reference. Hooked it to the reference, measured 4.9998V. I guess that will have to do. :twothumbs

Great news, the second PCB prototype boards have shipped! I just might see those saturday! :naughty: Never mind. They shipped UPS, so no saturday delivery, most likely. Thought they were going to use priority mail.

I have been thinking about smaller [email protected]'s. Perhaps a 2D [email protected] It is possible to fit 3 C Li-Ion cells into a 2D body with a tube and short spring. That would be one sweet little [email protected] Runtime nearly an hour on high. Lots more runtime with the regulator on medium or low! :wave:

-- Alan


----------



## LuxLuthor (Jan 22, 2009)

I never thought I would be sad I got a Fluke 179 until this RMS issue developed. LOL! I will be taking new measurements with your technique in post #467, Alan. Thanks!

There are so many setups that can be done now though.


----------



## Alan B (Jan 23, 2009)

LuxLuthor said:


> I never thought I would be sad I got a Fluke 179 until this RMS issue developed. LOL! I will be taking new measurements with your technique in post #467, Alan. Thanks!
> 
> There are so many setups that can be done now though.



The 179 is also a great meter. I actually had to cancel an order for it when I realized it did not have the right RMS. I'm really glad I upgraded. This is quite a machine. Note that the 189 has been discontinued so getting a new one will become more difficult, and the price for new ones is probably near its lowest now.

I've looked at a few combinations, but I want something small like a 2D, not special in appearance, moderate power, good runtime, good white output and small bulb for good pattern, and inexpensive bulbs. Some bulbs like the WA1111 are very pricey. It would be nice to have a slightly lower voltage bulb since the regulator makes that work so well, but I have not seen much that had the balance of the WA1185. Perhaps 4x18650 in a 2D dual-bored, if that fits, but 3xC LiIon in a 2D would be easier I suspect and lower cost and has more AH. With the low voltage dropout in this regulator we don't really need protected cells, so that gives more choices on C LiIons.

The new UI code is really looking good. I think it will actually be more efficient code wise than the old one, and is a lot easier to understand and modify. I'm not quite to the compile and test stage, but getting very close.

-- Alan


----------



## LuxLuthor (Jan 23, 2009)

There are many options on quad bored 1D/2D mags, using 4s (4s2p) x 14670, or tri-bored 3s (3s2p) or 6s x 17670. If you need higher current (>5.5A) then you are into the Li-Mn 18650/26700 size cells.


----------



## mpteach (Jan 23, 2009)

I'm waiting for Li-Mn 17670s to become available. I would love to put 6 in a bored 2D mag.


----------



## wquiles (Jan 23, 2009)

Alan B said:


> Fluke 189 arrived. Wow. Beautiful meter. 50,000 counts, AD+DC RMS, perfect for my 5V precision reference. Hooked it to the reference, measured 4.9998V. I guess that will have to do. :twothumbs
> 
> Great news, the second PCB prototype boards have shipped! I just might see those saturday! :naughty: Never mind. They shipped UPS, so no saturday delivery, most likely. Thought they were going to use priority mail.
> 
> ...



Awesome!!!

The 189 (and the 289) are outstanding meters indeed 

Will


----------



## Alan B (Jan 23, 2009)

New UI progress report:

I had some success this morning with the new UI (I woke up at 1AM and could not sleep). It seems to be working now, and the codesize is somewhat smaller. In the process I discovered that global variables are more expensive to access than local variables with this compiler, so I moved most of the variables from the global scope to main(), and saved about 20% of the chip codespace. Major improvement. I have more space to play with now. This is about 50% full on the small chip!!

The new UI converts switch activity into discrete events, and then the next layer of code interprets those events into flashlight control actions. Much simpler to change and understand than before.

I will add some more user features such as specifying what voltage to go on click.

I really like the interface. It is smoother and more consistent than before. Three levels are directly accessible from off:

click to memory level
double click to maximum
press to lowest level

Once on press to ramp up or down, reverses each time
click to off

double click always goes to max

If you want to click to high, set the memory there. Memory is set by ramping. clicking does not affect memory.

I will provide a compile time switch to make click go to whatever voltage is desired, or to memory.

I also added a global timeout feature, so the light can be configured to go off after XXXX seconds of on and not touching the controls. At the moment it just turns off but we could change that to ramp slowly off.

What temperature should we set as the default shut-off temperature? The code is already there, just need to choose a good default.

-- Alan


----------



## wquiles (Jan 23, 2009)

Great progress Alan :thumbsup:

Will


----------



## mpteach (Jan 23, 2009)

With some hotwires the low voltage cuttof will trip long before a reasonable runtime timeout.


----------



## Alan B (Jan 23, 2009)

mpteach said:


> With some hotwires the low voltage cuttof will trip long before a reasonable runtime timeout.



Or perhaps the overtemperature will cut out first. 

With a really high powered incan perhaps the runtime timer will be set for 30 seconds when the runtime is 5 minutes or so..

-- Alan


----------



## mpteach (Jan 23, 2009)

If I took a mag runing a bulb at 180w ,finned the head and fiberfrax insulated around the socket how much heat would be coming back to the body and batteries?


----------



## JimmyM (Jan 23, 2009)

Alan B said:


> New UI progress report:
> 
> I had some success this morning with the new UI (I woke up at 1AM and could not sleep). It seems to be working now, and the codesize is somewhat smaller. In the process I discovered that global variables are more expensive to access than local variables with this compiler, so I moved most of the variables from the global scope to main(), and saved about 20% of the chip codespace. Major improvement. I have more space to play with now. This is about 50% full on the small chip!!
> 
> -- Alan


That's good to know. 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 quite like the routine. I pass it a couple of values that the routine interprets. I pass it an ADMUX value setting the Vref and ADC specifics, wether it should discard the first reading ot not, and how many samples to do for averaging purposes if I want it to do more than one reading. To use the bit-shift division, I use averaging values of 2,4,8, etc. I've tried doing 4 and 8 averages, but they're no better than the 2 reading average.


----------



## Alan B (Jan 23, 2009)

JimmyM said:


> That's good to know. 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 quite like the routine. I pass it a couple of values that the routine interprets. I pass it an ADMUX value setting the Vref and ADC specifics, wether it should discard the first reading ot not, and how many samples to do for averaging purposes if I want it to do more than one reading. To use the bit-shift division, I use averaging values of 2,4,8, etc. I've tried doing 4 and 8 averages, but they're no better than the 2 reading average.



I have a similar setup with an ADC reading function. Those variables need to be global if you want them to be shared.

I just added a lockout feature. A certain number of clicks toggles the lock. Now it is child-safe! :naughty: 

-- Alan


----------



## Mr Happy (Jan 24, 2009)

Alan B said:


> I have a similar setup with an ADC reading function. Those variables need to be global if you want them to be shared.


They don't strictly need to be global...there are alternatives, like defining key data structures at main() scope and passing references to them into your functions.

But I'm disappointed you guys are not programming it in assembly language -- it is a microcontroller after all. Using C is cheating :devil:


----------



## Alan B (Jan 24, 2009)

Mr Happy said:


> They don't strictly need to be global...there are alternatives, like defining key data structures at main() scope and passing references to them into your functions.
> 
> But I'm disappointed you guys are not programming it in assembly language -- it is a microcontroller after all. Using C is cheating :devil:



Yes, you are quite right of course. But one has to be careful. Some constructs are quite inefficient in these CPUs.

Using C in a very small micro is not quite the same as in larger computers. It is, in some cases, harder than assembler to get the code to be small and be efficient. There's more magic going on that occasionally must be understood to be managed. :shakehead

The Tiny25 I am working with now has 2K bytes code space. Each instruction takes 2 bytes. My present flashlight code is using about 1100 bytes, or about 550 instructions. It is absolutely amazing how the C compiler and optimizer squish it all in there! There is a lot of code, and quite a bit of math in spots. 8, 16 and 32 bit integers, multiplication and even division is being used. I have even put floating point in there in some versions! The Tiny85 has four times as much memory, but it doesn't look like anything like that is needed yet. They are plug compatible, and in fact I started with the 85 until I found that I didn't need that space.

We could program it in assembler, or even mix assembler with the C. However if we did it fully in assembler the project might take another year. 

-- Alan


----------



## JimmyM (Jan 24, 2009)

Alan B said:


> We could program it in assembler, or even mix assembler with the C. However if we did it fully in assembler the project might take another year.
> 
> -- Alan


Amen to that!


----------



## Alan B (Jan 24, 2009)

Part Three of this thread continues here:

https://www.candlepowerforums.com/posts/2803333

Thanks to all who have contributed!

-- Alan


----------

