STAR Firmware by JonnyC - Source Code and Explanation

1335 posts / 0 new
Last post
ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 23 min ago
Joined: 01/12/2013 - 14:40
Posts: 10731
Location: (469219) 2016 HO3

It really sounds like it might be resetting or rebooting or something, dropping the timer back to zero. But it’s hard to say for sure.

You could try looking at STAR_noinit for an example of how to let a variable keep its value during short power blips. It might help.

KramKram
Offline
Last seen: 4 years 3 weeks ago
Joined: 10/15/2015 - 03:13
Posts: 46

Hi. I am building a driver fet + 7135. I want to flash the firmware of toykeeper blf a6. I want to achieve around 100 lumens on low mode using the 7135 but i don’t have equipment to measure the lumens. Anyone knows what value should should i put ex. 150/255?

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

KramKram wrote:
Hi. I am building a driver fet + 7135. I want to flash the firmware of toykeeper blf a6. I want to achieve around 100 lumens on low mode using the 7135 but i don’t have equipment to measure the lumens. Anyone knows what value should should i put ex. 150/255?

What emitter?

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

KramKram
Offline
Last seen: 4 years 3 weeks ago
Joined: 10/15/2015 - 03:13
Posts: 46
pilotdog68 wrote:
What emitter?

xml2 u2

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

Ok, so according to Match, you get 100 lumens at around 200ma. He tested a T6, but lets assume that the extra gain from the U2 is cancelled out by losses in the lens and reflector.

So 200ma/380ma*255pwm = 134pwm. That should get you close.

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

That emitter, at 350mA, should put out about 140 or 150 OTF lumens. So, for 100 lumens you’ll want the 7135 chip running at about 69%, or about 175/255.

This is a very rough guess though.

You can get the PWM levels from bin/level_calc.py, if you have the ability to run python scripts. For example, this calculates 9 evenly-spaced levels from 0.5 lm to 1400 lm on a FET+1 driver:

(~/src/torches/trunk/bin/)-]> ./level_calc.py 9 1 8 1400 y 3 0.5 145
1: visually 0.79 (0.50 lm): 0.00/255, 3.00/255
2: visually 2.09 (9.17 lm): 0.00/255, 18.11/255
3: visually 3.39 (39.03 lm): 0.00/255, 70.19/255
4: visually 4.69 (103.24 lm): 0.00/255, 182.17/255
5: visually 5.99 (214.95 lm): 12.30/255, 255.00/255
6: visually 7.29 (387.33 lm): 43.76/255, 255.00/255
7: visually 8.59 (633.53 lm): 88.68/255, 255.00/255
8: visually 9.89 (966.70 lm): 149.48/255, 255.00/255
9: visually 11.19 (1400.00 lm): 255.00/255, 0.00/255
PWM1/FET  values: 0,0,0,0,12,44,89,149,255
PWM2/7135 values: 3,18,70,182,255,255,255,255,0
KramKram
Offline
Last seen: 4 years 3 weeks ago
Joined: 10/15/2015 - 03:13
Posts: 46

Thanks for all your suggestions. I think i’ll try in-between what pilotdog68 and ToyKeeper suggests, i’ll try 155. Thanks

mattlward
mattlward's picture
Offline
Last seen: 3 hours 48 min ago
Joined: 06/19/2015 - 09:20
Posts: 3120
Location: Illinois, USA

Do I understand correctly, the only way to get mode reversing is with a light built around a momentary switch? So a partial press of a tail cap switch will not work to reverse? Please explain this if you can… I am trying to get reversing on a 105c.

I have compiled and flashed standard Star and it does not seem to back up…

Thanks Matt

EDC rotation:
FW1A, LH351D 4000k (second favorite)
FW3A, LH351D 3500k
FW3A, SST20 FD2 4000k
FW3A, Nichia 4000k sw40 r9080 (favorite light!)
FW3A, Cree XP-L Hi 5A3
Emisar D4V2, SST20 4000k
S2+, XM-L2 T6 4C

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

mattlward wrote:
Do I understand correctly, the only way to get mode reversing is with a light built around a momentary switch? So a partial press of a tail cap switch will not work to reverse? Please explain this if you can... I am trying to get reversing on a 105c. I have compiled and flashed standard Star and it does not seem to back up... Thanks Matt

