STAR Firmware by JonnyC - Source Code and Explanation

1335 posts / 0 new
Last post
wight
Offline
Last seen: 1 year 4 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

Hoop wrote:
6.2 build 1502.

The actual line of code related to the error is: PROGMEM uint8_t modes[] = { MODES };

I also edited the line at the beginning of the program to change mode spacing: #define MODES 12,70,255

Right, the fix is in post #413 I think. http://budgetlightforum.com/node/29150?page=13#comment-636664
JonnyC wrote:

Hmm, I don’t get that error when I compile. The line in question must be this…

PROGMEM  uint8_t modes[] = { MODES };

Maybe try just adding “const” in there, as it is constant (doesn’t change at runtime), so it doesn’t hurt for me to add that too.

PROGMEM  const uint8_t modes[] = { MODES };

Maybe you’re on a slightly newer version of ARV Studio than me (5.0.1223) so it’s providing better warnings?  I tried enabling all warnings and it still wasn’t giving me that error.

If that’s the fix I’ll have to add that into the file posted on my site.

Subsequent posts indicated that this fix worked.

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

JonnyC
JonnyC's picture
Offline
Last seen: 3 months 1 week ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

Whoops, I'll fix that up.  The Dual Switch is kind of the redheaded stepchild that doesn't get the attention that the other programs do.  I actually haven't even used it yet other than in my test rig.

I just pushed the changes to Git.

Hoop
Hoop's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 12/20/2012 - 05:33
Posts: 1036
Location: Spokane, WA

Thanks a lot wight and JonnyC.

I am putting this driver in a Convoy L4. I sure am glad to use this firmware!

JonnyC
JonnyC's picture
Offline
Last seen: 3 months 1 week ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

Hoop wrote:
I am putting this driver in a Convoy S4. I sure am glad to use this firmware!

Funny thing is, I wrote this so that I could mod the S4 I bought a while back but never used.  I still haven't modded it or used it Sad  It's an awesome light, but I'm so used to the overhand grip and being able to switch modes with just my thumb that a C8 is my go-to light.

Hoop
Hoop's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 12/20/2012 - 05:33
Posts: 1036
Location: Spokane, WA

Oops, I meant L4, not S4. Party How would the momentary version of the firmware behave in the L4 I wonder?

JonnyC
JonnyC's picture
Offline
Last seen: 3 months 1 week ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

Ha!  I meant L4 too Smile

RMM
RMM's picture
Offline
Last seen: 1 year 5 months ago
Joined: 07/23/2013 - 13:47
Posts: 4006
Location: USA

Hoop wrote:
How would the momentary version of the firmware behave in the L4 I wonder?

Every time you turned off the light it would just default back to off, unless you set the lowest mode to something other than off then I'm pretty sure it would default back to that mode.  

Mountain Electronics : batteries, Noctigon, and much more! What's new? 

Hoop
Hoop's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 12/20/2012 - 05:33
Posts: 1036
Location: Spokane, WA

I haven’t seen this mentioned anywhere so I guess it’s a no brainer to connect the switch to ground? But do I wire star 4>switch>GND for the Dual Switch version?

wight
Offline
Last seen: 1 year 4 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

Hoop wrote:
I haven’t seen this mentioned anywhere so I guess it’s a no brainer to connect the switch to ground? But do I wire star 4>switch>GND for the Dual Switch version?
Yes.

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

Hoop
Hoop's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 12/20/2012 - 05:33
Posts: 1036
Location: Spokane, WA

Dang wight. You fast. :bigsmile: Thanks again.

Edit: Anyone in the mood for a sandwich? Crown

Everything worked well and looks fairly trim and proper. I don’t think it warrants its own thread, but what I did was remove all of the components from the stock driver contact board and then made the necessary connections for the switch and power. One leg of the switch is jumped to ground, the other leg is connected to a wire which wraps around the flat side of the board and makes its way up to star 4. I didn’t have any really tiny wire (or bother to use a single strand of copper) so Kapton tape was necessary to prevent the switch wire from shorting on the driver retaining ring after the driver was installed. The mode spacing I went with was 12,70,255. It isn’t night time yet but the spacing seems pretty good. I gas de-domed an XM-L2 U3 on a 16mm noctigon (didn’t have any 20mm ones) and bolted it up. The holes that the stock LED board mounting screws “thread into” are actually not threaded at all, but they are the perfect size for a 4-40 cut tap so I tapped them and used some 4-40 BHCS. 3/16” is a good length.

