Moonlight and firmware questions from a newbie

Hi everyone, first post here. Been searching and reading a lot over the last few weeks. Started out looking to replace the internal “non serviceable” battery on my bike light to now having ordered eight S2, one FW3 (SS), and likely another FW3A or D4. The ability to customize exactly what I want is what led me down this slippery slope. With the help of the various threads on this forum I have successfully flashed several variations of JonnyC’s STAR firmware last night, working through different settings to see how I liked them. However, I’ve got some questions now that I’m hoping you experts can help clear up for me. FYI, my firmware modding experience so far is on an S2 host with QLITE driver (running Atiny13A and reduced to 6x 7135’s for max output of 2,280 mA) and a single Nichia 219C 4000K.

  1. Figuring out what I like in the moonlight setting. A setting of 10 seemed too dim, 15 was too bright, and dropping back down to 12 still seemed a bit bright. Maybe I’m misinterpreting the common use of moonlight setting because those values are higher than I see in various firmware codes. However, starting out at 5 didn’t light up enough to tell it was on, and 10 is on but flickers. I’m at 12 now and will try 11 next. Behavior was the same whether I achieved the setting via soldering star or coded into the low mode. I tested because I wasn’t sure if true moonlight mode via soldering star runs on only one 7135 chip vs all six chips (not sure the term for this—dual PWM?). Is this behavior due to the LED, like maybe the 219C doesn’t run very well at low current? Maybe I’ll try that on the XP-L2 5000K’s I have, but I like the 219C 4000K.

  2. I see a lot of mention of frequency and there seems to be a lot of debate about it, but I don’t understand it in this context. Note that my tests so far had the FAST_PWM_START unchanged in the code at 8, and my tests straddled that value. Could that be why my test at 5 didn’t light up, but 10 was on (and also unstable)?

  3. I guess in a broader context, my two questions above could be about what driver, LED, and firmware settings achieve a smooth moonlight setting?

  4. With regards to firmwares to try, I would kind of like for turbo mode (whatever level I code that to be) to be accessible via hidden menu. I see TheStar out there, but it is a lot more complicated than my current code reading skills allow me to understand, as it has been 20 years since basic computer science class that I didn’t do well in. Maybe I can comment out some of those blinkie modes, but curious if there’s something else to look at? Right now I’m thinking it would be nice to have moon-low-medium as regular modes, then double-click to access turbo, maybe even with a timeout that kicks back to moon-low-medium regular modes.

Sorry for the long post and thanks for reading this far!

The issue is a matter of how long each pulse is. While in a theoretical sense, each pulse is a square wave which rises immediately to its maximum level and then drops just as quickly at the end of the pulse, in reality the shape is more of a curve. The leading edge takes a while to rise far enough to make visible light.

For moon mode, the big question is … how long does that leading edge take to rise? As you’ve found, it might be 10 or 11 or 12 clock cycles before it reaches a useful level.

Related to this, the chip has two PWM modes… fast (1 clock cycle per frame) and phase-correct (2 clock cycles per frame). In fast mode, level N is on for N clock cycles, while phase-correct would be on for 2*N cycles.

So with a FAST_PWM_START value of 8, the pulse width and frequency per level would be:

  • 5/255: 10 @ 7.8 kHz
  • 6/255: 12 @ 7.8 kHz
  • 7/255: 14 @ 7.8 kHz
  • 8/255: 8 or 16 (I forget)
  • 9/255: 9 @ 15.6 kHz
  • 10/255: 10 @ 15.6 kHz
  • 11/255: 11 @ 15.6 kHz
  • 12/255: 12 @ 15.6 kHz

But due to the leading edge of the pulse rising slowly, basically subtract ~10 from each of those. That means level 6 and 7 should light up, and 11 and 12 should light up, but not 5 or 9 or 10.

I hope that makes sense.

(edit: fixed broken formatting)

Wow, thanks! I was hoping you’d respond. This is totally not what I was thinking, and my mind is officially blown! I don’t understand it but I’ll drop the moon down next time I update that firmware.

Can you suggest a firmware to look at that, or one to attempt to modify, that has turbo accessible through double click?

This is an interesting article about PWM and the AMC7135: http://www.pratikpanda.com/amc7135-pwm-led-control-max-frequency-speed/

The only clicky-switch firmware which comes to mind with double-click-for-turbo is what DrJones uses on the H17F driver. I haven’t really attempted to do that feature because I don’t like it. On a clicky-switch light, I generally turn it on and then rapidly tap to get to the brightness I want, and double-click-for-turbo interferes with that.

The closest I’ve done was in Crescendo, which uses ramping with a shortcut to turbo on 3 taps. 1 is up, 2 is down, 3 is turbo, 4 is blinky modes.

Thanks for the help TK and Sammy! The article was very good and explained what TK mentioned about how it takes time to rise. I’ve modified my firmwares to put the lowest level back down to 6 and 7 between various lights and they’re working just fine. It is nice to be able to quickly update firmware to try different things. Right now I’m using STAR source code, but will branch out to others.

My kids are also enjoying the blue and red colored LED’s that I put in some S2+ hosts. Those are modified to basically have two modes, a low level of 14 and a moderate level of 140 (on a 6x7135).