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

513 posts / 0 new
Last post
emarkd
emarkd's picture
Offline
Last seen: 11 months 3 weeks ago
Joined: 04/14/2015 - 22:04
Posts: 1608
Location: Georgia, USA

nvanlaar wrote:

I saw some Zebralights advertise some sort of PID. I wonder how they have it implemented.

Thanks guys!

I can’t report how its implemented because I don’t know, but I can say that it works incredibly well in those lights, better than any other thermal regulation that I’ve experienced. It responds very quickly to both rises and drops in temp. You can tailstand a Zebra on turbo and as it warms up you’ll start to notice very very faint step-downs, the sort of thing you won’t even really see unless you’re watching for it. Then after a few minutes when its good and hot, add some sort of cooling (even just grabbing it with your hand), and watch it reverse, stepping back up in very faint steps. Its cool to watch happening.

But then those lights also have tightly regulated boost drivers and other more advanced features than most of the lights on the market. They’re really smart lights…with a very divisive UI that some folks love and some hate. Someone should port NarsilM to one of their drivers. I’d flash all of mine. Smile

Tom E
Tom E's picture
Offline
Last seen: 3 hours 1 min ago
Joined: 08/19/2012 - 08:23
Posts: 15012
Location: LI NY

Definite advantages to smart buck/boost drivers, which also explains why they cost more. Usually of course they will have limited output because it's hard or expensive to do high amps with those designs. For us, it's a huge EE design project, and then we would also have issues with real estate and parts count, probably have to drop to 0402 size parts, then it gets more and more challenging to use the cheap PCB fab houses like OSHPark, and be able to reflow the boards ourselves. When you are planning on full manufacturing, you got a lot more options.

Ideally you want a smart buck/boost combo, then a separate output channel for a high amp direct FET -- best of both!

nvanlaar
nvanlaar's picture
Offline
Last seen: 3 months 1 week ago
Joined: 08/30/2017 - 16:57
Posts: 275
Location: CA, USA

Not your grandfather’s flashlight to say the least… Wink

“Facts don’t care about your feelings.”
~Ben Shapiro

LightRider
LightRider's picture
Offline
Last seen: 3 years 7 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

I flashed my version of narsilm and was unsuccessful at creating a ramp ceiling less than max turbo. My ramp table is configured for 225 levels and is set to “#define RAMP_SIZE 190”

In the main .c file the code looks like this:

#define MAX_RAMP LEVEL (RAMP_SIZE)

#ifdef TURBO_LEVEL_SUPPORT #define TURBO_LEVEL (MAX_RAMP LEVEL+1)
#else #define TURBO_LEVEL (MAX_RAMP LEVEL)
#endif

So I’m my case turbo level would be 190+1 or 191
Level 191 is not max output so how does this set turbo to level 225 or 255pwm?
Should I just change define turbo level to something like:

define TURBO_LEVEL (225)

I guess I just don’t get the +1 in the define?

Everything else seems to be working. One weird action is when I do a click-clickhold-click the main led and the indicator shut off?

LightRider
LightRider's picture
Offline
Last seen: 3 years 7 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

Oh, I should note that the output is reduced. Using my test led it sets a max at about 2amps. However a 2x click goes to about the same level. Maybe a few ma more which makes me think it is just going to the next ramp level of 191 on gone ramp table.

LightRider
LightRider's picture
Offline
Last seen: 3 years 7 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

I decided to just give some things a try. However I was unable to successfully reflag the MCU.

I kept getting this error:

avrdude verification error first mismatch at byte 0×0000
0×00 != 0xa0 content mismatch

I disconnected some parts of the circuit as I added the led and switch board sinse the first flash and then retried three or four times. Now the MCU is not responding to any command. Crying

I think I may have to give up on this one for a while. It’s been trouble the whole way. Idk? If anyone has suggestions I’ll give them a try but I may need to start over if I’m gojng to make this one happen. Oh well…

vestureofblood
vestureofblood's picture
Offline
Last seen: 9 hours 36 min ago
Joined: 08/17/2012 - 15:21
Posts: 2001
Location: Missouri

If I wanted to flash this to the BLF GT driver is it the same process/setup/hardware as doing the regular stuff to tiny13 micros? Or are any hardware/software changes needed (besides selecting the tiny85 micro)?

In Him (Jesus Christ) was life; and the life was the light of men. And the light shineth in darkness; and the darkness comprehended it not.
http://asflashlights.com/ Everyday Carry Flashlights, plus Upgrades for Maglite.

The Miller
The Miller's picture
Offline
Last seen: 2 years 1 week ago
Joined: 12/14/2015 - 12:08
Posts: 9908
Location: Charente France