With STAR that's correct.  ToyKeeper was the first one with a firmware that could do reversing with a clicky switch.  Take a look over at her repository.  

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

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

To do reversing on a clicky switch, you’ll need an off-time capacitor… which the nanjg 105c drivers don’t have. You can add one, though.

With an unmodded nanjg, the best it can do is detecting “short” or “long” button presses by checking whether the attiny’s RAM has decayed or not.

For reversing, it needs to detect short/med/long presses, so you can go forward/backward/reset (or forward/backward/mem).

mattlward
mattlward's picture
Offline
Last seen: 3 hours 48 min ago
Joined: 06/19/2015 - 09:20
Posts: 3120
Location: Illinois, USA

TK, would it involve a modified BLG-A6 firmware or is there one already written? When I use lights and night, more often than not I want a very low mode and would love to go from ML to low and back without being required to go thru high. All of my FET and FET+1 have gone to a slightly modified version of that firmware, except for 1 that is a ramping driver.

I did not get time to pour over the firmware site last night, it may be right there in my face. So, I apologize up front if it is obvious.

Matt

EDC rotation:
FW1A, LH351D 4000k (second favorite)
FW3A, LH351D 3500k
FW3A, SST20 FD2 4000k
FW3A, Nichia 4000k sw40 r9080 (favorite light!)
FW3A, Cree XP-L Hi 5A3
Emisar D4V2, SST20 4000k
S2+, XM-L2 T6 4C

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

It just depends on what you’re looking for.

I have nanjg-based lights (with no physical mods) which let me use moon and low without having to loop through turbo. For example, my CNQG brass 18650, for which I wrote brass-edc.c. It uses a short press to go forward or a long press to reset to the first mode. There are no hidden modes or config options, but after turbo there are a bunch of blinkies for various purposes.

There are also options like TheStar, which implements hidden modes by requiring you to go through the main modes twice quickly in order to access any blinkies.

Anyway, there are options.

vestureofblood
vestureofblood's picture
Offline
Last seen: 1 day 13 hours ago
Joined: 08/17/2012 - 15:21
Posts: 1987
Location: Missouri

When using the star off time firmware what exactly happens for the low voltage protection?

I see that it says "Low voltage ramp down and shutoff" in the OP, but at what voltage does the light ramp down and to how low, and also what voltage does it cut off?


Also how are you guys able to set low voltage protection for a 2 cell zener moded FET driver?  I see this is an option on RMM site.

In Him (Jesus Christ) was life; and the life was the light of men. And the light shineth in darkness; and the darkness comprehended it not.
http://asflashlights.com/ Everyday Carry Flashlights, plus Upgrades for Maglite.

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

vestureofblood wrote:

When using the star off time firmware what exactly happens for the low voltage protection?

I see that it says “Low voltage ramp down and shutoff” in the OP, but at what voltage does the light ramp down and to how low, and also what voltage does it cut off?


Also how are you guys able to set low voltage protection for a 2 cell zener moded FET driver?  I see this is an option on RMM site.


It has been a while since I tested that code, but IIRC it drops one level at a time until the lowest, then shuts off. The specific voltage it uses depends on the driver it’s running on and how the code was calibrated. It should be somewhere near 2.8V though, give or take like 0.4V depending on the exact hardware used. I think the default is calibrated for a nanjg driver, so your FET driver will probably have slightly different values.

To make it work on a multi-cell light, you’ll almost certainly have to re-calibrate it yourself. Tools for this are in my code repository under battcheck/ .

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

Hi guys, I successfully uploaded star momentary to my flashlight and it works fine. However I miss battcheck mode from clicky star firmware. Is there a modded version of star momentary that includes battcheck mode. I need to be implemented in the newer version of star momentary with dual pwm output though. Is it possible to do battcheck in momentary firmware at all? Thanks

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

I think e-switch battcheck is available only in Tom E’s tiny45/85 firmware (eswBrOutCfg) and in my tiny13 single-PWM firmware (Ferrero_Rocher).

I’m planning to make a new one which is hopefully small enough to fit that, but I haven’t really started yet. It’ll be basically a total rewrite to reduce the size, and to make it easier to map button sequences to different modes. I’m not sure how much will fit on tiny13 though.

