# Computing stuff tied to the physical world

## Mechanical relays

In Hardware on Oct 13, 2012 at 00:01

Hm… with such a nice switching 5V pulse, it’s sad to tear down yesterday’s circuit again.

One more experiment then. Let’s switch a little relay (the one used in the Relay Plug) at 10 Hz, and give it a serious beating. I’m going to put my dual power supply to work and put 5V @ 3A straight across the relay’s contacts. In other words, let’s see what happens when we switch the full 3A across those tiny relay contacts.

At first sight, it all looks reasonably ok:

That’s 5V across the relay while it’s open, and about 0.3V when it closes. So these contacts seem to have a resistance of about 0.1 Ω. The overshoot when the relay opens up again is probably in the power supply, as it recovers from just having been shorted out at 3A. Note that any inductance in the wiring will have this same effect. Inductance is a bit like a flywheel – it wants to keep going after such massive current (i.e. magnetic field) changes.

It’s quite impressive to see how this little relay rattles away at ≈ 10 Hz, working just fine.

But those transitions look quite different when we zoom in:

You’re seeing a mix of arcing and contact bounce, as all mechanical switches do.

Note that the switch hasn’t quite closed yet – there is still about 1.5V between the contact points, 30 µs after switching – due to contact bounce. This drops to 0.3V after some 400 µs, at which point the contacts are really firmly closed.

Here’s a much better example, this time using a 10 Ω resistor in series so the power supply just delivers 5V @ 0.5A without going into current-limiting mode:

Opening is again not quite what it seems, once you zoom in:

Two things happening here: the mechanical release of the switch (less resistance as the pressure on the contact decreases, followed by some arcing), and then a fairly linear ramp and some overshoot as the power supply recovers its 5V setting after having been shorted out. Think of a stretched rubber band, and how it “overreacts” when released.

So as you can see, a relay does some nasty things while switching on and off!

1. I do like my 5 volt switching relays. Dont forget those latching 5 volt relays. I use those to build low voltage disconnects for low power 12 volt things – which use a simple voltage divider to get 12 volts from a lead acid battery down to micocontroller voltage.

The one thing I make sure to do with the voltage divider is to make sure it can handle much higher voltages than 12 volts. Lead acid batteries charge at 13.8+ volts – with some crappy chargers putting out as much as 18 volts. My reccomendadtion – plan for 24 volts worst case scenario – and so you dont burn that analog pin.

Add a sleep mode… you know that better than I mr. Jee. Check the battery voltage – and when it gets below 11.2 volts (whatever that would be in terms of an analog voltage from the voltage divider) ( also I dont like to abuse my batteries – sometimes I set it as high as 11.5 and even 11.8)

Maybe you should be considering a solar charging solution. Heck, if you could interface a jeenode attached to a solar charge controller plug (you figure that out- Im not even sure if there are enough pins) attach the plug to solar panels/batteries. Now use the jee link attached to a computer to monitor the system. Heck, write a program for the computer that would use battery capacity and voltage to estimate how mouch energy is being harvested/used and the money saved. Heck, make it an android app (or Iphone) that talks to the computer and lets you monitor the system/ change variables like the low voltage disconnect voltage.

I do like to dream these things up from time to time.

2. I must say, that blog is a complete eyeopener. Should I ever give a lecture on relays and switches, this would be reference material. A clever setup, a few good scopeshot’s and bang, you just learnt a lot.