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

863 posts / 0 new
Last post
Microa
Offline
Last seen: 13 hours 40 min ago
Joined: 06/29/2011 - 21:20
Posts: 246

I am thinking to write the BLF-VLD-0.4 to another driver with an Attiny13A. The program seems to suit changing modes by the power on/off switch. Can I use an additional momentary contact switch to change modes without modifying the code ?

Thanks in advance,

shatz
Offline
Last seen: 10 years 3 months ago
Joined: 06/28/2011 - 18:44
Posts: 6
Location: Moscow, Russia

Microa wrote:

Can I use an additional momentary contact switch to change modes without modifying the code ?

Thanks in advance,

AFAIK, no, this program doesn't support external switch to change modes

Microa
Offline
Last seen: 13 hours 40 min ago
Joined: 06/29/2011 - 21:20
Posts: 246

Hi Folks,

I tried to build a version 4 BLF-VLD with 3 modes + battery monitor from the Driver.c file by AVR Studio. The Studio failed to build the files because the contents of the object file exceeded the maximum program monery of the device. So I deleted the lines from 88 to 140 to save space.

 

The Hex file and the eep file can be built and run. However, the LED will be slow flashing after the light is switched on for a while. When the light is switched on at high or at Med, it will rampdown to low. Also, no response to the change of the voltage of the voltage divider. I would like to ask somebody to help me fixing the issue. Thank you. 

 

E1320
E1320's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 03/30/2011 - 05:26
Posts: 3376
Location: New Hampshire

I am already visualizing the duct tape over your mouth.

HID45
HID45's picture
Offline
Last seen: 7 years 6 months ago
Joined: 04/13/2011 - 03:45
Posts: 291
Location: Finland

I had that one in the middle. That's crap. I've heard the 3M should be better, but cannot confirm by my own account. My advice? Go direct drive.

καὶ τὸ φῶς ἐν τῇ σκοτίᾳ φαίνει καὶ ἡ σκοτία αὐτὸ οὐ κατέλαβεν

shatz
Offline
Last seen: 10 years 3 months ago
Joined: 06/28/2011 - 18:44
Posts: 6
Location: Moscow, Russia

I vote for HID45-style too. It's not so hard and if you are flashing well-known 8x7135 driver, it has only 2 pins of MC need to be soldered directly on it, other pins have connections on PCB. So even wife is not necessary Smile 

E1320
E1320's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 03/30/2011 - 05:26
Posts: 3376
Location: New Hampshire

Guys I really want to use a clip I don't want to risk damaging the drivers by extra soldering. I found these but they only show two attachments top and bottom will they still work the price is good.

http://www.hmcelectronics.com/product/3M-Interconnect-Solutions/923650-0...

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

http://parts.digikey.com/1/parts/389604-8-pin-test-clip-alloy-soic-15-92...

I am already visualizing the duct tape over your mouth.

JonnyC
JonnyC's picture
Offline
Last seen: 5 months 3 weeks ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

The 3M clip is the one I have, and it's way better than the Ebay blue one.  I purchased it from Digikey as well.  It has 8 pins if you look at the picture. However, I did need to use the ribbon cable off of the blue one as the 3M came with only the clip.  I also had to modify the clip a bit (shave off the bottom) to get better contact, and now it's finicky.  Try to get it to work as-is first.

E1320
E1320's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 03/30/2011 - 05:26
Posts: 3376
Location: New Hampshire

JonnyC wrote:

The 3M clip is the one I have, and it's way better than the Ebay blue one.  I purchased it from Digikey as well.  It has 8 pins if you look at the picture. However, I did need to use the ribbon cable off of the blue one as the 3M came with only the clip.  I also had to modify the clip a bit (shave off the bottom) to get better contact, and now it's finicky.  Try to get it to work as-is first.

Good deal I will order the one from Digikey, thanks man. I am super excited about doing this. I took C programming in college so it's time to dust off the books and once the clip arrives I will be ready to rock.

I am already visualizing the duct tape over your mouth.

JonnyC
JonnyC's picture
Offline
Last seen: 5 months 3 weeks ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

E1320 wrote:

Good deal I will order the one from Digikey, thanks man. I am super excited about doing this. I took C programming in college so it's time to dust off the books and once the clip arrives I will be ready to rock.