Oh, wait. It looks like Ferrero_Rocher does support dual PWM after all. I just, um, have never actually tried it. It’s copied from STAR but is untested in its current form. Anyway, it accesses battcheck by doing a short press from off immediately followed by a long press. (so, off to low to off, then it’ll read out 1 blink per 25% charge)

vestureofblood
vestureofblood's picture
Offline
Last seen: 1 day 13 hours ago
Joined: 08/17/2012 - 15:21
Posts: 1987
Location: Missouri

ToyKeeper wrote:
vestureofblood wrote:

When using the star off time firmware what exactly happens for the low voltage protection?

I see that it says "Low voltage ramp down and shutoff" in the OP, but at what voltage does the light ramp down and to how low, and also what voltage does it cut off?


Also how are you guys able to set low voltage protection for a 2 cell zener moded FET driver?  I see this is an option on RMM site.

It has been a while since I tested that code, but IIRC it drops one level at a time until the lowest, then shuts off. The specific voltage it uses depends on the driver it's running on and how the code was calibrated. It should be somewhere near 2.8V though, give or take like 0.4V depending on the exact hardware used. I think the default is calibrated for a nanjg driver, so your FET driver will probably have slightly different values. To make it work on a multi-cell light, you'll almost certainly have to re-calibrate it yourself. Tools for this are in my code repository under battcheck/ .



