Experiment 09 - Hall Sensor
- Julius Harms (Unlicensed)
Material for this experiment:
- 1x 10kOhm Resistor
- 1x 0.1uF Capacitor
- 1x DRV5023-Q1 (BI) Digital-Switch Hall Effect Sensor
Datasheet: https://www.ti.com/lit/ds/symlink/drv5023-q1.pdf - 1x Arduino Uno
- 1x Breadboard
- Jumper Wires
- Circuit Board with DRV5055-Q1 Ratiometric Linear Hall Effect Sensor
Datasheet: https://www.ti.com/lit/ds/symlink/drv5055-q1.pdf - Magnets
Experiment Description
- In the first part of the experiment, a circuit for a hall sensor switch has to be implemented based on DRV5023-Q1 Digital-Switch Hall Effect Sensor.
Open the according datasheet on page 16 to find the chapter about "Application and Implementation". Use the given parts to setup the circuit on the breadboard. Connect your breadboard circuit to the Arduino as indicated on the figure. To light up the Arduino built in LED according to the hall switch state, flash the Arduino with the following code.
boolean digitalValue; // variable to store the digital read value // the setup function runs once when you press reset or power the board void setup() { Serial.begin(9600); // setup serial port to print messages while(!Serial){}; // wait for serial port pinMode(LED_BUILTIN, OUTPUT); // set pin mode for build in LED pinMode(0, INPUT); // set pin mode for digital input D0 Serial.println("Program Startet"); // Print to serial monitor } // the loop function runs over and over again forever void loop() { digitalValue= digitalRead(0); // read digital value of D0 // switch the LED according to the hall sensor switch if(!digitalValue) // the sensor output is pulled up by resistor R1. A triggered switch sets D0 to GND { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) }else{ digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW } delay(100); // wait for 100mS }
b. Which side of the magnet has to face the sensor to trigger the switch? Use the datasheet to find out.
c. Whats the distance between magnet and sensor for turning the switch on?
d. Whats the distance between magnet and sensor for turning the switch off?
e. Reed the datasheet to find out, to what magnetic flux densities these values are associated.
2. Use the soldered board and the jumper wires to connected the circuit to the Arduino as indicated in the figures. Modify the Arduino code as follows:
Create a variable of type double to store the analogValue
In the Loop, read the analogValue of pin A0 with the function analogRead(...)
In the Loop, use Serial.println(analogValue) to print the analog reading
a. Run the code. You should now see the reading of the hall sensor on the scale of 1024 bit, which is the resolution of the Analog Digital Converter.
b. Use the Datasheet to write a function which maps the ADC-Readings to flux density readings. Modify the code to print the flux density readings and run it.
Hint: To scale the reading to 0...1 devide the analogValue by 1023.0 → scaledValue = (analogValue / 1023.0)
c. Use the Arduino plotter instead of the monitor to display the readings graphically. When you turn the magnet with a constant angular velocity, what is the approximate function you see on the plotter?
d. Think about sensor applications, where you could use this kind of sensor.
Institut für Mechatronik im Maschinenbau (iMEK), Eißendorfer Straße 38, 21073 Hamburg