Attiny25/45/85 FW Development Thread

According to specs the mcu can be set into power down mode with the watchdog still running, and the watchdog could restart the mcu with an interrupt. This should enable us to wake up the mcu e. g. each 250 ms and check if power is still down. In my momentary firmware I am doing most things according to momentary presses of <250, <500, <1000 ms duration. If the power consumption of mcu with running watchdog oscillator is sufficiently low, this might also work in clickie drivers.

The hardest part is figuring out the power was cut. Then it’s indeed just a few cycles to turn off everything and enter “sleep with watchdog timer” state.

If you depend on the ADC read the power level, it’ll be about 0.2 ms (going from memory here, ~75 kHz ADC with about 12 cycles per conversion). That might be good enough but I’m not sure. You would definitely need to setup an ADC interrupt to check the reading as soon as it is ready. If it’s not fast enough, I believe the ADC can be run faster, with a loss of precision. This would be a good idea when checking for power from the watchdog interrupt, where precision is not important but getting a result quickly is.

The analog comparator or a digital input could do it faster but they have their own problems.

I was thinking more along the lines of a digital input, either the pin has voltage or it doesn’t (I guess it could be connected to ground as well).

What issues are there with using the input power signal as a simple on/of switch? There is no need to monitor the pin beyond that, that I can think of anyways.

A interrupt triggered by falling edge or low state should be the best solution.

0.2ms is about what I hoped for. I think it's good enough.

So if I is .005A and 5 wakes (including first) is .001s that's 5uAs of charge. Divided by 10 uF of capacitance is 0.5V drop. You can get MUCH bigger capacitors than that, in 0805 for sure, not sure about 0603.

Basically, I think this has almost been there all along. "Just" needs to be programmed.

It looks like it was .025ma that TomE got it down to in off mode, not sure if it can go lower for our purposes or not:

If an 0805 cap would handle it then the TA drivers might actually be able to do this now. The 0603 pads that are for C2 at the moment can easily handle 0805 components.

Tolerance is not as important in this case as total capacitance since we simply want to keep the MCU active and don’t care at what voltage that happens.

That’s similar to my measurements, but without running watchdog.

Does anybody know how much current FET and 7135 are pulling from the mcu?

Not exactly but some other stuff I was doing today suggested it is somewhere between .1-.3ma

That’s a complicated question. Fully on, it should be essentially nothing for the FET (nanoamps). Throw in PWM though and it’s a larger value because you’re constantly recharging that FET gate. I would eyeball it in the 0.1 to 1 mA range from past experiments. You could compute something better from the FET gate charge and PWM frequency but that’s outside my domain. I expect the 7135 to be in the same range.

Well, you need a pin. So some minor driver changes there. But most importantly you’re not supposed to exceed Vcc+0.5V on any of the pins so you’ll need a voltage divider for 2S or more setups. With a 1S light, the diode drop is low enough to avoid it but you’ll probably want DEL’s new circuit with the resistor to limit input current so the voltage spikes from the PWM don’t end up on your sensing pin.

Otherwise, I think it’s definitely the best setup as far as reaction time and programming simplicity are concerned.

The voltage divider is needed for 2s setups anyways for the LVP. We could just split it off into 2 pins if using the same pin is not practical. So no new parts, just a different way of routing them it sounds like.

Thanks. I’ve already built a simple test circuit on breadboard, currently fiddling about firmware …

Just to be clear, and I think you knew this, the math I was doing in the post previous to that was for the on-time, during wakes. So yeah, for 0805, I've found 220uF and I think 330uF caps in low voltage, 6.3V, but even the 10uF is looking like it can probably handle it.

I'd be surprised if it needs to be simply split. Might need a different divider though if using some threshold trigger instead of ADC. Could set it up for 2.56V for though if needed for a 2S light. For 1S you can do whatever you need to.

Be sure to connect the power leads to the lightening rods, and let us know.

Not quite, it’s a different range. < 1.1V for the ADC and > 2 to 2.5V for the digital input so probably one extra resistor. Could use the 2.56V reference for the ADC on an attiny25 but the doc says it needs a 3V supply so it wouldn’t work well over the whole range for a 1S setup.

So it seems possible to do it for 1S (read voltage from Vcc, use divider for on/off input) or more (use 2.56V ref to read Vcc) but not both at once. At least I don’t see how without some reconfiguration of the firmware / driver.

Exactly how I read it. Anyway, there's a solution in both cases. It's not a big firmware change either I think. Litterally just need to flip a bit in the right places. It does mean distributing twice the hex files though, probably setting up some precompiler logic and a build script to make them both, so a little more mess.

If needed the firmware could be split into 1s and 2s setups with the 1.1v reference for the 1S and 2.56v for the 2s. The parts list is already slightly different for 2s anyways. Or better yet, simply make the options selectable via defines to easily select which setup you are using in bistro.

Of course could also stick with the ADC solution instead. It kind of seems like while the ADC is slow, it might be fast enough.

Created code and got some positive results meanwhile. More tomorrow, need some sleep now.