STAR Firmware by JonnyC - Source Code and Explanation

1335 posts / 0 new
Last post
ImA4Wheelr
Offline
Last seen: 3 weeks 13 hours ago
Joined: 02/03/2013 - 14:51
Posts: 7924
Location: SC

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.

Sirius9
Sirius9's picture
Offline
Last seen: 17 hours 23 min ago
Joined: 03/04/2012 - 19:23
Posts: 4603
Location: South Europe

@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 Big Smile

 

drdanke
drdanke's picture
Offline
Last seen: 1 year 2 months ago
Joined: 12/05/2013 - 18:21
Posts: 82
Location: Milwaukee, WI
Sirius9 wrote:
@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 Big Smile

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.

Sirius9
Sirius9's picture
Offline
Last seen: 17 hours 23 min ago
Joined: 03/04/2012 - 19:23
Posts: 4603
Location: South Europe

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 Silly

 

Primal
Primal's picture
Offline
Last seen: 17 hours 8 min ago
Joined: 07/17/2013 - 17:07
Posts: 119
Location: De Pere,Wisconsin

CRX wrote:
I was just getting comfortable changing out drivers, soldering and reflowing LEDs. Now THIS!...

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.  

JW980
Offline
Last seen: 1 year 5 months ago
Joined: 01/12/2014 - 11:15
Posts: 45

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.

JW980
Offline
Last seen: 1 year 5 months ago
Joined: 01/12/2014 - 11:15
Posts: 45

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 Sad

Thanks for sharing this with us!

WarHawk-AVG
WarHawk-AVG's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 01/04/2014 - 06:47
Posts: 5071
Location: H-Town

drdanke wrote:

Absolutely BRILLIANT!

NightCrawl
Offline
Last seen: 3 years 10 months ago
Joined: 01/22/2012 - 08:20
Posts: 3071
Location: Karlsruhe, Germany

How does ADC_LOW 130 and ADC_CRIT 120 translate into volt?

Tom E
Tom E's picture
Offline
Last seen: 1 hour 55 min ago
Joined: 08/19/2012 - 08:23
Posts: 12427
Location: LI NY

NightCrawl wrote:

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?

AlexTG
Offline
Last seen: 3 years 2 weeks ago
Joined: 10/29/2012 - 08:40
Posts: 202
Location: Kiev, Ukraine

Tom E wrote:
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)
Tom E
Tom E's picture
Offline
Last seen: 1 hour 55 min ago
Joined: 08/19/2012 - 08:23
Posts: 12427
Location: LI NY

Could do that, but you would get the flicker of the temporary mode change (brighter). If you pause and wait to process the single-click to see if a double-click is coming, you introduce a response delay. Double-clicks are great when they simply continue, or feed off the single-click operation.

AlexTG
Offline
Last seen: 3 years 2 weeks ago
Joined: 10/29/2012 - 08:40
Posts: 202
Location: Kiev, Ukraine

Then extra-long press (>1s) for off?
There’s a lot of options there, we just need to find the most convenient.

Tom E
Tom E's picture
Offline
Last seen: 1 hour 55 min ago
Joined: 08/19/2012 - 08:23
Posts: 12427
Location: LI NY

Well with the current design, as soon as a long press exceed 512 msecs, it acts on a long press action (mode decrement), so you have the same mode flash issue. Also, I would prefer one simple single click to turn it OFF.

JW980
Offline
Last seen: 1 year 5 months ago
Joined: 01/12/2014 - 11:15
Posts: 45

I just want to say “Thanks” again to JonnyC (and anyone else who contributed to the Star1.1 code) for sharing this with the rest of us.

With a little more fiddling around today, I was easily able to customize it to provide exactly the functionality I’ve been looking for:

  • L, MH, Turbo (1-minute) output levels
  • No low battery step-down warning flash (step-down is warning enough for me)
  • “Soft Blink” critical low battery cut-off warning (20 blinks @ 750ms on / 750 ms/slightly dimmed)
  • 3.17V low battery step-down trigger voltage
  • 2.84V critical low-battery cut-off trigger voltage (might raise that a bit for unprotected cells)

This code accommodates my needs (and my limited programming skills) quite nicely.

Sincerely, Thanks – again,

JW

Tom E
Tom E's picture
Offline
Last seen: 1 hour 55 min ago
Joined: 08/19/2012 - 08:23
Posts: 12427
Location: LI NY

