STAR Firmware by JonnyC - Source Code and Explanation

1335 posts / 0 new
Last post
pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 1 week ago
Joined: 05/30/2013 - 23:31
Posts: 6422
Location: Held against my will in IOWA, USA

Quote:
Here is a link to the diff vs the original STAR_on_time v1.1 code (pre dual-PWM): https://www.diffchecker.com/6wbp3uu9

thanks for that! now I can get it all set up while i’m still at work.

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

vex_zg wrote:
I don’t know (yet) how to adjust PWM frequency, any tips/code snippets?

Yes, it’s quite a big jump, when I increase it from PWM=2 to 3.

I am only using “secondary” PWM output at those low PWM levels, why would that be a incompatible with adjusting PWM frequency?


The attiny13a can do two PWM channels or one PWM channel with a variable ceiling value. Not both. Since you’re already using two channels, you can’t change the ceiling. It uses the same register for both functions, but can only do one function at a time.

It would technically be possible to change modes when necessary, but it still can only change the ceiling on the primary PWM channel. The secondary channel is hardcoded to the highest ceiling value. So, it still doesn’t help, if your low modes are on the second channel.

Otherwise, if you’re curious I have a code example in both Ferrero_Rocher/Ramping_UI_table.c and in cypreus/cypreus.c .

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

pilotdog68 wrote:
What would it take to add a fast strobe mode? Or is there already an off-time FW that includes a strobe?

I have an example of off-time FW with strobe in cypreus/cypreus.c in my code repo. Or an example with the new “noinit” off-time and fast strobe in s7/s7.c. But those both include a lot more than just a strobe; they’ve got all sorts of extra modes, and have diverged pretty far from their STAR origins.

Regardless, it demonstrates a way to add blinky modes.

pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 1 week ago
Joined: 05/30/2013 - 23:31
Posts: 6422
Location: Held against my will in IOWA, USA

ToyKeeper wrote:
pilotdog68 wrote:
What would it take to add a fast strobe mode? Or is there already an off-time FW that includes a strobe?

I have an example of off-time FW with strobe in cypreus/cypreus.c in my code repo. Or an example with the new “noinit” off-time and fast strobe in s7/s7.c. But those both include a lot more than just a strobe; they’ve got all sorts of extra modes, and have diverged pretty far from their STAR origins.

Regardless, it demonstrates a way to add blinky modes.


hmm I looked at cypreus, but for some reason I thought it was a momentary FW. I might have to take another look. This is for someone else, it just needs L> M > H > Strobe

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

pilotdog68 wrote:
hmm I looked at cypreus, but for some reason I thought it was a momentary FW. I might have to take another look. This is for someone else, it just needs L> M > H > Strobe

Yeah, it’s massive overkill for just four modes. It has, um, 15 modes. Or 18 depending on how they’re counted. Mostly, it just demonstrates one method of adding more stuff (like strobes) with an off-time clicky.
marruz
Offline
Last seen: 5 years 11 months ago
Joined: 09/05/2014 - 03:52
Posts: 17
Location: Czech Republic

Hello guys,
I am working on the a17pzl driver and I would like to make a change in STAR off-time firmware that would enable me to set 255 pwm on secondary output for single 7135 and 0 pwm on primary output. I know that this change might create complications with stepdown battery monitoring and other functions but I am willing to comment them out for the ability to have the driver run 350mA on a single 7135 in one of the modes.
I am not sure what is the right and easiest way to do it. Any help would be appreciated.
Thanks.

vex_zg
Offline
Last seen: 3 years 5 months ago
Joined: 08/10/2014 - 11:08
Posts: 420
Location: Sweden
marruz wrote:
Hello guys, I am working on the a17pzl driver and I would like to make a change in STAR off-time firmware that would enable me to set 255 pwm on secondary output for single 7135 and 0 pwm on primary output. I know that this change might create complications with stepdown battery monitoring and other functions but I am willing to comment them out for the ability to have the driver run 350mA on a single 7135 in one of the modes. I am not sure what is the right and easiest way to do it. Any help would be appreciated. Thanks.

you can take a look at star momentary firmware, there you can see how the second PWM output is used, it’s just a few more lines to be able to use the second PWM output.

In that FW, there is another array with PWM levels for the alternate PWM Channel, and for each flashlight mode you can set separately what the PWM levels are outputted at both channels.

marruz
Offline
Last seen: 5 years 11 months ago
Joined: 09/05/2014 - 03:52
Posts: 17
Location: Czech Republic

Thank you vex_zg for a prompt reply. It seems more complicated than I thought. The momentary FW deals with modes a little differently and I am not sure how to adjust the off-time FW that I will be using.

