How To Build a Flashlight With Perfect Modes (picture heavy)

Man I got everything working except i cant figure out how to load the program. I would like to load Tidos program just to go from there if someone could steer me in the right direction that would be great.

You have to be in the directory that holds the blf-vld files when flashing. Now you seem to be in c:\documents and settings\E. That's why it does not find the files.

After unzipping the blf-vld the default path is something like blf-vld0.4\blf-vld and after that you must go to either simple, fixed modes, programmable or default directory to flash, depending on your preference. If you have compiled your own code or have different path for blf-vld, you need to just be in the directory holding the .hex and .eep files and flash from there.

Staring at this computer for 8 hours is making me stupid thanks for the help. I will give it another try.

In case anybody is wondering this 3M clip from Digikey works perfect no problem at all with connecting to the chip.

http://parts.digikey.com/1/parts/389607-8-pin-test-clip-gold-soic-15-923655-08.html

Thanks for Tido sharing his wonderful program with us. I have built this buck driver for BLF-VLD_4 in 6 modes + last mode memory. It works prefectly well except I still have problem in applying the PINSWITCH and MONITOR_BAT. It is fun to study and to look into the program.

Hi Sixty545,

I have noticed that this wiring #264 was a little different from your post #177. I would like to confirm that because the capacitor and the diode, resistor are wired in series. Both methods of wiring are workable.

Microa

Microa,

Welcome to BLF! Great looking driver board, did you make it? I appreciate seeing the work of people that decide to "roll their own". I know there are many out there that don't have the resources to do this kind of work. Just as I am frustrated with no access to a lathe or milling machine. We all do what we can with what we have.

I have a comment on your schematic - the battery sense resistors R2 and R3. These allow about 100uA drain on the battery at 6V, not terribly excessive but this is the same problem I've been dealing with in my designs. If you make them larger then you start running into problems with the impedance of the ADC. Perhaps adding a capacitor across R2 would help lower its impedance while allowing a larger resistance value? Of course, using protected cells would eliminate the need for any changes in the circuit.

Keep us posted on how this is working, I'm sure others, besides myself, are eager to learn what you find out.

Crux,

There are a couple of methods you could use to allow higher impedance input to the ADC pin. One, as you say, is to put a 1uF or so cap from the test point to ground. I have had this method allow me around 5Megohms of impedance on a ADC pin and still give accurate results as long as you dont poll it too often. One thing to note, it may be obvious to you but if you try to use a DMM to check the voltage, it may give duff results due to how it constantly samples the voltage.

Another interesting method I have used in the past, though is perhaps a little overkill here is to have the voltage divider switch on only when needed. Either by disconnecting the ADC pin first(!) then the low side of the voltage divider, or have the high side disconnect. Both methods will probably need a couple of transistors.

Good observation, Microa!

#177: From the MCU pin 2 first a diode and a resistor(10MOhm) in parallel, after them a condenser (100nF) to ground (-).

#264: From the MCU pin 2 first the condenser and then the diode and the resistor in parallel, both to ground.

The two circuits are equivalent but #264 is more rugged having two components soldered to the board (ground). I experienced that the condenser could easily break in #177 if I pressed on the diode/resistor pair.

