NarsilM - configurable e-switch firmware for Multi channels, v1.3

You are using setups-31S.h, right? Then in RampingTables.h, it has to be under the banner:

//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
#elif OUT_CHANNELS == 3    // Triple Channel
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------

And under 3 channels, there are two separate tables, depending on what compile switch is set, TRIPLE_3_7135 or TRIPLE_8_7135.

So, you have to have everything set up properly in the "Setups" header file you are using.

I am probably assuming wayy too much knowledge to do all this setup and configurations, but what you are trying to do is pretty advanced customization, and I did build in a lot of provisions for customizing things withkeeping the main source code in tact.

Just finished all the bug fixes and couple features/enhancements for the next release. I need to get more testing in on it, but so far all the changes tested ok.

Of course it's not everything I wanted to get in, but running out of time at this point. Here's a brief list:

  • ADDED : (from MAD777, maybe others) if strobes are disabled, a 2X click from 2X turbo should restore the previous level you were at
  • FIXED: 4X clicks in modes operation engages lockout - not supposed to
  • ADDED: operation change: make click&hold in MODES or STROBES wrap from 1st mode to last
  • FIXED: in LVP switch LED control: the LED sometimes is left on after an LVP drop, and is not blinking the way it should be. The "bug" is that I'm trying to control the switch LEDs from multiple places so it's getting turned off quickly after turned on, and left on when it should be left off. It's a timing thing, so has sort of a random pattern - sometimes left on, sometimes left off. The 8 sec LVP blink need to be qualified better, and should not be calling Setlevel() as is because it wants to control the LED
  • FIXED: temp stepdown should not happen right away from turn ON. Delay it by 15 seconds
  • FIXED: for temperature stepdown, in moon mode, a temp stepdown is actually done because moon mode is marked as special level 255, which is considered as a high level of output instead of very low. The stepdown results in the light switching much brighter. This should only happen id the temperature threshold is set to a low temp, or the light is still hot and not cooled down when moon mode is chosen. It can also result in an immediate jump to the stepdown level as soon as the light is turned on in moon mode. Might appear as a bright flash when ramping first starts.

There's more previously implemented:

  • ADDED: momentary/tactical mode via 5X clicks - only active til a power reset 2X or 5X clicks exit tactical mode (full turbo only when switch is held down)
  • full BLF GT buck driver support
  • capability of setting max ramping to less than full max FET (Hi mode), while the 2X click still goes to full FET turbo. This is being used for the GT buck driver configuration.
  • added more compile switches, little better custom configuration of the source in header files

Nice work Tom. :+1:

Yeah, great job!

Excellent!

Wow, once you drill out the driver screw holes and put decent screws in there, extend the LED wires to 67-70 mm, the Q8 is one of, maybe the easiest light around to upgrade firmware with. I find it easier and quicker than even driver retaining rings.

The 2nd round production Q8's should be easier with the screws, but looks like they shortened the LED wires in some, maybe all, so I haven't tried one of those yet.

That’s a nice list of updates! Do you have it available yet? It would save me trying to finish trying to mod the code for ramping to less than full max. I’m close, but flashing testing, flashing testing to fully figure it out could take me a while yet. :slight_smile:

Ahhh, got the source code pushed to my google share drive, but was hoping to get more testing time in. Actually could use whatever help I can get. Hoping Lexel and anyone else. Don't have any official type manual update on it yet though.

Here it is: https://drive.google.com - NarsilM V1.2 BETA

It's v1.2 because v1.1 was used in the BLF GT proto. The default code/hex file are set to the Q8, meaning 2 Channel, 1S cells, indicated by "2C1S". This is my new convention for header files.

I've only tested it so far on a couple Q8's, so didn't even try a "3C" configuration yet, but should work.

Again this is early, it might still change, but if you do want to give it a go, let me know how it works out. Again, I tested the LVP and temp regulation issues on the list above, and all seems to be working well. The strobe mode wrap around works well, and also applies to MODES operation.

Ok. Thanks Tom! I’ll let you know how it goes. If I have any trouble I’ll probably just go back to v1. I’m using it in the m3 clone and thinking about it, there won’t be any reflashing once the light is put together so I’ll need to trust whatever firmware I decide to use. :slight_smile:

Hhhmmm - might pay to wait til I try out a triple - think your M3 clone is a triple channel, like my M3. I got a couple test lights, easy to dnld to, like the SupFire M2-Z, SupFire L5, etc. Got quite a few lights running Narsil that are not so easy to dnld to, many have the old e-switch or early Narsil versions.

