STAR Firmware by JonnyC - Source Code and Explanation

1335 posts / 0 new
Last post
ToyKeeper
ToyKeeper's picture
Online
Last seen: 2 min 6 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10798
Location: (469219) 2016 HO3

Without the capacitor, you could still do tricks with the total amount of time passed… but the UI will rapidly get harder to use with more than just “short” and “long”.

Like, you could say that if it has been on 0.0 to 0.5 seconds, step forward. 0.5 to 1.0 seconds, step backward. 1.0+ seconds, and it would stay at the same level. Easy enough to implement in firmware on stock hardware, but kind of hard to actually use the thing in practice.

vex_zg
Offline
Last seen: 3 years 5 months ago
Joined: 08/10/2014 - 11:08
Posts: 420
Location: Sweden

ToyKeeper wrote:
Without the capacitor, you could still do tricks with the total amount of time passed… but the UI will rapidly get harder to use with more than just “short” and “long”.

Like, you could say that if it has been on 0.0 to 0.5 seconds, step forward. 0.5 to 1.0 seconds, step backward. 1.0+ seconds, and it would stay at the same level. Easy enough to implement in firmware on stock hardware, but kind of hard to actually use the thing in practice.

Yes, that’s what I had in mind. But as you said, makes the ui complicated.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 2 min 6 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10798
Location: (469219) 2016 HO3

So… this has been bugging me for a while. Every time I edit the STAR sources, I have to fight the urge to fix this so as to avoid cluttering up the diff and the revision history, and also thus making cross-tree patches break… but it’d be really nice to agree on one and then make it consistent:

fellfromtree
fellfromtree's picture
Offline
Last seen: 7 years 2 weeks ago
Joined: 07/25/2014 - 15:14
Posts: 470
Location: spelunking

I flashed in jonnys dual switch firmware and put in a few more modes like your driver toykeeper. That moon is really really low Smile I can see why this is so addicting- but I need to move the laptop over and use that so I can flash/mod and test without running across the house like an idiot

I couldn’t get comfys beta to come on, still working on that. Silly Now if I can get the e-switch working.


edit Ugh it looks bad.. PB4 is acting like it’s grounded all the time. I found it’s fine with the ohmeter and the switch is working. I might have to switch over to PB3 and hope that one isn’t fubar

Oh the joy

That’s probably why I couldn’t get comfys to work too.. The eswitch was acting down the whole time.

zeremefico
zeremefico's picture
Offline
Last seen: 2 hours 22 min ago
Joined: 03/27/2012 - 02:44
Posts: 1390
Location: Greece

The op shows STAR Off-time memory v1.4 but in JCap page it is 1.3?

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

My YouTube channel

Flashlights & edc gear

K40M F16

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

zeremefico wrote:
The op shows STAR Off-time memory v1.4 but in JCap page it is 1.3?
Maybe the latest versions are on JonnyC’s GIT repo?

EDIT: took me a minute to find the link… https://github.com/JCapSolutions/blf-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)

ImA4Wheelr
Offline
Last seen: 2 months 2 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

Anyone every have issues with STAR Momentary locking up?

I'm trying to determine if its a hardware or FW issue. I think it may be where I'm connected the PWM output, but am wondering if others are having this issue before I do surgery on the light.

I'm using the version that Tom E modified to include strobe.  It generally locks up in the 3rd mode (going up or going down).  I have 7 modes (1,3,9,27,81,130,255), Turbo, and voltage monitoring.  Cell voltage does not seem to matter.  Lock does not happen often and I have seen no pattern to when it happens yet.

Driver is HX-1175b, two R33 resistors added for 9 amps current, 4 cells driving a MT-G2.  Original MCU has been removed.  No heat issues appear to exist.  Using 81000 and 4700 ohm resistors for voltage monitoring.

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

I have had no issues of that type, but I haven’t used the modified version. Off the cuff it sounds like a code issue to me though, not hardware.

EDIT: and I should point out that I have only used the momentary version a little bit.

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
Online
Last seen: 2 min 6 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10798
Location: (469219) 2016 HO3

Interesting. I haven’t seen it lock up… then again, I don’t generally leave the power connected while it’s not in use.

I’ve seen some bugs in my own STAR-momentary derivative, but I haven’t noticed any in STAR itself. I don’t think I’ve ever seen it lock up, in any case.

Do you have any of the hardware for reflashing an attiny13? It’s possible that maybe the flash was incomplete or the ROM got corrupted… but I really don’t know.

ImA4Wheelr
Offline
Last seen: 2 months 2 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

Thanks wight and ToyKeeper.  It locks up when on.  If I disconnect power for just even an instant, the FW works normal again.

I'm thinking its a hardware issue.  Maybe a weak connection to the switch.  Or, it may be that I'm tying PWM directly into the Buck Converter.  There is a resistor to ground on the Buck Converter PWM input pin, but I could go downstream.

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