Yeah, it was a lot of fun doing this.  I haven't built any flashlights in a while, and since I upgraded to Windows 7 I can't get the Atmel software working.  I might get back into it again if a friend asks for a different light.

What programmer are you going with?

E1320
E1320's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 03/30/2011 - 05:26
Posts: 3376
Location: New Hampshire

JonnyC wrote:

E1320 wrote:

Good deal I will order the one from Digikey, thanks man. I am super excited about doing this. I took C programming in college so it's time to dust off the books and once the clip arrives I will be ready to rock.

Yeah, it was a lot of fun doing this.  I haven't built any flashlights in a while, and since I upgraded to Windows 7 I can't get the Atmel software working.  I might get back into it again if a friend asks for a different light.

What programmer are you going with?

I ordered this one I hope it works.

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=200460739146&ssPageNa...

I am already visualizing the duct tape over your mouth.

JonnyC
JonnyC's picture
Offline
Last seen: 5 months 3 weeks ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

The nice thing about this one, http://www.adafruit.com/products/46, is that she has a detailed out guide on how to use avrdude to program with (which yours might be able to work with too, not sure), and it ships from the US.

E1320
E1320's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 03/30/2011 - 05:26
Posts: 3376
Location: New Hampshire

JonnyC wrote:

The nice thing about this one, http://www.adafruit.com/products/46, is that she has a detailed out guide on how to use avrdude to program with (which yours might be able to work with too, not sure), and it ships from the US.

I wish I had seen that before I ordered the other one. Digikey is on point I placed my order about an hour ago and it already shipped unbelievable.

I am already visualizing the duct tape over your mouth.

E1320
E1320's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 03/30/2011 - 05:26
Posts: 3376
Location: New Hampshire

OK it looks like its working but I have a problem maybe someone can help.


I am already visualizing the duct tape over your mouth.

E1320
E1320's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 03/30/2011 - 05:26
Posts: 3376
Location: New Hampshire

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.

I am already visualizing the duct tape over your mouth.

HID45
HID45's picture
Offline
Last seen: 7 years 6 months ago
Joined: 04/13/2011 - 03:45
Posts: 291
Location: Finland

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.

καὶ τὸ φῶς ἐν τῇ σκοτίᾳ φαίνει καὶ ἡ σκοτία αὐτὸ οὐ κατέλαβεν

E1320
E1320's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 03/30/2011 - 05:26
Posts: 3376
Location: New Hampshire

HID45 wrote:

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.

I am already visualizing the duct tape over your mouth.

E1320
E1320's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 03/30/2011 - 05:26
Posts: 3376
Location: New Hampshire

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

I am already visualizing the duct tape over your mouth.

Microa
Offline
Last seen: 13 hours 40 min ago
Joined: 06/29/2011 - 21:20
Posts: 246

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.

 

Microa
Offline
Last seen: 13 hours 40 min ago
Joined: 06/29/2011 - 21:20
Posts: 246

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

Crux
Crux's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 05/03/2011 - 16:27
Posts: 227
Location: Northcoast, Ohio, USA

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.

Subterranean
Offline
Last seen: 10 years 2 months ago
Joined: 03/21/2011 - 01:18
Posts: 4
Location: UK

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.

sixty545
Offline
Last seen: 1 year 8 months ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

Microa wrote:

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

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.

Microa
Offline
Last seen: 13 hours 40 min ago
Joined: 06/29/2011 - 21:20
Posts: 246

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. 

Crux
Crux's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 05/03/2011 - 16:27
Posts: 227
Location: Northcoast, Ohio, USA

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?

Tido
Offline
Last seen: 3 years 3 months ago
Joined: 05/28/2010 - 15:28
Posts: 189
Location: Berlin, Germany

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.

Crux
Crux's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 05/03/2011 - 16:27
Posts: 227
Location: Northcoast, Ohio, USA

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 Embarassed 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!

mash.m
Offline
Last seen: 5 years 4 weeks ago
Joined: 07/29/2011 - 00:39
Posts: 17
Location: germany

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

Tido
Offline
Last seen: 3 years 3 months ago
Joined: 05/28/2010 - 15:28
Posts: 189
Location: Berlin, Germany

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.

mash.m
Offline
Last seen: 5 years 4 weeks ago
Joined: 07/29/2011 - 00:39
Posts: 17
Location: germany

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

Pages