STAR Firmware by JonnyC - Source Code and Explanation

So why not link here? GitHub - JCapSolutions/blf-firmware at dual_pwm

Because I forgot to save the URL where I could find it easily, and didn’t remember where I originally found it. Also, I had some difficulty getting a copy of that via git, because it kept giving me the master branch instead of dual_pwm (even using the clone URL suggested at that site). I need to learn more about git.

I merged the dual_pwm feature into the "master" branch, so it's in the latest version of the program...

https://github.com/JCapSolutions/blf-firmware/tree/master/STAR_off_time

Fair enough. I had to search for my own post on the topic to find the link. Or I thought I did - now that I say that it strikes me that JonnyC has added a link to the GIT repo on the firmware page of his website. I forgot about that.

FYI for Cereal_killer or anyone else, to go from the link JonnyC posted on his website to the dual_pwm branch you must use the little “branch:” dropdown menu that defaults to branch: master.

EDIT: I got ninja’d by JonnyC: apparently the dual-pwm branch has already been merged back into the master branch. The latest code in the master branch is what you want.

Thanks. Right after posting earlier I grabbed updates on the main branch and found that the dual_pwm bits had been merged in. :slight_smile:

Also, I got bzr-git working, which lets me use bzr to access git repos. This is much much easier for me, and should greatly simplify merging in changes.

Edit: … and it’s all up to date now. :slight_smile: (plus, future updates should be much easier) I should note that the dual_pwm/ dir is gone though, since it got merged back into the main STAR code.

Just FYI, I'm not sure that the latest versions with the dual-pwm have been fully tested, so please let me know if there are any issues.

Using dual-PWM whats the lowest you guy’s are able to get XP-L’s to light up?

Quad XP-L with BLF 17dd V3 driver

I don’t know the answer either way, but are you asking about 7135s, FET, or something else?

Er, the lowest mode is really hard to predict, and highly dependent on hardware (driver, emitters, battery, etc).

For example, I’m getting 0.1 lm from a triple-219B driven by a FET, using fast PWM=0. But that 0.1lm drops down to like 0.00001 lm when the cell gets down to like 3.7V.

On the same hardware, if I use phase PWM=1 instead, the minimum level is about 3.6 lm (drops to about 0.9 lm at 3.6V).

On nanjg/qlite drivers, the lowest mode seems to depend mostly on the exact bin of 7135 chips used.

Basically, you’ll just have to try it and find out.

So, I put together a test light today with an off-time cap on the driver, and I adapted the cap-reading code from STAR off-time to fit in with my “s7” EDC code. I also added another cap threshold for medium presses, so it can detect short/med/long presses.

I haven’t really tweaked it yet, but it seems a short press is about 0 to 0.7s or so, a medium press is about 0.8 to 2.0 seconds, and a long press is anything over 2 seconds. These are mapped to “next mode”, “previous mode”, and “reset to mode 0”, respectively. I think the timings need to be shorter, but I can calibrate it later.

If the user does a prev-mode action at mode 0, it’ll go into semi-hidden “negative” modes, so it gives quick access to turbo, my favorite strobe, and battery check. Also, a next-mode action from any negative mode will always return to mode 0; no need to cycle back up through them again. Doing next-mode at the end of the main sequence will loop back to 0, instead of going through the negative modes.

I’m considering making back-from-zero change the mode group instead of doing just limited “negative” modes, but I’m not sure if I’ll bother.

Anyway, this went together pretty quickly and it seems to work well. Now I have firmware ready to go for my Cypreus, as soon as the emitters arrive (tomorrow or the next day). :slight_smile:

Am I correct in thinking that the ATtiny13A defaults to REFS0==0 on startup? So if I want to use Vcc as my analog reference I must change this line:

DMUX  = (1 << REFS0) | (1 << ADLAR) | ADC_CHANNEL; // 1.1v reference, left-adjust, ADC1/PB2