I think ToyKeeper is on the right track – even if it’s not corruption, reflashing with something else (like stock STAR momentary) would be a good way to test. If the problem goes away you can work from there. If it doesn’t go away we can be pretty certain that it’s a hardware problem.

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)

ImA4Wheelr
Offline
Last seen: 2 months 2 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

Sounds like a good idea.  Will do next time I open up the  light.

By the way wight.  You're idea on how to have low voltage protection with more than 1 cell in series works.  I will post my experience with it so far in the HX-1175b thread as soon as I get a chance.

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

ImA4Wheelr wrote:

Sounds like a good idea.  Will do next time I open up the  light.

By the way wight.  You’re idea on how to have low voltage protection with more than 1 cell in series works.  I will post my experience with it so far in the HX-1175b thread as soon as I get a chance.

Thanks, that’ll be good!

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: 7 months 1 week ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

wight wrote:
zeremefico wrote:
The op shows STAR Off-time memory v1.4 but in JCap page it is 1.3?
Maybe the latest versions are on JonnyC's GIT repo? EDIT: took me a minute to find the link... https://github.com/JCapSolutions/blf-firmware[/quote]

Yeah, sorry, it's pretty disorganized.  The plan is to redirect my webpage to the github repository which will have it's own landing page describing what the programs do.  I've been busy with work and I'm making some changes for RMM, but once that is all buttoned up and tested (two separate PWM outputs and fast/phase-correct selection by level) I'll do the updates so it's easier to find.

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

I have a problem I haven't run into before. I'm still using AVR Studio 5.1.208.

Trying to build one of ToyKeeper's FWs, AS5 gives no errors or warnings, everything seems fine until I go to flash it in avrdude, when I get this:

avrdude: ERROR: address 0×0410 out of range at line 65 of Ferrero_Rocher_v02.hex

I did try changing the optimization to -Os, but it still won't flash. (also, how the hell do you change that setting permanently, so it doesn't have to be done every! single! time! you open the program??!)

ToyKeeper
ToyKeeper's picture
Online
Last seen: 2 min 6 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10798
Location: (469219) 2016 HO3
comfychair wrote:

I have a problem I haven’t run into before. I’m still using AVR Studio 5.1.208.

Trying to build one of ToyKeeper’s FWs, AS5 gives no errors or warnings, everything seems fine until I go to flash it in avrdude, when I get this:

avrdude: ERROR: address 0×0410 out of range at line 65 of Ferrero_Rocher_v02.hex

I did try changing the optimization to -Os, but it still won’t flash. (also, how the hell do you change that setting permanently, so it doesn’t have to be done every! single! time! you open the program??!)

That’s really weird. avrdude in Ubuntu handles it with no problems. Here’s the script I’m using to flash it:

#/bin/sh
FIRMWARE=$1
avrdude -c usbasp -p t13 -u -Uflash:w:$FIRMWARE -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m

To change the optimization setting permanently, the only method I know is to use a Makefile or shell script to build things. All this “integrated development environment” stuff is weird to me. However, I suspect you can probably at least configure it per-project, meaning if you save the code as a project it’ll remember the setting for next time.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 4 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

First off, big big thanks to Richard, JohnnyC, Dr. Jones, Tido, etc.

I’m mostly interested in using this firmware at much lower output levels, nothing more than 1A. Instead of the 105c I’m more interested in using this firmware with an AK-47A which I’ve had success programming with various other firmwares.

My big question is if it would be possible to extend the turbo timer beyond the current 2 minutes. I’m ignorant in all things firmware but is there any reason you couldn’t have a 20 minute turbo timer (heat issues, etc. aside)?

vex_zg
Offline
Last seen: 3 years 5 months ago
Joined: 08/10/2014 - 11:08
Posts: 420
Location: Sweden

HighEfficiency wrote:
First off, big big thanks to Richard, JohnnyC, Dr. Jones, Tido, etc.

I’m mostly interested in using this firmware at much lower output levels, nothing more than 1A. Instead of the 105c I’m more interested in using this firmware with an AK-47A which I’ve had success programming with various other firmwares.

My big question is if it would be possible to extend the turbo timer beyond the current 2 minutes. I’m ignorant in all things firmware but is there any reason you couldn’t have a 20 minute turbo timer (heat issues, etc. aside)?

you can easily define as many modes as you wish, with whatever output levels you desire. For example, I usually create moon mode (with the lowest output possible while still giving some light output, so that I get like 1-1.5 months of battery life on moon mode) + 4 “normal” modes. If the light is big enough that I consider it can take the heat, I don’t limit the turbo mode. If it’s a smaller light, I limit the turbo mode to 1-2 minutes.

Adjusting duration of turbo mode is just one line of code.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 4 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

Understood.

As I interpreted the description of the turbo mode I read it as having a 2 minute limit.

I will try for a 20 minute turbo mode and see how it works.

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

HighEfficiency wrote:
Understood. As I interpreted the description of the turbo mode I read it as having a 2 minute limit. I will try for a 20 minute turbo mode and see how it works.

