NLITE, a free firmware for NANJG drivers

I do it all the time. Note that if the star connected to pin 5 of the processor is connected you cannot flash the firmware.

Noted, thanks!

I just wanted to take a second to thank you for this! Even though I program my own drivers, this is actually a great option for some hunting lights that I will be building for friends. This will give me the ability to provide them with 4 brightness options with no memory (when out in the woods on a dark morning, moonlight is a great mode to always start on). If later they want to add memory and get rid of moonlight, I won't need to remove the driver and reflash it.

Does this still retain the low-voltage detection?

I've had a hard time setting a moonlight mode on my drivers, especially with that high of PWM frequency. It does vary per LED type, so it was always trial and error until I got the PWM level right. We'll see how this works with an XM-L2.

I'm glad it proves useful :)

Yes, it has low-battery stepdown at 3V under load, like most of my drivers.

Thanks DrJones!

This setup is really great - much better than standard Nanjg. Bit selection is much better instead of 3 predetermined groups prepared by programmer.

By no memory, you mean it will reset back to mode 1 after use, right? What criteria do you use for the memory reset?

Yes, returns to mode 1 after a mode was used for >1s (on-time memory).

Hey DrJones,

About to program this firmware, and I noticed you said PWM is 18kHz. I assume that's using Fast PWM then considering a low fuse of 75 would be running at 4.8MHz, so 4.8MHz/256 = 18,750? Is that correct?

When writing programs before I never paid attention to the PWM mode and used code for the PWM setup from luxdrv and previously from Tido's program. Those both use Phase Correct PWM (TCCR0A=0b00100001). That would be 9.4kHz (4.8/510), which is what I program my lights at. I like this frequency because it's plenty fast, but you can still set PWM levels that somewhat correspond to their output (128 is ~1/2 output, and a value of 4 is usually where it first causes the LED to emit light).

When I tried a ~19kHz frequency by bumping the clock to 9.6MHz (wasn't aware of Fast PWM) I really had to push those PWM values up to the point of having to guess. Does Fast PWM change this, or are you still having to bump up your moonlight value quite a bit?

Also, the prescale factor (N in the frequency equations), I assume that's used just to tweak the PWM frequency? I wouldn't mind something like a ~4.7kHz PWM with the clock at 9.6MHz and a prescale of 8 (or just done by dividing the clock by 8 via the low fuse).

Thanks for reading my ramblings if you made it this far :)

- Jon

Yes, I use fastPWM at 4.8MHz, and it needs pushed up PWM values, too; the value 8 works in all my lights I tested it with, sometimes 7 is fine, too. Timer prescaler is always 1 in my firmwares.

9.6MHz with /8 timer prescaler is what the standard NANJG firmware uses, if I remember correctly.

Thanks for the response!

OK, I started to play with this. It’s harder than it looks like :bigsmile:

Got this installed in a light last night with number 2 and 4 stars bridged for 4 modes with no memory. Works awesome! Thanks DrJones!

Is there any way this works with the Nanjg 105C driver in a Convoy S2-7?

It will work with any NANJG 105C driver, well, as long as it doesn't have the fuses locked (I have yet to experience one that does though). You just need to remove the driver to have access to the MCU for programming.

Could someone go through the procedure, and list all the necessary hardware needed to do this? I tried to plow through the main thread but got lost pretty quickly.

All the stuff about how to set up & test the connection is at http://flashlightwiki.com/AVR_Drivers where it's explained better than I could do here.

Once you have a working connection, to flash Nlite all you have to do is double-click a .bat file.

Make a new folder, and drop nlite.hex into it. Open a new text file, paste the string:

avrdude -p t13 -c usbasp -u -Uflash:w:nlite.hex:a -Ulfuse:w:0x79:m -Uhfuse:w:0xed:m

into the text file, save it as nlite.bat into the same folder where you put nlite.hex. Connect to your driver, then double-click nlite.bat. Done.

I recommend this programmer and an SOIC clip from ebay with attached leads. You'll need to figure out which leads go where, but that's listed in the wiki page. I followed this guide for installing AVRDUDE for doing the flashing.

The other option is to send a 105C to me or anyone else willing to do it, I just charge the cost of return shipping (or you can include a return envelope with stamps). I have some extra 105C's as well, so we could do it that way too.

EDIT: I actually just submitted a product request to FastTech to see if they can carry the SOIC clips and cables.

For some strange reason i can’t get this thing working!
Let’s go chronologically:
1- yesterday I uploaded Tido’s BLF-VLD code with Fixed Modes and it worked (command to do that from flashlightWiki/AVR)
2- then I uploaded NLITE but nothing changed, driver has same behaviour like with “Fixed Modes”
3- like comfychair suggested, I created new folder with nlite.hex I also made 3 bat files here: run cmd.bat with cmd command to open cmd prompt with desired folder path, check.bat with avrdude -p t13 -c usbasp -n command to be able to check if there is proper connection between programmer and driver just by typing check in cmd and flash.bat with this: avrdude -p t13 -c usbasp -u -Uflash:w:nlite.hex:a -Ulfuse:w:0x79:m -Uhfuse:w:0xed:m
using this bat files I uploaded nlite.hex to drive again and it doesn’t work :quest: not a blink from the LED …
4- I used this command then: +avrdude -p t13 -c usbasp e+ which is supposed to do a chip erase. Just to check, connected batt, doesn’t work> OK, chip is erased
5- Now I went to step 3, following same procedure I uploaded nlite.hex, connected batt -> doesn’t work :exmark:
6- Uploaded again Tido’s Fixed Modes code -> it works (with fixed modes UI of course)…

puzzled …

Download a new copy of nlite.hex?

Also there's some weird text formatting in your command, the 'w:0×79' is different than 'w:0x79'. Re-type it by hand instead of copy/paste.

downloaded nlite.hex again, retyped also changed the fuse setings according to DrJones recommendations to: low: 0x75, high: 0xFF
and it works :slight_smile: thanks
Now, to solve “*.elf: No such file” error :slight_smile: in AVR studio 4

×x×x×x×x×x×x×x×x×x×x×x×x×x×x

Those are two different characters and don't mean the same thing to avrdude. Where are you getting the weird little x from?