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

I’ve used usbasp from Fasttech too (on Linux though). At least my devices are not lemons. Fasttech jtag debugger works like a charm with Avrstudio on my virtual machine as well.

The usual reasons for programming failure for me have been: bad contact, incorrect pin connection order, too fast programming clock and noisy signals due to too long cables (where lowering programming clock rate may help). (Assuming the programmer is not a lemon and the software is in the working order).

Did you connect the VCC pin to the clip? A lot of places say you don’t need that or skip it… it does not work without it.

I just have to show you "clip" that I made a couple days ago for Nanjg 105c :)

scary, isn't it :D

That’s pretty ingenious.

damn, that’s really impressive! Nice job :slight_smile:

I have just made a similar firmware, available here .

Heres my experience programming attiny13.

My setup.

Driver is NANJG101-AK-A1. I can’t get ID for attiny13 and I tried tens of times so no go for programming (tried 5v and 3.3v). Then I removed attiny13 and put it in the clip and it worked perfectly, could read it 4 times in row.

Second driver is NANJG AK47 which I can access once. So I have to plug off the UASASP and plug it back in if I want to to anything else to attiny13. Reading it 2 times in row is impossible. Didn’t try removing the ic but I guess it would help

forgot to add that I compiled the code with raspberry pi with installed gcc-avr avr-libc

If you have star 2 connected (pin 5 of the micro) connected to ground (also pin 6 or pin 7), it won’t program.

Also, some drivers have a filter cap on the battery voltage divider bottom resistor. The chip won’t program if it does (or might program with a very slow ISP clock).

There are no stars in this driver and attiny13 pin 5 doenst seem to be connectected to anywhere

Hi all,

DrJones has been helping me with this however it appears that he is very busy these days so in an attempt to bug him less I'm going to see if anyone can help me here

I have some code that I want to use on an ATMEL 25V. It's proven to be working with a 13V. DrJones believed that the code would more or less work on the 25V with 2 minor changes to get voltage detection working. Anyway, his last comment on the matter was to suggest some fuse settings:

[QUOTE]As fuses I’d recommend low:0×52 high:0xFF extended:0xFF

(clock runs at 1MHz then, in AVRstudio: clock:8MHz-RC and check CKDIV8).[/QUOTE]

Now it is important to note I know nothing about ATMEL programming - this is the first time I've ever attempted writing new firmware to an ATMEL chip (I finally got hold of an ISP programmer that works!!!!).

So using what information I could get from the flashlightwiki I entered this:

[QUOTE]avrdude -p t25 -c usbasp -u -Uflash:w:led.hex:a -Ueeprom:w:led.eep:a -Ulfuse:w:0×52:m -Uhfuse:w:0xFF:m[/QUOTE]

Now that appeared to work until it got to the high fuse:

[QUOTE]

avrdude: 1 bytes of hfuse written

avrdude: verifying hfuse memory against 0xFF:

avrdude: load data hfuse data from input file 0xFF:

avrdude: reading on chip hfuse data:

Writing | ################## | 100% 0.01s

avrdude: verifying …

avrdude: verification error, first mismatch at byte 0×0000 0xff !=0xdf

avrdude: verification error; content mismatch

avrdude done. Thank you.

[/QUOTE]

So 2 things:

1) How can I fix the high fuse issue?

2) What is causing the high fuse problem?

3) I didn't even think about it last night, but what should I be doing with DrJone's suggested extended fuse!? I completely missed it lol.


I'll start reading up a bit more and see if I can find something helpful elsewhere on the interwebs. It might be important to note that DrJones' suggested changes to the code have not been made yet. Just in case they could help rectify this issue his suggestions were:

[QUOTE]58: #define ADC_PRSCL 0x06 // ADC prescaler of 64

---> #define ADC_PRSCL 0x05 // ADC prescaler of 32

515: ADMUX = _BV(REFS0) | _BV(ADLAR) | (uint8_t) ADC_MUX;

