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

Is it possible to get on those newer Buck and Boost drivers to use the free pads to use NTC thermistor on an unsued input

I also get frequently requests on dual e-switch input, or even triple, just something like safe current mode to this extra button by click and hold it for 3 seconds or so

Hi guys! I’m new to Narsil, just got a BLF Q8 and have a question. While in ramping, when the main light is clicked on, the indicator switch blinks sometimes once whereas sometimes it blinks twice. What does 1 blink versus 2 blinks mean? Also, right after I ramp the light up or down it will blink once or twice as well. It seems to blink only once if the output is on the low spectrum and twice for the higher spectrum.
Oh and another simple one, when the head is loosened and then tightened, the light blinks 2 times, is there any significance or is just letting me know it’s made contact?
Thanks!

1 blink: moon to ~160 lumens (maximum level for the 7135 current regulation chip).
2 blinks: Above ~160 lumens (direct-drive FET is engaged).

2 blinks when turning on: Just lets the user know power is connected.

Awesome thanks a lot!

I tried to use the ramp to 80% for normal 3 Channel output

but it is notworking

turbo is very low almost like moonlight

P.S.

I added turbo after the last used mode and it works
so ramp size is 140 and 141 value is turbo

Does someone have instructions how to compile narsilm 1.2 under linux? the Makefile seems to be prepared for windows only…

Edit: figured it out. Will create repository for linux later.

Done: https://bitbucket.org/dmn/narsil

Sorry for the late response… I normally just use the bin/build-85.sh script in my firmware repository. It seems to work fine on NarsilM. I think v1.2 may have had a typo on one of the #include lines though, a capitalization issue, which made it throw an error.

I initally started out using Makefiles in the repository, but almost every project uses the same build and flash commands and I got sick of trying to keep all the Makefiles in sync. So now it mostly uses shared build scripts instead.

I discovered today an odd behavior on the GT v1.2

The driver starts to step down at about 3.45V cell voltage, not sure why, in the tkcalwright is written 3.1V

thermal and cell voltage readout shows no error

How can I change the ramping speed in v1.2?

And is a voltage divider the only option for battery voltage sensing? Or can it compare the VCC input voltage with the internal reference as well?

The ramping goes at 62 fps, with 150 total steps. To change the speed you could either make it go at two/three/four frames per step, or change the number of steps in the ramp table.

It should be able to measure voltage either through a divider or direct on the VCC pin, by setting the relevant option in the code. I don’t recall what the #define for that is though.

So in the channels.h, where “SetLevel” for the specific channel configurations gets defined, I could simply change “level -= 1;” to “level -= 2;” to skip every second ramp table value?

No, that part just converts values of 1-150 to 0-149.

You probably want to look in NarsilM.c for something like “outLevel = ++rampingLevel;” or “outLevel = —rampingLevel;”, and make it move by 2 each time instead of 1. That should double the ramp speed.

Or you could just give it a shorter ramp in RampingTables.h. That’s generally the preferred way to adjust ramp speed.

I was unhappy with my last hack to get the light start up at moon when powered on

I use this code and it seems to work

#ifdef STARTUP_MOON
modeIdx = 1; // Turbo modeIdx = modesCnt - 1; Moon modeIdx = 1
if (ramping)
{
modeIdx = outLevel = rampingLevel = 1;
SetLevel(outLevel);
}

#endif

STARTUP_MOON is defined in the config file

I am wondering if its possible to let the light blink 2 times then go to moon as well

Just a very odd behavior

the temperature readout was blinking constantly

in the end I had to set in the firmware an offset of +30

it seems the firmware does not like negative temperature values,
at least to blink out the value, if its also affecting the internal reading this gets a problem
this would mean on very cold lights that go into thermal stepdown while they are like –10°C

I had a similar issue myself that took while to figure out. Indoors I couldn’t get the bug, but outside it stepped down (it was below 0°C outside, and not very warm inside the hut). At first I didn’t know why it stepped down so I programmed a separate step-down blink for voltage and temperature, and also if level is critical or not. It turned out that my issue was that when the readout goes below 0, the unsigned integer roles around to 255, causing the software to think the light is burning up at 255°C. Maybe similar issue you are having?

So I just removed role around to 255 on my 85 based drivers. I was low on space so I didn’t implement negative readouts. Now that I have double the space I’m considering implementing negative readouts, because sometimes I use my bike light to see approximately how cold it is when cycling in the winter. As it is now I can see when it’s below 0°C, but not how much below.

I think that ToyKeeper has mentioned something about negative temperature fix for RampingOS.

If I recall correctly, I did fix this in RampingIOS… but I completely removed and replaced all the thermal code there. The patch wouldn’t really apply to NarsilM, since the two projects have both diverged significantly from their shared ancestor. The RampingIOS patch could still be a general guide for implementing something similar in NarsilM though.

I can’t really apply the code from FSM / Anduril either since it has no common ancestor at all, and virtually no code which overlaps with Narsil.

At a quick glance, NarsilM seems to be using a uint8_t for its temperature value, so it can’t represent anything colder than freezing. It also appears to use a uint16_t for the initial raw value, from which it subtracts 275, which could set the value to 65,5XX during cold weather.

To fix only the negative temperature issues, it might work to simply use signed 16-bit values for all of this, and maybe add some checks to make sure it’s above 0. But I’m just guessing.

Add a default offset like 50. Then an unsigned integer can represent –50°C to 205°C. Should be enough.