Mike C drivers and X85 firmware.

I have a bunch of different drivers for different applications and have been asked a number of times about making them available. I’ve sent a few here and there, but had not made them publicly available before. Now they are…

Firmware X85 v1 available in following post.

NOTE: I do not consider my driver designs as open source hardware. As OSH Park currently do not support sharing for public order with downloading source disabled, so I won’t openly share on OSH Park until they do. They are planning to implement this but can’t tell me when. In the meantime, those that want to build a driver using my designs can order through me. I’ll do the OSH Park order and just forward your address to them (I won’t be adding anything to the price). These boards are not for everyone. I do some things a lot differently and some may frown on my methods.

I can also sell fully built, flashed, tested and calibrated drivers, but they will probably not fall under the category of “budget”. I’m not saying that my built and programmed drivers will be worth the price I ask, it’s just that it takes time for me to make them. I’ve made stencils for them so it’s not as bad as it used to be. I can share all stencils if there is interest, the BMF-SRK driver without a stencil takes for ever…

I can also offer fully built lights as time permits. It’s what I do for fellow climbers and underground explorers, and is what started all this development in the first place. It won’t as cheap as building yourself though, and I don’t have a vast amount of hosts laying around so it won’t be as fast either.

List of drivers available.
F-8 v2 (17mm FET driver with 8 x AMC7135): Driver: F-8 v2 (17mm FET driver with 8 x 7135)
G-12 (17mm driver with 12 x AMC7135): No driver page for it yet but I used one here: Build/Mod: Zoomie with Brynite B158B host (wider flood mod)
G-16 (20mm or 24mm driver with 16 x AMC7135): No driver page for it yet… An earlier 23mm version is in this light under different name: Custom dual switch driver finally seeing some light.
BMF-SRK: No driver page for it yet… For a photo of the latest version, see post #1036 here: What did you mod today? - #1026 by Mike_C.
ZY-T08: This link will have to do for now: Mod/Driver: ZY-T08 series conversion, MT-G2.

The BMF-SRK and ZY-T08 driver are dedicate 6V drivers with LDOs. The others are both 3V and 6V compatible, depending on components used when building them. For 6V versions a zener diode is used. Voltage monitoring is working in all configurations on all drivers.

X85 Firmware v1 : http://www.mikec.se/Stuff/X85.zip

Here is a first release of my firmware that I use for my drivers. It’s been totally changed many times, is constantly undergoing changes, has a heap load of crap that is unnecessary, it’s messy and hard understand, and most certainly has bugs in it… But this latest version I’ve tested seems good so far…

The zip file linked above also contains the BAT files I use to flash with AVR dude. As I use the no init “brown out detection” trick for temporary storing stuff it is important that the fuse settings are set correctly, check the BAT files for fuse settings I use. One BAT file is for flashing normally, another when flashing and enabling PB5/reset pin as IO, and finally a test BAT file just to test the clip connection before flashing.

I’ll only start with very basic instructions and will have to fill on more as time goes, it’s just too much. Also, I was thinking about making a “release” version of it, cleaned up without all the development stuff, but to be honest I don’t want to have to manage it. I’ll release what I use in my lights, be it full of stuff that no one else needs or not.