I still left some open issues on the triple channel ramping tables in my notes, but think I resolved those issues by re-gening the tables - not sure now. I know the mode sets for MODES operation are not the same as 2 channel setups.

Ya, I’m using a triple channel. 1+3+FET. I’ll try to pay attention to the possible problems. Actually, I think I’m going to build two drivers. One to test with and one for the final use. The final driver won’t be reflashable unless I solder leads to the MCU pins. Hmm? That would be possible but probably still easier to make two drivers. I’ll be able to use the extra driver in another light soon enough anyway.

So, I guess:

- momentary works only in RAMPING

  • you can use momentary if the lamp is ON or OFF

1 - Yes, for now, only accessible from ramping

2 - not sure what that means. Momentary/tactical turns the lamp ON and OFF - ON while holding the switch in, OFF when released. A lamp is the main LED or LEDs?

I don’t understand tactical mode.

After 5x clicks, can I push the button in morse code as fast, till the button melts?
To exit tactical mode I would unscrew the tailcap.

The % ist not clear, does that mean more than two clicks?
Is that another way to exit tac. mode?
But that would prevent fast morse code.

Toykeeper has in Andúril:
Momentary mode is permanent until power is disconnected.

What I mean is
The lamp is off: I click 5x and I am in tactical mode.

The lamp is switched on: I click 5x and I am in tactical mode.

Yes lamp is the main LEDs

"%x" must be a typo - as said in other places, it's "5X" clicks.

No bout the super fast morse code currently.

I see I'll have to remove the 2X clicks to exit tactical mode - way too easy to inadvertently hit, but the 5X is not as easy to trip up on. Dunno - maybe I could just remove the 5X click method to exit, then yes, it would work like Andúril then - power cycle to exit.

If this is preferred, it's basically removing code - easy to do.

Ok, understand now -- Yes, you can enter tactical mode via 5X clicks when the main LEDs are ON or OFF.

Also the 4X click lockout works with the main LEDs ON or OFF, as does 3X and 2X clicks.

Looks like there are two ramp table .h files. One for high performance lights(high power/output) and one for standard. No ramp tables for three channels in HP but three channels has ramp tables in the standard file. To throttle back the ramp ceiling looks like I would just chance ramp_size to less than 150?

Will there be troubles anywhere else if I change the rampsize to 200? I know I would have to make a number of changes to the start levels and also I will need to generate a new ramp table but other than that, looks like no other changes need to be made?

Oh, what sets the output value of the 2x click turbo? Is it hard coded to pwm 255 or is in codes to ramp max?

To clarify: what I’m thinking on doing is generating a ramp table to 225 levels using level_calc.py and then setting ramp_size to 200 or so. Then I would have a longer ramp time, ramp max level less than turbo, and turbo via 2x clicks? Is this correct? Sorry, lots of questions…

Yes - that should all work. The high performance files are for lights like the 27K lumens MT03 or 37K 18 XHP50 lights, so yes - don't use them.

Nowadays, 6K or 12K lumen lights are common -- go figure.

TK mentioned a limit above, forgot what the limit # was, and not sure where the limit is imposed - maybe in the Python script?

In your setups file, you need to have this set:

#define TURBO_LEVEL_SUPPORT // set if you want a max turbo level above the max ramping level

Then in the ramping tables file, you need to set RAMP_SIZE to 200, and generate the table for 225. So the last entry at 225 should be 0 for the 7135, 255 for the FET. You can delete all the points after 200 since they won't be used -- this will free up some space.

It's also important to set these in the ramping tables file:

#define FET_START_LVL 68

#define TIMED_STEPDOWN_MIN 115 // min level in ramping the timed stepdown will engage,
// level 115 = 110 PWM, this is ~43% (for 350's)
#define TIMED_STEPDOWN_SET 102 // the level timed stepdown will set,
// level 102 = 72 PWM, this is ~32% (for 350's)

I did everything you listed besides Define turbo level support and change the last entry to 0.
And I got the error messages below. So I’ll give it another try later tonight and do as you describe as I’m not at my pc now.

Actually, I am unsure about where to put the “0”. My 190th(I used 190 instead of 200) entry is 255,255,90. I also set all the last entries in mode sets to the same 255,255,90.

Do I need to have the 190th ramp level use only the fet? I would have to guess where it would mesh with the ramp. Probably around 145? Anyway, I need to try what you have said and see if my error messages go bye bye.