Ok, apparently I understand even less about this than I thought ( which wasn't much).  

I put a cell in this light and ran it down to dead and never go any cut off at all.


I was assuming that enabling line 67 where it says #define VOLTAGE_MON      was the LV protection.   Is this correct?   If not then what?

Also where do I change the value for this at to get a higher cut off?




In Him (Jesus Christ) was life; and the life was the light of men. And the light shineth in darkness; and the darkness comprehended it not.
http://asflashlights.com/ Everyday Carry Flashlights, plus Upgrades for Maglite.

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

You probably need to edit ADC_LOW and ADC_CRIT.

To figure out what the right values are, try flashing ToyKeeper/battcheck/ , which dumps out the raw ADC values for any power source it’s connected to. I usually check it once with a full cell and once with a nearly-empty cell, then plug those values in to battcheck.py so it can estimate the values needed for various voltages. It describes more of this process in the battcheck/README file.

seasam
Offline
Last seen: 5 years 2 months ago
Joined: 01/31/2015 - 13:15
Posts: 189
Location: GA, USA
vestureofblood wrote:

When using the star off time firmware what exactly happens for the low voltage protection?

I see that it says “Low voltage ramp down and shutoff” in the OP, but at what voltage does the light ramp down and to how low, and also what voltage does it cut off?


Also how are you guys able to set low voltage protection for a 2 cell zener moded FET driver?  I see this is an option on RMM site.

RMM posted his google spreadsheet for setting ADC value a while back:

https://docs.google.com/spreadsheets/d/1OFGFmolrQoM3xoGQRSz2wzirq5tuozPf...

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

Voltage varies per driver, even with identical components. Identical ones have very small variation, like 0.05V, but with different parts the ADC values can be very different. So, I don’t even try to guess at the values any more… I just measure it.

vestureofblood
vestureofblood's picture
Offline
Last seen: 1 day 13 hours ago
Joined: 08/17/2012 - 15:21
Posts: 1987
Location: Missouri

Ok so I decided to give the battcheck a try.   I flashed the driver with it an using a 4.17V cell I got 255.   Using a 3.06V cell I also got 255 Sad     Did this on 2x 1S FET drivers and got the same result so I tried it on a Qlite.    The 4.17V cell gave me 182, and the 3.06V cell gave me 13.

So my problem with the FET driver is a component issue?  Layout maybe?

Do the readings I got for the Qlite seem right?

In Him (Jesus Christ) was life; and the life was the light of men. And the light shineth in darkness; and the darkness comprehended it not.
http://asflashlights.com/ Everyday Carry Flashlights, plus Upgrades for Maglite.

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

Are you sure you got 13 at 3.06V, not 113 or 103? If you keep the power connected to the driver it’ll keep measuring and blinking forever, so you can read the value more than once.

Some example measurements are in readings.txt and readings/*.volts, if you’d like a reference for what to expect.

For example, on two nanjg drivers I got these results:

  • 4.09V – 179
  • 3.15V – 136

… other driver:

  • 4.17V – 182
  • 3.00V – 125

So, it’s typical to see values from about 80 to 210 with a single cell.

If you get 255, that’s the highest possible 8-bit value and it means your voltage dividers are probably the wrong resistance… so the voltage being measured is outside of the attiny’s range.

In general, you probably want to adjust the resistors so that a full cell will measure 224 or less, with a really empty cell being 32 or greater. Measurements aren’t as accurate near the edges of its range.

vestureofblood
vestureofblood's picture
Offline
Last seen: 1 day 13 hours ago
Joined: 08/17/2012 - 15:21
Posts: 1987
Location: Missouri

I think what happened is that I was getting 130 for the low voltage.   I see that the battcheck will do a "low blink" for the "0", maybe I just did not catch the low blink?   I tried it again with a 3.15V cell and got 134.

On the FET driver there are 2 resistors.  I have a 4.7K and a 19.1K.   I assume the 19.1K is the voltage divider?

Assuming I change that to something higher what other effects is this going to have on the way my board functions?



In Him (Jesus Christ) was life; and the life was the light of men. And the light shineth in darkness; and the darkness comprehended it not.
http://asflashlights.com/ Everyday Carry Flashlights, plus Upgrades for Maglite.

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

That’s what RMM’s spreadsheet is for. Check seasam’s link above for the recommended resistor values for various cell configurations.

The attiny needs its VCC pin to get an input between 0.1V and 1.1V. Anything outside of that range is unusable.

vestureofblood
vestureofblood's picture
Offline
Last seen: 1 day 13 hours ago
Joined: 08/17/2012 - 15:21
Posts: 1987
Location: Missouri

Is simply connecting my DMM leads from pin 8 to ground with the battery hooked up the correct way to measure that voltage?

If so this is my problem.    I had the same resistors RMM shows in that sheet, but am getting Vbat (3.06v)    Even after I jumped the resistor values up much higher there was no change.  

The only thing I can think of now is maybe I have another dirty or incorrect trace?

In Him (Jesus Christ) was life; and the life was the light of men. And the light shineth in darkness; and the darkness comprehended it not.
http://asflashlights.com/ Everyday Carry Flashlights, plus Upgrades for Maglite.

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

I think that would do it, but I haven’t tried… It’s possible that maybe one of your resistors is bridged or maybe fried. Hard to say. In any case, you can check the correct behavior on your qlite driver… and get a baseline for comparison on others.

For that matter, you could probably measure resistance on each component on the qlite, then check the same components on the other driver(s), and maybe identify which part isn’t working.

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

Hello ToyKeeper, It tried your Ferrero Rocher firmware with alt-pwm modes and it does not work. It works only with single pwm. When I have for example first three modes only on second output (pwm on first output is zero) it stays off untill I press the button several times over these modes. It would be great if you get to fix it. Otherwise I really like this UI and everything. Thanks.

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

I haven’t actually tried Ferrero Rocher on a two-channel driver. The only development driver I have with an e-switch is a FET-only driver, so I’m not surprised that doesn’t work. However, I’d like to set up a two-channel dev driver soon. I need to order some things from RMM as soon as I get back home.

zeremefico
zeremefico's picture
Offline
Last seen: 29 min 31 sec ago
Joined: 03/27/2012 - 02:44
Posts: 1389
Location: Greece

Hi, I want to modify star firmware to low-medium-high (or turbo) modes.
I tried to commend out moon mode but I face a step down after 3 blinks, after some seconds on high, of course with a fully charged battery.
Should I change anything else in firmware?

₪₪₪₪ ΟΥΔΕΝ ΚΡΥΠΤΟΝ ΥΠΟ ΤΟΝ ΗΛΙΟ ₪₪₪₪

My YouTube channel

Flashlights & edc gear

K40M F16

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

Sounds like it’s hitting low-voltage protection and stepping down. Which it shouldn’t do on a full cell.

You may want to flash the battcheck.hex firmware to check if your voltage readings are sane, and to get numbers to plug into STAR.

Pages