[UPDATE:v1.7.1,Q8&1chanOTSM]bistro-HD, bistro your way. OTSM, eswitch(devel), Vcc reads, safe_presses, turbo timeout...

OTSM is fixed. (OP updated) and is working perfectly on a TAv1 17mm light. I don't see any reason this shouldn't become the default setup for these lights. It's just so much better than OTC. As this TAv1-OTSM build is now really (was always meant to be) the flagship HD build, maybe I need a new name for it.

Below are some details about how to build it, also found in the Manual and the OP. In the end this worked so well that it's likely possible to cut some corners, like use cheaper ceramic caps. Personally I probably just wouldn't, but it may work fine.

VIII.1 Parts and build for tested TAv1 board

OTSM is working better and better, but getting it there required a combination
of software work and the best parts. It may be possible now to use cheaper or
lesser parts since OTSM performs a little better than needed with these, but
these are tested and work.

MCU:
It's required to have BODS support for the mcu (see theory below). From page 36
of the manual this requires:
• ATtiny25, revision E, and newer
• ATtiny45, revision D, and newer
• ATtiny85, revision C, and newer

[This note not in manual yet: Revision letter is lower left most letter on bottom of Attiny 25. I forgot on attiny 45 where it is, might be on top.]

The spec for OTSM also requires V version (10Mhz, low voltage version) chips.
You might get by without it, but it won't work as well and may cause
corruption.

Unfortunately most ATtiny 85s reported off the shelf have been revion B, for
the past many years even. They don't work. So far Attiny25, attiny25V,
attiny45 and attiny45 v's where reports exist on this, have been of recent
enough version. Of course attiny25V is available in the smaller footprint and
fits 17mm TAv1 boards. At the time of this writing all HD features including
OTSM can fit on an attiny25.


Diode part number: RB751V40T1G
http://www.onsemi.com/pub/Collateral/RB751V40T1-D.PDF

This is the MCU protection diode. It isolates voltage from the C2 cap that
powers the MCU while input power is down. It was chosen for its low leakage
even at high temperatures. Leakage below 1 or 2 uA is probably fine.

C2 cap (powers MCU during off time, quality counts here)

Cap part number: 298D476X0010P2T
http://www.vishay.com/docs/40065/298d298w.pdf

This cap was chosen to get the most capacitance in an 0805 possible and because
Tantalum does not suffer from DC bias de-rating or temperature fluctuation.
Capacitance this high (47uF) in an 0805 are all low voltage. For Ceramic if
the DC offset is more than about 1/3 of the rated voltage the capacitance
starts to drop, some times a bunch. This cap does have a large tolerance
though unfortunately.

Voltage divider:

Tested with R1 of 1K and R2 of 3.3K R1 should be no more than about 1/3 of R2,
but this ratio should be ideal for OTSM performance in a 1S light (but only in
a 1S light). Lower values can improve OTSM performance, at the expense of
higher mood mode drain. If you use lower quality caps or diode, you can try to
add a bleeder of about 500ohm to gain a little advantage on off time, not much.

OTC:
None, unpopulated.

C1: 1uF (see TA instructions for part numbers)

For all other parts, see the Texas Avenger instructions.

I haven't had a chance to read in detail yet, but this sure seems like some really exciting stuff you're doing here Flintrock.

Click click, whoo.. lol. Fun at least. Don't forget Mice C and flashy mike who took the early talk is cheap attitude to get this all going.

Version 1.1 posted (see OP)

Includes firmware for an LDO OTSM TA build. Latest Build instructions will be maintained in the Manual, and the OP, but the excerpt is below.

Also split the dual switch build into a noinit version and an OTSM version. The OTSM version is specifically targeted at lexel's "option 3", but an option 1 configuration should arrive soon.

These are not tested builds/firmwares, but the differences from the regular OTSM versions are fairly straightforward and those differences have each been independently tested. The LDO build should work. Dual switch, enh, probably. No guarantee or implied anything.