The drivers it supports are the ones I will be listing. The F8 in the OP, G-12 (17mm with 12xAMC7135), G-16 (20mm with 16xAMC7135), BMF-SRK (latest version post #1036: What did you mod today? - #1026 by Mike_C) and the ZY-T08. All of these drivers are available as of now according to the OP in this thread. I just haven’t made dedicated driver threads for them yet, I need a break from my computer screens now…

When compiling for a certain driver type, definitions are used. Here is a quick list of the most import ones:

Driver type: One of these must be defined, the others commented out or removed.

#define F8 // F-8 & ZY-T08
#define G12
#define G16 // G-16 & BMF-SRK
#define LOW // Low output modes for development testing.

Switch setup One must be defined, the other commented out or removed.

#define DUALSWITCH
#define OFFSWITCH

Driver config Define DOUBLE_CELL if driver is for light with 2S config, comment out for 1S.
Define PB5_IO if reset pin will be enabled as IO, comment out if not.

#define DOUBLE_CELL
#define PB5_IO

Note: I have made a fuse reset system with Arduino and a board I’ve designed so I can clip on to the MCU and reset it while it’s in the light. If you don’t have this it will be a pain in the * to flash the MCU again, so you might not want to enable PB5/Reset pin as IO. If not set to IO there are some limitations, and the solder pads on my drivers must be soldered so what ever would have been on PB5 should be soldered to PB3. All my drivers have these solder pads. Pin config for all drivers:

PB0 = PWM dedicated AMC
PB1 = 1 x AMC
PB2 = 2 x AMX
PB3 = 4 x AMC and solder pad.
PB4 = input pin (voltage divider, off time cap and E-switch).
PB5 = Solder pad.

On the F-8 the FET is connected to a solder pad only. This solder pad can be soldered to connect to either PB3 or PB5.
If connected to PB5, then any amount up to all 8 AMCs can be used, but PB5 must be set to be used as an IO with the correct fuse settings. Once set to IO the MCU can’t be flashed again unless you use a high voltage serial programmer and reset the fuses. I have an Arduino and built a addon board according to this page: High Voltage programming/Unbricking for Attiny – Arduino, ESP8266, ESP32 & Raspberry Pi stuff I had a few problems on the way, but it’s now working fine.
If you connect the FET to PB3, then maximum four AMCs can be used as the remaining four would now on the same pin as the FET.

G-12 kind of works the same way, but has four additional AMCs instead of the FET. G-16 has eight additional AMCs. With PB5/Reset pin as IO, any amount of AMCs up to full number can be used, otherwise it’s any amount up to four, then all of them on for boost mode.

I only use PWM on the single PWM dedicated AMC between constant current steps. With 8 x AMCs on as highest mode available before turning on the FET, I see no need to PWM the FET. Not even with 4 x AMC would I care about PWMing the FET, so I won’t be making any firmware version that can PWM the FET.

Interface and modes: There are four “standard” interfaces. How they work is described in the C file.
UI 1 and 2 have up to 4 modes including BOOST.
UI 3 uses RAMP1 and BOOST.
UI 4 uses RAMP2 only.
I use UI 4 for moon mode because it’s not possible to accidentally go from moon to full boost within just a few button presses.

#define UI 1
#define MODECOUNT 4

Modes: The mode values consist of two bytes. The first is PWM value of the PWM dedicated AMC, the second is the amount of AMCs on in constant current.
MAX is basically all output pins on in constant current. However, as I have mode level readouts I’ve defined the readout results differently when all pins are on depending on what driver it is.

#define MODE1 20,0
#define MODE2 100,0
#define MODE3 0,2
#define BOOST 0,MAX
#define RAMP1 15,0
#define RAMP2 15,0

I hope the rest of the definitions down lower are self explanatory, at least enough until I get some instructions written… The amount of time it’s taken me to get to this stage is pretty long, so don’t hold your breath for full instructions, it’ll take some time. There are comments next to a lof of stuff, some of them should assist.

Almost everything is user configurable… but how to configure it all is quite complicated… If everything is defined correctly from the start, not much should need to be user configured. However, I’ve noticed that when compiling for DOUBLE_CELL (2S config) drivers, the voltage should be calibrated. I had to keep the same resistor values for 2S or the off time cap would take too long to charge. To solve this I switched to 2.56V internal reference voltage for 2S drivers. It works, and should work OK out of the box, but the measured results are more off than with 1.1V on 1S lights so I do the calibration routine… Well, to be fair I wrote this firmware so I know how to use it, it’s pretty easy for me so I calibrate all my lights.

A list of what can be configured on the light by the user (all options configurable with both dual switch and off switch only setups).
UI 1 to 4, mode count 1 to 4, all mode brightness levels, mode direction, boost timer, low voltage monitoring, low and critical voltage thresholds, critical low output mode or shutdown, temperature monitoring, max temp threshold, mode memory (can include or exclude boost).

Special modes and functions:
Strobe and beacon with brightness modes and speed adjustment, SOS with brightness modes( no speed adjust), noob mode, safety lock, two reset to default routines (one without calibration values, the other a full reset).

There is also the start of an experimental routine that checks the temperature profile of the host (cooling time). I haven’t touched this code in a long time. So far I am OK with just high temp step down, but I’d like to have some sort of thermal regulation later.

I first made the dual switch version with all it’s options. When making a off switch version I originally stripped out most of the config crap, but later changed my mind and “ported” all dual switch config options to off switch and then combined it all by #definitions. By doing it this way the code is definitely not optimized, it just makes managing easier as I don’t have to change function specific code in two places.

I’m planning on making an E-switch only version… someday…

That’s enough for now, I can answer questions about this stuff here and add instructions as I go along… providing there is some sort of interest of coarse.

X85 dual switch functionality

A video that describes the interfaces and special modes. Sorry about the quality, crappy mobile phone camera that couldn’t lock any brightness or focus settings.

Note: The firmware changed slightly since I made this video but I couldn’t be bothered to make a new one. The difference is with special mode 3 (programming mode brightness for UI 1 & 2 modes). I’ve removed the timeout that exits programming mode. It will now stay in constant programming mode until the light is turned off for about 5 to 6 seconds, so there is no rush to adjust those modes to perfection.

This post describes how my X85 firmware works for dual switch lights (lights with both a clicky switch and a momentary “E” switch). There are four user interfaces (UIs):

E press = Press with E-switch, P press = press with power switch.

UI 1
Next mode: Short E or P press.
Previous mode: Long E or P press.
Boost: In mode cycle.

UI 2
Next mode: Short P press.
Previous mode: Long P press.
Boost: E press (not in mode cycle). Hold for 1.5 seconds to lock.

UI 3
Adjust mode: Short P press enables mode adjustment (indicated by three quick flashes).
Boost: E press. Hold for 1.5 seconds to lock.

UI 4
Adjust mode: Constantly adjustable.
Boost: Not available, UI 4 mode is adjustable all the way up to maximum output.

Adjusting output in UI 3 and 4:
Increase brightness: E press and hold.
Decrease brightness: Double E press, hold on second press.

UI 3 mode adjusting times out after about one second of no activity. A flash indicates timeout and the new brightness level is saved.
UI 4 mode adjusting always available. Timeout for saving is the same, but no flashes to indicate timeout.

Setup
The setup menu and all other features are accessed by holding the E-switch pressed while turning on the light, counting the amount of blinks that correspond to the menu of interest and then releasing the E-switch. Directly after releasing, additional E-switch presses access settings under that specific menu, and then additional presses to modify that specific setting. If no additional presses are entered directly after releasing the E-switch from the first blink out menu, the light will in most cases perform a readout of some sort. Also, single long presses (L) are in some cases detected (holding E-switch for about a half second).

Copying in the text with setup info into here looked crap so I put it here instead: http://www.mikec.se/Stuff/SetupDsw.txt
Left column is blink counts while holding E-switch on startup. Columns to the right are by pressing X number of times.

Examples
These are the steps to set the UI.
1: Turn on light with E-switch pressed.
2: Count 1 blink then release the E-switch.
3: Immediately after releasing E-switch in step 2, press 1 to 4 times quickly to select UI 1 to 4.
4: The light will flash a sort of “entry accepted” blink (fade in, fade out). Done.

To engage the safety lockout feature, follow the steps above except for step 3:
3: Immediately after releasing E-switch in step 3, press and hold the E-switch for about half a second.
When locked, the light blinks every now and then. To unlock from safety lockout, either repeat or set any UI as in first example.

To readout the voltage level:
1: Turn on light with E-switch pressed.
2: Count 1 blink then release the E-switch.
3: The light now flashes 1 to 5 times depending on cell voltage level. If it does a fade out instead of blink, the level is below level 1.

X85 off switch functionality

A video that describes the interfaces and special modes. Sorry about the quality, crappy mobile phone camera that couldn’t lock any brightness or focus settings.

Note: The firmware changed slightly since I made this video but I couldn’t be bothered to make a new one. The difference is with special mode 3 (programming mode brightness for UI 1 & 2 modes). I’ve removed the timeout that exits programming mode. It will now stay in constant programming mode until the light is turned off for about 5 to 6 seconds, so there is no rush to adjust those modes to perfection.

This post describes how my X85 firmware works for off switch lights (lights with only a clicky switch). There are four user interfaces (UIs):

UI 1
Next mode: Short off press.
Previous mode: Long off press.
Boost: In mode cycle.

UI 2
Next mode: Short off press.
Previous mode: Not available.
Boost: Long off press (not in short press mode cycle).

UI 3
Adjust mode: Long off press enables brightness adjustment (indicated by three quick flashes).
Boost: Short off press.

UI 4
Adjust mode: Constantly adjustable.
Boost: Not available, UI 4 mode is adjustable all the way up to maximum output.

Adjusting output in UI 3 and 4:
Increase brightness: Short press starts increase of brightness. Stop with short press.
Decrease brightness: Double short press starts decrease of brightness. Stop with short press.

UI 3 mode adjusting times out after about one second of no activity. A flash indicates timeout and the new brightness level is saved.
UI 4 mode adjusting always available. Timeout for saving is the same, but no flashes to indicate timeout.

Setup
The setup menu and all other features are accessed by short off presses directly after a cold start (turning on the light after it has been off for 5 to 6 seconds or longer). To enter the menu off interest the corresponding amount of off presses must be entered, each off press within a second of the previous. The light will then give a confirmation flash (quick fade in/fade out) and then await input in the form off additional off presses to access a specific function or setting within that menu. If no additional presses are entered directly after the first menu selection confirmation flash, the light will in most cases perform a readout of some sort. Also, single long presses (L) are in some cases detected (holding the off switch off for about a half second).

Copying in the text with setup info into here looked crap so I put it here instead: http://www.mikec.se/Stuff/SetupOsw.txt
Left column is press count directly on cold start to access that menu. Columns to the right are by pressing X number of times.

Examples
These are the steps to set the UI.
1: Turn on light after it has been off for at least 5 to 6 seconds.
2: Within one second perform three off presses.
3: Wait for the confirmation flash (quick fade in/fade out).
4: Enter 1 to 4 short off presses quickly to select UI 1 to 4.
5: The light will flash a confirmation flash. Done.

To engage the safety lockout feature, follow the steps above except for step 4:
4: Immediately after the confirmation flash, perform a long off press by holding the off switch off for about half a second.
When locked, the light blinks every now and then. To unlock from safety lockout, either repeat or set any UI as in first example.

To readout the voltage level:
1: Turn on light after it has been off for at least 5 to 6 seconds.
2: Within one second perform three off presses.
3: Wait for the confirmation flash (quick fade in/fade out).
4: The light now flashes 1 to 5 times depending on cell voltage level. If it does a fade out instead of blink, the voltage level is really low, below level 1.

I think things are just getting lost with all of the activity on BLF recently. Browsing the ‘Recent Posts’ page doesn’t work as well as it used to.

Well, I’ll let this thread hang around for awhile. If there is no interest at all I’ll just delete all info in it and continue on in silence like before.

That’s a truckload of code! I can barely imagine how much time you must have put into it. Almost makes me glad I’m limited to an attiny13a for now :]