VOB people got pointed to the “how to flash AT13 topic” when asking hiw to flash AT85 and when Tom send me then list of things I needed I think it was the same as for 13.

Tom, from the Q8 thread
How about an extra setting for side switch led where people can set brightness?

*

Tom E
Tom E's picture
Offline
Last seen: 3 hours 1 min ago
Joined: 08/19/2012 - 08:23
Posts: 15012
Location: LI NY

Oh boy, hard to keep up here. 

For the 85 in on the GT or Q8 drivers, yes - same ol process as we use for 13's, but of course, specific to the 85. For th AVRDude commands, you must specify the MCU, for example:

This dnld's the firmware:

rem 85NarsilM - downloads NarsilM (Tiny85 Multi-channel e-switch UI configurable)
rem
avrdude -p attiny85 -c usbasp -u -Uflash:w:\Tiny254585Projects\NarsilMulti\Release\NarsilM%1.hex:a

This sets the fuses:

REM BOD enabled at 1.8V:
avrdude -p t85 -c usbasp -Ulfuse:w:0xe2:m -Uhfuse:w:0xde:m -Uefuse:w:0xff:m

 

So using "attiny85" or "t85" says it's an ATtiny85 MCU. For 13, 25, 45 -- same thing.

 

Tom E
Tom E's picture
Offline
Last seen: 3 hours 1 min ago
Joined: 08/19/2012 - 08:23
Posts: 15012
Location: LI NY

LightRider wrote:
I decided to just give some things a try. However I was unable to successfully reflag the MCU. I kept getting this error: avrdude verification error first mismatch at byte 0x0000 0x00 != 0xa0 content mismatch I disconnected some parts of the circuit as I added the led and switch board sinse the first flash and then retried three or four times. Now the MCU is not responding to any command. Crying I think I may have to give up on this one for a while. It’s been trouble the whole way. Idk? If anyone has suggestions I’ll give them a try but I may need to start over if I’m gojng to make this one happen. Oh well...

Hhmm. I get this quite often - usually a bad clip engagement. Sometimes cleaning the MCU pins and clip pins with isop. alcohol does the trick.

LightRider
LightRider's picture
Offline
Last seen: 3 years 7 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA
Tom E wrote:

LightRider wrote:
I decided to just give some things a try. However I was unable to successfully reflag the MCU. I kept getting this error: avrdude verification error first mismatch at byte 0×0000 0×00 != 0xa0 content mismatch I disconnected some parts of the circuit as I added the led and switch board sinse the first flash and then retried three or four times. Now the MCU is not responding to any command. Crying I think I may have to give up on this one for a while. It’s been trouble the whole way. Idk? If anyone has suggestions I’ll give them a try but I may need to start over if I’m gojng to make this one happen. Oh well…

Hhmm. I get this quite often – usually a bad clip engagement. Sometimes cleaning the MCU pins and clip pins with isop. alcohol does the trick.

Hmm? That weird. I soldered leads to each leg of the MCU straight to my programmer. It worked the first time but not the second and I had left the leads soldered on as I anticipated reflashing a couple times. Huh. I’m starting over anyway.

I still didn’t get the double click to turbo working. I can get the top of the ramp reduced but then a double click only goes up about 300ma or so. Do you have that option working on any light yet?

Thanks Tom! I wish We had a way for you to share the tech support load! I’ve been thinking of some ideas but don’t know if anyone would engage or not. Anyway if you coule just answer the do you have the “reduced ramp with 2x click to turbo working for sure” question, that would be helpful.

Flashy Mike
Flashy Mike's picture
Offline
Last seen: 2 months 1 day ago
Joined: 01/14/2016 - 16:38
Posts: 1222
Location: Germany

@LightRider:
You might have set wrong fuse on last programming.

Tom E
Tom E's picture
Offline
Last seen: 3 hours 1 min ago
Joined: 08/19/2012 - 08:23
Posts: 15012
Location: LI NY

It works well on the BLF GT, actually, I think - pretty sure. Hhmm, I had to test it out somehow without having a GT buck driver light though, so tested on something - think a 2 or 3 channel test light. Ohh, trying to recall, think I modded up a header file to use only the first 130 or so levels of the 150, then 2X click went max, and ramping stopped at the 130 level.

Maybe you can send me your files you changed, or ZIP up the whole project? Probably be easy for me to find a problem.

LightRider
LightRider's picture
Offline
Last seen: 3 years 7 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA
Tom E wrote:

It works well on the BLF GT, actually, I think – pretty sure. Hhmm, I had to test it out somehow without having a GT buck driver light though, so tested on something – think a 2 or 3 channel test light. Ohh, trying to recall, think I modded up a header file to use only the first 130 or so levels of the 150, then 2X click went max, and ramping stopped at the 130 level.