vex_zg
Offline
Last seen: 3 years 5 months ago
Joined: 08/10/2014 - 11:08
Posts: 420
Location: Sweden
marruz wrote:
Thank you vex_zg for a prompt reply. It seems more complicated than I thought. The momentary FW deals with modes a little differently and I am not sure how to adjust the off-time FW that I will be using.

I plan to add secondary output to off-time capacitor reverse-clicky star firmware, within a week or two… I can share once I’m done…

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

I finally built a moonlight special test host tonight, and should be making a STAR derivative very soon with that sort of thing built in. I’ve been busier than I expected, but I’m getting there…

marruz
Offline
Last seen: 5 years 11 months ago
Joined: 09/05/2014 - 03:52
Posts: 17
Location: Czech Republic

That would be excellent vex_zg and ToyKeeper. I am glad to hear that. Please share the code when you are done. Thank you

pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 1 week ago
Joined: 05/30/2013 - 23:31
Posts: 6422
Location: Held against my will in IOWA, USA

pilotdog68 wrote:
Quote:
Here is a link to the diff vs the original STAR_on_time v1.1 code (pre dual-PWM): https://www.diffchecker.com/6wbp3uu9

thanks for that! now I can get it all set up while i’m still at work.

Well obviously I’m doing something wrong, I’m just too inexperienced to know what that is. I’m trying to integrate a strobe into Star off-time. Here is my full code.

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

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

pilotdog68 wrote:
pilotdog68 wrote:
Quote:
Here is a link to the diff vs the original STAR_on_time v1.1 code (pre dual-PWM): https://www.diffchecker.com/6wbp3uu9
thanks for that! now I can get it all set up while i’m still at work.
Well obviously I’m doing something wrong, I’m just too inexperienced to know what that is. I’m trying to integrate a strobe into Star off-time. Here is my full code.
Please post a diff against your most recent code which compiled correctly.

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)

pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 1 week ago
Joined: 05/30/2013 - 23:31
Posts: 6422
Location: Held against my will in IOWA, USA

wight wrote:
Please post a diff against your most recent code which compiled correctly.

https://www.diffchecker.com/miv37pun

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

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

pilotdog68 wrote:
wight wrote:
Please post a diff against your most recent code which compiled correctly.

https://www.diffchecker.com/miv37pun
Your problem is here on line 381:
“else {”

You added an open bracket without a closing bracket. “else {do normal non-blinky flashlight stuff}” is the correct form.

EDIT: try just deleting “else {“.

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)

pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 1 week ago
Joined: 05/30/2013 - 23:31
Posts: 6422
Location: Held against my will in IOWA, USA

I tried deleting it first, then also closing the bracket after the if statement, and it still gives the same error. AVRStudio says the error is in line 455.

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

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

It compiled fine for me when I deleted it.

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)

pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 1 week ago
Joined: 05/30/2013 - 23:31
Posts: 6422
Location: Held against my will in IOWA, USA

Hmm. Maybe I’m having cache problems again… At least now that I know the code isn’t the problem, I should be able to figure it out. Thanks.

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 1 week ago
Joined: 05/30/2013 - 23:31
Posts: 6422
Location: Held against my will in IOWA, USA

Ok it is working now, just had to restart AVRStudio. I still don’t know why it does that…
………………….
If anyone else is interested in it, here is the code.
It is STAR Off-Time, no memory. L > M > H > ~10Hz Strobe

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

Isn’t it satisfying when you get it working? Smile

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

Okay, I got a first pass written. It works but isn’t well-tested.

The “ToyKeeper/starry-offtime/” firmware is basically STAR_off_time except it lets the user set PWM levels individually per channel, and PWM speed per mode. Also, it uses the single solderable star to toggle mode memory instead of mode order. And it drops any attempt to support single-channel PWM, since the whole point of it is to improve how the second channel is handled.

This is an early rev; I’m planning to add some blinky modes as options, so you can add a strobe or beacon or battery check mode if desired. And probably the 3-level offtime handling to let people go both back and forward in the mode sequence. I don’t want to take it too far away from its origins though, so I’ll branch off into a different file before it diverges too far.

Anyway, it’s in my code repo below.

LinusHofmann
LinusHofmann's picture
Offline
Last seen: 2 years 4 months ago
Joined: 09/28/2013 - 08:27
Posts: 974
Location: Switzerland

I’m looking to add a basic temperature monitor to STAR OFF-TIME v1.2 using an external temperature sensor like an LM45. (output is 0-100degrees mapped to 0-1v)

I reckon it’d be trivial to just co-op the voltage monitor shutdown procedure and simply feed it the temp monitor output instead, but that would mean losing the LVC functionality.
Is there a relatively simple way to do both? ie keep Low voltage protection and also step down at a critical temperature.

