ECE 110/Equipment/Hall Effect Sensor

From PrattWiki
Jump to navigation Jump to search

$$\newcommand{E}[2]{#1_{\mathrm{#2}}}$$

Introduction

A Hall effect sensor measures magnetic flux density (with units of gauss or G) and converts the measurement into a voltage. The magnetic flux density is directional, and the output from the sensor takes this into account. For ECE 110, you will be using the Allegro Microsystems A1324 linear Hall-effect sensor in the 3-pin ultramini single inline package (SIP, also called the "UA" version).

On the Data Sheetprovided on the A1324, A1325, A1326: Low Noise, Linear Hall Effect Sensor ICs with Analog Output Product Page, you can see a picture of the package on page 1, a pinout diagram on page 3, and information about the electrical and magnetic characteristics of the device on page 4.

Leads

  • 1 (left): Supply voltage $$\E{V}{CC}$$, typically 5 V
  • 2 (middle): GND
  • 3 (right): $$\E{V}{out}$$ between 0 and $$\mathrm{V}_{\mathrm{CC}}$$ with a sensitivity of 5 mV/G if $$\E{V}{CC}$$ is 5 V

The CX-Bot has no header for the Hall effect sensor.

Operation

The voltage on the third lead will vary depending on the supply voltage and the magnetic flux density through the Hall effect sensor. The sensor is mounted in the same plane as the leads and reads the flux density as it passes from the front of the sensor to the back.

Assuming a 5 V external supply, lead 3's voltage will be between 0 and 5 V. A voltage of 0 V indicates the strong presence of a south pole while a voltage of 5 V indicates the strong presence of a north pole. An output of 2.5 V indicates no magnetic field. The sensitivity is 5 mV/G.

Sample Code

The code below has three variables:

  • Hall_In stores the analog input pin number that is connected to the sensor's third lead,
  • VCC stores the voltage used to power the sensor (typically 5 V), and
  • Hall_sensitivity stores the sensitivity of the sensor in volts per gauss, which for the A1324 is 0.005 V/G

The code will read the voltage from the specified analog pin as a value between 0 (for 0 V) and 1023 (for 5 V). It then converts that into a voltage measurement (assuming a 5 V based Arduino). Finally, it converts the voltage measurement into a flux density measurement based on the sensitivity of the Hall effect sensor and prints out the analog pin reading, the equivalent analog pin voltage, and the measured magnetic flux density.

const int Hall_In = 0;
const float VCC = 5.0;
const float Hall_sensitivity = 0.005; // 5 mV/G

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

void loop() {
  float Hall_Reading = analogRead(Hall_In);
  float Hall_Voltage = Hall_Reading * 5.0 / 1023.0;
  float Hall_Gauss = (Hall_Voltage - (VCC/2)) / 0.005;
  Serial.print("Analog reading = ");
  Serial.print(Hall_Reading);
  Serial.print(" ");
  Serial.print("Analog voltage = ");
  Serial.print(Hall_Voltage);
  Serial.print(" ");
  Serial.print("Flux density = ");
  Serial.println(Hall_Gauss);
  delay(100);
}

Notes

  • When viewed from the top, the sensor has a trapezoidal profile. The front is the smaller of the two bases.
  • The front has $$\mathcal{A}$$324 stamped on it and the back has a circular indentation.

References