STAR Firmware by JonnyC - Source Code and Explanation

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

fellfromtree wrote:
[snip] I got thinking about this and I don’t like writing to the chip for memory. I dunno why, think down the road some guy gonna get errors and roid rage if it’s anything like the old flash sticks.[snip]
Does Tom E’s version even have memory? (The stock JonnyC versions which have memory all use wear leveling to prevent this issue from appearing.)

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 6 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

vestureofblood wrote:
[snip] added the momentary switch between pin 1 and pin4 of the micro. [snip]
I think you wanted Pin 2 & Pin 4.

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)

fellfromtree
fellfromtree's picture
Offline
Last seen: 6 years 10 months ago
Joined: 07/25/2014 - 15:14
Posts: 470
Location: spelunking

I’d ask Dr. Jones if you paid for it. Without the source, how’s anybody going to fix it but him =\

If that’s Tom’s eswitch. He uses PB3 (mcu pin 2) as the e-switch default . It shouldn’t flash when the power gets connected though.

*Yeah wight went over Jonnys code and seen the wear leveling. murphys law kind of guy

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 4 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10725
Location: (469219) 2016 HO3

vestureofblood wrote:
When I tired to power it on nothing happened.

The ONLY flash of light I ever got was right when I hook up the battery.

I’m not sure which firmware you used there, but I make a point of including a brief flash on boot on all eswitch-only firmwares I make. It lets me know the power is connected and the chip is booted, and any issues afterward are therefore some other type of problem. I don’t think I’ve seen this behavior on other people’s firmware though, unless you count Zebralight.

However, e-switch firmwares generally won’t make light just because they have power. Getting light requires activating the switch, so the switch must be wired up correctly. If it won’t activate, I’d check for switch issues.

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

wight wrote:
vestureofblood wrote:
[snip] added the momentary switch between pin 1 and pin4 of the micro. [snip]
I think you wanted Pin *2* & Pin 4.

This was my problem.   Thank you.

 

That said    WOW            

Oh my GOSH>>>>>>!!!!!!!!!!!!!!!!!!!!!!!!!


Let it be know that from hence forth

JonnyC and TomE are legends of flashlight

history FOREVER!


That one click OFF is the most un sung hero of the world.   OOOOOOOH how I have dreamed of this.    No looooooong press for OFF.       NO cycling through stobe, but STILL IN THERE!!!!!!!!!!

Had I written a Christmas list I could not have asked for a thing more!





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.

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

I guess I’d better try it then 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)

fellfromtree
fellfromtree's picture
Offline
Last seen: 6 years 10 months ago
Joined: 07/25/2014 - 15:14
Posts: 470
Location: spelunking

Coolabs came in today, finished the blfdd light. I noticed something interesting putting firmware in my light. I looped this line in making the beacon off while monitoring button clicks.

PWM_LVL = 0; _delay_ms(50);

I assumed it would keep the FET closed, but it didn’t. When you loop the above it makes very little amount of light on fast pwm Smile You can put your face into it and see the die clearly. Maybe someone is interested in that- thought it was pretty cool. If you want to try it, code is at the bottom. Hold the button for ~3 seconds to get beacon and you’ll see in between pulses. Could be an even lower moon Smile

http://pastebin.ca/2866670

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 4 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10725
Location: (469219) 2016 HO3

It’s a known “bug” that PWM=0 will still produce a little bit of light when using fast PWM on a high-powered driver (FET, or 32×7135). In phase-correct PWM mode, this doesn’t happen.

I’ve been meaning to tweak my ramping UI firmware to take advantage of this, but have been too busy so far.

fellfromtree
fellfromtree's picture
Offline
Last seen: 6 years 10 months ago
Joined: 07/25/2014 - 15:14
Posts: 470
Location: spelunking

ToyKeeper wrote:
It’s a known “bug” that PWM=0 will still produce a little bit of light when using fast PWM on a high-powered driver (FET, or 32×7135). In phase-correct PWM mode, this doesn’t happen.

I’ve been meaning to tweak my ramping UI firmware to take advantage of this, but have been too busy so far.

