STAR Firmware by JonnyC - Source Code and Explanation

1335 posts / 0 new
Last post
FmC
FmC's picture
Offline
Last seen: 7 months 3 days ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

Tom E wrote:
the CPU drain in power saving mode is pretty darn low.

 

What is the drain in an eswitch light using the ATtiny mcu's?

Is the power saving mode the same between the 13A & it's bigger brothers?

 

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

Ahh, I believe it’s the same between MCU’s. Think power-on #‘s are higher cause of running at 8 Mhz, not 4.8 Mhz. Not sure of the exact #‘s, but I’ve had 85 based lights sitting for weeks/months on sleep mode. Just going by what others measured/said – been mentioned several times, many others know off hand, sorry, I can’t recall and never measured it. I did recently measure the running MCU with the indicator LED on, then saw it drop to about 1/2 when power saving kicked in. I delay the power savings – normally 10 secs, but when in a low battery state, I keep it running for 6 minutes to periodically flash the indicator LED to show the battery is low, then when it finally goes into power saving mode, I turn off the indicator LED to keep the light alive longer.

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

Ok, so very close… the tail cap switch does start the light in the lowest mode. But the modes do not switch… I am not at a real computer at the moment, on a laptop with cell tether for network and it is really slow. I appreciate the effort! Really! This is coding over my head… I did not expect to have a problem with simply powering down the MCU.

Thanks Matt

wight wrote:
Oops, sorry. I didn’t notice line 409 sleep_until_switch_press();

So here are a couple of things:

  1. I don’t see why you need line 409 for your application.
  2. Note the first if inside the while(1) loop – that’s a problem for you I think. Remember that there’s a difference between mode_idx==0 and any modes actually defined as 0 (eg PWM=0/255). This firmware is designed around having modes[0] == 0… you’ll probably have to iron out a few more little things.
  3. With that said… I hacked it up a little. I removed line 409, I removed the offending IF statement I mentioned above, I removed the IF statement and actions from 435-439, and I changed the initialization on line 411 as described previously. It’s not a great hack, but I think it’s probably going to work for you. STAR_momentary_v1.6w1.c

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

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

Heh, does a long press work? I think I see what I overlooked. EDIT: no that’s not it, duh. EDIT2: maybe it is, that’s why we shouldn’t do ugly hacks. Check the long press.

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)

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

FmC wrote:

Tom E wrote:
the CPU drain in power saving mode is pretty darn low.

 


What is the drain in an eswitch light using the ATtiny mcu’s?


Is the power saving mode the same between the 13A & it’s bigger brothers?


 


This was bugging me so I did some measurements this morn.

Convoy L4 w/13A FET driver: 0.299 mA (139 days to drain 1.0 Ah)

Stock EE X6R: 0.56 mA (74 days to drain 1 Ah)

ZY-T11 clone running a ATTiny85 w/Narsil (Indicator LED Off): 0.326 mA (128 days to drain 1.0 Ah)

ZY-T11 clone running a ATTiny85 w/Narsil (no Indicator LED): 0.302 mA (138 days to drain 1.0 Ah)

Measured a couple other 85 base lights all in the same neighborhood.

fixed it
Offline
Last seen: 1 year 8 months ago
Joined: 12/08/2015 - 14:27
Posts: 396
Location: Canada

Tom E wrote:
FmC wrote:

What is the drain in an eswitch light using the ATtiny mcu’s?


Is the power saving mode the same between the 13A & it’s bigger brothers?


This was bugging me so I did some measurements this morn.

Convoy L4 w/13A FET driver: 0.299 mA (139 days to drain 1.0 Ah)

Stock EE X6R: 0.56 mA (74 days to drain 1 Ah)

ZY-T11 clone running a ATTiny85 w/Narsil (Indicator LED Off): 0.326 mA (128 days to drain 1.0 Ah)

ZY-T11 clone running a ATTiny85 w/Narsil (no Indicator LED): 0.302 mA (138 days to drain 1.0 Ah)

Measured a couple other 85 base lights all in the same neighborhood.


Is that from the MCU alone? Or is there perhaps also a voltage divider with resistors of a few Kohm only? Maybe I’m an idiot for believing any of the numbers but the spec sheets for both the 13A and the 25/45/85 claim about 5 µA in power-down mode with the watchdog timer running and one tenth that without. What you’re seeing is nearly 100 times more so something must be off (spec, hardware, firmware).
fixed it
Offline
Last seen: 1 year 8 months ago
Joined: 12/08/2015 - 14:27
Posts: 396
Location: Canada

mattlward wrote:
I know someone has made this work… I have looked at the STAR dual switch, but it is not built for dual PWM channels. I guess that I could abandon the channel that runs the 7135 and go purely FET and run that code. What are the other options for dual switch code?