Maybe someone has already done something like this and would be willing to share their code?

Cheers
Linus

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

LinusHofmann wrote:
I’m looking to add a basic temperature monitor to STAR OFF-TIME v1.2 using an external temperature sensor like an LM45.

Is there a relatively simple way to do both? ie keep Low voltage protection and also step down at a critical temperature.

Maybe someone has already done something like this and would be willing to share their code?


JonnyC was working on this; look at the MTN_momentary_temp version of STAR. It’s written for e-switches instead of off-time clicky, but it should at least demonstrate how.

The difficult part is that the attiny13a can only process one ADC reading at a time, so you have to keep switching the ADC channel between voltage and temperature. And you’ll most likely need different code to respond to each, since one steps down as values get lower low while the other steps down as values get higher. Also, one can step back up while the other never does.

You probably won’t need much of the solder star configuration code either, since you’ll have a maximum of one star available after connecting the OTC and temp monitor. Add an e-switch or second PWM channel or indicator LED, and then there are no pins available for stars.

LinusHofmann
LinusHofmann's picture
Offline
Last seen: 2 years 4 months ago
Joined: 09/28/2013 - 08:27
Posts: 974
Location: Switzerland

ToyKeeper wrote:
LinusHofmann wrote:
I’m looking to add a basic temperature monitor to STAR OFF-TIME v1.2 using an external temperature sensor like an LM45.

Is there a relatively simple way to do both? ie keep Low voltage protection and also step down at a critical temperature.

Maybe someone has already done something like this and would be willing to share their code?


JonnyC was working on this; look at the MTN_momentary_temp version of STAR. It’s written for e-switches instead of off-time clicky, but it should at least demonstrate how.

The difficult part is that the attiny13a can only process one ADC reading at a time, so you have to keep switching the ADC channel between voltage and temperature. And you’ll most likely need different code to respond to each, since one steps down as values get lower low while the other steps down as values get higher. Also, one can step back up while the other never does.

You probably won’t need much of the solder star configuration code either, since you’ll have a maximum of one star available after connecting the OTC and temp monitor. Add an e-switch or second PWM channel or indicator LED, and then there are no pins available for stars.

Ah cool, thanks for the tip. I’ll look through that version to see how it’s done, and maybe I can understand it enough to transplant a few code snippets Smile
Cheers

Microa
Offline
Last seen: 8 hours 29 min ago
Joined: 06/29/2011 - 21:20
Posts: 251

Please note the operation voltage of the LM45 is 4-10V while the MCP9700/A is 2.3-5V.

LinusHofmann
LinusHofmann's picture
Offline
Last seen: 2 years 4 months ago
Joined: 09/28/2013 - 08:27
Posts: 974
Location: Switzerland
Microa wrote:
Please note the operation voltage of the LM45 is 4-10V while the MCP9700/A is 2.3-5V.

Thanks, yes this would be used on a 2s driver running a 5v LDO so operation voltage isn’t a concern. Thanks for posting the alternative for 1s though, didn’t know about that one Smile

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

The starry-offtime firmware now has additional features:

  • 3-level offtime support, so you can go both forward and backward through the modes
  • 10Hz tactical strobe mode
  • battery check mode (also functions as a beacon)

It has some early code for hidden modes too, but it’s not working yet. Currently, it just tacks them on to the end of the regular modes, and they’re not hidden. I may branch before finishing that though, because I ran out of room and will need to remove some STAR bits before I can add new things. If I do, it won’t look much like STAR any more.

I’m mentioning this because it adds some things people asked for. Basically, STAR_offtime with individual control over each PWM channel, bidirectional mode switching, strobe, and battery check.

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

Thanks ToyKeeper. I’ll fire this code up soon.

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: 7 hours 45 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

Oh, um, the battery check code is currently calibrated for RMM’s Moonlight Special driver, which seems to get higher readings than any other driver I’ve tested (nanjg, BLF17DD). It may be a little “off” on other drivers unless you recalibrate it.

My measurements are in the ToyKeeper/battcheck/ directory, along with a firmware which can be used for making new measurements.

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

ToyKeeper wrote:
Oh, um, the battery check code is currently calibrated for RMM’s Moonlight Special driver, which seems to get higher readings than any other driver I’ve tested (nanjg, BLF17DD). It may be a little “off” on other drivers unless you recalibrate it.

My measurements are in the ToyKeeper/battcheck/ directory, along with a firmware which can be used for making new measurements.

RMM may have switched to a protection diode with lower forward voltage (eg voltage drop). Does the diode on your Moonlight Special have a marking on it? (like 41 or E2)

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