Component Tutorial - Hall Effect Sensors - Tangible Interaction Report

Hall Effect Sensors

Overview

The report will provide a tutorial on Hall Effect Sensors. This will cover background information on what a Hall-Effect sensor is, the underlying mechanisms that make it work, example applications and use cases.

The report will then go on to provide documentation on how to use the following hall effect sensors

  • Linear Analog Hall Effect Sensor
  • Digital Hall Effect Sensor

Other things the report will cover include

  • Code examples for various hall effect sensors
  • How to calibrate hall effect sensors for
  • Mounting suggestions

The report will then conclude with an analysis on the development of a chess piece detection board using magnetic hall sensing and explore the following problems

  • Chess Board & Piece - position detection
  • Chess Piece - unique identification of pieces
  • Chess Piece - unique identification of pieces in different sets (black & white)
  • Electromagnetic movement of chess piece and its impact on the position detection mechanism

Sensor Introduction

What is a Hall Effect Sensor?

Description

A Hall Effect Sensor is a magnetic field sensor. When subjected to a magnetic field, It detects the presence and magnitude of a magnetic field and responds with an output voltage that is directly proportional to the strength of the field.

They are often used for proximity, speed, positioning and current sensing applications. They are frequently combined with threshold detection to act as a binary switch.

As an example, printers detect missing paper, open covers. Blenders detect correct locking mechanisms for safety purposes.

Data Sheet

I've tried the following three sensors that will work ideally with this report.

  1. Unipolar Hall Effect - Digital Sensor - with built-in pull up resistor
  2. Omnipolar Hall Effect - Digital Sensor - no pullup resistor
  3. Unipolar Ratiometric - Analog Sensor

How Does a Hall Effect Sensor Work?

image

The underlying principle is the Hall effect, whereby a current-carrying conductor placed into a magnetic field will generate a voltage that is perpendicular to both the current and to the field.

When a perpendicular magnetic field is present, a force is exerted on the current and this disturbs the current distribution resulting in a potential difference (voltage) across the output.

Strengths

  • Support multiple measurement functions - Can be used for multiple sensor functions like position sensing, speed sensing, direction of movements.
  • No wear and tear - since they are solid state devices (no moving parts)
  • Less prone to mechanical failure - since they are solid state devices (no moving parts) they are immune to vibration, dust, water, wear and tear.
  • Operates with stationary input
  • Logic compatible input and output
  • Broad temperature range

Weaknesses

  • Limited to distance of 10cm - Unable to detect current flow at a distance that's more than 10 cm.
  • Accuracy affect by other magnetic fields - Accuracy of the measured value is always a concern because external magnetic fields may interfere.
  • High temperatures affect mobility and sensitivity - High temperatures affect resistance which will affect mobility and sensitivity of the sensor.

Application Examples

Hall Effect sensors are applicable in any use-case where the parameter to be sensed either incorporates or can incorporate a magnetic field.

It can be used as the principle component in many types of sensing devices (current, temperature, pressure, position, etc).

Example Applications of Digital Hall Sensors

  • Apple's iPad, for example, uses magnetic detection to detect whether the Apple Pencil is connected with the presence of hall effect sensors.
  • Modern Blenders detect locking position based on the presence of magnets so that they can detect whether to run or not.

Example Use Cases of Digital Hall Sensors

  • Sensing pressure
  • Sensing proximity of objects
  • Sensing rate of flow of materials
  • Sensing positioning of items
  • Keyboard Switches

Types of Hall Effect Sensors

By Output

Digital Output Hall Effect Sensors provide a digital LOW, HIGH output

Analog Output Hall Effect Sensors provide an analog voltage output

By Operation

Omnipolar Hall Effect Sensors respond to both sound and north magnetic poles

Unipolar Hall Effect Sensors respond only to south magnetic poles

By Active Area

This categorization is based on how the hall effect responds to the presence of a magnetic field in a particular orientation.

Planar Hall Device - will respond if the magnetic field approaches perpendicularly through the active area

Vertical Hall Device - will respond if the magnetic field approaches along the sides of the edges

3D Hall Device - will respond if the magnetic field approaches in any direction

Notes on Latching vs Non Latching Sensors

By default we assume the sensors are non-latching. They toggle on and output a voltage when a polarity is presented and toggle off when the polarity is taken away.

Latching Hall Effect Sensors, in comparison, latch on to an initial pole. After that they toggle when presented with the opposite polarity.

The magnetic field strength, polarity, and angle of approach are all important. The hall effect will switch only if it is subjected to a sufficient magnetic flux density as well as the correct polarity

How to Choose a Hall Effect Sensor