Please do not delete! You have viewers. The complexity of the subject makes it hard to interact with in the short term. It takes some prep to get to a place where one can even ask a question. I’ve been watching this thread and trying to absorb the great info. There is some excellent functionality here and over time it will help many! As I’m needing new drivers, I have come to this page, and to your work even prior to this posting. Each time I have not been able to use the information, but each time I come back, I get farther into what you are doing and soon I will be able to interact with this great firmware/drivers. They offer some things that are not currently out there so what you are doing is relevant, it’s going to take some time though. No doubt there are others thinking the same thing. Thanks for your work!

Thanks. I’ve been quite tired of it lately, but now I think it works as I have intended… But to be honest I don’t want to do more extensive testing and bug searching for a while, I just want to relax thinking all the quirks have been worked out for awhile :slight_smile:

Ok, point taken. I haven’t exactly released this stuff in steps so I guess a little understanding from my side is due. My companions and I wouldn’t have such awesome lights without BLF, and this stuff wouldn’t exist at all, so I kind of owe it to leave this stuff here, be it of interest or not.

It’s definitely of interest! Thanks for posting this info! Please don’t think it isn’t of interest!

I know exactly what you mean :slight_smile: Debugging firmware is about as much fun as debugging multithread code and ignorance is bliss.

On top of what PPDB22 wrote, keep in mind that there are probably under twenty people here who could read and understand that code. And I think we could really use a “firmware index” thread.