Well known to you Smile It’s kind of cool, can get something lower than PWM 1. It does turn all the way off with PWM 0 least on mine. But looping it on 0 causes the lowest moonlight and it’s not ghetto looking either, it’s a nice light up of the emitter. The only time seen this low was playing around with the buck drivers sense resistors, got a similar output.

Maybe running as default when you turn on the tail switch instead of sleep?
That would let whoever has the light know they left the tail on while still being almost parasitic. Just enough light to keep the ring glowing too maybe.

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

fellfromtree wrote:
ToyKeeper wrote:
It's a known "bug" that PWM=0 will still produce a little bit of light when using fast PWM on a high-powered driver (FET, or 32x7135). In phase-correct PWM mode, this doesn't happen. I've been meaning to tweak my ramping UI firmware to take advantage of this, but have been too busy so far.
Well known to you Smile It's kind of cool, can get something lower than PWM 1. It does turn all the way off with PWM 0 least on mine. But looping it on 0 causes the lowest moonlight and it's not ghetto looking either, it's a nice light up of the emitter. The only time seen this low was playing around with the buck drivers sense resistors, got a similar output. Maybe running as default when you turn on the tail switch instead of sleep? That would let whoever has the light know they left the tail on while still being almost parasitic. Just enough light to keep the ring glowing too maybe.

Or just add some status LEDs and use the Roche F6DD firmware. It keeps one status LED on at all times at about half power as a locator, plus the LEDs give you info about battery voltage under load (green/orange/red).

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 4 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10725
Location: (469219) 2016 HO3

FWIW, the standby light is barely more than the MCU’s parasitic drain. With the light completely off and the MCU in sleep/powerdown mode, the parasitic drain is 0.33mA. With the green LED on but dimmed, the drain is 0.36mA. So, it costs almost nothing extra to leave that slightly on.

Leaving the green LED fully on costs more though; then it runs at 1.23mA. And a lowest-possible moon mode on the main LED is even more — it depends on the exact hardware used, but 5mA is a common amount for moon on a single emitter on a 8×7135 board.

For a 25R 2500mAh battery, that translates to 10.5 months of standby time with everything “off”, 9.6 months with the green LED barely glowing, 2.8 months with the green LED fully lit, or about 21 days with the main emitter in moon mode.

Voltage measurements are not performed while the light is in standby. That would drain the battery faster and require removing other functions to make room in the firmware.

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

And I'm now using a 1.8K resistor on the green LED, your measurements were from one using a 1K resistor. Should be almost halved from that.

fellfromtree
fellfromtree's picture
Offline
Last seen: 6 years 10 months ago
Joined: 07/25/2014 - 15:14
Posts: 470
Location: spelunking

Nice idea.. I like the green led. Just need something to let the user know his tail switch is on

priest77
priest77's picture
Offline
Last seen: 3 years 11 months ago
Joined: 02/05/2014 - 03:59
Posts: 78
Location: Serbia

Can the lower mod be little lower on that firmware?
I like moon mode to be very low.

ToyKeeper wrote:

Voltage measurements are not performed while the light is in standby.

Voltage measurements are not performed while the light is in standby but it remains with the color it was while was ON. So if it its red while it is ON, it will glow red on stand by.
comfychair
comfychair's picture
Offline
Last seen: 5 years 4 months ago
Joined: 01/12/2013 - 05:39
Posts: 6198

The non-ramping version has a lower low (uses phase-correct PWM in levels 1 & 2): http://75.65.123.78/RocheF6/F6DD_v03/

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 4 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10725
Location: (469219) 2016 HO3

FWIW, I finally added a battery check mode to my clicky-switch firmware (based on STAR). It’s what I use on my EDC lights, like a modded Convoy S7 or a CNQG brass beauty.

http://bazaar.launchpad.net/~toykeeper/flashlight-firmware/trunk/files/h...

This firmware has a lot of modes… five solid modes across the full brightness range, three dual-level flashers, a heartbeat beacon, three fixed-speed motion-freezing strobes, two variable-speed strobes, and the battery check. Short-cycle memory to avoid the need to go through all the blinky modes when they’re not wanted. It’s a lot to fit in just 1024 bytes!

