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

Sadly 0 programming experience. :/

Actually the only reason i don't have the hardware yet is i never fully understood the rewiring of the soic clip to the usb programmer interface as from what i gathered have to be fiddled with.

Anybody got any ideas?

Hi first post,

I have been following this thread with great interest (thank you Tido and everyone for the resource) and have purchased an avrispmkII and 3M soic clip. I am trying to reprogram a 2.8amp (8x 7135) driver that I purchased from Shiningbeam. I've hit a snag. Below is a screenshot of the error message I'm receiving. At first I thought the connection was bad but the green light comes on after I run the command, apparently indicating that the chip/target is receiving power. I've checked pinout three times, and I seem to have continuity in all pins. Any ideas from anyone? Is this the type of message I would get if the reprogramming fuse is set to prevent re-writing? Anything else I could check?

-Jon

Macintosh-3:~ JCI$ avrdude -P usb -p t13 -c avrispmkII -n

avrdude: stk500v2_command(): command failed

avrdude: stk500v2_command(): unknown status 0xc9

avrdude: stk500v2_program_enable(): cannot get connection status

avrdude: initialization failed, rc=-1

Double check connections and try again, or use -F to override

this check.

avrdude done. Thank you.

Looks like your connection isn't good, but I gave up a while ago I hit a dead end with my programming at this point. I actually de soldered a tiny13 chip to play around with so I can get the connections on easier. Sorry I couldn't be more help.

Use your multimeter and go from the clip to the programmer and make sure there is continuity again. It is written kind of weird I had to do mine twice because i read it wrong the first time before i got the right connections.

http://flashlight-wiki.com/AVR_Drivers

Thanks for the suggestion, I double checked the continuity with DMM and even soldered the leads directly to the pins on the chip, and the continuity was good between avrisp board pins and the chip pins. I don't know what else to do. I have another question: if you test the voltage between the vcc and gnd pins on the programmer (avrispmkII), should there be a constant voltage of 5V? Mine is showing basically no voltage between vcc and gnd on the programmer. I know I'm using a power usb.

I just pinned mine out and except for the ground closest to the VCC pin the rest have 5 volts (VCC-Ground)

So I just finished reading a review of the avrisp mkII, and it happened to mention that this programmer only senses voltage, but does NOT supply power to the target. Oops. So, I connected an xml to the driver, and soldered up a simple switched circuit to power the driver with 1 18650 3.7V li-ion, and wouldn't you know it, now I get a response! Of course, being me, I don't get the correct response:

Macintosh-3:~ JCI$ avrdude -P usb -p t13 -c avrispmkII -B 1 -u -Uflash:r:flash-dump.hex:i -Ueeprom:r:eeprom-dump.hex:i -Ulfuse:r:lfuse-dump.hex:i -Uhfuse:r:hfuse-dump.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x068001

avrdude: Expected signature for ATtiny13 is 1E 90 07

Double check chip, or use -F to override this check.

avrdude done. Thank you.

Does anyone know why my attiny13A chip would spit out the wrong device sig? Anything I can do about it?

One thing I do know is that I'm getting a USBtinyisp so I don't have to rig a separate power source, which is cumbersome and impractical to use.

So, some progress, but still not able to load Tido's code yet.

-Jon

that is were i have been for about 2 months now

Wow,

When I first saw this thread, I was excited. I was thinking that I could get a 4-Mode driver w/memory, High-100%, Medium-50%, Low-15%, Moon-light-2%.

This conversation has gone so far over my head, that I'm back to searching the internet for an alternative. I don't think that this level of modding is EVER going to be within my reach 8-( .

Just to throw in my 2¢, if anyone gets to where they are custom programming some of these drivers, I'd like to buy 3-5 of them. Nothing fancy, just 4 modes, no strobes, w/memory.

Let us non-programmer types know. I'm still going to keep watching, but I'm not understanding a lot of what I'm reading.

Thanks, and keep up the good work!

I here you man I have been fighting with this for a couple months at this point I have given up. Maybe I will try again soon.

Let's make a pool to make someone savvy make a few custom flash ready images with desired modes for us to use. That's it.

Get the soic clip the usb programmer load that load of apps and flash rightaway. About 5 versions per drivery type (the most common would probably fit 90% of requests). Unless i'm missing something it would certainly be doable.

4 modes with low low, 3 modes with XY spacing, 4 mode H-M-L or L-M-H with beacon. etc...

So, I finally am able to flash Tido's code to my drivers! The solution for me was to buy a USBtiny programmer kit from Adafruit, which requires assembly but which also powers the target board. Once I connected my attiny13-controlled SB 2.8A driver to this programmer, I had no problem. Next up is tackling the code so that I understand it well enough to set custom levels for a 4-level fixed mode no-memory driver. I think I am starting to understand, although I agree with the others that having the simple, programmable, and fixedmodes code in separate files in C would greatly increase my understanding. If I ever get the fixedmodes code sorted by itself I will post it (with Tido's permission).

