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

863 posts / 0 new
Last post
sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

OK, brted, I'm slowly starting up now, the USBISP driver and WinAVR is now installed on my XP workstation.

I'm about to make the connections between the plug on the clip and that on the USBISP. I think we have bought the same gear so you can check against this:

Tiny13 pin  Clip plug    USBISP plug

1 RST              1                  5

2 no use           3

3 no use           5

4 GND              7                 4/6/8/10

5 MOSI             8                  1

6 MISO             6                  9

7 SCK              4                   7

8 Vcc               2                   2

I'm happy if you can find an error here.

brted
brted's picture
Offline
Last seen: 3 days 19 hours ago
Joined: 01/12/2010 - 19:44
Posts: 2371
Location: Atlanta

It seems like you have it. I'm not sure what your clip plug numbers are though. Going into the USBasp, the only cable I moved was the last one from position 8 to 9. I did all of the mixing and matching on the clip end. So the first wire in the ribbon cable matches up to USBasp 1, then 2 with 2, etc.

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

The clip plug numbers are for the 8 pin plug at the end of the cable.

I just discovered that the connection from pin 5 on the clip is broken between the tip and the little window at the side of the clip. What a bad quality!

The crimped leads seems to be easy to pull off and rearrange, so I think that I will make a straight connection between the two plugs with a 2x5 pin array and then rearrange the leads on the clip. Pin 9 on USBISP has to be handled separately.

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

I get exactly the same response from avrdude as you reported on nov.26. The green light (power on) is lid and the red flashes once when sending the command. There are more loose connections in the clip, that pease of sh..

I don't feel like going into micro surgery today, I am more courious of measuring on my newest light, a tiny Black Cat with Osram LED. This is my first Osram and I'm eager to see how it performs, tint-wise.

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

After a little (very small) soldering, and adding to the command: -P com2 -n (a little program, "USB View" showed me that USBasp was on Port2, the -n is for no writing).

I got this: 

 

But what now ? Tido, can you help? I don't really know what this means. Is it good, or is it very good?

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

That looks very promising. AVRDude has successfully established a connection to the ATtiny. Now you could try flashing one of the prepared images. Go to the "Programmable" directory and call AVRDude like this: 

avrdude -pt13 -c usbasp -P com2 -u -Uflash:w:BLF-VLD.hex:a -Ueeprom:w:BLF-VLD.eep:a -Ulfuse:w:0x79:m -Uhfuse:w:0xef:m

 

This should result in output like this:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.15s

avrdude: Device signature = 0x1e9007
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: current erase-rewrite cycle count is 18088202 (if being tracked)
avrdude: erasing chip
avrdude: reading input file "BLF-VLD.hex"
avrdude: input file BLF-VLD.hex auto detected as Intel Hex
avrdude: writing flash (1024 bytes):

Writing | ################################################## | 100% 1.88s

avrdude: 1024 bytes of flash written
avrdude: verifying flash memory against BLF-VLD.hex:
avrdude: load data flash data from input file BLF-VLD.hex:
avrdude: input file BLF-VLD.hex auto detected as Intel Hex
avrdude: input file BLF-VLD.hex contains 1024 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.35s

avrdude: verifying ...
avrdude: 1024 bytes of flash verified
avrdude: reading input file "BLF-VLD.eep"
avrdude: input file BLF-VLD.eep auto detected as Intel Hex
avrdude: writing eeprom (64 bytes):

Writing | ################################################## | 100% 0.89s

avrdude: 64 bytes of eeprom written
avrdude: verifying eeprom memory against BLF-VLD.eep:
avrdude: load data eeprom data from input file BLF-VLD.eep:
avrdude: input file BLF-VLD.eep auto detected as Intel Hex
avrdude: input file BLF-VLD.eep contains 64 bytes
avrdude: reading on-chip eeprom data:

Reading | ################################################## | 100% 0.11s

