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

From PrattWiki
Jump to navigation Jump to search
(Created page with "{{LaTeX Shortcuts}} == Pins == * 1 (left): Supply voltage $$\E{V}{CC}}$$, typically 5 V * 2 (middle): GND * 3 (right): vout between 0 and $$\mathrm{V}_{\mathrm{CC}}$$ == Ope...")
 
Line 2: Line 2:
  
 
== Pins ==
 
== Pins ==
* 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): vout between 0 and $$\mathrm{V}_{\mathrm{CC}}$$
Line 13: Line 13:
 
*  
 
*  
  
 +
== Sample Code ==
 +
<syntaxhighlight lang=C++>
 +
const int Hall_In = 0;
 +
const float VCC = 5.0;
  
 +
void setup() {
 +
  Serial.begin(9600);
 +
}
 +
 +
void loop() {
 +
  float Hall_Reading = analogRead(Hall_In);
 +
  float Hall_Voltage = Hall_Reading * VCC / 1024.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);
 +
}
 +
</syntaxhighlight>
  
  
 
* 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 22:21, 17 August 2022

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

Pins

  • 1 (left): Supply voltage $$\E{V}{CC}$$, typically 5 V
  • 2 (middle): GND
  • 3 (right): vout between 0 and $$\mathrm{V}_{\mathrm{CC}}$$

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

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. The sensitivity is 5 mV/G (where G stands for gauss)

Sample Code

const int Hall_In = 0;
const float VCC = 5.0;

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

void loop() {
  float Hall_Reading = analogRead(Hall_In);
  float Hall_Voltage = Hall_Reading * VCC / 1024.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);
}