STAR Firmware by JonnyC - Source Code and Explanation

Here is updated source code: https://drive.google.com/file/d/0B1IxYZuk4Djcc09STnlITjh5OW8/edit?usp=sharing

Few Notes:

  • I used Atmel Studio 6.2 to compile this (latest - marked as BETA)
  • I formatted for tabs being set to every 3 columns, not 4
  • I added a few comments and function headers, etc.
  • I'm a long time C programmer, so re-formatted the code to a style I'm used to. Please understand just because you have 3 lines of code in one line in the source code, doesn't mean it will take less memory up when compiled. Comments and blank lines are free - no penalty in the compiled code.
  • I'm not sure of the de-bouncing is working the way JohnnyC intended. I could be wrong -- waiting on JohnnyC to respond to my PM. The "fix" I suggested is not in this code. I'm thinking de-bouncing may not be necessary on this hardware - not sure...

Thanks Tom E,

I built and run the code in Studio 4.18 with no error. I shall flash the 13A to-night to play with.

In playing with it, the 1/4 sec long click/hold is maybe too aggressive. Probably wise to back off a little - I'm gonna try 0.3 secs or 0.35 secs next time. The way it is now, you can accidentally get a long click if you are not quick.

19 would be the value to use for "LONG_PRESS_DUR" to get 300 msecs, 22 for 0.35 secs.

Tom, I replied to your PM. I'll follow up to other questions/comments tonight when I get back in the US (took a trip to Cozumel for a week). Real quick though I'll say I'm glad you all can utilize this and customize it so easily! I will be adding a slightly modified program for off-time memory. Capacitors arrived at my house yesterday and I'll be building my first light to test it out soon.

I can’t seem to stop playing with this code – I’m having too much fun with it.

In addition to customizing the low battery warning blinks as mentioned previously, I’ve made one more tweak I think I’m going to like.

In essence, I’ve configured the driver for 3 basic mode levels, but with a fourth level that is only reached following turbo time-out.

Momentarily releasing the switch following time-out bumps it back into turbo for another time cycle.

Normal mode cycling is simply L-H-Turbo (skipping the turbo step-down level).

It goes something like this:

Low = PWM 15
High = PWM 75
Turbo = PWM 255 (1-minute)
Turbo Step-down = PWM 150

I’ll fine tune the levels and turbo timer once I put the driver into a host and use it for awhile.

The reason I chose to do this is because I found that having 4 or 5 levels resulted in too much “switch fiddling”. It wasn’t long before I found myself missing the simple 3-mode w/memory configuration. (K.I.S.S. comes to mind once again…)

I think the turbo step-down level combined with a short turbo timer will help to manage heat while not drastically hindering usefulness (at least for my needs).

Thanks for reading…

-JW

once the turbo step down happens can you bump it back up to turbo with a 1/2 button press, or do you have to recycle back thru?

most excellent...can we get a code posting of what you did here [in quotes or a link or whatever]?

If you make a change, post the .c code here so others to compile and mess with it too

Cycling through is not necessary.

Following turbo time-out, last mode memorized was “turbo”, so turning off (for any length of time) then back on will return to turbo mode. In other words - short off, then back on will return to turbo and restart turbo timer.

Are you saying I could copy the text from the .c code, put quotes around it, then post it here? I suppose I could try that…

-JW

comfy - Great info on the dip switches! I was actually browsing DigiKey the other day as I was thinking about doing the same, and I figured someone had already done it. And I agree, after going through about three 3M clips I just went with the Pomona and it's working great.

drdanke - Awesome work and excellent documentation!

BIG-P - Just let me know what you need and I'll get some drivers to you :)

JW980 - Excellent. I just guessed on the low-voltage warning signals and I figured the 250/500ms was a bit goofy, but figured what the heck. And I hear you on tearing down lights to reflash. I probably have 3 or 4 sitting around that have old programs that are just clunky to me now, have bad PWM, etc.

Tom E - I like your firmware. Someone else did/suggested the same thing, where you can switch through modes at the start but after a set number of seconds a short press will turn it off. There are so many options for momentary drivers it's hard to write a program that everyone will like, so I'm glad you were able to customize it.

I received a couple of different 1.0uF capacitors and one style of 2.2uF caps today that I'm going to try out for the off-time memory. I guess that's the next source that RMM can toss up there if it ends up working well, although it's really only 4 or 5 lines that need to change.

I tried that, it get’s all squiffy…

JohnnyC - There are so many thread that I forget which one I have read ” the capacitance change because of the temperature may affect the off-time memory” and there is a link to MLCC of Y5V. I hope you have purchased the 1uF and the 2.2uF are X5R or X7R which capacitance are more stable at high temperature.

Is there this kind of thread in CPF?

No idea..I don't go there

To be honest I had no clue what I was looking at when ordering the capacitors, but I did get X7R ones because they had the greatest operating temperature range. This is one of the ones I purchased - http://www.digikey.com/product-detail/en/CL21B105KBFNNNE/1276-1029-1-ND/3889115.

For anyone interested, my modified version of the Star1.1.c program (see “JBW-” comments) and corresponding hex file have been posted here:

https://www.dropbox.com/sh/yjq5ahllbuqf1zh/yoJRh8nJPT/STAR/JW980.build

Thanks to WarHawk-AVG for posting it for me so others can see what was done :slight_smile:

-JW

Anyone given thought to modifying the e-switch version to do something with a tail power switch? I'm thinking tactical style switch, where power ON comes up in high. With the tail switch off, it's a simple "lock-out". With this no-memory style of mode changing, I don't think mode memory has to be added just for the tail switch - any thoughts?

I got the Yezl Y3 and Convoy L4 I need to do something nice with.

I know that JonnyC was working on something like this back in December...not sure what happened with it. I probably discouraged him (as did the limited memory space).

Tom - you mean lights that have a power switch (rear clicky) and an e-switch? I was building a program for these a while back and thought it was almost done. Basically, the power switch just turned it on to the last mode every time. When you wanted to change modes or ramp you would use the e-switch. I just need to add memory to the momentary program then. Your idea seems interesting though.

Oh, and as for ramping, my original plan was to make the momentary/e-switch program so that it would allow a press-and-hold to ramp, along with all of the other features. I got it working but ran out of room for voltage ramp down, then saw what DrJones was able to do with one of his programs (pretty much everything you could imagine) and gave up in frustration and defeat. Then RMM told me about the UI Werner came up with so I scrapped the ramping for now.

That was because he used a ATtiny58 with 8K flash rather than a ATtiny13A with 1K flash. Which is also the same size as Tido’s MCU but is a different critter all together, it doesn’t use a Amtel MCU, it uses a Zilog Z8F082A MCU

I must say a hybrid type driver would be cool as heck though!

I was actually referring to DrJones' lumodrv which uses the stock 105C. I'm amazed what all he can fit within 1K.

The other UI I really really like is from the LD-36 (I think it's been changed in recent versions, the ones currently being shipped are different). It's really simple. Short press turns on/off, long press for ramping. Each long press alternates direction. And, even if you keep the button held down, it stops when it reaches min/max (the ones that keep going up-down-up-down forever are a P.I.T.A.). If you go up too far, just release and long press again and it goes down.