• You must be a Supporting Member to participate in the Candle Power Forums Marketplace.

    You can become a Supporting Member.

Sold/Expired Discussion - Programmable Hotwire Regulated Driver drop-in for D-M@g

Candle Power Flashlight Forum

Help Support CPF:

1) The only thing that needs to be installed for this to work is WinAVR, as I understand it. This installs to the default location and is added to the execution path so it will work properly. (Note that I have not tested without AVR Studio installed.)

2) The two batch files and the program file xxx.c should be in the same directory.


3) The USB driver for the AVRISPmkII needs to be the one provided in WinAVR, as discussed above.

That's it.

It seems like the 3 files would need to be in a specific directory of the WinAVR install so it knows where to find the needed files...but just for the heck of it, I reinstalled WinAVR (again) on this PC, put all 3 files into a new folder C:\Alan and ran the compile.bat without having made any changes to the c file you sent. Got this in the DOS window:

Code:
C:\Alan>avr-gcc.exe -mmcu=attiny45 -Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT HotwireRegulator.o -c HotwireRegulator.c

HotwireRegulator.c:192:3: warning: #warning INFO - SN108 Osram 64623, 5 A123 cells, full features, slow start, no max
HotwireRegulator.c:826:3: warning: #warning INFO - Bulb Type Osram 64623 12V 100W (16.0V)
HotwireRegulator.c:897:2: warning: #warning INFO - Lithium Ion Iron Phosphate chemistry selected
HotwireRegulator.c:926:3: warning: #warning INFO - Low Battery Protection Override using Specified Voltage
HotwireRegulator.c:986:6: warning: #warning INFO - REV2E board
HotwireRegulator.c:997:3: warning: #warning INFO - CPU is ATTiny45
HotwireRegulator.c:1070:6: warning: #warning INFO - 26V 6S range selected (J1 REMOVED)
HotwireRegulator.c:1088:6: warning: #warning INFO - RMS AC+DC Meter Calibration value used
HotwireRegulator.c:1368:3: warning: #warning INFO - Lockout stored in EEPROM Enabled
HotwireRegulator.c:1429:3: warning: #warning INFO - Lockout Mode Feature Enabled
HotwireRegulator.c:1443:4: warning: #warning INFO - Lockout Mode Basic Flashlight Enabled
HotwireRegulator.c:1469:3: warning: #warning INFO - QuadClick to Change Interface Modes (when ON, goes OFF)
HotwireRegulator.c:1497:3: warning: #warning INFO - DoubleClick to Max Voltage Feature Enabled
HotwireRegulator.c:1510:3: warning: #warning INFO - TripleClick to Middle Voltage Feature Enabled
HotwireRegulator.c:1553:3: warning: #warning INFO - Level Memory Feature Enabled at turn-on
HotwireRegulator.c:1569:3: warning: #warning INFO - MultiLevel Stepping Feature Enabled
HotwireRegulator.c:1607:3: warning: #warning INFO - Varilevel Ramping Feature Enabled
HotwireRegulator.c:1667:3: warning: #warning INFO - Mean-Squared Voltage Regulation Feature Enabled
HotwireRegulator.c:1763:3: warning: #warning INFO - Low Battery Protection Feature Enabled
HotwireRegulator.c:1778:3: warning: #warning INFO - OverTemperature Shutdown Feature Enabled
HotwireRegulator.c:1879:3: warning: #warning INFO - Low Standby Current Feature Enabled

C:\Alan>avr-gcc.exe -mmcu=attiny45 -Wl,-Map=HotwireRegulator.map HotwireRegulator.o -lm -o HotwireRegulator.elf

C:\Alan>avr-objcopy -O ihex -R .eeprom  HotwireRegulator.elf HotwireRegulator.hex

C:\Alan>avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex HotwireRegulator.elf HotwireRegulator.eep   || exit 0
Press any key to continue . . .
The C:\Alan folder contents are then:
compiled.jpg