---> ADMUX = _BV(REFS1) | _BV(ADLAR) | (uint8_t) ADC_MUX;[/QUOTE]


So yeah - any help would be greatly appreciated.

Thanks,

- Matt

EDIT: I'm using DrJone's Luxdrv firmware now and have learnt a few things reading through that thread - namely how to use AVR Studio 6 lol. I can compile code now, and for the 25V at that, so now I just need to work out how to make it work for me...

nice job - don’t forget to report back :slight_smile: I have a couple of 25s I’d like to use and programming scares the beejesus out of me…

Will do. The pin layouts between the 13 and 25 are identical so as far as I can tell you should be able to readily compile code written for the 13 to run on the 25. Fuses may be different but I know sweet F.A. about them at the moment!

My issue now is that I think (haven't had the opportunity to check yet) that the pin associations on my PCB are different to what you typically find on the KD/DX boards people use here. I'm hoping at least a few a similar. My board has:

  • Voltage monitoring on pin 7 - VIN to a 3k resistor, sensed on pin 7, and 10k resistor to GND.
  • Temperature monitoring on pin 3 - Vref out of pin 2, into a 10k resistor, sensed on pin 3, and a 100k NTC thermistor to GND.
  • PWM out is on pin 6.

Ideally I will just modify the luxdrv firmware to move functions to different pins (if required) and to work with my particular components, but as yet I have no idea where to start.

I'm sure i'll be back here in the coming days begging for help lol.

Cheers,

- Matt

No, one nasty difference between the TINY13 and TINY25/45/85 is the register value that you have to write to select the 1.1V bandgap reference for the A/D converter. Atmel could have easily made the registers compatible, but they screwed up…

The TINY25 does have an internal temperature sensor, you could use that instead of an external thermistor.

Shows how much I know lol. The pin layout is still the same is it not? I'll have to grab the datasheets again and check...

As for the temperature sensor - I'm using a leaded NTC thermistor so I can place the actual sensor tip closer to the LEDs (or whatever parts I specifically want to keep an eye on). Granted I did not realise the 25 had an internal sensor - I chose it for the added flash so I can have more complicated code and features.

I'll post in DrJones' luxdrv thread and see if he can help me convert the luxdrv to run on the 25. He seems to be very busy at the moment though so I may be waiting a while :(

Ah well!

Recently, I have modified Tido’s codes to suit my driver with LM45 temperature sensor. Three modes, light level step down to a pre-set level when over-temperature.

The codes are deleted.

The driver code that I have is not compatible with the Nanjg style drivers and would not be of much use… I plan on doing some Nanjg compatible code… someday, hopefully soon.

Have a look from post #155 on in the luxdrv thread: https://budgetlightforum.com/t/-/4672?page=3#comment-406170

There is some discussion there regarding the use of the luxdrv firmware on a Tiny25. I am busy working on code that will work with the Tiny25, but again it is based on the luxdrv firmware. I'm also VERY new to this so it'll take me days, whereas people like PilotPTK, texaspyro, DrJones, Tido etc could probably smash something out in 5minutes.

Note the code PilotPTK posted in post #157 has a few typos and 1 or 2 bugs in it. These are pointed out later on in the thread.

No problem, I will patiently wait for your good news.

Microa use a service to share code, don’t paste it into comments.
pastebin
ideone
gist.github.com
etc.

But don’t worry it seems you’re not the only one who can’t share code online. I guess this is normal outside programming places… but it’s horrible.

Mattaus: Fuses, Fuses calculator, and the rest just try to google or search on atmel and atmel/avr forums/programming related places

Fuses are settings of the chip. And no you can’t probably just take settings from one type of chip to another. Maybe they would work when the only difference is just the speed etc. But you gotta make settings for each chip you program for. Or at least be damn sure they are the same between those chips. And refer, see the chip’s documentation for the settings. There is something online, sure but it may be outdated. And I think you can even render your chip useless, brick it by wrong fuses so be careful what you set the fuses to.