Me Too! Thanks double JonnyC and RMM!! Just programmed my customized version of STAR Momentary into a ZY-T11 clone (here), UltraFire. Here's what I did:

  • Modes: 0,5,15,92,255 (5=moonlight, 15=6%, 92=36%, 255=100%)
  • Running PWM's at 9.4 kHz (phase corrected)
  • Cut the long press down time from a 1/2 sec to 1/4 sec (much more responsive!)
  • Added a new compile switch option of "Idle Lock", and set the time to 1.2 secs. What this does is if the light is ON, check for a time the button is Idle for - if it exceeds the limit (ex: 1.2 secs), then the short click will turn the light OFF. The long click is still functional
  • Disable TURBO option, enable Voltage Monitoring keeping the low of 3.1v, and critical changed to 2.84v

So for me, I like the Idle Lock feature because with the quicker long press because:

  • From OFF - one click to moonlight
  • From OFF - 1/4 sec hold to High
  • When turning ON, you can change modes all you like as long as mode changes are within 1.2 secs of each other, just as you used to
  • While ON, if you pause from changing modes more than 1.2 secs (i.e. idling), a click will turn the light OFF, but longer clicks will still change modes from higher to lower

The behavior is more like Dr Jones' lumodrv, but not exactly the same. Also the one-click-OFF feature is really nice with a higher numbers of modes, like 5 or 6.

If anyone is interested, I can publish the modified source code - let me know.

Other details of the mod build:

  • QLite 3.04A with 2 7135 350's added (3.74A total), piggy backed on stock driver, stripped all components off the stock driver except the switch. Removed the stupid charger connector too.
  • copper penny added under the pill top for extra heat sinking (Arctic epoxied, surfaces sanded, solder added on edges of penny to fill small gap to the pill walls)
  • XM-L2 U2 1A on 20mm Noctigon -- thinner star from stock results in reflector rattle, so added an o-ring between the reflector and glass -- worked well!
  • copper braided driver spring, need to copper braid tail spring also
  • roughly doing 1,100 lumens or so on a Pana PD. May go up a bit with copper braiding on the tail, using a Pana PF or Sam 20R, and replacing the stock lens with a AR
WarHawk-AVG
WarHawk-AVG's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 01/04/2014 - 06:47
Posts: 5071
Location: H-Town

Tom E

Got a STAR_Tom_E.c for us?


Tom E
Tom E's picture
Offline
Last seen: 1 hour 55 min ago
Joined: 08/19/2012 - 08:23
Posts: 12427
Location: LI NY

I can post it, somewhere, maybe on Google Driver like RMM did. But, I pm'ed JonnyC with a question/issue yesterday, waiting for a response. I'd like to get his response first to be sure the code is ok... Also I'd like to hear from RMM if this is ok to do?

Microa
Offline
Last seen: 1 week 1 day ago
Joined: 06/29/2011 - 21:20
Posts: 236

Thanks JohnnyC and RMM sharing the code. Also, Tom E enrich the features of convenient option.

Please publish the code to let us the AVR dummies can learn and experience the new customized features.

Tom E
Tom E's picture
Offline
Last seen: 1 hour 55 min ago
Joined: 08/19/2012 - 08:23
Posts: 12427
Location: LI NY

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...
Microa
Offline
Last seen: 1 week 1 day ago
Joined: 06/29/2011 - 21:20
Posts: 236

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.

Tom E
Tom E's picture
Offline
Last seen: 1 hour 55 min ago
Joined: 08/19/2012 - 08:23
Posts: 12427
Location: LI NY

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.

JonnyC
JonnyC's picture
Offline
Last seen: 1 year 1 month ago
Joined: 01/14/2011 - 19:12
Posts: 1145
Location: Green Bay, WI - USA

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.

JW980
Offline
Last seen: 1 year 5 months ago
Joined: 01/12/2014 - 11:15
Posts: 45

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

WarHawk-AVG
WarHawk-AVG's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 01/04/2014 - 06:47
Posts: 5071
Location: H-Town

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

JW980
Offline
Last seen: 1 year 5 months ago
Joined: 01/12/2014 - 11:15
Posts: 45

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

JonnyC
JonnyC's picture
Offline
Last seen: 1 year 1 month ago
Joined: 01/14/2011 - 19:12
Posts: 1145
Location: Green Bay, WI - USA

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 Smile

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.

WarHawk-AVG
WarHawk-AVG's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 01/04/2014 - 06:47
Posts: 5071
Location: H-Town

JW980 wrote:
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
I tried that, it get's all squiffy...
Microa
Offline
Last seen: 1 week 1 day ago
Joined: 06/29/2011 - 21:20
Posts: 236

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.

MountainKing
Offline
Last seen: 1 month 2 weeks ago
Joined: 12/01/2011 - 03:20
Posts: 2273
Location: Lost Islands ™

Is there this kind of thread in CPF?

Never ever forget and forgive. Niwal**er new kid on the block trying to act tough.
http://budgetlightforum.com/node/24847
Do not support this brand.

DINODIRECTSCAM COMPANY. DO NOT BUY
http://budgetlightforum.com/node/11324?page=2#comment-254983

Pages