There are small relays which are just weak enough to be switched directly by the ATmega’s I/O pins, even at 3.3V. I’ve been chasing and trying out these types of relays for some time, especially the latching types which only require power to switch, not to stay on.
Today, I received a very nice surprise package from @eljonco, who sent me a nice little latching relay (from eBay) which I’ve immediately mounted on a Proto Board:
Bottom side connects DIO2 + AIO2 to one side of the coil, and DIO3 + AIO3 to the other:
Why both? Because one pin drive is not strong enough to make these units switch at 3.3V:
…whereas driving them both in parallel works, resulting in a clear clicking sound and a very nasty “inductive kick-back” switching pulse across the coil on power-off:
There are horrific things going on here, electrically speaking, which I’ll look into later.
For now, let me just explain what’s going on and how this single-coil latching relay is being switched, using four I/O pins (port 2 and 3 on a JeeNode in this case):
The relay core can be switched with a brief pulse, reversing the polarity to reverse the action. So we connect it to two different I/O pins and drive it as an H-bridge. When both pin levels are the same (or when the I/O pins are floating), nothing happens. By putting one pair in “0″ state and the other in “1″ state, current flows through the coil.
So to turn the relay on, the actions are:
- set DIO2 = AIO2 = 0
- set DIO3 = AIO3 = 1
- wait 3 ms
- set DIO3 = AIO3 = 0 (same as DIO2 and AIO3), or make them float, i.e. inputs
To turn it off, we simply exchange the 0′s and 1′s in the above.
More on this tomorrow. Stay tuned…