Mostly, I’m just happy that I no longer have to remove the battery from my EDC to find out if it’s ready to be recharged. Smile

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

ToyKeeper wrote:
It's a known "bug" that PWM=0 will still produce a little bit of light when using fast PWM on a high-powered driver (FET, or 32x7135). In phase-correct PWM mode, this doesn't happen. I've been meaning to tweak my ramping UI firmware to take advantage of this, but have been too busy so far.

Yeah, previously the STAR_momentary program shut down the output (went to sleep) when PWM = 0, but RMM had me change it so that 0 is a valid mode so that he can utilize the Fast PWM "bug".  Going to sleep is entirely dependent on the MODE_PWM value for that mode instead of the PWM value.  That feature is in the latest version of the program from Github.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 4 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10725
Location: (469219) 2016 HO3

BTW JonnyC, what is your view on STAR derivatives which no longer follow the main purpose of STAR? Is it obnoxious having that sort of thing here?

I’m wondering, because I love having STAR as a base for other firmwares, but I took out the star solder-based config bits to make room for tacos (er, more modes)… so it kind of misses the point of being simple, solid, and end-user configurable.

fellfromtree
fellfromtree's picture
Offline
Last seen: 6 years 10 months ago
Joined: 07/25/2014 - 15:14
Posts: 470
Location: spelunking

Awesome work Jonny. I still have to check out your changes Toy. But I came to a realization last night sleep lol

You don’t even need boards with the tiny13a. If you can modify the output on a buck driver you just need to glue 2 resistors (4 total) top and bottom of the tiny and wire it up to the existing FET and vcc to the existing mcu. Disconnect the eswitch from the existing mcu and cut the gate, wire your new pwm in. You would then have voltage monitoring (not sure this even works on a buck because it’s series cells- probably better to stick protected cells) from the divider and full control of the fet.

Trying to find the cheapest solution to having a ~6a buck with modes on the Y3 Smile I’ll have to try all this new stuff out when the next light gets here- takes awhile to get here..

You could even add in a smaller fet for a second out on a lower amp light but it would add another 2 resistors, and you would have to be careful in programming so one is closed while the other is on. I think can do dual outputs (only one out at a time) like that for next to nothing and still have a 2-3s light. Is there a tinyavr compatible chip that does 4 out? Not sure if fitting 2 tinys in would fit yet for something like that 4 color XML. Or do we have to invest in the PIC equipment Cereal uses.

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

ToyKeeper wrote:
BTW JonnyC, what is your view on STAR derivatives which no longer follow the main purpose of STAR? Is it obnoxious having that sort of thing here? I'm wondering, because I love having STAR as a base for other firmwares, but I took out the star solder-based config bits to make room for tacos (er, more modes)... so it kind of misses the point of being simple, solid, and end-user configurable.

I think this is a great place to discuss derivatives.  I'm assuming there are people out there that downloaded STAR and used it in stock form by configuring the options, even though the majority of the discussion here is about custom, one-off programs.  I see this thread as just a continuation of Tido's original thread with a more configurable, perhaps easier to work with codebase to start from.

And yeah, the idea behind "STAR" was just that you could solder different stars for different options (ala NLITE), but the more features are added the less purposeful that feature is since the user will need to enable/disable so many options at compile time that they don't need the solderable ability.  But I'll keep the name "STAR" just for consistency.

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

fellfromtree wrote:
Awesome work Jonny. I still have to check out your changes Toy. But I came to a realization last night sleep lol

You don’t even need boards with the tiny13a. If you can modify the output on a buck driver you just need to glue 2 resistors (4 total) top and bottom of the tiny and wire it up to the existing FET and vcc to the existing mcu. Disconnect the eswitch from the existing mcu and cut the gate, wire your new pwm in. You would then have voltage monitoring (not sure this even works on a buck because it’s series cells- probably better to stick protected cells) from the divider and full control of the fet.

Trying to find the cheapest solution to having a ~6a buck with modes on the Y3 Smile I’ll have to try all this new stuff out when the next light gets here- takes awhile to get here..