Thanks Matt


See over here . It’s not quite what you want as I modified it for pilotdog68’s triple channel driver but it would be easy enough to add a few ifdef’s to make the pin 3 turbo optional. As it is now, it would still work but without a useful turbo timeout. Oh and it isn’t tested yet so it might not quite work at all Wink
Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

fixed it wrote:
Is that from the MCU alone? Or is there perhaps also a voltage divider with resistors of a few Kohm only? Maybe I'm an idiot for believing any of the numbers but the spec sheets for both the 13A and the 25/45/85 claim about 5 µA in power-down mode with the watchdog timer running and one tenth that without. What you're seeing is nearly 100 times more so something must be off (spec, hardware, firmware).

Dunno, it's actually measured off a full up flashlight at the tail using either a wight v009 FET+1 driver or a MTN-17DDm driver, on both a Fluke DMM and a UNI-T UT50B DMM. No watchdog running, just the e-switch will wake it up. No idea if this is the right way to measure it or not. Again, I'm no expert at this stuff at all and don't claim to be. All I did was set the meter to read DC milliamps, moved the DMM lead to the connector marked for mA's, so I think I did it right?

If my measuring method is somewhat correct (no idea), then at least it proves our custom boards and firmware draw less amps than say a stock Eagle Eye X6R.

I can also see it step down when the power saving mode kicks in. I delay it for 10 seconds after turning the light OFF (PWM=0). For example, the ZY-T11 clone with no indicator LED was at 4.91 mA with the MCU running, then dropped to 0.302 mA after 10 secs (sleep mode).

Edit: did A few more tests of stock Olights, SWM, and NiteCore and it's interesting. These are much lower in power saving modes:

Olight S15: 0.001 mA, Olight S1: 0.002 mA

NiteCore MH20: 0.027 mA (button LED blink off), 0.061 mA (button LED blinking enabled)

So, there is something goin on here - why these lights are so much lower in standby than our designs. I thought we can't do any better in firmware (sleep mode with only the e-switch configured to wake it up), so would the 2 voltage divider resistors be actively draining power from the cell?

Edit #2: Again, not sure bout this, but using V = I * R, for 4.2v I calculate the 4.7K and 22K resistors in series would eat 0.157 mA. If so, that's bout 1/2 the current I'm measuring. Partially explains the amps draw at least.

 

fixed it
Offline
Last seen: 1 year 8 months ago
Joined: 12/08/2015 - 14:27
Posts: 396
Location: Canada

Tom E wrote:

Dunno, it's actually measured off a full up flashlight at the tail using either a wight v009 FET+1 driver or a MTN-17DDm driver, on both a Fluke DMM and a UNI-T UT50B DMM. No watchdog running, just the e-switch will wake it up. No idea if this is the right way to measure it or not. Again, I'm no expert at this stuff at all and don't claim to be. All I did was set the meter to read DC milliamps, moved the DMM lead to the connector marked for mA's, so I think I did it right?

I'm no expert either but I think you have a reasonable method, as long as your DMM is able to measure that low (it looks ok by its spec sheet). I don't know what RMM actually puts on the MTN-17DDm but his "FET+7135 DIY kit" has 4.7k and 19.1k resistors. So that's about 24k between GND and VCC, meaning around 0.18 mA drain for 4.2V even if you rip the MCU off the driver. I think there was talk in wight's driver thread about increasing these resistors for this reason but I don't remember if it went anywhere. 

 

Edit: Ok so you beat me to it Smile But there's still a bit of current missing. Could be the firmware not shutting down everything it should. The missing current is about what the spec sheet gives for a idle MCU (vs powered off), or roughly between 0.3 and 0.4 mA.

EasyB
Offline
Last seen: 1 day 4 hours ago
Joined: 03/09/2016 - 15:24
Posts: 2166
Location: Ohio

I have a question about the STAR momentary firmware offered as an option on the mountain electronics FET+1 7135 driver. I have not gotten to the point of modifying FW code, so this is just a question about what I would get from mountain electronics.

I’m interested in having a very low moonlight. Am I correct in thinking that the moonlight mode and low modes will use just the 7135 chip? If I was to do the custom mode levels, at which PWM % level would the output switch to just 7135 output?

I’m trying to understand the user interface. This is my understanding from what I’ve read.
From off:
short click turns on to lowest mode
long click turns on to highest mode
From on:
short click moves to next higher mode
double click moves to next lower mode
long click turns off?

Is this correct?

Thanks.

FmC
FmC's picture
Offline
Last seen: 7 months 3 days ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

Tom E wrote:

This was bugging me so I did some measurements this morn.

Convoy L4 w/13A FET driver: 0.299 mA (139 days to drain 1.0 Ah)

Stock EE X6R: 0.56 mA (74 days to drain 1 Ah)

