STAR Firmware by JonnyC - Source Code and Explanation

Oh, um, the battery check code is currently calibrated for RMM’s Moonlight Special driver, which seems to get higher readings than any other driver I’ve tested (nanjg, BLF17DD). It may be a little “off” on other drivers unless you recalibrate it.

My measurements are in the ToyKeeper/battcheck/ directory, along with a firmware which can be used for making new measurements.

RMM may have switched to a protection diode with lower forward voltage (eg voltage drop). Does the diode on your Moonlight Special have a marking on it? (like 41 or E2)

Indeed. On the Ferrero Rocher, I see one labelled 41. On the Moonlight Special, it’s labelled E2. The ADC readings between the two differ by about 10, which is enough to make LVP and battery charge estimations not work well.

Mystery solved - that’s PMEG1020EA. The lower forward voltage should improve the driver’s overall drop-out by a small amount.

Hi guys,
First time im posting in your forum but its been a while that i read your stuff. Pretty amazing what you have done with this little nanjg-105c. Tido, JohnnyC , drJones and all other programmer could be proud of yourself!

I have programmed around 20 drivers (nagj-105c with 4 stars)with your technics but some fails . Let me explain!:slight_smile:

First , i modified the code by simply add more Modes to the star mom like 1,8,14,100,255 . 90% of the Times everything work the way it should. But some refuse to get 5 mode even if i reflash several times. It only work on 4 modes with the turbo in??? Any idea what could go wrong.

After i got one that the turbo is really fast even if i programmed it to 60 sec? is duration is around 10 sec? reflashing and it change nothing any idea whats happening here :slight_smile:

tks for your help

Glad to see you here!

The problem is likely your mode level setting of "1". That is far too low for most 7135 chips to turn on, especially when there are multiple 7135 chips on the same board. Depending on the number and type of 7135 chips, you probably need the lowest level to be between 6 and 8.

The turbo timer on the momentary driver is set in 0.016 second increments. So for 60 seconds you would need to enter a value of 3750 for the timer (60/0.016).

Hope that helps!

Thanks for your reply,
i changed the code for the two driver that have only 4 mode and now is working with 6 modes… ill removed one entry and i should end up with 5 mode :wink: problem solved tks!

for the timer… that one i really don’t know what to do with. I changed the number of ticks to 10000 ! so more than 120 seconds and its not responding… 5 sec on and it change to the previous mode , really strange!. All other driver( more than 20!) work perfectly with turbo but only one is not working??? Ill work on it but i think it will end up as a 7135 chips spare parts!

Anyone have a idea what could go wrong with the timer?

I wonder if you are seeing the low voltage protection kick in on that driver. If it steps down from any mode other than the highest mode, then that is probably the case.

Because I'll be running an ATtiny13A from a regulated voltage, would it be better to switch the ADC Vref to Vcc rather than the Internal reference?

It seems like this would allow finer control of battery voltage monitoring. Of course the resistors will still be across the battery and the values will need to be tweaked.

Do I only need to change the REFS0 bit in the ADMUX register and adjust the low voltage stepdown values? Or is it even worth the bother?

-Crux

Looks like changing that bit is all you need to do to change Vref, but I haven’t tried it myself. If you’re using an off time cap you’ll have to make a few more changes though.

I didn't think about that... I have figured that too much capacitance on the output of the regulator will affect the click times, may have to add a bleeder resistor to hasten the discharge. But this will (slightly) increase current draw with no benefit to the LED current. Not a big deal for big batteries.

ToyKeeper, thank you very much for your work on this code. I can’t wait to use it in practice. Now I need to find time to try it in practice.

Regardless of actual battery voltage (tried varying it with lab PSU), I always end up as ADCH=128 and ADCL between 106 to 110.

Don’t know what to try next. The ADC routine is the standard one from Star_offtime. Went through datasheet, seems everything is the same as with tiny13a, but I’m no expert in uC programming.

Hey guys, I’m looking at doing a dual PWM build but I’m wondering, does the alternate PWM output stay on once it get’s to the set-point above and if so, what would be the best way to turn it off, so it’s only one or the other outputs? I’m wanting to make it so moonlight is a separate emitter (and it’s own 7135) and that emitter turns off above moonlight.

Yes, it stays on. Check out Toykeeper's STARRY mod, or alternatively just change the code from

void set_output(uint8_t pwm_lvl) {

#ifdef DUAL_PWM_START

if (pwm_lvl > DUAL_PWM_START) {

// Using the normal output along with the alternate

PWM_LVL = pwm_lvl;

} else {

PWM_LVL = 0;

}

#else

to

void set_output(uint8_t pwm_lvl) {

#ifdef DUAL_PWM_STOP

if (pwm_lvl > DUAL_PWM_STOP) {

// Above this level alternate will turn off

PWM_LVL = 0;

} else {

PWM_LVL = pwm_lvl;

}

#else

And also define a DUAL_PWM_STOP value. Toykeeper's method is much simpler, and more in line with what how the momentary firmware works.

Ok thanks man. One more question, now that I’m looking at it- what’s the best proper way to enable moonlight when using the alternate PWM output? Before [when using a single PWM, before the new stuff came around] if I wanted to make moon be on without having to solder the star I would do this:

if ((PINB & (1 << STAR2_PIN)) > 0)

Is that still how I should do it or is there a better way?

edit: stupid smileys

With JonnyC's firmware if you use the secondary PWM output then moonlight is automatically enabled, since the firmware was originally designed as a firmware to get an exceptionally low moonlight (obviously not to control two different colors, otherwise the interface would be different).

In short: no need to change anything. I would take a look at what Toykeeper has done, as it may be easier for you to do what you want with your project.

In the starry-offtime firmware, the only solderable star is the one which toggles mode memory. All the other pins are used for other things.

So, you’d probably want to just do something like this in the #defines at the top:

// PWM levels for the big circuit (FET or Nx7135)
#define MODESNx             0,2,12,100,255
// PWM levels for the small circuit (1x7135)
#define MODES1x             3,0,0,0,0
#define MODES_PWM           PHASE,FAST,FAST,FAST,PHASE

Edit: You might also want to remove the HIDDEN_MODES bits too, which aren’t actually hidden yet. I’ll go back and hide those on a day I’m feeling a little better.

Ok thanks, and I’ll have a look at TK’s FW now too.

What I’m trying to do is make a driver to run my new 17650 light as an EDC, I want to have a triple in it with a nichia 219 powered by 2 or 3 7135’s for a good moonlight (plus low and medium modes) and then have it switch that off and turn on a FET that powers 2 XP-L’s for medium-max (to help with runtime from the little cells), does that seem doable?

I’ve made the changes you specify above and compiled, I got 5 warnings (but all were preexisting), it’ll be a few weeks before I have a board to test this setup tho.

edit: it’s a tail clicky only

That will work, no problem.