Now I just have to make the rifle mount. I’ll update this post when I’m done with it in a few hours.
————————————————-
Edit: There we go. Now off to the folks to see if it fits….

————————————————-

Edit: nope, I underestimated the size of the barrel. I’ll remake it with a hinge and a pull pin screw so the light can be removed instantly. My parents have too few lights to let it sit on the rifle unused so it should be removeable easily. Good point about the physical connection of the driver in this application wight; I hadn’t considered it much. Fortunately it is only a .22 and has virtually no recoil so I think the solder joint on either side of the switch housing will suffice in this instance.

wight
Offline
Last seen: 1 year 4 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

Hoop wrote:
Dang wight. You fast. :bigsmile: Thanks again.

Edit: Anyone in the mood for a sandwich? Crown

http://i988.photobucket.com/albums/af2/vibratoryfurniture/light%20projec...

Everything worked well and looks fairly trim and proper. I don’t think it warrants its own thread, but what I did was remove all of the components from the stock driver contact board and then made the necessary connections for the switch and power. One leg of the switch is jumped to ground, the other leg is connected to a wire which wraps around the flat side of the board and makes its way up to star 4. I didn’t have any really tiny wire (or bother to use a single strand of copper) so Kapton tape was necessary to prevent the switch wire from shorting on the driver retaining ring after the driver was installed. The mode spacing I went with was 12,70,255. It isn’t night time yet but the spacing seems pretty good. I gas de-domed an XM-L2 U3 on a 16mm noctigon (didn’t have any 20mm ones) and bolted it up. The holes that the stock LED board mounting screws “thread into” are actually not threaded at all, but they are the perfect size for a 4-40 cut tap so I tapped them and used some 4-40 BHCS. 3/16” is a good length.

Now I just have to make the rifle mount. I’ll update this post when I’m done with it in a few hours.

No problem. Your work looks good. One thing to consider, especially for a rifle light IMO, is the physical connection between the two PCBs. It looks like your only rigid physical connection is the switch casing being soldered onto the GND ring of the driver. If that’s the case consider adding epoxy or something to stiffen up the bond. In fact, consider air-wiring that connection and then using epoxy/whatever to do the physical connection. Just my two cents!

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

wight
Offline
Last seen: 1 year 4 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

Hoop wrote:
Edit: There we go. Now off to the folks to see if it fits….
Woah! Snazzy looking. Love

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

wight
Offline
Last seen: 1 year 4 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

Hoop wrote:
Edit: nope, I underestimated the size of the barrel. I’ll remake it with a hinge and a pull pin so the light can be removed instantly. My parents have too few lights to let it sit on the rifle unused so it should be removeable easily. Good point about the physical connection of the driver in this application wight; I hadn’t considered it much. Fortunately it is only a .22 and has virtually no recoil so I think the solder joint on either side of the switch housing will suffice in this instance.
I realized that I’d spoken out of turn as soon as I saw your snazzy barrel-clamping mount made up for such a small barrel. I agree with you.

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

JonnyC
JonnyC's picture
Offline
Last seen: 3 months 1 week ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

How did you make that clamp?  That's really nice.  Are you hiding some nice machines and machining skills from us? Wink

Looking back at your posts:

1.)  Very nice firmware flashing guide!!

2.)  Did you ever develop those Mag heatsinks?

Hoop
Hoop's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 12/20/2012 - 05:33
Posts: 1036
Location: Spokane, WA

Thanks fellas. :bigsmile:

Yea, I’m a professional machinist and happen to have a Haas vertical machining center in my garage. I really need a turning center though. In due time…
I did develop the mag heatsinks but I’m still working on the battery carriers. It’s going to be a whole kit.

