Hall Effect Sensors 101

From ESE205 Wiki
Jump to navigation Jump to search

Know Your Sensors

Hall Effect sensors are simple sensors that respond to a magnetic field using the Hall Effect. They can be easily hooked up to an Arduino to sense a magnet and relay that info to the computer.

However, there are two distinct kinds of Hall Effect Sensors, and this tutorial will show you how to use them.

First, you need to decide whether you want to use Latching or Non-Latching Hall Effect sensors. When buying the sensors, know what you need from them. Use the info below to determine what will work best for your uses before you order.

Application

measurement of displacement

measurement of forces

measurement of angle velocity

measurement of linear velocity

All Hall Effect Sensors (regardless of whether they latch)

  • Operate on a single digital input pin.
  • Take a Power line (usually between 3V and 7V, most frequently 5V)
  • Take a Ground line(usually there is "-" sign which shows it is the ground line)
  • Take a Signal Line (this is usually shown by a "S" sign)
  • Usually take a resistor of some sort
  • Output a 1 or a 0 down its signal line. These ones and zeros can be sampled and utilized by a computer with fairly simple code, given below.
  • This is a fairly comprehensive hookup guide, but be sure to read your own sensor's Data Sheet before purchasing, as your sensor could be wired very differently.

Hall effect sensor.jpg

Non-Latching Sensors

  • Output a 1 only in the presence of a specific pole of a magnet (IE North or South)
  • Output a 0 when not in the presence of a magnet
  • Output a 0 when in the presence of the "wrong" pole of the magnet
  • Are two-sided with each side reacting to a different pole
  • An example of output is given below:
Non Latching.PNG


Latching Sensors

  • Output a 1 or 0 depending on the last pole seen
  • Also function on both sides
  • An example output is given below:
Latching.PNG

Simple Code

This is some simple code to interact with your sensor. It looks like a lot of code, but it's actually just 4 lines! The rest is annotations to walk you through each line of code.

Some simple code to view a sensor's reading in real-time.


Help! I Bought the Wrong Kind!

Have no fear!! If you bought Latching when you wanted Non-Latching, there is a solution!

To transform your Latching to a Non-Latching, you need to simply turn its power pin off then back on to "reset" it each time you take a reading. This is best done using a MOSFET Switch (excellent student tutorial liked here) which is essentially a switch the Arduino can turn on and off on its own. Hook up the MOSFET in series with the Hall Effect's ground pin, then implement the following code:

Some simple code to view a sensor's reading in real-time.

Your Latching Sensor should now behave like the Non-Latching Sensor..