STAR Firmware by JonnyC - Source Code and Explanation

Yes.

ah facepalm… Thanks :slight_smile:

Couldn’t find any dedicated procedure in the momentary version code to switch the light off.
Should we just click all the way up or down to “zero mode” to do this?

With 5 levels you're never more than 3 clicks away from the 0%/off mode. Add more levels and it gets annoying, but with 5 it's manageable. Being able to choose to turn on in either high or low, to me, more than makes up for not having an instant-off function.

I would like to think everyone involved with flashlight driver coding and thanks for sharing your hard work with the rest of us crazy flashlight modders. Being able to program a driver to my very own liking has made flashlight modding fun and for me, is the single best thing to happen to flashlight modding in all my years modding. Sure is nice not having to go through all those da flashy modes just to get to the mode you want. Thanks to all, and a special thanks goes out to jonnyC for your help. :wink:

Actually it gives the ability to select a star without permanently soldering it to ground, just unscrew the head, flip the switch to whatever star or turn em all off for stock and screw it back together instead of having to solder/unsolder a star if you want to make a mode “(semi)permanent” for whatever reason

Actually that is a tinkerers dream as you can flash whatever firmware you want to the ATtiny13A, and test it out very easily without all that soldering/unsoldering

Comfychair seems to make some of the most useful "utility" mods...

And I would like to thank ALL the coders that have contributed whatever to the designs...absolutely incredible!!!

And for what it's worth

In the GNU project, our aim is to give all users the freedom to redistribute and change GNU software. If middlemen could strip off the freedom, we might have many users, but those users would not have freedom. So instead of putting GNU software in the public domain, we “copyleft” it. Copyleft says that anyone who redistributes the software, with or without changes, must pass along the freedom to further copy and change it. Copyleft guarantees that every user has freedom.\

Copyleft also provides an incentive for other programmers to add to free software. Important free programs such as the GNU C++ compiler exist only because of this

Nice teamwork guys! Thank you for doing this for all of us. :beer: :beer:

You guys have no idea what it means to share this kind of stuff with us! This source code gave me enough ambition to finally figure out how to flash these things and I had complete success! The comments in the source really helped a lot for me to be able to modify the code a little.

How did I do it? I flashed some Qlite drivers to both NLITE and STAR using an Arduino Uno as an AVRISP using the ArduinoISP sketch. The source was compiled in Atmel Studio 6.1, and I used the newest version of avrdude (version 6.1).

I used a scratch built pin contact setup made of wood, CA glue, bare solid tinned wire, and some breadboard jumpers. The bare drivers were held in place by flipping an empty P60 pill upside down, and the contact pins were lowered onto the driver and held under spring pressure while executing the avrdude commands. Ugly, yes… but works every time with no fiddling, and cost nothing except a little time and a Arduino Uno clone that I had laying here.

Here is a link to the solid wire that I use for the contacts. It’s nothing special, except it’s stiff and solid, and not stranded wire:
http://www.radioshack.com/product/index.jsp?productId=2102500

First upload the ArduinoISP sketch to your Uno. Now your Arduino can function as an AVRISP programmer.
Here is a chart showing the connections that the arduino needs to program the Attiny13A. I also placed a 10uf capacitor between RESET and GND on the Uno. I don’t know if this is really necessary, but the ArduinoISP page says that it is necessary with the Uno. I have also tried it without the capacitor and it still works fine without it, so it is probably unnecessary.

Now, you have to set up avrdude. Download it at the avrdude website here: http://download.savannah.gnu.org/releases/avrdude/avrdude-6.1-svn-20131205-mingw32.zip

Place the avrdude program file and config file in a new folder on your main hard drive, like C:\avrdude or D:\avrdude or replace the drive letter with whatever drive letter your hard drive is.

Now you need a file called libusb0.dll in order for avrdude to work. You can get the file here: http://dlldb.com/libusb0-dll/

Place that file in your C:\avrdude folder.

Now find the shortcut to your windows command prompt. This is located at, Start:All Programs:Accessories:Command Prompt (on Windows Vista)

Right click the Command Prompt icon, and select: Send To: Desktop (Create Shortcut)

Now, there is a command prompt shortcut on your desktop. Right click it and select “Properties”. In the box that says “Start in”, type this in: C:\avrdude

Now, when you need to use avrdude, just click your command prompt shortcut, and simply copy and paste your avrdude commands in. WARNING: When using the command prompt, CTRL+V does not work to “Paste”. You have to right click and select “Paste”.

Here’s the avrdude command I used to flash the star or NLITE firmware using the Arduino. Just replace the COM3 with whatever com port your arduino is connected to, which you can see in your windows device manager.

STAR FIRMWARE
avrdude -p t13 -P COM3 -c avrisp -b 19200 -u -Uflash:w:star.hex:a -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m

NLITE FIRMWARE
avrdude -p t13 -P COM3 -c avrisp -b 19200 -u -Uflash:w:nlite.hex:a -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m