VIII.1b Parts and build for TAv1 board for LDO (2S, 3S etc)

Quick version:
See section VIII.1a for mcu, cap and diode selection.
Place the diode on the R7 resistor pad with the anode (+ side) pointing away
from C2. No OTC cap is needed. Use the following divider resistors, in ohms.

R1 R2
2S: 1780 2210
3S: 2250 1500
4S: 2870 1100

Should be 1% or better. Dropping R2 by 1% or 2% might help get full range of voltage read on the very top end and the risk of pushing the specs slightly at the low end. Not a big deal either way. The default calibration is centered around the values above though.

No bleeder. That's it.

For all other parts, stick with the original Texas Avenger instructions.

Long version:

For 2S or more build, the attiny must be fed power by some form of voltage
regulation such an LDO. This means that Vcc (input voltage) cannot be used to
measure the battery voltage. The divider must be used. Furthermore because
the divider pin must stay logic high to indicate power on, the 1.1V reference
cannot be used. The REFERENCE_DIVIDER_READS_TO_VCC option must be used (It's
compiled into the LDO firmware) This reads pin voltage as a fraction of Vcc
with Vcc being the max, allowing the highest possible divider voltages.

There's some difficulty here because a low battery, 2.5V/cell is 0.6 the
voltage of a full battery: 4.2V/cell. 0.6Vcc is also the maximum trigger level
for a pin change interrupt, which indicates a click and puts the light into
sleep. In reality the trigger level should be below this, but by spec it can be
this high. So we need the divider voltage to really stay as high as possible.
Furhtermore Vcc is reduced from the LDO voltage by the diode voltage. This
fluctuates slightly with temperature and current, so we need to estimate this
max voltage as well as possible. From the diode spec sheet a maximum diode
voltage of about 0.4V at 2 to 4mA is seen, but more typical is 0.35V and this
should be correct within 0.1V even when hot.

Parts:
Using a TA generation 1 (v1) LDO board, a diode must be added, the same one as
for the 1S configuration above. The diode can be added in place of the R7
0-ohm resistor. The same caps are used as for the 1S OTSM version.

The only other difference is the correct resistor values should be chosen. We
want a total resistance R2+R1= about 4kOhms. We need the voltage on pin 7 to be
equal to the LDO voltage minus the diode voltage, ie Vcc, when the batteries
are at max voltage, Vbm.

So the divider should be R2/(R1+R2) = Vcc/Vbm.
Following the TA build specs and the diode used here, Vcc is 5.0-0.35 = 4.65V

This gives R2 = Vcc/Vbm *4kOhm.
And R1 = 4kOhm-R2

here is the calculated table for various voltage levels:
R1 R2 Vcc/Vbm ideal:
2S: 1786 2214 0.5536
3S: 2524 1476 0.3690
4s: 2892 1107 0.2768

Of course these resistors don't exist, so we need to look for something close,
with the ratio being the most important thing.

R1 R2 Divider Error %
2S: 1780 2210 0.06
3S: 2250 1500 0.36
4S: 2870 1100 0.1

These should be in 1% tolerance or better. Any inaccuracy here pushes the
measureable voltage range up against the spec limits.

:+1:

So, please humor me… It looks to me like a normal AT25 driver such as the X6 driver could be converted to OTSM if the OTC was removed? Or am I making this way to simple?

You mean attiny25? I'd have to consider case by case, (lots of the details are explained in the manual). But generally it should be possible to convert one, so long as there's a place to put a diode between the voltage divider and the mcu input bypass cap and so long as the input bypass cap is at least an 0603 footprint (there may always be ways to squeeze past these rules with enough hacking/squeezing).

No, just removing OTC isn't enough. You need to follow the full parts selection above for diode, mcu bypass cap ("C2"), and divider resistors. I should make it more clear but the diode and cap for the LDO lights are the same as for the 1S. I also forgot to point out that the anode of the diode (+) should point away from C2, but I guess that's obvious. I'll add a picture shortly. You can surely find other components than the ones I found that will work. I've gotten tests working with very different resistor combinations too (for 1S, LDO has pretty strict requirements there), but not just anything will work, and you can be pretty sure the original parts won't work. The ones I list are what I know works. They probably aren't the cheapest, but figuring out how best to cut corners wasn't my goal.

