NLITE, a free firmware for NANJG drivers

How do you know that it doesn’t have lock bits set if you didn’t tried reding it :slight_smile:

I read the lock bits and the fuse bits. I didn’t try reading and re-loading the firmware (didn’t want to muck it up if it didn’t work).

If I only know how to do that I would backup genuine SW immediately (also if I had new Qlite) :smiley:
so, in the name of BLF progress please do download that SW :stuck_out_tongue:
Thank you and God bless you :bigsmile:

+1

Thanks Dr. Jones!

BTW, is there any danger in flashing the driver in the assembled flashlight (with the LED connected to driver)?

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.