Difference between revisions of "ECE 110/Equipment/Hall Effect Sensor"

From PrattWiki
Jump to navigation Jump to search
(Sample Code)
Line 1: Line 1:
 
{{LaTeX Shortcuts}}
 
{{LaTeX Shortcuts}}
  
== Pins ==
+
== 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 [https://www.allegromicro.com/-/media/files/datasheets/a1324-5-6-datasheet.pdf Data Sheet] provided on the [https://www.allegromicro.com/en/products/sense/linear-and-angular-position/linear-position-sensor-ics/a1324-5-6 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
 
* 1 (left): Supply voltage $$\E{V}{CC}$$, typically 5 V
 
* 2 (middle): GND
 
* 2 (middle): GND
* 3 (right): vout between 0 and $$\mathrm{V}_{\mathrm{CC}}$$
+
* 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
  
 
== Operation ==
 
== Operation ==
The voltage on the third pin will vary depending on the supply voltage and the magnetic flux density through the Hall effect sensor.  If the magnetic flux density is 0 G (where G stands for gauss), the third pin will read
+
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, pin 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.
+
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 (where G stands for gauss)
+
The sensitivity is 5 mV/G.
*
 
  
 
== Sample Code ==
 
== Sample Code ==
Line 19: Line 24:
 
* <code>Hall_sensitivity</code> stores the sensitivity of the sensor in volts per gauss, which for the A1324 is 0.005 V/G
 
* <code>Hall_sensitivity</code> 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 denisty.
+
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.
  
 
<syntaxhighlight lang=C++>
 
<syntaxhighlight lang=C++>
Line 46: Line 51:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
+
== References ==
 
* https://www.allegromicro.com/en/products/sense/linear-and-angular-position/linear-position-sensor-ics/a1324-5-6 A1324, A1325, A1326: Low Noise, Linear Hall Effect Sensor ICs with Analog Output  ]
 
* https://www.allegromicro.com/en/products/sense/linear-and-angular-position/linear-position-sensor-ics/a1324-5-6 A1324, A1325, A1326: Low Noise, Linear Hall Effect Sensor ICs with Analog Output  ]

Revision as of 15:59, 18 August 2022

$$\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 Sheet provided 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

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);
}

References