Ive recently thought about offering machining services to BLF. I saw Nitro’s x6 heatsinks thread and thought… I could beat the price he was quoted by a few dollars per part. I’m more focused on starting a full fledged flashlight manufacturing company at the moment though.

There we go. This new clamp design is almost sufficiently complicated, just how I like it. (when you see my mag heatsink you will get the joke)
On second thought… I think I will make a post about this L4 build when it’s done. Enough derailing this thread!

Edit: From concept to reality. It better fit this time cuss that took like 13 hours…. (I used my “micrometer eyeballs” on the barrel because I didn’t bring a measuring tool) I made the “T screw” handle bigger so it would be easier to use. More shots to come in the post I’m making about the build.

Hoop
Hoop's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 12/20/2012 - 05:33
Posts: 1036
Location: Spokane, WA

Say fellas, I think I will use the STAR firmware to customize the driver functionality in my mag kits, but one change I need to make is memory off by default.

I presume I need to change the following line, but how exactly?

memory = ((PINB & (1 << STAR4_PIN)) > 0) ? 1 : 0;
MRsDNF
MRsDNF's picture
Offline
Last seen: 3 weeks 6 days ago
Joined: 12/22/2011 - 21:18
Posts: 13473
Location: A light beam away from the missus in the land of Aus.

That is one sweet looking bracket you made Hoop. Have you a picture of your mill?

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 2 weeks 3 days ago
Joined: 01/12/2013 - 14:40
Posts: 10655
Location: (469219) 2016 HO3

Hoop wrote:
Say fellas, I think I will use the STAR firmware to customize the driver functionality in my mag kits, but one change I need to make is memory off by default.

I presume I need to change the following line, but how exactly?

memory = ((PINB & (1 << STAR4_PIN)) > 0) ? 1 : 0;

Just swap the 1 and the 0, and it’ll reverse the meaning of having that star soldered. So, “0 : 1” instead of “1 : 0”.

Or if there’s still room left, you could add a second line to logically invert it: “memory = !memory;”

With drivers that don’t have an off-time capacitor, I definitely prefer this “no memory” or “short cycle memory”, so it always takes 3 taps to access mode 3, always takes 5 taps to access mode 5, etc. Going from 3 to 5 still takes 5 taps because the saved mode resets back to zero after the light has been on for a full second.

But I like off-time methods even better. It can still have no memory, but it then becomes one tap to go from 4 to 5, and one medium tap to go backward from 5 to 4, instead of taking 5 taps and 4 taps respectively. And it will always start in the first mode after being off for a few seconds, regardless of what you did before. (short cycle memory has sort of a bug where if you tap 4 times quickly and immediately shut it off, it’ll start on mode 5 next time because it wasn’t on long enough to reset back to zero)

The other thing I like about off-time methods is that it allows for shortcuts or “negative” modes. Basically, turn it on, then instead of doing a short press to go to the second mode, do a medium press to go backward. It can do something different in that case, like turbo or battery check, or whatever. There can even be more than one “negative” mode.

Oh, um, but if you want the end user to be able to configure the modes, regular STAR firmware is the way to go (and a driver with solderable stars on the back).

Hoop
Hoop's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 12/20/2012 - 05:33
Posts: 1036
Location: Spokane, WA

Thanks ToyKeeper! Since my mag kit will be targeted to the general public I want it as simple as possible, so no memory. Three partial presses of the mag switch to get to mode 3. Always start in low mode from OFF.

MRsDNF wrote:

That is one sweet looking bracket you made Hoop. Have you a picture of your mill?

I actually made a thread on CPF about the whole garage conversion. I bought all the required components and made the fixtures for a 900 watt Nichia 219A lighting setup for the garage but still haven’t finished it…. Will be over 40,000 lumens of passively cooled light from my fixtures once I bother to finish it.

Hoop
Hoop's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 12/20/2012 - 05:33
Posts: 1036
Location: Spokane, WA

ToyKeeper wrote:
With drivers that don’t have an off-time capacitor, I definitely prefer this “no memory” or “short cycle memory”, so it always takes 3 taps to access mode 3, always takes 5 taps to access mode 5, etc. Going from 3 to 5 still takes 5 taps because the saved mode resets back to zero after the light has been on for a full second.