I also have a question about pinswitch: does this feature allow you to program to fixed groups of modes (two sets of Low-med-high for example), where the mode sets can be selected by the state of the pinswitch pin? If so I am interested in learning how I might include another switch, such as tightening/loosening the bezel or tailcap, to change the pinswitch state and access the alternate mode set. Does the attiny13 have the memory for something like this, or am I misunderstanding the pinswitch feature?

This might be of interest - this link http://hlt.media.mit.edu/?p=1229 gives instructions on how to program an ATtiny using an Arduino

For more information about AVR and ATTiny there is also AVR Freaks...a noob's nightmare ^^

I've successfully reprogrammed several drivers now, using a USBtinyISP programmer that supplies voltage to the target through USB power. I'm now working on modifying the code to so that I can have 4 fixed modes, similar to the changes sixty545 outlined for another member.

My problem is similar to others who have tried to build the code in AVRStudio: the error message "undefined reference to 'start_wdt' " comes up continually. I've solved the util.delay issue by defining the speed of the CPU, however I don't know where to start with this last error. I'm positive I have not changed anything in the code that would cause this, as I tried building the code without any modifications and this error still appears. It also occurs with an older version (0.3) of the code I downloaded. Does anyone know why 'start_wdt' is not defined in this code, and how I can fix this so it will build in AVRStudio5?

-Jon

I finally took the time and made my own driver program (from scratch). It mimics sixty454's UI: 11 modes currently, but once a mode is locked (>2s on), it will restart with the 1st mode as next mode. I have my most used modes at the beginning, no need to cycle through the rarely used modes all the time.

It's my 1st version and leaves room for improvement, as it doesn't have many features: Just various levels of brightness, strobe, beacon. No batt level measurement yet, no off-time-measuring ("pinswitch"), not programmable. And it doesn't have BLF-VLD's flexibility.

The other meaning of "leaves room for improvement" is that there is quite some free space: It uses 480 byte currently. The source code is shorter and maybe a bit easier to see through. Further it uses much less EEPROM writes and a wider wear leveling over 32 bytes. Some kind of ramping could be done.

Next thing I'll probably implement is a 5 minute timer; I have a need for that. My watch can do that of course, but a flashlight doing that is somewhat special :) Won't be very precise though I guess, due to ATtiny's frequency variations, but I think it'll suffice.

Implemented the 5 minutes timer; every minute it blinks out the number of remaining minutes, after 5min it strobes for 10 seconds, then it blinks weakly and slowly (in case you missed the strobe). I like it. :) Costs 126 bytes though.

With XM-L and Nanjg 105C at 1.2MHz and Tido's driver I don't get any output on the lowest level (PWM 1) (I guess the 1.7µs pulse is just too short for the AMCs).

Does anyone of you do? With what settings?

Edit: Hm, I just browsed the thread, Tido seems to use 4.8MHz, I guess with a prescaler of 8 with phase-correct PWM that should give a minimal pulse of 3.3µs and a PWM frequency of ~1.2kHz.

Edit: Ah, I got it now... low fuse 0x69, that's 0.6MHz CPU freq, PWM prescaler of 1, PWM frequency 1.2kHz. Thanks Tido!

Dear Tido,

I am thinking to replace the R2 with a NTC resistor to change the battery monitor to a temperature monitor. I would like to ask for your help to change the RAMPDOWN from every five seconds to let say 30 seconds or 60 seconds. If LOWBAT_RAMPDOWN is not defined, whether LOWBAT_MAX_LVL is also needed to be undifined. Many thanks.