I still need to stop and remember the issues with lighted tailcaps, if there are any issues.

Oh at the moment I don't know any way to make this work on a zener driver, not without replacing the zener with an ldo at least. The LDO is needed for the LVP voltage reference.

I’ve been trying to plow through all this information. It’s been a struggle but I know that if I keep at it I’ll eventually get it:)

It would be great if someone could write do a write up of the process. Kind of like comfrchair did here. That’s the thread that really got me going. Basically go through an example build and take photos/screen shots along the way. This is asking a lot though. And most who are capable of this have already done so much. It would be helpful though…

Thanks for all your efforts!!!

Hi lightbringer. Let me know what you're trying to do and I'll walk you through it. I will try to add picture of TA's boards to explain which things to change. Using a specific example, it's very simple. the instructions above are such examples, and apply directly to his boards. Just change C2, R1, R2, and the diode (and the OTC, well the lack of it) exactly according to what's said there. That's it. And flash the 1S hex for 1S or the LDO hex for regulated mcu input.

If you're trying to get a different driver board working or there's something you don't get there, just let me know. I added a bunch of background to the instructions so that people can extrapolate to new scenarios, but if you just follow the component list for the basic TA boards, you should be fine.

I'm pretty interested in getting something working on your dual switch Supfire A2, but that stuff is much more experimental right now.

@mattlward, I almost forgot, it's also highly recommended to change out the mcu to a V version, either attiny25 or attiny45. See post 69 above.

Ok. I haven’t actually started something yet as I’ve not been confident enough. It’s good to know there will be help available for when I jump in:)

Supfire A2 dual switch? The a2 is single e-switch…

Oh I guess I got confused on the supfire. Well I like it anyway, and eswitch bistro still looks good for it to me.

yeah. I can't promise tons of time, but what you're asking is easy. Really there's nothing harder about this than building the normal TA setup. It's just a different component list. That's all, and while maybe I didn't write list clearly, those components are known now, so just have to buy the right ones and solder them on the right place. That's it. So sure, I can help with that, and any bugs that show up I hope, although in the basic OTSM build, I'm not seeing any.

I updated the LDO post (post 72) with a short version, hopefully it makes it a little more clear.

Awesome, awesome, awesome!

In VIII OTSM of the manual you say,

"The spec for OTSM also requires V version (10Mhz, low voltage version) chips. You might get by without it, but it won't work as well and may cause corruption."

I guess I need new chips . All the 25's I have from MTN are the 20SSU "high voltage" variations.

RH you can try it. I'd recommend reducing the divider resistors to 500ohm total or adding a 500ohm bleeder, and don't cut corners on the cap. To be honest, I suspect you'll get by with it. At worst, you might have trouble getting medium presses when your battery is at 2.9V.

There is the potential corruption issue. Mike C says with the chips running extended times at low voltage he can verify EEPROM corruption. For awhile this bothered me, and I've seen some comments of lights misbehaving that do smell like corruption, but I can't actually see how eeprom corruption breaks the light. That's just configuration values, things like is memory enabled or not. The main menu should operate regardless of what the eeprom state is, and you should be able to get to reset, but I'm not 100% sure that some corner case can't break something. And is it possible to corrupt program memory? Again, I'm not sure. I have seen the non-V chips just occasionally do strange things when in very low voltage, with improper BOD setting, like lock up in a high current state, and so you may just get that the clicks occasionally don't work.

The specs documented are safe, but I'm sure over time people will figure out what they can get by with.

By the way, there's presently a known bug where turbo tap up doesn't work in the biscotti-HD build. Will be fixed in next version. Those features will move out of the untested category.

I have a draft of options for all 2-switch combinations including LEXEL's dumb click switch (his option 2). Some testing to do. Nothing posted yet, plans for next release are in OP.