You can extend it out pretty far on the momentary version without any changes, and on the off-time version if you change the WDT values.  On the normal clicky you can't do it very well since the 0.5s precision is really needed for the mode lock time.  Remember that on the clicky versions, the max value is 255 ticks.

This is from JonnyC:

Find this line...
 
WDTCR = (1<<WDTIE) | (1<<WDP2) | (1<<WDP0); // Enable interrupt every 500ms
 
Then switch it to one of these, whatever timeout you want...
 
WDTCR = (1<<WDTIE) | (1<<WDP2) | (1<<WDP1); // Enable interrupt every 1s
WDTCR = (1<<WDTIE) | (1<<WDP2) | (1<<WDP1) | (1<<WDP0); // Enable interrupt every 2s
WDTCR = (1<<WDTIE) | (1<<WDP3); // Enable interrupt every 4s
WDTCR = (1<<WDTIE) | (1<<WDP3) | (1<<WDP0); // Enable interrupt every 8s

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

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

ImA4Wheelr wrote:

Thanks wight and ToyKeeper.  It locks up when on.  If I disconnect power for just even an instant, the FW works normal again.

I'm thinking its a hardware issue.  Maybe a weak connection to the switch.  Or, it may be that I'm tying PWM directly into the Buck Converter.  There is a resistor to ground on the Buck Converter PWM input pin, but I could go downstream.

I've never had one lock up yet on the HX1175B drivers, but I have always run through the resistors into the buck IC.  I am interested to see what it ends up being.  

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

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

We can probably change the "static uint8_t ticks = 0;" to be "static unit16_t ticks = 0;" so that you can extend the timer to be much longer along with changing the WDT like RMM suggested.  The main downside is that we use the watchdog timer to do the counts, and the timing can be pretty far off.  If you do a 5 minute timer, it might kick in at 4:30 or 5:30 depending, or even worse.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 2 min 6 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10798
Location: (469219) 2016 HO3

HighEfficiency wrote:

As I interpreted the description of the turbo mode I read it as having a 2 minute limit.

I will try for a 20 minute turbo mode and see how it works.


Or you could just disable turbo entirely and make it never step down.

If necessary though, you could use a limit higher than 255. Just change the declaration to be a 16-bit integer instead of the usual 8-bit one. No need to muck with WDT timings.

Edit: D’oh, JonnyC posted the same idea while I was writing this. ;P

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

My driver was modified to temperature monitoring instead of voltage monitoring. Would you please educate me to modify the code to ramp down and to shut off when the voltage of the ADC is higher than the threshold.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 4 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA
JonnyC wrote:

We can probably change the “static uint8_t ticks = 0;” to be “static unit16_t ticks = 0;” so that you can extend the timer to be much longer along with changing the WDT like RMM suggested.  The main downside is that we use the watchdog timer to do the counts, and the timing can be pretty far off.  If you do a 5 minute timer, it might kick in at 4:30 or 5:30 depending, or even worse.

Johnny – thanks for the input.

I did as you suggested and changed to “static uint16_t ticks = 0” then changed the turbo timeout to 600. Let the light run for 9 minutes and did not see any step down.

Is there something I’ve missed?

Much appreciated.

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

Microa wrote:
My driver was modified to temperature monitoring instead of voltage monitoring. Would you please educate me to modify the code to ramp down and to shut off when the voltage of the ADC is higher than the threshold.
You don’t want to do both voltage and temperature monitoring?

If you want to do only temperature I assume you don’t want a “critical” value which turns the light off, only a step-down temperature. In that case I’d do something like this:
Replace:

#define ADC_LOW				130
#define ADC_CRIT			120

with
#define ADC_LOW				130
#define ADC_CRIT			0

also replace

if (ADCH < voltage_val) {

with
if (ADCH > voltage_val) {

That’s a pretty dirty way to hack the code. It should work I think, but I don’t like it. For my own use I’d want a separate check done for temperature.

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)

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

Thanks Wight, That is what I supposed to modify the code.

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

Microa wrote:
Thanks Wight, That is what I supposed to modify the code.
Sure. Remember that I did not try it, but I think it will work fine. Will you post a thread about your temperature monitoring? I would like to do that myself.

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)

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

Here is the thread of my temperature monitoring driver. http://budgetlightforum.com/node/22377

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

comfychair wrote:

I have a problem I haven't run into before. I'm still using AVR Studio 5.1.208.

Trying to build one of ToyKeeper's FWs, AS5 gives no errors or warnings, everything seems fine until I go to flash it in avrdude, when I get this:

avrdude: ERROR: address 0×0410 out of range at line 65 of Ferrero_Rocher_v02.hex

I did try changing the optimization to -Os, but it still won't flash. (also, how the hell do you change that setting permanently, so it doesn't have to be done every! single! time! you open the program??!)

This was 'solved' by using Atmel Studio 6.2, the problem code now flashes correctly.

Pages