Maybe you can send me your files you changed, or ZIP up the whole project? Probably be easy for me to find a problem.

Very generous of you! PM sent with a link to my zipped project Smile

bwings
Offline
Last seen: 12 hours 55 min ago
Joined: 01/31/2016 - 04:42
Posts: 108
Location: South Sumatra, Indonesia.

Tom, in v1.2, what should I edit if I want a faster response for double clicks to turbo? It seems like double clicks to turbo has a bit slower (pauses at memorized level about half a second). compare to v1.0
Thanks.

____________________________________________________________________________________

Sorry for my poor English

Tom E
Tom E's picture
Offline
Last seen: 3 hours 1 min ago
Joined: 08/19/2012 - 08:23
Posts: 15012
Location: LI NY

bwings wrote:
Tom, in v1.2, what should I edit if I want a faster response for double clicks to turbo? It seems like double clicks to turbo has a bit slower (pauses at memorized level about half a second). compare to v1.0 Thanks.

Yes, intentionally so. I've answered this question before but dunno where. It's not as long as 1/2 sec, it's definitely quicker.

If I didn't delay it, when you do a 3X, 4X or 5X click, you would get flashed with max/turbo every time. I did not want to delay the 1 click operations, so decided to start it at 2X since the flash of max/turbo is annoying.

From what I can tell, the delay is 0.288 seconds, as defined below. If you change it to be less, you will make the multi clicks tighter timed and might get difficult:

# define SHORT_CLICK_DUR 18 // Short click max duration - for 0.288 secs

 

bwings
Offline
Last seen: 12 hours 55 min ago
Joined: 01/31/2016 - 04:42
Posts: 108
Location: South Sumatra, Indonesia.

Thanks Tom Thumbs Up

____________________________________________________________________________________

Sorry for my poor English

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 min 15 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10811
Location: (469219) 2016 HO3

Tom E wrote:
I’m pretty confident now in the new v1.2 version of NarsilM. Not as much features in it as I would like to have done, but it seems pretty solid. I pre-built a few common configurations including the Q8, so you can find the google share folder here with the source code and HEX files. Docs are not updated yet:

drive.google.com – NarslM v1.2

This is now updated in the repository.

Tom E
Tom E's picture
Offline
Last seen: 3 hours 1 min ago
Joined: 08/19/2012 - 08:23
Posts: 15012
Location: LI NY

Thanx TK! laughing

LightRider
LightRider's picture
Offline
Last seen: 3 years 7 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

Does narsilm without voltage dividers require the 85v 10Mhz?

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 min 15 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10811
Location: (469219) 2016 HO3
nvanlaar wrote:
I’m new to the programming side of flashlights, but do some industrial automation for a living. I’m curious, has a PID loop ever been considered for Turbo/high settings for flashlights like the Q8 or GT? Is it an issue of enough storage space to hold the bits or enough processing power? Thanks for any insight!

Yes, at least two of us have implemented it now, and there is some code for it in the repository. It’s included in the Emisar lights, Crescendo, and the FSM toolkit… and I’ve been dragging my feet about patching something into Narsil.

While not PID, Narsil already has thermal step-down. It was tuned for the Q8, but didn’t respond fast enough for use on a D4 (much smaller, similar power level). This is what I measured on a D4v1 light (which was way too hot from about 30s to 4m):

Tom E wrote:
Dr Jones did this a few years back, and he’s very good and took him a lot of time to develop and test, then I hear it’s still not great.

Yeah… these things take an inordinate amount of time to test, and I’ve found it tends to be really sensitive to small changes.

I tested a DrJones H17F driver’s thermal response recently, and it looks like his solution was to make the regulation response relatively slow and gradual. In my test, it took almost 8 minutes to reach a stable state… which was fine on the heavy copper host I used, but would be way too slow for something like an Emisar D4. However, it was very smooth and had no significant oscillations or noise. It merely stepped down one PWM level at a time, one channel at a time, until it was no longer overheating. And when ice was held against it afterward, it stepped back up just as slowly. I wouldn’t really say it’s a PID algorithm though, since it didn’t act like one. The I term seemed to be zero, I couldn’t tell if there was a D term or not, and if there was a P term it seemed to have only two states — two steps per second, or one step per second.

My attempts to make a more responsive PID regulator have been less than ideal. It works, but I’m not totally happy with it. After reaching a stable state, it’s still more noise-sensitive than I’d like, and occasionally I’ve measured rather undesirable behavior like oscillations. The response is proportional though, and fairly heavy on the derivative term so it can anticipate and “steer into” the turns, but I’ve mostly only used the integral parts as a way to reduce noise. And, as already mentioned, it’s still not at a point where I’m happy with it. Sensor readings are low-resolution and noisy and subject to thermal lag due to having the sensor in the MCU, and my attempts to deal with the lag have made it even more noise-sensitive.