**

**

Posted version 1.3.

Version 1.3 (there was no 1.2) adds new thermal control, dual switch operational modes, and latest TA modegroups.

http://s000.tinyupload.com/?file_id=42489563655022665614 (link is external)

Detailed changes:

-TURBO_TIMEOUT tap-up didn't work, probably fixed (not 100% tested).

-ESWITCH menu lockout didn't work, maybe fixed it, took a stab at it anyway, but no testing. Never was sure I liked it anyway.

-New TA v1.3 modegroups are included. I've also added 1 old mode from original and one hybrid of my own. The modegroup file for details, the extra modes are not well documented yet.

-OTSM_powersave which is not only for OTSM, is now available to save power on attiny13's too now (4mA to 2mA for on-current if similar to attiny25).

-New temperature step-down option, like BLFA6 turbo timeout and tap up, except the drop down is temperature-triggered. A minimum (not max) time in turbo is set to 10s by default.

-Both the minimum time and the level to step down to are configurable. All levels above that will get thermal protection (except strobes, in bistro way, reading temp is too slow to work with strobes).

More space savings, about 50 bytes, but this was mostly re-used by the new thermal stepdown and added modes.

-Trying to clean up cap-timing section and comments, adding clear preprocessor sections for every possible switch and timing combination.

1-switch: no_init, OTC, OTSM

2-switch: Eswitch + nothing, no_init, OTC, OTSM, or lexel mode.

-Dual switch noinit has a better chance of working correctly now (no eswitch or dual switch lights have been fully tested).

-Dual switch OTSM is discontinued for now.

-Dual switch dumbclick option/build is added. by request of Lexel, the power switch does nothing. It comes back on in the same mode it went off.

- Dual switch turboclick option/build is added. Variation of lexel request (that I like), power switch always comes on in first hidden mode (typically turbo).

Ideas for farther ahead:

