### Using Hall Effect Switches and Sensors

by Lewis Loflin

Hall effect sensors are solid state magnetic devices used as either magnetic switches or to measure magnetic fields. There are three basic types I'm concerned with here: The Hall effect switch, the Hall effect latch, and the ratiometric or analog sensor. For more on the general operation see my You Tube video above. Here I'm concerned with illustrating various electronic circuits and how to connect the sensors and use them.

A Hall effect switch will turn on in the presence of south magnetic field on its face or north magnetic field on the opposite side. It will turn off when the magnet is removed.

A Hall effect latch works like a switch, but will stay on when the magnet is removed. It will turn off if the north pole is applied to the face or the power is turned off.

A ratiometric Hall effect sensor outputs an analog voltage proportional to the magnetic field intensity. The devices I will use on a separate page are unipolar and in general with no magnetic field applied the output is one-half the supply voltage. The voltage will increase with the south magnetic pole on the face or decrease with the north magnetic pole on the face.

Pictured above are typical pin outs on three lead Hall sensors. The south pole of the magnet goes towards the 'face' turning the device on. The north pole on the face will have no effect unless the device is a latch, which it will turn off if it's already on.

### Considering Magnets

The magnetic field typically produced by rare-earth magnets can be in excess of 1.4 teslas, whereas ferrite or ceramic magnets typically exhibit fields of 0.5 to 1 tesla. The Tesla is named in honor of the inventor, physicist, and electrical engineer Nikola Tesla. A smaller magnetic field unit is the Gauss (1 Tesla = 10,000 Gauss):

10-9 - 10-8 gauss: the human brain magnetic field;
0.31-0.58 gauss: the Earth's magnetic field on its surface;
25 gauss: the Earth's magnetic field in its core;
50 gauss: a typical refrigerator magnet;
100 gauss: a small iron magnet;
2000 gauss: a small neodymium-iron-boron (NIB) magnet;
15,000-30,000 gauss: a medical magnetic resonance imaging electromagnet.

Above ref. Wiki. To find out more about rare earth magnets in general visit www.rare-earth-magnets.com. Magnets can be stacked (N to S) to form a more powerful magnet.

Let's consider a UGN3013T five volt Hall effect switch. To trip the switch on requires typically 500 gauss to a max of 750 gauss. But to release or cut off is a typical 225 gauss to as low as 110 gauss. So we have a reasonable range of 275 that we need to stay in for reliable operation. So it's obvious even a small iron magnet may work well or has to be very close to the sensor. Note this is an old obsolete part I just happened to have. Newer units are much more sensitive.

We can also use electromagnets.

Pictured above is a basic Hall effect switch. It consists of a Hall effect plate, amplifier, Schmidt trigger, and open-drain field effect transistor. (FET) The Hall effect plate produces a very small output that must be amplified, the Schmidt trigger will turn on when the amplifier output reaches a certain level, which will then turn on the FET.

The FET is an electronic switch much like a mechanical light switch. When "ON" it completes the path to ground switching on an external device connected to positive VCC. A Hall Effect latch only differs in having some additional latching circuitry.

When on uses the turn "HIGH" we men the FET is turned off breaking the path to ground. The voltage on the drain will climb to VCC. When we say "LOW" the FET is turned on it will "sink" the current to ground and the voltage on the drain goes to zero. This is true of almost all modern digital circuits.

For more on the concept of sink/source see Basic Transistor Driver Circuits for Micro-Controllers

Pictured above is a Hall effect switch connected to a light emitting diode. (LED) In the off condition TP2 will be "HIGH" or 5 volts measured relative to ground. The LED will be off. When switched on by a magnet TP2 will measure about .5 volts and the LED will be on.

This can be directly connected to the input port of a micro-controller or other 5-volt digital logic.

The problem with the above circuit is that a Hall sensor is a low power device that can sink about 20 mA. Now we will look at a number of simple circuits to boost the power output of the device.

In the example above we used 1/6 of a 7406 HEX inverter to drive an N-channel MOSFET such as the IRF630. With the Hall effect switch (U3) off, TP1 is five volts, TP2 is 0 volts, and TP3 is 12 volts with the lamp off.

Apply magnet:
TP1 = 0 volts;
TP2 = 12 volts;
TP3 = 0 volts and lamp is on.
R1 is 4.7k and R2 is 10k.

To use a 12-volt Hall effect switch or a latch such as a SS466 from Honeywell, change the 7406 to a 74C906 and R1 to 10k. Note the IRF630 is an enhancement mode MOSFET.

In the above example we used a N-channel depletion mode MOSFET. When U4 is off, TP4 and TP5 each = 12 volts and the lamp is off. When a magnet switches U4 on TP4 and TP5 both go to 0 volts and the lamp is on.

### Voltage Isolation

In the above sample circuit we use a 5-volt Hall switch to operate a 24-volt relay circuit to operate a high-voltage AC circuit. All of the voltages are electrically isolated from each other and even the common ground between the 5 and 24 volt supplies can be severed. With the Hall switch off we note the following meter readings:

TP1 = 5 volts;
TP2 = 24 volts;
indicator LED D3 is off;
relay K1 is de-energized, contacts open;
the voltage across K1's contacts is 120 VAC;
and lamp B1 is off.

When Hall switch U2 is turned on by a magnet:

TP1 = 0 volts;
TP2 = 0 volts;
indicator LED D3 is on;
relay K1 is energized, contacts close;
the voltage across K1's contacts is 0 VAC;
and lamp B1 is on.

R1 can be 330 ohms while R2 can be 1000 ohms. D2 is a general purpose silicon diode used for spike suppression when the relay coil is de-energized.

In our final circuit we use a 5-volt Hall switch and a MOC30XX type opto-coupler to operate a high voltage triac circuit. When Hall switch U4 is turned on TP1 goes to zero volts and the lamp turns on. R1 is still 330 ohms and R4 is 180 ohms. Triac Q1 should be at least 200 volts.

This completes my introduction to Hall Effect switches. Our next section we will look into ratiometric sensors, circuits, and uses. From there we will connect a Hall sensor to a micro-controller.

To purchase Hall sensors or explore the many varied types of sensors see www.allegromicro.com. If one wants a kit of parts to perform the above experiments contact me at lewis@bvunet.net for information.

### Added January 2012: PICAXE Micro-controller Projects!

The PICAXE series of micro-controllers rank as the easiest and most cost effective way to use Microchip processors. I wanted an easier and less expensive way to introduce my students to the "PIC" micro-controller. Here I hope to get those starting out past poorly written literature and lack of simple working code examples.

The next groups of links below go to specific electronic/electrical devices on how to use and test them.

### Sample Arduino code for the above video:

```/*
LiquidCrystal Library as a voltmeter

Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.

connect the ouput of the Hall sensor to analog(0).

The circuit:
* LCD RS pin to digital pin 12
* LCD R/W to GND
* LCD E pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* 10K pot:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/

// include the library code:
#include "LiquidCrystal.h"

int sensorValue;
float volts = 5.0 / 1023; // volts per step on ADC
float temp = 0;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {

// set up the LCD's number of columns and rows:
lcd.begin(16, 2);  // 16 char by 2 lines
lcd.noCursor(); // Hides the LCD cursor.
}

void loop() {