(by the way in #177 I switched the big diode with the small diode (S6) on the component side to get a small component, but when I found out that it was a shottky diode with a purpose, I switched back again).

I think I have mounted this circuit on 7-8 drivers now. Memorizes the mode 1/2 sec after switch-off.

Crux,

Thanks for your comment. I shall add a 1uF capacitor to the sensing point which is simple and effective. The famous LFlex driver is also using this method. My driver is powered by 2 pieces of Sanyo 18500. The current of the LED is set at 2A. The IC of the protection circuit is Ricoh R5460N212AF.

Sixty545,

Thanks for your quick reply. I shall try the PINSWITCH with 3 SMD for my driver.

I've added the cap, resistor, diode network to pin 2 of my AK-47A and programmed it with the 8-mode driver files from sixty545. (Thanks for the files!)

It works, but I don't get a reliable tap detect. It seems the tap must be very short to register and advance to the next mode. Is that normal? I've tried using a 1uF cap and that helps a bit but I think that something else is going on here. What am I missing? The diode I'm using is a ZHCS400 schottky, should it be a standard silicon? (cathode to ground, right?) Caps are X7R. Did I miss something in programming? FuseHigh = 0xED FuseLow = 0x79.

I'll try scoping it out, I hope the probe doesn't load the circuit down too much... maybe the resistor could be 1Meg (or less? with a larger cap)

How can something so simple cause so much trouble?

I'm using a 100nF/10mΩ/silicon diode circuit and it works like a charm. When I tried replacing the diode with a schottky type, I had the same problems you are seeing.

Thanks Tido. As that late Jim Williams (of Linear Tech) once said, "Didn't read the datasheet? Then you shall have no pie." The Schottky diode I used has a reverse leakage of about 3-5uA, seems low till you do the math, 4uA at 3Volts = 750kΩ. The 10MΩ in parallel was effectively out of the circuit! I'm now using the venerable 1n914, (reverse leakage = 25nA) and the tap works like a charm.

Oh, by the way I'm having trouble building the code using AVR Studio 5. It creates a .hex file of 4.5kbytes. I'll ask the firmware guys at work for some tips on Monday, have a nice weekend!

hi, i just registered to thanks tido and all here for this great sources and comments.

yesterday i setup my first own driver and it work like sharm. i modify some timings at the beacon mode.

now i wan to take a closer look to the low battery routine. my wish is that a seperate small led will light when 3 volts are detected. and i will flash slow maybe at 2.9 volt, little faster at 2.8 volts...realy fast at 2.5 volts (i am using a imr setup so the 2.5 volts are not realy a problem). i think this is doable, but i am not a programmer. i am a administrator and i had a electronic education several years ago.

thanks again, markus

Take a look at the README to find out how to adjust the low voltage threshold. Controlling a second LED is a bit more tricky. You can either modify every mode function to handle the extra LED or change the watchdog timer ISR to do this.

The second option is the one I would choose. I'd rewrite the voltage monitoring part to toggle an I/O pin after being triggered and every time it's called thereafter. To adjust the blinking frequency, you'd have to change the WDT prescaler, so the ISR gets called with increasing frequency.

hi tido,

that sounds great. i read about to modify the voltage threshold, so today i will start to build the voltage devider and test it, but the extra led will be a nice feature for me (maybe also for other).

thanks, markus

Welcome to BLF Markus! There is a wealth of knowledge here.

Let us know how your program works, you can share your code if you like.

-Crux

I got all the required hardware and was able to upload the Fixed settings without any problems. Now I will try to compile the driver of my dreams, moon-l-m-h, hidden Beacon, Strobe and SOS.

Thanks to everyone involved in this great project, especially Tido!

hi crux,

nothing special at my code. only some changes at the beacon timing. fixed modes with ultra low, low, med, high and beacon.

i am an electronic engineer, not a programmer so i have to wait and hope that tido implement the trigger function for me.

i still need a other change, for a other project i have in my head. i try to illustrate my next idea: i wan to make a little flashlight that have two xp-g (high cri) an one xp-e (red) for night. now when you first power on the light the red schould be glowing. second: the white with low mode, third: white with med and so on. my idea for the shematic is that the first power on triggers any other io pin, for example pb0, from the attiny. idealy it should only go to logic high. with this a can use a 7135 to power the red one. the second power on trigger should be a normal pwm to io pb1. i think this will be no problem for a coder...

markus

That's an interesting idea for a light. The red light works well at preserving night vision. About five years ago, I modified a headlight to use 3 red Leds (instead of 3 white ones) and one Luxeon 1W (instead of a krypton bulb). It had a neat control circuit for selecting either light, so I kept that. I redesigned the driver circuit to accommodate the different Leds. It has only one mode, but will dim when the batteries get low (to extend their life). I'm not tempted to redesign it again, even though today's Leds are brighter.

I hope you have success with your project, I agree that it seems like a SMOP (Simple Matter Of Programming) - but I'm not a coder either...