Attiny25/45/85 FW Development Thread

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.

If the ADC could be sped up some then that would help, while the light is on extra MCU usage to monitor that is not really an issue. Then when it turns off it will slow it down to save power.

Sounds good! This would be a great item to finish. If we did this without needing to use the OTC pin that would be even better as it would free up a pin for other uses (indicator LED anyone? Quad channels?)

Good to know there are options, if it could reliably power the MCU for say ~3-5 seconds even when warm I think that would be more then enough for any programming options we could come up with later.

You're not going to get 5mA for 5 seconds if that's what you mean by warm, That's 25mF for 1V. But you can get the periodic wakes for a few ms total, possibly quite a bit more with the big caps.

No, I was talking about a total of 3-5 seconds of the MCU being powered to detect the click (only checking every X cycles).

The when warm was referring to the capacitance dropping significantly when ceramic caps get hot.

I really don't see the big deal about heat even for a capacitor clock. An x7r changes by at most 15% from -55C to 125C. For this new trick, 15% is just 15% less time. For a capacitor clock it's bigger, only if you go out into a couple of RC-folds or more in time, which probably shouldn't be happening (but maybe is). I'd almost wonder more if the leakage through the mcu is what is causing temperature dependence. Solid state junctions seem to have much larger temperature variations than caps do. One of several potential instabilities that had me thinking about controlling the resistance better. But this new plan is better yet.

Success!
Test setup (breadboard, single cell):

  • Attiny25 at 10 Mhz (lower clock frequency might allow even better results).
  • No cap before polarity protection diode (C1), 47 uF behind (C2). Polarity protection diode is simple 1N4148, don’t have schottky.
  • No FET and 7135, but single npn transistor with 220 ohm resistor between mcu port and transistor base which means a rather high current from mcu port (simulating worst case with 10 mA draw, should be more than FET + 7135 are pulling). Transistor drives a simple LED with a few milli amperes.
  • Vbatt is connected to an input port in order to recognize switch press.
  • Clickie.
  • I had to put a resistor (10k) between Vbatt and GND, otherwise Vbatt did not fall fast enough for reliable results.

When firmware detects power down at input port it shuts off output and starts a loop with -

- watchdog (timeout 250ms),

- powering down mcu,

- checking Vbatt when watchdog interrupts,

  • incrementing a counter and looping again if power is still down.
    Counter is blinked out afterwards.

I could measure click duration up to 3 seconds with full cell. Check with discharged cell pending.

Some more numbers …
Replaced 1N4148 with schottky diode.

47uF and cell at 4.15V: 4 seconds
47 uF and cell at 2.9V: 1.5 seconds
94 uF and cell at 4.15V: 8 seconds
94 uF and cell at 2.9V: 3 seconds

Very nice. It seems like it should maybe be possible to considerably better and or do it with more capacitance, on the other hand, the programming work isn't that easy and this is already pretty great. I'd say it's beyond proof of principle which a feat for a first test. A 220uF cap should get 6 seconds at 3 volts, which is enough.

Did you use the ADC or some simple trigger? 10k between batt and ground is pretty normal.. well ok there's usually 25k or so. Probably not much difference. I wonder if you can put the cap back with the resistor installed.

Give or take the initial wake, your numbers come out to 22.6 uA average current drain for 47uF and 23.5 for 94, which is probably easily within the precision of the numbers given.

It's maybe better to state that as 5.7 or 5.9 uA*s per wake (not counting the first wake, so give or take that, but actually they were in better agreement without the first wake and for all I know it uses less power than the later ones.)

If you were running at 5mA while awake (I doubt it was much more but I don't really know), that would be a bit more than 1.1ms per wake. So not so fast, but good enough.

This assumes "off" power is essentially irrelevant though. Simulated wake cycles without delay to measure timing could be interesting.

I was looking for caps at mouser and came across those COQ spec’ed 1206 ones, that aren’t that expensive, so it got me thinking if that could maybe help to make the timings more reliable. But I’m far from beeing an expert. I’m using only X7R caps as OTC but I had the feeling that the timing for short, medium and long presses varies much more than 15% with temperature. Hence my question, if a COQ would make any sense… Anyways, I knew that the OTC, as it is implemented in almost all most recent designs, isn’t ideal, I think I remember Sharpie came up with some suggestions and wight also made some changes in the layout of one of his drivers, one of those changes was a pull-down resistor for a beefed up OTC. The idea of keeping the MCU powered with a cap seems to be a good one I guess.

Flashy Mike, your results look quite promising.

But have you guys looked up 100µF caps in adequate sizes? For example, a MLCC 100uF 16V X5R 20% 1210 is about 1,4 $ if you buy 10. That’s quite pricey. Also it’s 1210, that is quite huge. Also it’s only 16V X5R 20%… Not that great. And that thing costs more than the MCU or the MOSFET.

I didn’t use ADC, just digital input. 10k between Vbatt and GND was my first try, I’m pretty sure there are more working alternatives.

To only replace the OTC without more options it’s required to recognize only one second of press duration, 47uF might be sufficient for that.

We should also think of using capacitors in standard casing (if there is space in the host), you can get them with more capacity for little money. I’ve seen commercial drivers where they are used.

It’s important to shut down everything very fast when switch press is recognized. I’m doing the recognition in the delay loop currently by reading digital input, using level change interrupt (if possible)) might be faster and should also interrupt ADC readings.

Accuracy of cap doesn’t matter.

Reducing mcu clock frequency didn’t make a difference, so I guess most of the power is used by the watchdog oscillator and counter.

This topic is goin way too long, but I think I really do like how it's goin. Could someone take a step back and explain the goal? Was this for a power clickie setup? I wanted to do something similar for e-switch's - to wake up periodically to do LVP - shut down the indicator LED when getting low, and do a full shutdown when below critical.

Are you guys using the bleed resistor power to keep the MCU goin, and then periodically doing LVP?

We are using a capacitor behind the schottky diode as energy buffer which powers the mcu for a few seconds when clickie is pressed. To reduce power consumption mcu is set in power down mode and woken up by the watchdog timer at certain intervals to recognize if switch is still pressed or not.

With the watchdog timer you can wake up the mcu from power down mode in intervals of 8 seconds max (with Attiny25). But using watchdog timer will result in more power consumption during power down mode (but probably much less than your indicator LED).

I'm not sure what you mean about standard casings. There are 0805 220uf caps. They cost half a dollar as I recall. 1s may be how it works now, but 2 seems more comfortable and/or yeah, leaves more options.

edit.. oh I think you were responding to the 1206 point. Yeah, no need for 1206 or C0G. That's half the point of this thing, that analog stability isn't an issue anymore.

Ohh, ok. Goal is for a more reliable way to detect length of OFF times in a clickie light, without using a regular OTC which has it's own problems.

Very interested in how it turns out!