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

Yes, it will run out of regulation rather fast and act as direct drive, only less effective due to the AMC's own voltage drop.

Hm, I think they may be only needed when used with a switching power supply?

I just did a quick test and the stars work just like they do on the AK-47. You get exactly the same mode groups.

One version of the datasheet states that a 0.1µF ~ 1µF buffer cap should be added to the output pin if the LED is not mounted on the same PCB. It's probably true that this will only have an effect if the supply current is not steady, but with PWM we're having a switching frequency of up to 20kHz.

I'm just a software guy, so when the datasheet strongly recommends adding this caps, I try sticking to it. Do we have an EE around here who could comment on this?

That is so awesome! Thanks for checking, Tido!

The capacitor is used to limit oscillations that can occour when switching large currents through inductive paths like a long wire. The oscillations produces voltages that could be destructive for the components and/or violates EMC regulations. EMC = Electro-Magnetic Compatibility. This concerns noise disturbance of other electronic equipment. A driver without the capacitor could make a "dirty" light.

The clip showed up today. Hopefully I'll get the USB stick soon and be ready to try this thing out. If I do a programmable UI, I'm thinking I'll set up 4 modes and set them L-H-L-H to start with. Then if I need a medium or a different Low, I can set that. But L-H-L-H will be like having a 2-mode light with an option for 4 modes.

All my stuff has arrived. I just can't find the time to test it the first few days

I got my programmer today, but I'm not having any luck yet. I downloaded WinAVR first, then Eclipse C/C++ and configured it using instructions here:

http://interactive-matter.org/how-to/developing-software-for-the-atmel-avr-with-avr-eclipse-avr-gcc-avrdude/

But when I tried to get the settings from the device, I got an error. So then I started using AVRdude to see if I could read the chip and I don't think I'm getting a connection. I don't know if it is the driver or the clip, but I get one message when I have a bad connection (same message I get when I don't even connect to the clip) and another when I am connected, but it still can't seem to find the chip. I'm using USBasp as the programmer which I guess is right for the thing I got from eBay.

There is a jumper on the board that I am leaving in place. Also, I hope I didn't fry the board but one time I was grabbing it and my finger was across the 3 resistors near the USB jack and they felt very hot or maybe even shocked me. Also I guess it is okay to pull the programmer out of the USB port whenever I want? And I can connect or disconnect the flashlight driver while it is plugged in? Also does it matter which way the clip is attached? I've tried both ways to make sure I'm not clipped upside-down.

This is the no connection error (programmer has a green LED lit, a red LED flashes briefly when I send this command):

C:\>avrdude -c usbasp -p t13

avrdude: warning: cannot set sck period. please check for usbasp firmware update
.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

This is the other one I get when I seem to have the clip on the chip correctly (green light is off):

C:\>avrdude -c usbasp -p t13
avrdude: error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc

Did you reconfigure the clip's pinout? The pattern on the output of the 10-pin avr header doesn't magically match the chip's pins.

That's probably a big part of the problem. The programmer came with a 10-pin cable and the clip came with an 8-pin cable. Plus, the 8-pin cable is not feeding into slots in position 9 and 10 on the programmer, so I need to undo the connector on the clip's cable and move wire number 8 over to position 9 in order to connect to MISO on the controller.

The programmer circuit board has the following printed, the first column on one side, and the other column on the other side of the board near the connector. The numbers are my guess as to the wire numbers in the ribbon cable.

1 MOSI VCC 2
3 NC GND 4
5 RST GND 6
7 SCK GND 8
9 MISO GND 10

The ATTiny13 is configured as follows, using ATMEL's pin numbers. The pin numbers are as follows in this table and the picture. I don't think Pins 2 and 3 are needed for programming the chip:

1 RST VCC 8
2 ??? SCK 7
3 ??? MISO 6
4 GND MOSI 5

You'll always need to rearrange the pin wires (almost all of them), there's no way around it. Nobody makes an AVR 10-pin to ATTiny13 clip. :) Undo the clip, pull everything out, stack them back in right order and crimp again. Forget the numbering for this part, just look at the entirety of the setup and make sure the right pin on the usbavr goes to the right pin on the chip.

The little hole/depression on the chip in lower left is likely pin 1.

Hmmm . . . I originally guessed Pin 1 based on how the text was printed and figuring the chip was right-side up if you could read the text. But when I connected it that way the green LED would turn off. So when I do it with Pin 1 in the lower left, at least the green LED stays lit, but I still get the no connection error in AVRdude. But connecting the six pins that I think are needed for programming still didn't work, though I also tried all the combinations of Pins 2 and/or Pin 3.

The green led probably indicates powered-on. Not all of the wires need to be connect for programming as it's just serial.

Did you recrimp the rest of the wires correctly? Checked continuity w/ meter?

I checked continuity from the USBasp-labelled point to the correct pin on the clip. But I'm not sure the wires in the teeth of the clip are making good contact. Some of the teeth seem a little short. I might have to try soldering the individual ribbon wires to the Atmel chip legs which won't be easy.

You should first check that all the pins make proper contact. You picture shows that, except for RESET (pin 1) and MOSI (pin 5) all relevant pins are connected somewhere on the PCB, so you won't have to probe the chip's pins with needles or something like that. Also make sure that the target receives power from the programmer and maybe check whether the PCB still works. Applying Vcc to the wrong pins might have fried the chip.

If you can find no problem there, it might be that the chip has its clock fuses set to 1MHz or less. In that case you will have to tell avrdude to use a slower bit clock. Default is set at ~1µs and it's suitable for clock speeds of 4MHz and up. Try -B 0.25 or 0.1 (if your programmer is based on the USBasp, you might need to set a jumper somewhere to enable programming of slow clocked targets).

Still nothing. I don't have the AK-47 board hooked up to anything yet, so I can't really check to see if still works, but I did put my NANJG 106 driver back together and it still works (kind of; Low and Medium seem to be the same thing now). I tried the bit rate thing and still got the same error. I also tried soldering to the legs of the Atmel chip and that was pretty hopeless. I actually got one wire on there pretty easily, but when I tried to put a wire next to it, they were bridged. Instead of a clip, it seem like it would be better to have a housing that fits over the chip with wires where each leg goes. Then you could clamp the housing down to make sure there was good contact. Theoretically the clip should work just fine, but it seems so poorly made. Some of the pins are loose so when you pull on the crimped joiner the whole pin comes out of the clip.

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.

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.

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.

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.