Just a breakdown of the added avrdude commands to use the ArduinoISP programmer:
-P COM3 tells avrdude what port the ArduinoISP programmer is connected to.
-c avrisp is what an arduino ISP programmer is called.
-b 19200 specifies the serial baudrate that the arduino ISP programmer communicates at.

And all the other avrdude commands are standard for avr programming.

Just plug in your Arduino Uno usb cable, let the Arduino boot up, place the pins onto the Attiny13A, and hold it under spring pressure. Press the “reset” button on your arduino, and let the arduino reset. Now just execute the avrdude command. This is what a successful flash will look like in the command prompt:

I had a 3M SOIC8 test clip, and it was a severe pain to get working at first. The shape of the grippers wasn't right to hold onto the chip, I had to disassemble the whole thing and reshape the ends and file the metal contact pins to match. The spring was also way too stiff. It finally wore out for good last week.

I decided to try the cheaper Pomona clip, and whaddya know, it works as-is right out of the box. Already has a fairly light spring, but still able to stay latched on just fine. It's cheaper, too. $11.85 at Digikey, that's about $6 less than the cheapest U.S. sellers on ebay.

Nice Drdanke. I will definitely try making a rig like that soon.

Great tip Comfy. I've been using that same clip since I started flashing chips. It's still holding up well, but I do have to be very precise positioning it every time.

@drdanke
easy and simple, I like it.
If you add 2 more contact wires, for + and - and one emitter you will be able to flash and test the driver in matter of seconds :smiley:

Very good idea. I have been meaning to make a complete external testing setup with an emitter on a heatsink, and having 2 contacts to test a driver right away would be sweet. I will definately work with that.

I had an idea to add battery and switch and make all that as a flashing/testing unit, just pop in the driver, flash, test -> not like -> reflash -> test and so on but…. I was to lazy to do that :stuck_out_tongue:

Im totally with you on this one. It's amazing what JohnnyC and others can do on these drivers. Jon has a great head on those shoulders of his. Now I have to buy some more hosts and buy some of those drivers to put them in. Great work guys.

Thanks to all who have contributed and freely shared their code.

I’m anxious to try out the Star program.

Since others have commented on connection methods in this thread, I thought I’d share my method.

I purchased a pack of 12 mini pin grabbers from a fleabay seller, and they seem to work well on these driver boards - with one minor exception:you can’t attach them to adjacent pins on the Tiny13a (namely 5-6-7).

My solution was to solder a short stiff piece of wire to Vdd of one of the 7135’s (which are all connected to pin 6 of the Tiny13a). This provides an alternate connection point for pin 6 of the Atmel.

So…the mini pin grabbers easily connect to pins 1, 4, 5, & 7 on the Atmel, plus the additional “pin 6” on one of the 7135’s.

Works well for me-ymmv.

Kudos to JonnyC!

I like the Star1.1 firmware very, very much. IMHO - it is well written and well documented. Enough so, in fact, that a hack like myself was easily able to change a few things to better suit my personal preferences.

For instance, I changed the warning flashes to “soft” blinks instead of on/off blinks by changing the appropriate PWM=0 statements to PWM=13. Since I used PWM=15 for low mode, a value of 13 is still easily distinguishable as a warning flash.

I also changed the timing of the warning flashes from 250ms/500ms to 500ms/500ms.

I believe the soft blinks combined with equal dim/bright timing makes the light more usable while the warning is active. This is actually a lot like the warning Willie Hunt programmed into his LVR incandescant regulators many years ago (which is where I got the idea). Many of his regulators were used for bicycle lights, so an on/off warning flash might have been a bit unnerving when travelling at speed on a bike.

While I was at it, I changed the number of flashes announcing eminent shut-off from 10 to 20 to give a bit more time to react.

There are more changes I’d like to make to the low battery step-down and warning code, but I won’t go into that now.

The ability to customize the low battery and critical low battery points is rather nice.

I should mention that the code compiled perfectly using Atmel Studio 6.1 with no errors or warnings at all.

The only real downside I can see is that I now have several lights to tear apart so I can re-flash them :frowning:

Thanks for sharing this with us!

Absolutely BRILLIANT!

How does ADC_LOW 130 and ADC_CRIT 120 translate into volt?

Well, from the luxdrv source, looks like 125 is 3.0v and 5 is 0.1v. I added comments as follows:

#define ADC_LOW 130 // When do we start ramping (3.1v)

#define ADC_CRIT 120 // When do we shut the light off (2.9v)

I've been working with the e-switch version. Added more comments, re-formatted the code a bit, moved all the configurable settings up top with the rest of the settings.


Possible Mod/Enhancement to the e-switch version:

I'm debating adding a 2-4 second time-out (maybe longer) to add a one click OFF. The way it would work is if the light is ON and no clicks for the configured time (2-4 secs roughly), one click turns the light OFF. This means the OFF time-out acts as a lock mode, so you can change modes all you want since turning the light ON, but if left idle, you no longer can change modes. Anyone else see an advantage to this?

Why not just assign some dedicated command for turning off? Double-click, for example?
It would requre adding another check after first click, of course (no click in, say, 0.3 seconds -> next mode; another short click -> off)