But I like off-time methods even better. It can still have no memory, but it then becomes one tap to go from 4 to 5, and one medium tap to go backward from 5 to 4, instead of taking 5 taps and 4 taps respectively. And it will always start in the first mode after being off for a few seconds, regardless of what you did before. (short cycle memory has sort of a bug where if you tap 4 times quickly and immediately shut it off, it’ll start on mode 5 next time because it wasn’t on long enough to reset back to zero)

I just tested out my mag kit with the fresh STAR firmware and no memory. I don’t like how it functions. Just like you said, it always starts from low when changing modes from an existing mode, so if I am in medium and I want to go to high, it takes three clicks instead of one. Ideally the mode would be changed every time with a single click, but from off it would always start on LOW.

I’ll have to give off-time firmware a try once I get some caps in…

wight
Offline
Last seen: 1 year 4 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

Hoop wrote:
ToyKeeper wrote:
With drivers that don’t have an off-time capacitor, I definitely prefer this “no memory” or “short cycle memory”, so it always takes 3 taps to access mode 3, always takes 5 taps to access mode 5, etc. Going from 3 to 5 still takes 5 taps because the saved mode resets back to zero after the light has been on for a full second.

But I like off-time methods even better. It can still have no memory, but it then becomes one tap to go from 4 to 5, and one medium tap to go backward from 5 to 4, instead of taking 5 taps and 4 taps respectively. And it will always start in the first mode after being off for a few seconds, regardless of what you did before. (short cycle memory has sort of a bug where if you tap 4 times quickly and immediately shut it off, it’ll start on mode 5 next time because it wasn’t on long enough to reset back to zero)

I just tested out my mag kit with the fresh STAR firmware and no memory. I don’t like how it functions. Just like you said, it always starts from low when changing modes from an existing mode, so if I am in medium and I want to go to high, it takes three clicks instead of one. Ideally the mode would be changed every time with a single click, but from off it would always start on LOW.

I’ll have to give off-time firmware a try once I get some caps in…

In my opinion ontime with “no memory” is 100% intolerable. It’s the polar opposite of offtime with “no memory”. Look forward with hope. Wink

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 2 weeks 3 days ago
Joined: 01/12/2013 - 14:40
Posts: 10655
Location: (469219) 2016 HO3

FWIW, the off-time firmware expects the capacitor to be on the star normally used to toggle memory. So, there is no “no memory” option. You’ll probably have to add that yourself, but it’s not too hard. The issue is that end users won’t be able to toggle it.

Personally, I’d rather sacrifice the mode-order star for this instead, and retain the moon toggle and memory toggle. Always low to high, but at least people can have memory if they want it.

BTW, if you enable mode memory without the capacitor, it’ll still take two clicks to change modes. It’s really annoying. Sometimes it’ll take one click, sometimes two, depending on how long the light has been on.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 2 weeks 3 days ago
Joined: 01/12/2013 - 14:40
Posts: 10655
Location: (469219) 2016 HO3

wight wrote:
In my opinion ontime with “no memory” is 100% intolerable.

I still find it preferable to ontime with memory. I don’t really mind short-cycle memory, since the most-used modes are generally at the beginning so they never take many clicks to access… and the least-used modes are at the end where they can be ignored most of the time.
wight
Offline
Last seen: 1 year 4 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

ToyKeeper wrote:
wight wrote:
In my opinion ontime with “no memory” is 100% intolerable.

I still find it preferable to ontime with memory. I don’t really mind short-cycle memory, since the most-used modes are generally at the beginning so they never take many clicks to access… and the least-used modes are at the end where they can be ignored most of the time.
Hmm. I’ve only used ontime with no memory on the bench. Maybe if I used it on an EDC things would seem different. Make no mistake: I also strongly dislike the “sometimes one, sometimes two” taps required by a standard ontime-with-memory firmware.

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

Hoop
Hoop's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 12/20/2012 - 05:33
Posts: 1036
Location: Spokane, WA

