[Flashing drivers] Lexels firmware builds and flashing guide

Bistro HD OTSM v1.7.1

if you want to change the flash and later reset values to a different behavior change the Boot up values

#define USE_FIRSTBOOT //Enables reset menu option, only costs a couple of bytes.

#define INIT_MODEGROUP 11 // which mode group will be default, mode groups below start at zero, select the mode group you want and subtract one from the number to get it by defualt here
#define INIT_ENABLE_MOON 1 // Should we add moon to the set of modes?
#define INIT_REVERSE_MODES 0 // flip the mode order?
#define INIT_MEMORY 0 // mode memory, or not
#define INIT_OFFTIM3 1 // enable medium-press by default?
#define INIT_MUGGLE_MODE 0 // simple mode designed for mugglesotsm
#define INIT_LOCKSWITCH 0 // 0 => E-swtich enabled, 1 => locked.
#define INIT_MAXTEMP 88 // maximum temperature

Calibrate voltage readings

Anduril

3 clicks from off shows you the read battery voltage compare to measured voltage or assume full battery is 4.2V

in the light specific hwdef-“lights name”.h file

for 1S builds without voltage divider
// average drop across diode on this hardware
#ifndef VOLTAGE_FUDGE_FACTOR
#define VOLTAGE_FUDGE_FACTOR 6 // add 0.25V
#endif

change the diode offset value in 0.05V steps

.

for builds with LDO
// Raw ADC readings at 4.4V and 2.2V (in-between, we assume values form a straight line)
#ifndef ADC_44
#define ADC_44 184
#endif
#ifndef ADC_22
#define ADC_22 92
#endif

#define VOLTAGE_FUDGE_FACTOR 0 // add 0.25V

2 options:

- change the voltage fudge factor –1 is here about 0.1V lower

  • change the ADC_44 and ADC_22 value similar to NarsilM

.

NarsilM

look if 3 clicks show proper voltage reading either at full or drained battery

Changes in the Setups.h file

LDO Builds
in NarsilM I have added different voltage reading tables those you can simple enable
#define VOLTAGE_MON // Comment out to disable - ramp down and eventual shutoff when battery is low
//#define VOLT_MON_R1R2 // uses external R1/R2 voltage divider, comment out for 1.1V internal ref
//#define USING_2200K
//#define USING_1000K // for 4S
//#define USING_1000K_01 // 2.8V +0.1
//#define USING_1000K_02 // 2.7V +0.2
//#define USING_1000K_m01 // 3V –0.1
//#define USING_1000K_m005 // 2,95V –0.05
//#define USING_680K // for 3S GT buck
//#define USING_680K_02 // 2.8V +0.2
//#define USING_680K_01 // 2.8V +0.1
//#define USING_680K_m01 // 3.0V –0.1
//#define USING_680K_m02 // 3.1V –0.2
//#define USING_680K_m03 // 3.2V –0.2
#define USING_360K // for using a 360K resistor (LDO and 2S cells)
//#define USING_360K_m01 // 3V –0.1
//#define USING_360K_m005 // 2.95V –0.05
//#define USING_360K_005 // 2.85V +0.05
//#define USING_360K_01 // 2.8V +0.1
//#define USING_220K // for using a 220K resistor (LDO and 1S cells)

.

for 1S builds change the diode offset
#define D1_DIODE 4 // Drop over rev. polarity protection diode: 0.2V normally, 0.3V for Q8, bigger value for too high voltage

.

Bistro HD

see if full battery shows 4.2 blinks in hidden modes or if the LVP is at 2.7V

change v correction value in the fr-calibration.h file

1S builds
//Calibration for traditional voltage-divider, NON LDO*/////////
//
#define v_correction 0.0 //in volts for minor calibration adjustment.

.

LDO builds
//LDO OTSM calibrataion//
//
#else // next version is the value used for LDO OTSM configs where the divider voltage is read relative to Vcc
#define v_correction 0.0 //in volts for minor calibration adjustment.

.

.

Calibrate temperature readings

Anduril

read the actual MCU temperature

  • 3 clicks from Off followed by 3 double presses
    measure the driver’s temperature with IR thermometer or use room temperature

2 options:

  1. while you are in the temp read from above do 4 clicks then follow user manual to set the calibration and the max. temp value

2. if use 10 clicks for thermal calibration is enabled in the setup file
10 click and then follow the manual

NarsilM

read actual MCU temp by 3 clicks followed by double press

in Setup.h
// Temperature Calibration Offset
#define TEMP_CAL_OFFSET (–6)

- change this value and compile a .hex so that the readout is as the drivers temp

  • flash driver and check if it is now equal

Bistro HD

set the max limit in the light

Many thx for all of these info’s!

As I don't flash drivers, this thread isn't really for me, but it looks impressive!

Sweet!

:+1:

Thanks! Sticky’d.

Thank you Lexel… Can’t wait to ruin one of my FW3A drivers lol

Great works! :+1:

Thank you Lexel. Very useful informations. I just realized that none of my bistro hd drivers have voltage calibration.

You have little bug in post #7
Should be:
Calibrate voltage readings
and then
Calibrate temperature readings
You have Calibrate voltage readings twice

Great ressource you provided here. Got it working all by myself, but this thread would have saved me a lot of time :)

Thanks Lexel. Nice work putting this together. I still dont understand it though. :person_facepalming: :slight_smile:

Thanks Lexel! This is huge!

Thanks for this. :slight_smile:

It’ll be a big help for anyone who has a light based on your work and wants to get the sources for reflashing or modifications. Also very helpful for investigating and fixing any potential issues people might discover.

With open-source stuff like this, the main idea behind the license is that it stays open. To do that, it requires that anyone who distributes a compiled version also needs to make sure the sources are available and information about how to get it is published in an easily-found place.

A thread like this helps a lot with that goal.

Awesome work :beer:

If someone succesdes to update the “Anduril Atmel project folder” to the latest files, do share :wink:

It worked out of the box, even with the changes I made to Anduril, it built a hex file. I flashed it, and it worked. HUZZAH.

My issue is that it’s based on an older revision of Anduril, on older files (fx.: 2-level lockout is missing) . When the files are updated, it makes 5-6 errors and doesn’t compile anymore :cry:

Nice work Lexel! :beer:

you sir are a noble and a scholar!

When I want to select the chip ATtiny25 in Atmel Studio 7 there are no ATtiny chips available. There are loads of other to choose from. What am I doing wrong?

This is really good. I am following this for future reference.