On first blush, it looks like it worked.

Alan, I uninstalled both AVR Studio and WinAVR. Not sure if that uninstall removed USB drivers. Step One: Re-installed WinAVR and ran file:

Code:
C:\WinAVR-20090313\bin>avrdude -c avrisp2 -p t45 -P usb:xx -v

avrdude: Version 5.6, compiled on Mar  5 2009 at 09:59:30
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "C:\WinAVR-20090313\bin\avrdude.conf"


         Using Port                    : usb:xx
         Using Programmer              : avrisp2
avrdude: usbdev_open(): did not find any (matching) USB device "usb:xx"

C:\WinAVR-20090313\bin>@pause
Now I will install AVR Studio and do it again

Edit: Done, and same result. Also running that on computer that AVR Studio runs on gives same result.

In true noob style, I should note that in running my earlier post above looking for the USB driver, I did not plug my AVRISP2 device into my PC (? via a powered flashlight) when I ran that batch file because...well....you didn't say to, and I thought you were just looking to see if it found some driver feedback.

Code:
batch file:
avrdude -c avrisp2 -p t45 -P usb:xx -v 
@pause
I had tried inserting it as an unpowered device via USB, with only WinAVR installed, but it triggers the unrecognized device that windows tries to install files for, and I aborted when that started.

Just now, on this same problematic PC, I plugged in device, and cancelled Windows auto-driver install. Went to Device Manager; right clicked on Yellow USB flagged device, and updated driver navigating as your later quote said:

Code:
C:\WinAVR-20090313\utils\libusb\bin\
and resulted in:

usb.jpg


Then I re-ran the batch file with unpowered USB AVRISP2 device plugged in (green USB LED blinks on insertion, but no continuous LED glows on unpowered device) and got this:


Code:
C:\WinAVR-20090313\bin>avrdude -c avrisp2 -p t45 -P usb:xx -v

avrdude: Version 5.6, compiled on Mar  5 2009 at 09:59:30
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "C:\WinAVR-20090313\bin\avrdude.conf"


         Using Port                    : usb:xx
         Using Programmer              : avrisp2
avrdude: usbdev_open(): Found AVRISP mkII, serno: 0000B0042093
avrdude: usbdev_open(): did not find any (matching) USB device "usb:xx"

C:\WinAVR-20090313\bin>@pause
 
Last edited:
Lux, wow, what a detailed posting!

Looks like your are in good shape. Everything there looks good. You're ready to program!

The regulator program and batch files can be in any directory. They find WinAVR's programs via the path variable, so once WinAVR is in the path it is available everywhere. Just double click the batch files to trigger the program.

You can ( and should ) make separate directories for each regulator with this technique. That is the easiest way to manage it for now. Later we will have a gui to do this in one directory and give us a list of each configuration, but for now the separate directories are really easy.
 
DRAFT Instructions to use regulator software without AVR Studio

Preparation (one time)

1)
Install WinAVR. Select the "add to path" default option.

2)
Plug in USB AVRISPmkII programmer.

3)
When it asks about driver installation, Select "Have Disk" and navigate to WinAVR<version> / utils / libusb / bin.

4)
Get the files HotwireRegulator.c, compile.bat, avrisp2.bat and put them into a new directory designated for this regulator.

Configure the Software (each time)

1)
Edit the HotwireRegulator.c file with changes. If changing ranges set the calibrate mode. Save the file.

2)
Run the compile.bat to compile the software. Review for errors.

3)
Plug in the AVRISP2 device via programming stick to battery powered up M@glite with regulator Sled. LED lights up.

4) Plug AVRISP2 USB connection to PC, other LED lights up.

5) Run the avrisp2.bat to load the chip. Review for errors.

7) If calibrating, measure output else jump to step 9.

8) Put the measurements into the software, repeat steps 1-5.

9) Remove programmer, reinstall switch and Enjoy.
 