ZY-T11 clone running a ATTiny85 w/Narsil (Indicator LED Off): 0.326 mA (128 days to drain 1.0 Ah)

ZY-T11 clone running a ATTiny85 w/Narsil (no Indicator LED): 0.302 mA (138 days to drain 1.0 Ah)

Measured a couple other 85 base lights all in the same neighborhood.

Thanks for being bugged Smile

I tried to measure the drain, but realized I did not have the correct equipment to measure that low.

If Halo’s idea is implemented using the internal vref, then we should see most of that drain gone.

FmC
FmC's picture
Offline
Last seen: 7 months 3 days ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

EasyB wrote:
I have a question about the STAR momentary firmware offered as an option on the mountain electronics FET+1 7135 driver. I have not gotten to the point of modifying FW code, so this is just a question about what I would get from mountain electronics.

I’m interested in having a very low moonlight. Am I correct in thinking that the moonlight mode and low modes will use just the 7135 chip? If I was to do the custom mode levels, at which PWM % level would the output switch to just 7135 output?

Thanks.

The FET & 7135 are controlled independently, so you can set whatever value you would like in the firmware for each, or a combination of both.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

Important Note on this parasitic drain issue - it's being discussed in the 25/45/85 thread here, and they are mentioning the diode, besides the resistors, we use adds to the parasitic drain as well.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

I did the tests. First removed the diode, bridged the pad with solder, and saw absolutely no difference in the parasitic drain at all - zero, nothing. Still doing in the 0.30 to 0.32 mA range.

Then I pulled the 22K resistor. The light acted kind of weird, because I didn't re-burn the MCU with firmware not supporting LVP. Anyway, it would settle down, and go into its sleep state. There I measured in the 0.16 mA range, which is about exactly what I expected - it went to half the draw, as calculated from the resistor values.

Dutcheee
Offline
Last seen: 1 week 2 days ago
Joined: 12/19/2015 - 21:40
Posts: 481
Location: Netherlands

I've been looking around a lot on the forum, but can't get a definitive answer to my noob question..

I'm planning to build my first triple XPL HI in the DQG tiny 4. Can the BLF driver

Banggood link

be used to flash the STAR momentary firmware to and use it with the e-switch?

Then do I just connect the e-switch to ground and MCU pin 2 (PB3) and should be good to go? Or does it have to be piggy backed?

Or is the LD-2 driver the one to go for? 

I already have the BLF driver.

 

I'm sorry if this is in the wrong thread, but help is much appreciated!

 

 

 

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

