Attiny25/45/85 FW Development Thread

Latest Narsil version, 1.1 is now posted up on my google drive share, here: https://drive.google.com 254585Support.

Improvements/Changes:

  • re-wrote LVP handling to fix a couple bugs and handle ramping-moon mode properly
  • blink 8 times when shutting off the level by dropping below the critical level, 2.6v now (was 2.7v)
  • changed timing of LVP check to every 4 secs, not 3 secs, added a 1/4 sec delay after the drop
  • in ramping, Add Dbl-click in Battery Check: blink out version # of firmware
  • in ramping, Add Dbl-click on max to enter strobe modes

Hi, do I need an input capacitor for the Attiny? I dropped the output capacitor and the off-time capacitor already.
Driver output is around 3A max with a single li-ion

Does anyone know?

Not sure what you mean by input capacitor, don't know what exact attiny you are using, or what driver you are referring to - we got dozens.

Never heard the terms "input capacitor" or "output capacitor" used before.

C1, as far as we know, is required. It's connected between Batt- and Batt+. The OTC cap is for clicky switch drivers, and is not needed for e-switch drivers, and doesn't have to be used even for clicky switch drivers.

Not sure which specific driver you are referring to, or which capacitors (there are no ‘input’ / ‘output’ capacitors on these drivers).

Most sub-circuits need a decoupling capacitor, which is simply a kind of near-and-ready voltage source. The MCU should have one, located very close to it. On most drivers this is C1. On many drivers C1 is separated from the MCU by D1. In that case you should add a second capacitor C2 very close to the MCU.

On most drivers C1 is also decoupling the FET/emitter, making it almost useless (actually detrimental) for the MCU. Enter the added low-value resistor R5 to isolate the FET/emitter from C1 and the MCU. (A ferrite bead would actually be a more more appropriate part to use here, but can add complications if not selected correctly). For our purposes you can easily get away without C2 when you have this resistor.

As I'm new here, I'm not sure if I should have stuck this:

https://budgetlightforum.com/t/-/41582

in here instead of making the new thread.

I'm going to suggest discussion there, not here, and just place this post in case it interests people who frequent here, especially since I don't want to interrupt the discussion here of people who know what they are doing. If mods or others think it should merge, that's fine too.

Thank you for the replies! I think now I understand it a little better.

So it is not possible to use the driver like that:

and I should add a capacitor between GND and the VCC pin at the Attiny, right?

At the minimum. That is what the Nanjg 105 drivers look like.

R5 is less important when it is not a FET driver. But I would still put C1 upstream of D1 and add R5.

Has your opinion on C2 changed or is it still worth the board space if R5 is in place?

There really should be a C directly across pins 4 and 8. But we have been getting away with much, much worse before. I would not bother on the 17 mm boards. Stuff like the ADC will see more noise, but I am pretty confident the driver will be stable with R5 in place. On the larger boards by all means put C2.

I have some 0603 ferrite beads on the way. The idea is to try these in the R5 position. Low DC impedance, but 100s of ohms in the MHz range. This should lower the current pulses going through R5-C1 during PWM. C1 can then be relocated to the C2 position, without stressing D1. I still prefer C1 ahead of D1 though, for the sake of more accurate voltage monitoring - no D1 drop to account for (R1/R2 should always tie to C1).

I have a rev01 of one these running and it looks good enough:

No C2, or R4 (or OTC!). Rev02 increases the vias size and shifts the 7135 to get more clearance for the programming clip. Rev02 is untested and may get further revised once I try 0603 parts on rev01 (currently using all 0805).

EDIT: OSHPark link updated to revision 02 - Small change to facilitate stacking a C2 on/beside C1/D1.

Ohhhh - DEL, I like that board! Pin #2 and #3 pads and a big spring pad - nice!! K, so no C2, no R4 -- cool! Are the MCU pins 13A size? Gotta get some 0603 parts though, for sure.

Hi Tom, yes that is an SS package size. So unfortunately 85s will still need some pin-bending to fit.

I also have 20 mm and 22 mm versions. These have all the components and full size MCU pads. But I need to rework them a little first with what I saw on the 17 mm version.

Edit: The board is intended for 0603 parts, but 0805s will fit as well.

Be sure to post if you come up with a better component layout/list. I might be making some changes to the TA drivers anyways if we are able to eliminate R1/R2 and I could update the other changes at the same time.

So far the 17mm boards with C2 in place seem to be working very well. Although if space is an issue for some reason I suppose you could just not install C2, so not sure I would remove it even on the 17mm. The only thing I would really gain is a slightly larger pass through and a tiny bit more space in the center of the board to spread things.

I think I figured out internal Vcc measurement (so we can remove R1/R2).

Its all in 17.13.1 (page 134) of the datasheet.

The only required ADC-configuration change is to set the ADMUX register to use Vcc as reference voltage. (Note this configuration will give a 10-bit result, to be read from the ADC register.):

ADMUX = b00001100;

If we want to read internal temperature, ADMUX need to be set back to read ADC4 with Vbg as reference:

ADMUX = b10001111;

…and we then alternate between the two configurations with a small time delay after each change. Possibly we also need to read the ADC twice each time, to get more accurate results.

To figure out the ADC result for Vcc:

adc_result = ADC;    //16-bit integer

where adc_result = (Vbg / Vcc) * 1024;
= Vbg / (Vbat - D1) * 1024;

where Vbg = 1.1 V
and D1 = drop over Schottky = ~0.25 V

So adc_result = 1.1 * 1024 / (Vbat - 0.25)

The typical lookup table we use will look like this for Vbat:

4.2 V = 285
4.1 V = 293
.
.
.
2.5 V = 501

Note lower Vbat gives higher results (Vbg becomes larger as a percentage of Vcc). This would also be an opportunity to finally upgrade to 10-bit ADC operation.

DEL, has anybody told you lately that we really appreciate you here? Thanks for working on this stuff for us. :smiley:

With all these driver improvements going on, as well as Tom E and ToyKeeper kicking out newer and better firmware so often, it’s a good time to be a BLFer!

DEL - does this match what Halo... posted in post #731: https://budgetlightforum.com/t/-/34900/731 ?

DEL - is very much appreciated!!

Very exciting. Once we get this into common firmwares I can drop two 0805 components off my boards (so it will be much easier to fit on the little ones, like the glorious X2R) and we get an extra pin available, so triple channel + indicator LED for NARSIL, or maybe some dual-eswitch lights if the host fits, or who knows what else

Just a reminder: internal Vcc measurement doesn’t work with zenermods.

Ouch! Didn't realize that, makes sense, and am sure was mentioned, and forgotten by me . Can we assume same for LDO, because it's doing the same thing, regulating the voltage coming in to the MCU?

Could we take a voltage reading on the same pin but compare it to the internal reference? Or is it still limited to ~6v max no matter the input pin?