Consider the following constraints when making this decision []

  1. Sensitivity: The combination of sensor strength, magnet strength. A strong sensor can work with smaller cheaper magnets more easily.
  2. Stability: The sensor may need different thresholds to toggle state based on temperature, for example. You will need to check if a part operates at a particular sensitivity of 30 Gauss at 25 °C then does it also operate at 30 Gauss at 125 °C
  3. Response Time: For simple presence detection a slow response time may be okay, but if you want to detect movement or response time matters as in a magnetic pixel grid to display output then you'll want to opt for a faster response time.

Tutorial

Mounting Design for Hall Effect Sensor

The mounting design is out of scope for this component report.

You might want to keep the following things under consideration when designing the mounting board.

  • Proximity of sensors to each other: This will affect how many sensors detect the presence of a particular magnet.
  • Proximity of the sensors to the magnet: This will be affected by how strong the magnet you're using is as well as the proximity.
  • Direction of the Hall Effect Sensor: Some hall effect sensors only support a particular direction.

Circuit Schematic & Software Examples

Describe the reasoning behind the circuit examples (Analog, Digital) etc etc.

Analog Setup

image
int analogPin = A0; // for Arduino microcontroller

void setup() {
  Serial.begin(9600);
}

void loop() {
  int analogVal = analogRead(analogPin);
  delay(100);
}

Digital Setup

Here's a basic schematic to use for one sensor.

Note: Some sensors come with their own pull-up resistors. This setup will suffice

image

Note: You may need to use a pull-up resistor for other sensors.

image

Basic code to detect Hall Effect Signal

// Pin
const int hallPin = 1;

int hallVal = 0;
int previousState = HIGH; 

void setup ()
{
  pinMode (hallPin, INPUT);
}
 
void loop ()
{
  hallVal = digitalRead(hallPin);
  previousState=hallVal;
}
Modified excerpt from Hall Effect Sensor with Arduino [3]

Test Harness

image

#include <Wire.h>

#define hallEffectSensorD 2    // Pin for Digital Sensor
#define hallEffectSensorA A0   // Pin for Analog Sensor

#include <Wire.h>              // Code to make DFRobot LCD work
#include "DFRobot_RGBLCD.h"    // Code to make DFRobot LCD work

DFRobot_RGBLCD lcd(16,2);      // Code to make DFRobot LCD work

int r,g,b;

void setup() {
  Serial.begin(9600);

	// Set Digital Pin as Input
  pinMode(hallEffectSensorD, INPUT);

  // Initialize Lcd
  lcd.init();
}

void loop() {  
  lcd.setRGB(0, 0, 0);
  // Print First Line (Heading)
  lcd.setCursor(0,0);  // Sets cursor at row 0, column 0
  lcd.print("Hall Effect:");

  // Print Second Line (Digital + Analog Values)
  lcd.setCursor(0,1); // Advances cursor to row 1, column 0
  lcd.print("D: ");
  lcd.print(digitalRead(hallEffectSensorD));
  lcd.print(" | A: ");
  lcd.print(analogRead(hallEffectSensorA));
  
  
  delay(20);
}

Additional Considerations

Methods of reading the signal in the microcontroller

Two main methods include polling and interrupts

Polling is a programmed method in which a microcontroller periodically checks the state of an input to see if there has been a change.

Interrupts are a hardware mechanism that immediately shift the microcontroller's program when the state changes on an input.

Chess Board

Note: This will be approached later and is out of scope for this report.

Board Detection & Identification on Pieces on the Board

Consideration: Distance as a way to identify Black & White Pieces

What happens when you place the magnet at a distance of 2cm for black pieces and 4 cm for white pieces

Consideration: Polarity as a way to identify Black & White Pieces

What happens when you use south polarity to identify black pieces, and north polarity to identify white pieces.

Consideration: Polarity + Distance as a way to Uniquely Identify All Pieces

Using the north and south polarities for white and black pieces respectively and additionally placing 2cm, 4cm, 6cm, 8cm, 10cm, 12cm could help us uniquely identify the pieces for example bishop, pawn, king, queen, rook, knight.

Effects of Magnetically Moving a Piece on Board Detection

Caveats

Consideration: In what design will a unipolar switch be better for identification

One thing I'm considering is ignoring a specific magnetic field polarity so that movement of pieces using magnets does not interfere with an electromagnet that moves pieces.

Consideration: In what design will a bipolar switch be better for identification

This is likely going to be useful for being able to uniquely identify black and white pieces, and hopefully also the specific piece in question such as rook, bishop, knight, queen, pawn, king.

Consideration: How frequently to poll to detect pieces on the board

How long would you want to wait before you register movement of a piece as final and build a new snapshot of the board position.

When the piece is being moved automatically we can programmatically turn on / off the board detection until the movement is finalized. However if we're waiting for a player to respond to a move we'd need to identify when a move has been completed by detecting a change.

Reference