to read this way:

DMUX  = (1 << ADLAR) | ADC_CHANNEL; // Vcc reference, left-adjust, ADC1/PB2

Thanks guys!

Not sure what bits REFS0 and ADLAR are setting in ADMUX. They start 0 I’m pretty sure though. Here’s a link on the basics- don’t see the bits for those two giving it a quick glance… I guess could just lave REFS0 out and it should be 0

Thanks fellfromtree. I went ahead and tried it before I saw your post and sure enough, leaving out REFS0 keeps it set to zero. (so vref is based on Vcc)

FYI for in the future, if you download the ATtiny13A datasheet you can just search for ADMUX and it will list the register, what the bits mean, and what their default values are.

Ah that’s cool… Yeah let us know how the monitoring of vcc goes wight. That sounds like fun for 1s, maybe eliminate 2 more resistors on the board

I don't think it is directly measuring voltage, but instead using the VCC as the reference voltage instead of the internal 1.1v. You could use it as the reference voltage with zener mod drivers or with an external voltage regulator (both with 2S+) since the voltage input will remain constant, but with 1S cells it would be pretty much useless. You would still need a voltage divider because the voltage you would be measuring against would still be higher than the reference. You can use it, however, for other measurements (like a temperature sensor) without needing an additional divider.

Ah gotcha… So your comparing it between the divider and vcc. Learn something new everyday thanks.

*Edit Wait wouldn’t it be the other way around. Cause the zener going to keep the voltage the same? The voltage will drain as the battery drains in 1s. Am I missing something… Oh nm I see what your saying 1.1v internal is always going to be 1.1. Still need the divider to get the voltage from B+… It’s too early for this sh :slight_smile:

Oh yeah sent my inlaw over your site yesterday. He saw my private video of the yezl blowing things up on dd and caught the lumen disease. He’s a pic guy though, so he’s talking about 3 phase pwm and all that other stuff. Can’t wait to see his lights really

Digging up an older concept here and hoping for some help.

I was hoping the above change in code would allow me to skip having the turbo timeout step down as an independent mode. My sense is I am one step away.

Here’s what I’m after: Low (1 value), Medium (2 value), Turbo (3 value) to step down (4th value).

As the FW is written, in order for me to have this I actually have 4 click through modes of Low, Medium, Step Down, and Turbo. I’m looking to have the turbo step down mode ONLY accessed following turbo time out. So in the end I’ll have 3 click through modes, but in operation 4 output modes.

I tried the above recommendation and then attempted to comment out “#define mode_high_w_turbo” but I was left with an error in line 259 “mode_high_w_turbo” undeclared (first use in this function)“. I assume the code is trying to reference the line I commented out but I don’t see it, and definitely don’t understand it.

With no working knowledge of C (other than reading through this whole thread), I was hoping I could get some help.

Thanks in advance.

Not sure which version of firmware you are looking at. Have you identified where in the code you are when the turbo times out? If so you should be able to set desired PWM_LVL and not store the mode.

Should be something like (simplified): “if ticks = turbotimeout and mode = turbo then {”

There you should be able to do a “PWM_LVL = XXX” (desired value).

Mike C is right, the concept works fine. You don’t need to comment out #define mode_high_w_turbo”, maybe that’s your mistake? Comment out other modes until you have only 3 user accessible modes (low, high-w-turbo, and turbo). Set those to your desired levels. This will give you 3 modes, then do the modification to “PWM_LVL =” discussed above:

// #define MODE_MOON            8   // Can comment out to remove mode, but should be set through soldering stars
#define MODE_LOW            14  // Can comment out to remove mode
//#define MODE_MED          39  // Can comment out to remove mode
#define MODE_HIGH_W_TURBO   39  // MODE_HIGH value when turbo is enabled
#define MODE_HIGH           120 // Can comment out to remove mode
#define MODE_TURBO          255 // Can comment out to remove mode