MISC
Parts List
Robot Forum
Chat
Member Pages
Axon MCU
Robot Books
Shop
Contact

SKILLS
How To Build
A Robot
Tutorial

Calculators
Mechanics
Programming
Miscellaneous

Robots
Space

HARDWARE
Actuators
Batteries
Electronics
Materials
Microcontrollers
Sensors

SCIENCE
Robot Journals
Robot Theory
Conferences

MERCURY SWITCH TUTORIAL

Mercury Tilt Switch
The mercury switch can be used to detect the tilt of something with respect to gravity. For example, suppose your robot needs to know when it's going up a hill that's too steep (in which case it will flip over), the mercury switch could give a warning to your robot when it reaches a certain angle. Another application I used it for is to count hills while driving around.

A quick video demonstration of the switch:

How to Make a Mercury Switch
The easiest way is to buy a cheap mechanical thermostat and hack out the mercury switch (see below image). Don't get the digital thermostat type because it will probably not have a mercury switch in it.

After taking it out, mount it on a block of wood in whatever way you like. I like to keep part of that long metal strip with it so I can use it as an angle adjuster. On the bottom I attached Velcro so I can put it on various robots real easy.

Notice that the mercury is encased in glass, with wiring going inside the encasing. Typically inside there is either air, an inert gas, or a vacuum.

Wiring
Wire up the mercury switch like you would for any other switch. In the mercury switch there are three wires inside the glass tube, located just like in this below diagram. Connect the top two wires to power and ground (order doesn't matter). Then connect the bottom one, which always keeps contact with the mercury, to the analog input of your circuit or microcontroller:

So when the mercury is tilted on one end, it connects the ADC to +, giving a logic high:

And when tilted the other way, it connects to -, giving a logic low:

There is also a middle state that lasts for a very very short time between the mercury transistion, in which case your ADC will float. If this is a problem, you can always connect it to ground via a 300k resistor - if it's in the transition state it will go to logic low.

Advantage of Mercury Switch vs. Accelerometer
You may be wondering, why use a mercury switch when you can use an accelerometer? The advantage of a mercury switch is that it can handle very high currents. If you want, you can have it directly control a DC motor or some other high powered device directly. Plus, its fairly easy to find an old thermistat around to scrap for free!

Not to give you bad ideas, but apparently this sensor was also used in car bombs because acceleration would trigger it . . . but you didn't read that here . . .

Problems with the Mercury Tilt Switch
There are some problems you will have with using the mercury tilt switch on a mobile robot. When your robot is driving around on rough terrain, the mercury in the switch will also bounce around. This is bad because it has the potential to give false readings.

I remember the first time I tried out my sensor, my robot would do a stop-start motion. Acceleration would cause the sensor to false trigger, causing my motors to reverse . . . and the sudden deceleration would cause the sensor to un-trigger, once again making the robot accelerate . . . It was a really bad control algorithm, but I was a noob back then too . . .

The mechanical fix to this problem is to adjust the tilt angle more steeply (bend the metal beam coming out the wood mount more).

An electrical solution would be to put a capacitor between the ADC and ground. Depending on the size of the capacitor, you can vary the time it takes for it to trigger. Higher values would result in lower possibility of a false trigger, but would also slow the sensor response speed. Experimentation will be required for your robot . . .

Safety Notes
Mercury (Hg) is poisonous - be careful at all times!

From Wikipedia (I couldn't have said it better):

"It can be inhaled and absorbed through the skin and mucous membrane, so containers of mercury are securely sealed to avoid spills and evaporation. Heating of mercury, or compounds of mercury that may decompose when heated, should always be carried out with adequate ventilation in order to avoid exposure to mercury vapor."

"Acute exposure to mercury vapor has been shown to result in profound central nervous system effects, including psychotic reactions characterized by delirium, hallucinations, and suicidal tendency."