You could even add in a smaller fet for a second out on a lower amp light but it would add another 2 resistors, and you would have to be careful in programming so one is closed while the other is on. I think can do dual outputs (only one out at a time) like that for next to nothing and still have a 2-3s light. Is there a tinyavr compatible chip that does 4 out? Not sure if fitting 2 tinys in would fit yet for something like that 4 color XML. Or do we have to invest in the PIC equipment Cereal uses.

I could be the only one who’s having trouble with your posts, but I’d really appreciate it if you put some more effort into making your posts easy to read. They seem to be very stream-of-consciousness or something.

I’ll try to reply to what you wrote, but what you wrote may not be what you meant.

IN ORDER:

  • You’re correct about not needing a PCB for the ATtiny13A – it’s just a lot easier that way. What you’re referring to is often called “dead bug” style wiring. As an example, here’s a picture of ImA4Wheelr doing it in post #176 of his HX-1175b thread.
  • Why do you say 4 resistors though? You need 2 for a voltage divider and… what? What are the other two resistors for?
  • Correct, you’ll generally use the VCC intended for the original MCU, regardless of whether you’re using dead-bug wiring or a child-PCB.
  • You will not cut the “gate” signal. That term has a specific meaning and the gate signal / trace does not need to be modified for any of this. Instead you would modify the trace for the PWM signal.
  • RE: the italicized stuff about voltage monitoring. Voltage monitoring will work fine as long as you choose appropriate resistor values.
  • For buck drivers you do not directly control the FET, the buck controller does that. The MCU simply feeds the buck controller a PWM signal. The buck controller establishes a duty cycle where it turns the FET off part of the time – the PWM signal from the MCU tells the buck controller how much additional time it should turn the FET off for.
  • Adding an additional, separately controlled [smaller] FET does not make sense with a buck controller. IMO it doesn’t make much sense for a DD driver either. Remember, the FET is not there to limit the current – it’s there to be controlled by the buck controller. A FET with more on-resistance will simply lower the efficiency of the buck circuit, not lower the output current!
  • Good news! Wink There is plenty of AVR hardware out there which can do whatever your heart desires. The ATtiny25/45/85 all seem to have 6 PWM channels. They’ve also got other nice stuff, like additional flash space and a temp sensor IIRC. The ATtiny25 is available in the exact same package / form factor as the ATtiny13A-SSU we currently use. (The 45/85 are both very slightly larger.) We use 150mil or 8S1, the larger chips are 208mil or 8S2. Frankly I’m not entirely sure what the limit on actually using all those PWM channels simultaneously is. There are only 2 timers and our use case may [probably does] prevent them both from being used for PWM. If the Tiny25/45/85 can’t do 4x simultaneously in our application it I’m sure another AVR product can. For anything beyond the ATtiny25 you’ll be forced to switch to a QFN style package. EDIT: hmmm.

My advice is to make sure you’ve got both feet on the ground with your understanding of a buck driver. Read some stuff on the internet, look for simplified explanations. An animation of the various states used by a buck driver is probably useful. Once you understand how a buck driver operates you’ll see the mechanism for limiting current. This will make it clear why adding an additional FET in the way you described is not a good idea.

Don’t be discouraged, keep working on 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)

fellfromtree
fellfromtree's picture
Offline
Last seen: 6 years 10 months ago
Joined: 07/25/2014 - 15:14
Posts: 470
Location: spelunking

I know I know Smile Thanks for posting, I was on my way to blowing something up tonight.. I just got all my parts in from digikey and dan sent a couple of old dd boards to play with (should thank him publicly for doing that.. you guys are really cool). Let me research a bit more and when the light comes in- I’ll post a build on it.. Instead of filling up jonnys thread.

I do have a bad train of thought anymore.. I can’t blame it on anyone, except maybe my wifes trying to poison me! naw.. it is what it is unfortunately Davie

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

fellfromtree wrote:
I know I know Smile Thanks for posting, I was on my way to blowing something up tonight.. I just got all my parts in from digikey and dan sent a couple of old dd boards to play with (should thank him publicly for doing that.. you guys are really cool). Let me research a bit more and when the light comes in- I’ll post a build on it.. Instead of filling up jonnys thread.

