But for future reference for circuits that don't use the ATTiny85, can we possibly come to any agreement on how the inductive spike of a single-coil latching relay should be dealt with?
Back-to-back zeners is a very appealing solution, provided they would respond rapidly enough, which I think is not obvious.
Even an H-bridge is going to produce these spikes. As far as I can tell, the spike is transferred to the supply rails through the body diodes of two of the mosfets (the ones that didn't just turn off). You would be raising both Vcc and ground. Does that cause any problems?
If not, then maybe just install external diodes that parallel the protection diodes in the 85 - from ground to each pin, and from each pin to Vcc. And maybe use shottky diodes to protect the protection diodes.
What else? Somebody mentioned TVS. What about inserting series capacitors into the lines. Would that eliminate the spikes because the current trails off automatically?
It seems there should be a school-approved solution for this. Or maybe people who know what they're doing just always use a two-coil relay.
Does anyone have a single-coil latching relay and a scope?
I think we all have been assuming that the relay coil terminals connect directly across the coil but that may not be true with this relay. This is a latching relay that requires polarity reversal to trigger the two states, so who knows what kind of electronics might be is inside.
Maybe it's actually a two coil relay with some diodes/transistors inside that steers the current to the appropriate coil.
The datasheet of the ATtiny24/44/84 shows it does have diodes on the I/O pins. Possibly they can withstand the same current as it's MOSFETs. (Datasheets of some other ATMEL microcontrollers specify 1mA.)
The proposed 8V TVS won't activate as long as these diodes are working.
If needed, the simplest protection is using 4 (schottky) diodes or (mis)using a rectifier bridge, made for at least the expected coil current.
The latching mechanism is most likely magnetic. The producer tested his product for the minimum pulse length, measurements came back with values between 1.5 and 3ms (if I read the datasheet right). I can't decipher a maximum pulse length, but if you intend to keep it activated you wouldn't need a latching type.
Am I reading correctly that the horizontal scale is set to 2ms per division? If so, I suspect you might see higher spikes at faster settings. But they would still be clipped by the protection diodes.
I wonder what current into or out of the GPIO pin would look like.
Yeah; stick a 1ohm resistor (or similar) between the IO pin and the relay, and use the scope to measure the voltage across that (simultaneously, if your scope has two channels.)
Or if you have a battery powered scope, which is not referenced to ground, you can measure directly across the resistor with a single probe. But you want to see both positive and negative currents.
This was the worst spike I managed to capture β not all pulses were this extreme. Many fell within the ATtiny84βs Β±40 mA limits, but occasionally this larger spike would appear.
I'm now waiting for a Littelfuse SA8.0CA bidirectional TVS diode to clamp these spikes. I'll post updated results once installed.