I did my first using this technique. Worked perfect for me.

Only remaining thing that your graphical project would solve for the relative beginner is sorting through the unfamiliar lines of information code in the HotwireRegulator.c file.

It may help to interimly tell people wanting to make changes to go directly to line xxx of the file?
 
I did my first using this technique. Worked perfect for me.

Only remaining thing that your graphical project would solve for the relative beginner is sorting through the unfamiliar lines of information code in the HotwireRegulator.c file.

It may help to interimly tell people wanting to make changes to go directly to line xxx of the file?

Congratulations on your successful firmware build.

I would recommend reading the program file down from the top. There are instructions on how to do things that I have just updated (so Lux's file is
out of date already, but only in documentation). I am continually updating this file, so going to line XX is not going to work very well.

I will be releasing the new graphical based interface in some weeks. It will make this process much simpler. In the meantime, folks who have purchased a regulator and wish to program it can request the software and I will email it. I don't think I will post this setup on the web until the GUI is ready.
 
I did my first using this technique. Worked perfect for me.

Only remaining thing that your graphical project would solve for the relative beginner is sorting through the unfamiliar lines of information code in the HotwireRegulator.c file.

...

The graphical interface will have a few more benefits. It does more checking and generates more clear feedback to the user when selecting things, and does a better job of preventing improper choices.

Also, the flexibility it will offer is greater than the current version. For example, it will allow selection of the mode order, and it will allow greater flexibility in selecting what each event does. For example, click when off can be selected to turn on at low, middle, high, basic or memory. Similarly for press when off, double click, triple click, etc. So the nature of the interface can be changed more dramatically if the user wants.

Another thing the GUI is going to do is to write a mini-manual for the configuration. A one page cheat sheet of what does what. This is necessary with all the flexibility.

I have not worked on the GUI for a couple of days but it has progressed nicely up to that point. The last thing I was working on was interfacing the programmer, and that led to the side trip with the batch files for the existing program, which is something I did in the past that makes things quicker and easier.

The next 3 regulators are programmed (as mentioned above), they need to have the socket heights set. Donn's reprogrammed regulator is ready to go into the mail.

On the GUI the next step is to complete the programmer interface based on the batch file testing, and then the configuration file reading/writing and the source code generation with embedded defines, and a few odds and ends. Lots of testing. Then the regulator code needs a rewrite to match all the new features. Much of the existing preprocessor code will go away as it is being handled in the GUI. Things like the bulb and battery data are moving out to the GUI, and all the configurations. So the regulator code will get much smaller. It will need to gain some new code to take the new flexibility from the GUI and conform to the interface between the two programs. It will make the regulator code more clear than it is now.

I considered doing this GUI a long time ago but decided that I needed to get the regulator code working well first. So I did that.

This is all taking far more effort than I originally planned to put into it, and it is taking awhile due to my other projects, work and family. I think the result is worthwhile, but the schedule is longer than I would like. I do appreciate people's patience. One advantage of the slow rollout is if there are any issues we won't have so much rework. Hopefully the folks receiving these units will give them a good test and feed back any issues so we can address them quickly.
 
Reading about just some of these enhancements that you are putting into this GUI is breathtaking, and revolutionary. Just amazing when I think back on how far this has come.

Even with all the wonderful LED & AW pre-programmed drivers, people are so used to being forced to adapt to the user interfaces provided. I don't think most people can yet understand being able to setup their own interface to do exactly what they want...and easily change it if new ideas/applications are desired.
 
Last edited:
I hope and believe that the 3 mentioned regulators are mine! I will be getting the sleds and all the parts for programming!

Please email me the all the software. Could you please include a copy of the file for both the different setups. You have my email address from paypal, but I can resend it if you need it.
 
Unfortunately, I am one of those with too little knowledge to understand even half of what is being said, but the little teaser AlanB put up is amazing!