avrdude: verifying ...
avrdude: 64 bytes of eeprom verified
avrdude: reading input file "0x79"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.05s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0x79:
avrdude: load data lfuse data from input file 0x79:
avrdude: input file 0x79 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.05s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xef"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.05s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xef:
avrdude: load data hfuse data from input file 0xef:
avrdude: input file 0xef contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.05s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: jtagmkII_close(): bad response to GO command: RSP_ILLEGAL_EMULATOR_MODE

avrdude done.  Thank you.

That's it, the driver should now be running the programmable version of the BLF-VLD.

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

Another screenshot:

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

Thank's Tido, Will this burn any fuses or can I program the device otherwise afterwards?

In fact I'm more interrested in making a light with fixed modes at my own levels but will try your example first if it is not destructive.

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

As long as you don't set any lock bits and don't disable serial programming, the chip can be reprogrammed a few thousand times. Just make sure you get the fuses right (that's what '-Ulfuse:w:0x79:m -Uhfuse:w:0xef:m' does).

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

Done! 

So now I have a monster-driver 2.8A (8x7135) with variable setting. Exiting. But what about 1020 bytes instead of 1024 bytes?

I would want to test it without undoing my elaborate soldering work. (must try to repair that clip).

Thank's again, Tido,

I hope that brted also will be successfull.

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

sixty545 wrote:

So now I have a monster-driver 2.8A (8x7135) with variable setting. Exiting. But what about 1020 bytes instead of 1024 bytes?

 

Nothing to worry about. I just created the example output from a current development version, not the flash image in the published archive.

agenthex
agenthex's picture
Offline
Last seen: 6 years 2 months ago
Joined: 07/14/2010 - 04:49
Posts: 3070
Location: Merica

I got the clip. It's true not the greatest build quality, but it's pretty standard "pomona soic clip 5250" sold at digikey, etc. If any of the pins are short, you can push them out from inside the clip near the hinge.

 

My problem is that DX won't ship out the drivers. I should probably order some at KD.

Reading this makes you smarter: http://lesswrong.com/

nkildal
Offline
Last seen: 4 years 5 months ago
Joined: 12/02/2010 - 03:13
Posts: 34
Location: Denmark

Hi All

 

This is my first post in the forum, and I just want to thank Tido for his work on the flashlight driver.

Using the soic clip listed in this thread and an arduino board as a very cheap avr programmer, I have now reprogrammed my BLF AA-Y4E to have exactly the modes I like.

It has also been great fun to play around with the driver software "inventing" highly unusable modes Smile

 

Regards

Nicolai

Don
Don's picture
Offline
Last seen: 2 years 9 months ago
Joined: 01/12/2010 - 16:32
Posts: 6617
Location: Scotland

Welcome nkildal. Good to have you here!

 

The numbers from my light tests are always to be found here.

https://spreadsheets.google.com/ccc?key=0ApkFM37n_QnRdDU5MDNzOURjYllmZHI...

brted
brted's picture
Offline
Last seen: 3 days 19 hours ago
Joined: 01/12/2010 - 19:44
Posts: 2371
Location: Atlanta

It's encouraging to hear people are having some success with this. I'll tinker around with mine some more this weekend and see if I can get it working. Nice that it works with the BLF AA Y4E, Nicolai! I always wonder how many people like you are lurking here, reading the threads, buying stuff, and yet we never know. Glad you've shown yourself.

nkildal
Offline
Last seen: 4 years 5 months ago
Joined: 12/02/2010 - 03:13
Posts: 34
Location: Denmark

brted - I found the following things a bit challenging:

1. My clip was of bad quality - some of the pins were pulled back a bit, making it hard to make proper contact with the pins of the chip

2. The right wires need to be connected from the AVR programmer to the connector of the soic clip. Your post with the images and tables helped me do that - thanks brted

3. Using Mac/OSX I had to download and set up a compiler environment (I chose CrossPack-AVR, http://www.obdev.at/products/crosspack/index.html) - this was easy Smile

4. Lastly I had to use the correct avrdude command line to program the chip. Tido and sixty545's comments above in this thread, helped enourmously - thanks guys.

None of the above are real showstoppers - I just had to take it easy and be careful - so good luck when you get to the tinkering Smile

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

nkildal wrote:

Using the soic clip listed in this thread and an arduino board as a very cheap avr programmer, I have now reprogrammed my BLF AA-Y4E to have exactly the modes I like.

Also a warm welcome from me, Nicolai!

I have an easy question for you, right away:

Does the BLF AA-Y4E have an ATtiny13 or did you put in a new driver?

nkildal
Offline
Last seen: 4 years 5 months ago
Joined: 12/02/2010 - 03:13
Posts: 34
Location: Denmark

Hi there

The BLF AA-Y4E uses a driver with an ATtiny13 - so it was very easy to open it up and just reprogram it.

It has very short wires from the driver to the LED, so I had to unsolder wires to get the driver out.

I have sinced replaced the wires with longer ones, so I now only need to loosen the driver board from the pill to program it.

I didn't originally plan to mess with my BLF AA-Y4E, but I had been waiting for too long, for DX to send me some AK-47's to play with Smile

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

Thanks for giving the BLF-VLD a try, sixty545 and nkildal. I'm very happy that finally someone else can test out my driver. It would be great if you guys could give me some feedback on the mode programming UI. I've got a new version with some new features ready, but I'm reluctant to push out a new release unless I know I won't have to rewrite the whole UI.

nkilda, have you tried using a PWM level of 1/255? I'd really like to know if the boost circuit stabilizes at such low PWM rates and if it's still running efficiently. Could you measure the current drawn from the battery?

nkildal
Offline
Last seen: 4 years 5 months ago
Joined: 12/02/2010 - 03:13
Posts: 34
Location: Denmark

Hi Tido

Yes - I have tried 1/255 and it seems very stable and usable (I like an ultra low low).

 

When using two different 14500 Li-ion cells I measure the following current at the tailcap, but please keep in mind, that my multimeter is a cheap one, so the PWM probably fools it:

DX Trustfire "Blue", sku 19626 @ 4.14V:  0.52A

DX Trustfire "Flame", sku 26124 @ 3.75V:   0.58A

 

I wanted to take a reading with a NiMH cell, but I just discovered, that the light does not come on at all, with any of my NiMH cells (even fully charged ones)...

I use the BLF-VLD with only 5 modes and no memory  ( 255/255 -> 32/255 -> 1/255 -> Strobe -> "Soft Beacon").

Can you think of a possible explanation for the light not turning on with NiMH ?

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

nkildal wrote:

I didn't originally plan to mess with my BLF AA-Y4E, but I had been waiting for too long, for DX to send me some AK-47's to play with Smile

The same here. I am waiting for 4 pc. of 101-AK from DX ordered nov.6 -shipped nov.25!

So I have now programmed a SKU: S009742 from Kaidomain ordered nov.8 arrived nov.22.

I just don't own an emitter (yet) that runs on 2.8 A. The XM-L plug-in is to expensive for me - I fear it should be caught by the P.O.

(I would really like to test that emitter) .

Actually, I bought that driver to harvest the 7135's for bringing  the 101-AK's to do 1.4A, but now I will keep it for the future XM-L Tongue out

I got my 8-pin clip to work after 1 hour of surgery and will now sacrifice the BLF for a better life, hopefully.

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

nkildal wrote:

Can you think of a possible explanation for the light not turning on with NiMH ?

The ATtiny needs at least 1.8V to work.

nkildal
Offline
Last seen: 4 years 5 months ago
Joined: 12/02/2010 - 03:13
Posts: 34
Location: Denmark

Ahh - the good old P.O. - here we have a limit of around 15$ - above this value you get an additional 30$ in handling fee plus 25% VAT Smile

The BLF AA-Y4E worked fine with NiMH before I re-programmed it, so there must be another explanation I think ?

sixty545
Offline
Last seen: 2 weeks 14 hours ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)

Oh, I smell Denmark here. Welcome, fellow countryman.

I think that the $ has risen so the limit is only $14 now Yell

At least we are in the same "boat".

The NiMH matter could be an issue for Tido, perhaps initialization is wrong. Or there should be some form of charge pump to bring the voltage up.

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

nkildal wrote:

Can you think of a possible explanation for the light not turning on with NiMH ?

 

Yes. Actually, that is exactly what I dreaded. When using Li-Ion, the driver is most likely in direct drive and not boosting. On NiMH it needs to boost, but the "on" periods are probably too short to allow the boosting circuitry to start up. Have you tried if it works with higher PWM levels?

Also, could you post a picture of the PCB's component side? Maybe there is no special driver chip and the ATtiny was used to switch the coil. In that case you're screwed when it comes to using NiMHs.

nkildal
Offline
Last seen: 4 years 5 months ago
Joined: 12/02/2010 - 03:13
Posts: 34
Location: Denmark

Nice - thank you - and "godaften til dig også" (sorry non-Danish forum members)...
The SKU S009742 from KaiDomain looks interesting - especially with the new XM-L arriving. I'd better place an order Smile

I could try make the BLF start in the lowest mode, and see if it will run with NiMH's again.

Btw: what is the PWM frequency when running the BLF-VLD firmware - I am very impressed with the flickerfree operation: I see no flicker whatsoever even in the lowest (1/255) mode

nkildal
Offline
Last seen: 4 years 5 months ago
Joined: 12/02/2010 - 03:13
Posts: 34
Location: Denmark

Tido: I think we cross-posted Smile
I'll grab my camera (and soldering iron) and upload some images in a minute... 

nkildal
Offline
Last seen: 4 years 5 months ago
Joined: 12/02/2010 - 03:13
Posts: 34
Location: Denmark

Tido wrote:

Have you tried if it works with higher PWM levels?

I just tried making the driver have one mode only - 1/255 and 255/255 - but it still won't start on NiMH's Sad

Tido wrote:

Also, could you post a picture of the PCB's component side?

Sure - here goes:

BLF AA-Y4E driver

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

Quote:

I could try make the BLF start in the lowest mode, and see if it will run with NiMH's again.

You should try the highest mode (255/255). This way there is a constant current draw from the LED and the boost circuitry should not be impaired by the output PWM.

 

Quote:

Btw: what is the PWM frequency when running the BLF-VLD firmware - I am very impressed with the flickerfree operation: I see no flicker whatsoever even in the lowest (1/255) mode

If you used the fuse settings I posted yesterday, the chip is clocked at 4.8MHz. With phase corrected PWM this should result in ~9kHz PWM frequency. This gives me an idea, you could try setting the chip to 1.2MHz (9.6MHz and CKDIV8 fuse set), thereby reducing the PWM frequency. This would result in longer "on" phases, maybe long enough for the boost circuit to stabilize. But for this the driver needs to be recompiled and after flashing the chip might not be accessible any more with your programmer.

nkildal
Offline
Last seen: 4 years 5 months ago
Joined: 12/02/2010 - 03:13
Posts: 34
Location: Denmark

Tido wrote:

If you used the fuse settings I posted yesterday, the chip is clocked at 4.8MHz. With phase corrected PWM this should result in ~9kHz PWM frequency. This gives me an idea, you could try setting the chip to 1.2MHz (9.6MHz and CKDIV8 fuse set), thereby reducing the PWM frequency. This would result in longer "on" phases, maybe long enough for the boost circuit to stabilize. But for this the driver needs to be recompiled and after flashing the chip might not be accessible any more with your programmer.

I use these parameters when flashing the chip - I took them from your post the other day:

avrdude -P /dev/tty.usbserial-A600aSmp -p t13 -b 19200 -c arduino -u -Uflash:w:BLF-VLD.hex:a -Ueeprom:w:BLF-VLD.eep:a -Ulfuse:w:0x79:m -Uhfuse:w:0xef:m

I am willing to try to lower the chip clock - could you give instructions on this ?

Should it fail, and my driver board becomes dead beyond repair - I will just put on a smile, wait for my AK-47/101 drivers to arrive and - most important - not blame you Smile

Pages