I do have a bad train of thought anymore.. I can’t blame it on anyone, except maybe my wifes trying to poison me! naw.. it is what it is unfortunately Davie

Don’t sweat it, but please do proofread! Write, take a break, then read/re-read.

and LOL @ wife excuse Smile

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)

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

Check this page out for attiny differences.   The attiny25/45/85 are code compatible with each other, but not exactly with the attiny13a.  The 25/45/85 can do 6 PWM outputs (assuming you have the model with enough pins!)  

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

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 4 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10725
Location: (469219) 2016 HO3

It still seems to me that we should be doing most of our custom drivers with attiny25 chips instead of attiny13a. It costs a few cents more, but can do significantly more complex tasks. The extra ROM space alone would be a big help for making deeper user interfaces or adding end-user configuration options.

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

ToyKeeper wrote:
It still seems to me that we should be doing most of our custom drivers with attiny25 chips instead of attiny13a. It costs a few cents more, but can do significantly more complex tasks. The extra ROM space alone would be a big help for making deeper user interfaces or adding end-user configuration options.
I’ve got some 85’s here which I plan to give a test run soon just as a proof-of-concept. Assuming I can get STAR running easily I’ll pickup some ATtiny25s on my next order from wherever.

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: 8 hours 4 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10725
Location: (469219) 2016 HO3

I tried to make something which reacts to an e-switch like a Zebralight, but I ran out of room really fast. Perhaps I’ll try implementing the Olight Baton interface first instead.

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

There really is no reason not to go to the 25 for more advanced UIs.  They don't cost much more and are pin compatible.  Even the 85 will work on the same pads if you fold the leads underneath, if you need more space.  Once we get the port to the 25, the 45 and 85 are the same thing, and if you want to scale up to more outputs, just move up to the higher pin count version and keep the same firmware.

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

fellfromtree
fellfromtree's picture
Offline
Last seen: 6 years 10 months ago
Joined: 07/25/2014 - 15:14
Posts: 470
Location: spelunking

Looked at that pin layout..

It looks like only 3 outs on the 25-85.. Unless you go with more pins. OC1B, OC0B, OC0A unless your using the same pin for 2 outs maybe?

That link is a good compare. It saws 6 pwm but wondering does that mean 3 outs with 2 per pin

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

fellfromtree wrote:
Looked at that pin layout.. http://i59.tinypic.com/2w4xjlj.jpg

It looks like only 3 outs on the 25-85.. Unless you go with more pins. OC1B, OC0B, OC0A unless your using the same pin for 2 outs maybe?

That link is a good compare. It saws 6 pwm but wondering does that mean 3 outs with 2 per pin

Yes, I think you are correct. You can’t use the same pin for 2 outs, so you’re just stuck with only 3 on the 25/45/85. Even switching to a 20pin QFN package doesn’t fix it, most of the pins are NC (not connected). If you check the pinout in the datasheet it still gives only 3 different OC registers at once. http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf

To me it appears that the ATtiny24/44/84 provide four pins with different OC registers. Again, MLF/QFN is the only way to keep physical size under control. http://www.atmel.com/Images/doc8006.pdf

Another option to shove in even “larger” MCUs would be skipping QFN and moving directly to BGA. We don’t have to use all the pads for anything. I think we could almost completely ignore the inner 12 pins and focus on the outer 20. A 32-pin MCU in BGA is apparently 4×4mm, very small. Disclaimer – I’ve never worked with BGA! Since we’re reflowing anyway, I figure what’s the difference… Wink Here are the megaAVR MCUs which have PicoPower, 1.8-5.5v, and 32 or less pins. Note that I think only the 168PA, 48PA, and ATmega88PA have BGA packages available. I think all of those provide a full 6 pins of hardware PWM.

As long as we’re talking about BGA Wink here are the two PicoPower, 1.8-5.5v ATtiny parts which have small BGA packages available (3×3mm!):
http://www.atmel.com/devices/ATTINY24A.aspx
http://www.atmel.com/devices/ATTINY44A.aspx

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