wight wrote:
Make no mistake: I also strongly dislike the “sometimes one, sometimes two” taps required by a standard ontime-with-memory firmware.
Agreed. Ontime without memory is preferable to ontime with memory, but still not ideal.
JonnyC
JonnyC's picture
Offline
Last seen: 3 months 1 week ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

We can probably all agree that on-time anything is worse than off-time anything Smile  A lot of us "grew up" with on-time w/ memory, so for me I was entirely used to it.  But anytime I gave a light to a friend and tried to explain how it worked I realized how horrible the UI is.

Hoop - Awesome, awesome, awesome shop.  A new flashlight company, hell yeah!  I'm excited to see what you can do.

MRsDNF
MRsDNF's picture
Offline
Last seen: 3 weeks 6 days ago
Joined: 12/22/2011 - 21:18
Posts: 13473
Location: A light beam away from the missus in the land of Aus.

Thanks Hoop. I'm pretty much speechless. Just gotta say love the garage. Smile

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

wight
Offline
Last seen: 1 year 4 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

I’ve run into a problem, I’m not sure why.

I built up one of these: DD driver w/ low parasitic drain for e-switch lights. I used 10uF for both input and output capacitors on the LDO (a 3.3v LT1761).

Then I flashed it with STAR_momentary w/ voltage-mon disabled. (how do I properly refer to the commit I used? Is there a concise way to communicate this information? ba5fb9efbd5ad11e0edd4008123301532ac0a277 ?) (for my own reference – 2014-12-20_STAR_momentary_v1.6+no-voltage-mon.hex)

The problem is that in the highest mode (Turbo) only a long press works. A short press doesn’t switch from Turbo to Off. I can step through the modes forward as expected – 0,3,14,39,125,255, but it does not loop from 255 to 0. I can step backwards 255,125,39,14,3,0 and have it loop from 0 to 255 as expected. Turbo does have an MT-G2 at >8A, but I don’t see how that would have an effect on my momentary input to the MCU, especially when we consider that it does recognize the long press. Any ideas? Thanks!

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

JonnyC
JonnyC's picture
Offline
Last seen: 3 months 1 week ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

Crap, that sucks.  When you are in turbo and a short press doesn't turn it off, will another short press bring you to the first mode?  I remember there was an issue with the PWM output not getting set to 0 before going to sleep for some crazy reason that makes me hate AVR programming, which is why I added this stupid line of code...

_delay_ms(1); // Need this here, maybe instructions for PWM output not getting executed before shutdown?

That seemed to fix it, but maybe it isn't enough.  Are you able to (I hope!) reprogram the driver with ease?  Maybe you can try commenting out the "sleep_until_switch_press()" call when it shuts the light down for being at the 0 index mode and see if it works then.  This is not a solution, but it will be a way to debug it.

wight
Offline
Last seen: 1 year 4 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

JonnyC wrote:

Crap, that sucks.  When you are in turbo and a short press doesn’t turn it off, will another short press bring you to the first mode?  I remember there was an issue with the PWM output not getting set to 0 before going to sleep for some crazy reason that makes me hate AVR programming, which is why I added this stupid line of code…

_delay_ms(1); // Need this here, maybe instructions for PWM output not getting executed before shutdown?

That seemed to fix it, but maybe it isn’t enough.  Are you able to (I hope!) reprogram the driver with ease?  Maybe you can try commenting out the “sleep_until_switch_press()” call when it shuts the light down for being at the 0 index mode and see if it works then.  This is not a solution, but it will be a way to debug it.

Thanks JonnyC! Good question, I didn’t connect the dots on my own. This is such a high current setup I can barely get my thoughts together during my brief, brief tests.

Yes, two short presses takes me to the first mode. I can go back to “off” with a long press. It seems that the problem is exactly as you suspected.

Unfortunately the driver is in a difficult to reach position. (oops!) I’ll build another for testing. Once there’s a solution I can take the other out and flash it. Smile

I’m eyeballing the sleep_until_switch_press function now. I guess this is the sort of thing where the debugger that was recently discussed could be very useful; many important things happen in that function and in the WDT_off() function it calls.

I guess you suspect that a slightly longer delay could band-aid the situation?

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

Pages