The DQG Tiny 4, reviewed here (http://budgetlightforum.com/node/43339), has no room to swap drivers. The LED is mounted on the driver itself to save space. Unless you know a method of doing so, I sure don't know how it would be done. These super compact lights make modding/upgrading difficult, to say the least.

Dutcheee
Offline
Last seen: 1 week 2 days ago
Joined: 12/19/2015 - 21:40
Posts: 481
Location: Netherlands

Thanks for your reply!

Firelight2 already dit it with the tiny 3
DQG tiny 3 mod

Since the triple carclo optic is shorter, there is a few mm to play with.
The tiny 4 unscrews really easy, just might need to machine some parts out of the head.
It’s not going to be easy, but I’d like to attempt it.
I already modded a few P60 dropins and a thrunite TI with the 10DD driver from RMM with the XPL Hi. This is a nice step up Wink No guts, no glory.

Since the heatsinking will be “marginal” at best, learning to flash and adjust the settings would be a nice extra skill to learn.

I’ve got all the parts inbound, but can’t find out about the BLF driver and momentary switch options.. Question

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

Interesting… I haven’t tried re-flashing a BLF A6 driver from BG, but as long as they didn’t lock it, which I’m pretty sure they didn’t do, I would think it could be re-flashed with STAR momentary just fine.
Firelight2’s thread doesn’t have much detailed pics, but he mentions the switch is side mounted and has 2 tiny wires – one goes to pin #2, the other must go to ground (batt-).
As far as mounting the driver, he describes a bit after the 1st pic, and has one pic – partially drills it out, and uses the remainder to mount the replacement driver.

It’s very creative work he did there.

Dutcheee
Offline
Last seen: 1 week 2 days ago
Joined: 12/19/2015 - 21:40
Posts: 481
Location: Netherlands

Thank you for the answer Tom E! The mod Firelight 2 did, does look really nice indeed. I’m hoping I can pull it off with the BLF driver. Very nice STAR firmware, hope I get it working!

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

I’m think’n this mod is a bit beyond my comfort zone. The copper work and mounting of the driver and MCPCB based on what you have to work with is a challenge for me. The results are rewarding though – a triple compact e-switch with a big cell (18650) is a rare combo.

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

fixed it wrote:
Tom E wrote:
This was bugging me so I did some measurements this morn.

Convoy L4 w/13A FET driver: 0.299 mA (139 days to drain 1.0 Ah)
Stock EE X6R: 0.56 mA (74 days to drain 1 Ah)
ZY-T11 clone running a ATTiny85 w/Narsil (Indicator LED Off): 0.326 mA (128 days to drain 1.0 Ah)
ZY-T11 clone running a ATTiny85 w/Narsil (no Indicator LED): 0.302 mA (138 days to drain 1.0 Ah)


… the spec sheets for both the 13A and the 25/45/85 claim about 5 µA in power-down mode with the watchdog timer running and one tenth that without.

I haven’t tested it yet, but I think there are a few methods left to reduce power. A big one is to turn off the ADC in sleep mode, and basically turn off everything except WDT and/or pin change interrupt. This will require a bit of extra code on sleep and wake, to disable/re-enable things, but the longer standby time is probably worth it. I especially want to get power draw as low as possible for the “smart” tailcap mods, so it can be both fancy and efficient.
ToyKeeper
ToyKeeper's picture
Offline
Last seen: 2 hours 16 min ago
Joined: 01/12/2013 - 14:40
Posts: 10743
Location: (469219) 2016 HO3

Tom E wrote:
… it went to half the draw, as calculated from the resistor values.

That’s the other thing on my list to try. Smile

In theory, the voltage divider values can be increased as long as their relative values are still proportional. Multiplying each by, say, 10X, should reduce standby current. I think. So instead of 19.1k and 4.7k, maybe 191k and 47k?

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

… and now I see Tom E already did both of these things, oops. I should read more before I respond. Smile

http://budgetlightforum.com/comment/921530#comment-921530

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

No prob! I’m a mess with this – I got things posted between 3-4 threads. Did a bit more testing, and it’s looking real good so far. Love the 0.016 mA draw from an 85. Only got bout 10 resistors with the 10X values, so I’ll be limited initially, but plan on updating a bunch of my e-switch lights running Narsil with the indicator LED’s. Modded Narsil this eve to have a quick way to toggle the locator LED functionality: quick click followed by click&hold, the let go as soon as the main LED goes OFF. Maybe sounds a little complicated but takes less than a 1/2 sec.

I just don’t think we gave e-switch support much attention, and that’s why these things haven’t been explored – one line of code cut parasitic drain by half, then the resistors cut it by 90%.

comfychair
comfychair's picture
Offline
Last seen: 5 years 4 months ago
Joined: 01/12/2013 - 05:39
Posts: 6198

Anybody have a version of STAR offtime with strobe added? Or something comparable that works on standard 17DD hardware?

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY
comfychair wrote:

Anybody have a version of STAR offtime with strobe added? Or something comparable that works on standard 17DD hardware?

I got it for the 25 posted up on my google drive share w/mode changing that works like luxdrv (short cycle). Not sure if I got a version for the 13A, think I do, but not sure it’s posted – @work now so might not have access.

comfychair
comfychair's picture
Offline
Last seen: 5 years 4 months ago
Joined: 01/12/2013 - 05:39
Posts: 6198

Tom E wrote:
comfychair wrote:

Anybody have a version of STAR offtime with strobe added? Or something comparable that works on standard 17DD hardware?

I got it for the 25 posted up on my google drive share w/mode changing that works like luxdrv (short cycle). Not sure if I got a version for the 13A, think I do, but not sure it's posted - @work now so might not have access.

Thanks, been a change of direction though. I'm updating a light I built for somebody a long time ago and it had phase-correct luxdrv on it, no ramping mode, with strobe & battcheck. Turns out it's the strobe he doesn't use, and I guess hacking luxdrv's battcheck into STAR would be impractical. He's OK with the way it was before, I'll just give it a fast PWM version of luxdrv and call it done.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 52 min ago
Joined: 08/19/2012 - 08:23
Posts: 14638
Location: LI NY

Ahh - luxdrv was my baseline driver code for years, tweaked to each individual's mode choices. I kind of abandoned it now in favor of STAR offtime, then tweaked my flavor of STAR offtime with some unique features, but then went on to the 25/45/85 stuff. Sorry - it's impossible for me to keep all these variations/tweaks in my head - my heads spinning from just typing bout it smile.

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

I have a version of STAR with a strobe I can link when I get home tonight, but is there a reason you don’t want to use TK’s blf-a6 firmware? It has strobe functionality built-in and you can just disable all of the other bells and whistles that you don’t want (that’s what I do)

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

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

The blf-a6/tk-otc.c code is made specifically for easy mods. It has the config mode stuff removed to make room for other changes, assuming that if you’re compiling it you probably don’t need runtime config options. Most things are easy to turn off or change if you don’t want them default. I don’t have one specifically configured as described though.

Pages