Side note - with this regulator, what would happen with 21 eneloops in series (25.2v) driving a bulb at 18v but 9amps? I thought I may have read somewhere that eneloops may be good for 5-6 amps but not higher. Is it easier on the batteries with a regulator stepping down the voltage?
 
I hope and believe that the 3 mentioned regulators are mine! I will be getting the sleds and all the parts for programming!

Please email me the all the software. Could you please include a copy of the file for both the different setups. You have my email address from paypal, but I can resend it if you need it.

Yes. Yes. Ok. I should be able to use the pp email.
 
Unfortunately, I am one of those with too little knowledge to understand even half of what is being said, but the little teaser AlanB put up is amazing!

Side note - with this regulator, what would happen with 21 eneloops in series (25.2v) driving a bulb at 18v but 9amps? I thought I may have read somewhere that eneloops may be good for 5-6 amps but not higher. Is it easier on the batteries with a regulator stepping down the voltage?

:welcome:

I think that is too much current for Eneloops. Instead consider Lithium Manganese or Lithium Iron. Either is well suited for this use.
 
Last edited:
I think that is too much current for Eneloops. Instead consider Lithium Manganese or Lithium Iron. Either is well suited for this use.

Yeah, there are two parts to consider: 1) the voltage (which Alan's regulator would handle) and 2) the current (which the Eneloopies can't handle).

Silverfox did testing of the Eneloopies, and while they can survive 9A, on a sustained basis, they would likely be damaged quickly. 21 of them is not a trivial expense.

If you have to use AA cells, then the Elite 1700 AA's will work. You can contact [email protected] to see when they wiill be back in stock.
 
Unfortunately, I am one of those with too little knowledge to understand even half of what is being said, but the little teaser AlanB put up is amazing!

Side note - with this regulator, what would happen with 21 eneloops in series (25.2v) driving a bulb at 18v but 9amps? I thought I may have read somewhere that eneloops may be good for 5-6 amps but not higher. Is it easier on the batteries with a regulator stepping down the voltage?
What bulbs are we talking about?

What I understand is that the regulator steps down the voltage while the batteries will keep providing 25.2v. That means that voltage and amperage are different at each side of the regulator. This may result in:
Batteries provide high voltage low amps
regulator provides bulb with low voltage and high amps

In that fashion 21 eneloops should be able to power a 64623 or even better, a 64447.

What do others think about this?
 
Alan, I thought you decided not to release "The Sparrow" prototype.

Donn, I missed the chirp question. There is a section in the FAQ that talks about sound. I suspect it is the bulb making the sound, not the regulator. The 250 hz is being ramped up from a narrow pulse and some bulb filaments will resonate from the forces of the magnetic fields. I hear some noise from some of my bulbs, but they are pretty quiet. Is this loud, or just noticeable?
 
What bulbs are we talking about?

What I understand is that the regulator steps down the voltage while the batteries will keep providing 25.2v. That means that voltage and amperage are different at each side of the regulator. This may result in:
Batteries provide high voltage low amps
regulator provides bulb with low voltage and high amps

In that fashion 21 eneloops should be able to power a 64623 or even better, a 64447.

What do others think about this?

You raise a good point. In the case of PWM regulators the current is pulsed, and the correct power is delivered to achieve the same heating. So the voltage is not really reduced, but the power is controlled. So if the battery voltage is twice that of the bulb, then the current pulses are twice and the continuous power would be four times normal! The duty cyle will be 25% to maintain the same power.

In the earlier example with 25V batt to 18V bulb at 9A the Eneloops would have to handle about 13 amps peak and 6.5 amps average. It might work but seems like a pretty harsh treatment. As Lux suggested, high current NiMH cells can handle this more easily.

Your choice, I have done this with Eneloops and it worked but I rarely run full current, and it is hard to manage so many cells. Li-Ions are easier with a factor of 3 fewer cells to deal with.
 
Back
Top