Try shortening medium click in OTSM, may require adding finer timing resolution for all times, or possibly just early times. (has a cap performance cost, but it's performing better than needed now).

Maybe rework dual switch stuff so every click type can be given assigned an action type in the configs. Hard to keep the programming tight, and clean, but avoids endless options, I don't have a full vision for how to implement it yet, many details.

In particular considering reverse click order for power switch, maybe separately from above plan.

Here are the present build sizes, not updated in the manual:

text data bss dec hex filename
704 0 41 745 2e9 .\bin\battcheck-4channel-dual-switch-HD-attiny25.elf
712 0 41 753 2f1 .\bin\battcheck-4channel-dual-switch-HD-attiny45.elf
712 0 41 753 2f1 .\bin\battcheck-4channel-dual-switch-HD-attiny85.elf
356 0 29 385 181 .\bin\battcheck-biscotti-HD-attiny13.elf
372 0 29 401 191 .\bin\battcheck-biscotti-HD-attiny25.elf
376 0 29 405 195 .\bin\battcheck-biscotti-HD-attiny45.elf
376 0 29 405 195 .\bin\battcheck-biscotti-HD-attiny85.elf
396 0 33 429 1ad .\bin\battcheck-BLFA6_EMU-HD-attiny13.elf
410 0 33 443 1bb .\bin\battcheck-BLFA6_EMU-HD-attiny25.elf
414 0 33 447 1bf .\bin\battcheck-BLFA6_EMU-HD-attiny45.elf
414 0 33 447 1bf .\bin\battcheck-BLFA6_EMU-HD-attiny85.elf
542 0 35 577 241 .\bin\battcheck-classic-HD-attiny25.elf
546 0 35 581 245 .\bin\battcheck-classic-HD-attiny45.elf
546 0 35 581 245 .\bin\battcheck-classic-HD-attiny85.elf
526 0 39 565 235 .\bin\battcheck-custom-HD-attiny25.elf
530 0 39 569 239 .\bin\battcheck-custom-HD-attiny45.elf
530 0 39 569 239 .\bin\battcheck-custom-HD-attiny85.elf
530 0 41 571 23b .\bin\battcheck-default-HD-attiny25.elf
534 0 41 575 23f .\bin\battcheck-default-HD-attiny45.elf
534 0 41 575 23f .\bin\battcheck-default-HD-attiny85.elf
688 0 41 729 2d9 .\bin\battcheck-dual-switch-dumbclick-TA-HD-attiny25.elf
696 0 41 737 2e1 .\bin\battcheck-dual-switch-dumbclick-TA-HD-attiny45.elf
696 0 41 737 2e1 .\bin\battcheck-dual-switch-dumbclick-TA-HD-attiny85.elf
640 0 34 674 2a2 .\bin\battcheck-dual-switch-noinit-TA-HD-attiny25.elf
648 0 34 682 2aa .\bin\battcheck-dual-switch-noinit-TA-HD-attiny45.elf
648 0 34 682 2aa .\bin\battcheck-dual-switch-noinit-TA-HD-attiny85.elf
660 0 41 701 2bd .\bin\battcheck-dual-switch-turboclick-TA-HD-attiny25.elf
668 0 41 709 2c5 .\bin\battcheck-dual-switch-turboclick-TA-HD-attiny45.elf
668 0 41 709 2c5 .\bin\battcheck-dual-switch-turboclick-TA-HD-attiny85.elf
512 0 40 552 228 .\bin\battcheck-TAv1-OTC-HD-attiny25.elf
516 0 40 556 22c .\bin\battcheck-TAv1-OTC-HD-attiny45.elf
516 0 40 556 22c .\bin\battcheck-TAv1-OTC-HD-attiny85.elf
588 0 41 629 275 .\bin\battcheck-TAv1-OTSM-HD-attiny25.elf
596 0 41 637 27d .\bin\battcheck-TAv1-OTSM-HD-attiny45.elf
596 0 41 637 27d .\bin\battcheck-TAv1-OTSM-HD-attiny85.elf
576 0 40 616 268 .\bin\battcheck-TAv1-OTSM-LDO-HD-attiny25.elf
584 0 40 624 270 .\bin\battcheck-TAv1-OTSM-LDO-HD-attiny45.elf
584 0 40 624 270 .\bin\battcheck-TAv1-OTSM-LDO-HD-attiny85.elf
568 0 34 602 25a .\bin\battcheck-trippledown-HD-attiny25.elf
572 0 34 606 25e .\bin\battcheck-trippledown-HD-attiny45.elf
572 0 34 606 25e .\bin\battcheck-trippledown-HD-attiny85.elf
1926 0 42 1968 7b0 .\bin\bistro-4channel-dual-switch-HD-attiny25.elf
1934 0 42 1976 7b8 .\bin\bistro-4channel-dual-switch-HD-attiny45.elf
1934 0 42 1976 7b8 .\bin\bistro-4channel-dual-switch-HD-attiny85.elf
1022 0 29 1051 41b .\bin\bistro-biscotti-HD-attiny13.elf
1112 0 32 1144 478 .\bin\bistro-biscotti-HD-attiny25.elf
1116 0 32 1148 47c .\bin\bistro-biscotti-HD-attiny45.elf
1116 0 32 1148 47c .\bin\bistro-biscotti-HD-attiny85.elf
1078 0 33 1111 457 .\bin\bistro-BLFA6_EMU-HD-attiny13.elf
1216 0 34 1250 4e2 .\bin\bistro-BLFA6_EMU-HD-attiny25.elf
1220 0 34 1254 4e6 .\bin\bistro-BLFA6_EMU-HD-attiny45.elf
1220 0 34 1254 4e6 .\bin\bistro-BLFA6_EMU-HD-attiny85.elf
1670 0 36 1706 6aa .\bin\bistro-classic-HD-attiny25.elf
1674 0 36 1710 6ae .\bin\bistro-classic-HD-attiny45.elf
1674 0 36 1710 6ae .\bin\bistro-classic-HD-attiny85.elf
1744 0 40 1784 6f8 .\bin\bistro-custom-HD-attiny25.elf
1748 0 40 1788 6fc .\bin\bistro-custom-HD-attiny45.elf
1748 0 40 1788 6fc .\bin\bistro-custom-HD-attiny85.elf
1750 0 41 1791 6ff .\bin\bistro-default-HD-attiny25.elf
1754 0 41 1795 703 .\bin\bistro-default-HD-attiny45.elf
1754 0 41 1795 703 .\bin\bistro-default-HD-attiny85.elf
1940 0 41 1981 7bd .\bin\bistro-dual-switch-dumbclick-TA-HD-attiny25.elf
1948 0 41 1989 7c5 .\bin\bistro-dual-switch-dumbclick-TA-HD-attiny45.elf
1948 0 41 1989 7c5 .\bin\bistro-dual-switch-dumbclick-TA-HD-attiny85.elf
1688 0 35 1723 6bb .\bin\bistro-dual-switch-noinit-TA-HD-attiny25.elf
1696 0 35 1731 6c3 .\bin\bistro-dual-switch-noinit-TA-HD-attiny45.elf
1696 0 35 1731 6c3 .\bin\bistro-dual-switch-noinit-TA-HD-attiny85.elf
1912 0 41 1953 7a1 .\bin\bistro-dual-switch-turboclick-TA-HD-attiny25.elf
1920 0 41 1961 7a9 .\bin\bistro-dual-switch-turboclick-TA-HD-attiny45.elf
1920 0 41 1961 7a9 .\bin\bistro-dual-switch-turboclick-TA-HD-attiny85.elf
1724 0 40 1764 6e4 .\bin\bistro-TAv1-OTC-HD-attiny25.elf
1728 0 40 1768 6e8 .\bin\bistro-TAv1-OTC-HD-attiny45.elf
1728 0 40 1768 6e8 .\bin\bistro-TAv1-OTC-HD-attiny85.elf
1812 0 41 1853 73d .\bin\bistro-TAv1-OTSM-HD-attiny25.elf
1820 0 41 1861 745 .\bin\bistro-TAv1-OTSM-HD-attiny45.elf
1820 0 41 1861 745 .\bin\bistro-TAv1-OTSM-HD-attiny85.elf
1792 0 40 1832 728 .\bin\bistro-TAv1-OTSM-LDO-HD-attiny25.elf
1800 0 40 1840 730 .\bin\bistro-TAv1-OTSM-LDO-HD-attiny45.elf
1800 0 40 1840 730 .\bin\bistro-TAv1-OTSM-LDO-HD-attiny85.elf
1658 0 35 1693 69d .\bin\bistro-trippledown-HD-attiny25.elf
1662 0 35 1697 6a1 .\bin\bistro-trippledown-HD-attiny45.elf
1662 0 35 1697 6a1 .\bin\bistro-trippledown-HD-attiny85.elf

I still forgot to remove BLFA6_EMU-attin13. It is too big for an attiny13 and should not be used.

Minor updated posted (see OP) to 1.3-r2. The code is not changed. Just added a one-click bat file buildall-AS.bat. If Atmel Studio 7.0 is installed in the default directory then double clicking that file from the windows file explorer will re-compile all hex files, which can then be found in the hex/ subdirectory. Editing the file : Makefile in any text editor you can find the ONEBUILD option, remove the # comment sign and define a single configuration to compile instead of making them all.

This is intended to allow compiling with the Atemel Studio 7.0 "toolchain" but without needing to actually import the project into Atmel Studio. You can still edit files with Atmel Studio, or with any other editor (Notepad, Notepad++, or whatever).

The one downside is build errors are not presently parsed. You'll be able to see them in the output window though, possibly requiring scrolling up.

When I compile this in Atmel Studio, I get a different (slightly larger) filesize from the pre-compiled .hex. Compiling in WinAVR gives yet another (even larger) filesize. Any idea what I might be doing wrong? Or does it even make a difference?