Here’s FSM’s behavior compared to a H17F:

So… long story short: Yes, but it’s still a work in progress.

Tom E
Tom E's picture
Offline
Last seen: 3 hours 1 min ago
Joined: 08/19/2012 - 08:23
Posts: 15012
Location: LI NY

LightRider wrote:
Does narsilm without voltage dividers require the 85v 10Mhz?

No, the "85V" version is not necessary.

LightRider
LightRider's picture
Offline
Last seen: 3 years 7 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

Does double click to turbo go to turbo in mode sets as well as ramping?

I was able to get narsilm with throttle control working in ramping configuration so i assumed it was working in mode sets. However, today i was testing out the rest of the options and realized the 2x click in mode sets is not working for me. two clicks simply advances the out put two levels. Is this just me or is this the way it works?

I have the ramping mode stopping at 2amps for normal operation of the M3 clone. then a 2x click and “BAM!” IN YOUR FACE 7amp Max turbo. I like it! Big Smile

JasonWW
JasonWW's picture
Offline
Last seen: 7 hours 8 min ago
Joined: 10/22/2016 - 11:41
Posts: 12893
Location: Houston Texas

No, I don’t think you can jump to turbo while in mode sets.

Texas Ace Lumen Tube and JoshK Sphere calibrated with Maukka lights

Click this to go to signature links. I'm still around, just not reading many new threads.

LightRider
LightRider's picture
Offline
Last seen: 3 years 7 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA
JasonWW wrote:
No, I don’t think you can jump to turbo while in mode sets.

Ahh. Ok, thanks. I thought it might be my inability to fast click. So good to know. It means I might still have my freakishly fast reflexes after all. Ch’ chahhh… LOL

joechina
Offline
Last seen: 4 months 3 weeks ago
Joined: 03/05/2016 - 08:23
Posts: 1459
Location: Germany

Lightrider,
no it doesn’t.

The command for TURBO in MODES is:
The lamp is OFF: Click&hold
Nothing else

In the cheat sheet:
The row for 2x in the MODES column is empty, as other multible click commands.

JasonWW
JasonWW's picture
Offline
Last seen: 7 hours 8 min ago
Joined: 10/22/2016 - 11:41
Posts: 12893
Location: Houston Texas

joechina wrote:

The command for TURBO in MODES is:
The lamp is OFF: Click&hold
Nothing else

Are you sure? It seems a click&hold from OFF first goes to strobe, then goes to the menu options.

Texas Ace Lumen Tube and JoshK Sphere calibrated with Maukka lights

Click this to go to signature links. I'm still around, just not reading many new threads.

LightRider
LightRider's picture
Offline
Last seen: 3 years 7 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA
JasonWW wrote:
joechina wrote:
The command for TURBO in MODES is: The lamp is OFF: Click&hold Nothing else
Are you sure? It seems a click&hold from OFF first goes to strobe, then goes to the menu options.

For me, click&hold goes to max, then strobe, then menu

The click&hold to max may be a new option in the latest version only. Not sure

Lexel
Lexel's picture
Offline
Last seen: 1 year 4 weeks ago
Joined: 11/01/2016 - 08:00
Posts: 5895
Location: Germany

I was playing today with my Q8

The batteries were almost depleted the light was already down to ML level

When I turn on strobe it is the full FET brightness
no step down of the strobe is going on its still flashing at max brightness the battery can deliver

I have a feeling LVP will not kick in

already 0.05V dropped, since I started the test
Firmware blinks out 2.8V real cell voltage 2.96V

OK I got now the confirmation, driver blinks out 2.7V and in normal operation the light shuts down
Strobe is still going strong and depletes the cells

JasonWW
JasonWW's picture
Offline
Last seen: 7 hours 8 min ago
Joined: 10/22/2016 - 11:41
Posts: 12893
Location: Houston Texas
LightRider wrote:
JasonWW wrote:
joechina wrote:
The command for TURBO in MODES is: The lamp is OFF: Click&hold Nothing else
Are you sure? It seems a click&hold from OFF first goes to strobe, then goes to the menu options.

For me, click&hold goes to max, then strobe, then menu

The click&hold to max may be a new option in the latest version only. Not sure


Your right, when you click and hold it goes to turbo first, then strobe, then the menu. I don’t have my lights right now, so I had to look at my own videos. Lol

I’m not a fan of mode sets. I learned them for the videos, but have appearantly forgot some stuff already. Silly

Texas Ace Lumen Tube and JoshK Sphere calibrated with Maukka lights

Click this to go to signature links. I'm still around, just not reading many new threads.

Pages