There is such a thread Flashlight Firmware Repository

Thanks, I knew of ToyKeeper’s repository but somehow never realized that thread was also a sort of index.

Mike C, if I remember correctly, you’re the one whose drivers have cell level readout, OTC and e-switch all on the same pin, right?

Thanks for sharing your time & work, Mike C. :beer:

Great 10x for your time and efforts m8, so far so good, you did a good job on the firmware too - i like F-8 v2

Actualy, most fo the time ppl dont need that fancy firmwares ( including me), 2-3 modes plus eventualy moonlight…. and strobe( for bikers)

Likewise. I dont understand a lot that goes on here but do understand the time put in. :beer:

Thanks for the positive comments all :beer:

Yep. All the drivers listed in the OP work like this and use my X85 firmware.

Yeah, I do know what you mean. I thought so too, but then I wanted to use constant current instead of PWM, and that required more pins, so I combined three functions on one pin, then after using them down in mines I got all these different ideas, and took ideas from friends… and then wanted to be able to configure the lights I’d built for them with them in the mines… and now here we are :slight_smile:
All the development stuff, configurable stuff and readouts are totally useless for people who flash their drivers and are done with it. I use that stuff because I set people’s lights up as they want in person out in the field away from computers and crap. Maybe one day I’ll release a “clean” version with all that crap cut out, leaving the bare essentials. Who knows, it might even fit into the ATtiny25 by then.

Bistro uses 2048 bytes. Meanwhile, blf-a6 with the runtime config parts removed uses 710 bytes. The difference is almost entirely the soft config options. I wouldn’t be surprised if yours went from 7500 bytes down to 2000 without the config options.

A light with one of my drivers and firmware is in the mail, so I have updated post #3 with dual switch setup info.

I’ve thought a little about making a clean version and I don’t think I will. If most of the features and functions are useless… don’t use them. Set the right driver type, then the mode levels under DEFAULT SETTINGS at the top of the C file, and it’s done. I believe I’ve made those definitions easy enough to understand, so if there is no interest in the rest, there’s no need to bother about the rest. Boost timers, low voltage thresholds, mode direction and all that stuff is also set by definitions. Set ’em and forget ’em.

Besides, making it smaller so it fits into the ATtiny25 is pointless for me. I’ll save like 0.5$ by switching to the 25, even less for low voltage versions, at least when buying from my component supplier. It’s too much work for 50 cents.

Dual switch= wow! I’m determined to build one of these now. I’ve started plans to build a BLF d80 with an added side switch. I think that will be my perfect opportunity. I will keep you informed.