Using Gear tooth Sensors in an Off-Road Racecar

Measuring systems that spin very fast is a common challenge in vehicle systems. To accurately measure how quickly something is spinning without touching it like an encoder, the UCLA Baja racing team makes use of the Littelfuse 55075 series of gear-tooth sensors. In this article, weā€™ll be exploring how gear tooth sensors use the Hall effect to function, as well a practical example of how we use them on our race car. After giving this a read, you should hopefully be able to implement your own gear tooth sensor solutions!

Theory

Gear tooth sensors like the Littelfuse 55075 use the Hall effect to detect ferrous materials. Thatā€™s a dense statement, so letā€™s take a second to unpack it. Ferrous materials (or any material with high magnetic permeability) have a very special property: they can guide and concentrate magnetic fields. In the figure below, you can clearly see that introducing a ferrous material into the magnetic field of a typical bar magnet concentrates the field directly in front of it. This means that as ferrous materials pass by the face of the sensor, the strength of the magnetic field will become stronger and weaker. Gear tooth sensors like the 55075 series typically embed this magnet into the sensor body, but you should check your sensorā€™s datasheet to be sure! Source: Edward Ramsen

But how is this useful, and how do we detect this phenomenon? The answer lies in the Hall effect. The Hall effect takes advantage of the fact that magnetic fields push moving electric charges. Charges of different signs move in opposite directions, allowing us to detect magnetic fields as a voltage! By reading this voltage, we can quantify the strength of the magnetic field through the sensor. The finer details of how a hall effect sensor works can get hairy, so hereā€™s a video by the organic chemistry tutor explaining how it works! Picture of the Hall Effect in Action. Charges moving due to the magnetic field create a voltage Vh that we can measure!

Implementation

By measuring the Hall Effect, gear tooth sensors can read when ferrous materials pass by them. Like I said, we can use this to read the speed of a spinning object (provided it is ferrous). Thankfully, because of some additional circuit magic inside the 55075 series, we donā€™t have to worry about reading and interpreting the Hall Effect voltage. Instead, the sensor outputs a digital high signal when it detects the presence of a ferrous material, and a digital low signal otherwise.

We can easily interpret these digital signals using a microcontroller like an Arduino Uno. Weā€™ll be using the same sensors we use on the car: the 55075 by Littelfuse. Wire up the sensor as shown below.

In this example, weā€™ll be using the gear tooth sensor to measure the speed of the front wheels of our vehicle. Picture of how the gear tooth sensor is implemented in the demo.

Circled in red is the gear tooth sensor. Itā€™s set up to read the slots in the steel brake disc. As the wheels (and the brake disc) spin, the sensor outputs a logic low when the slots in the disc pass by. If you donā€™t have access to a Baja car, donā€™t worry! You can also wave any ferrous item across the face of the sensor to test if its working! We like to use steel bolts in a pinch. If your sensor is powered with 5V, and you probe the output, you should see the following:

Code

In the Arduino IDE, we used the following code to record the RPM (rotations per minute) values as the wheel spins:

#define GEARTOOTH_INPUT 3Ā 
int ticks = 0;
double teeth_per_rot = 8.0;
double gear_rpm;
uint32_t last_gear_time_us = 0;
unsigned long time;
double milPerMin = 60000;
double lastTime = 0;
 
void on_gear_tick() {
Ā Ā ticks++;
}  
 
void setup() {
Ā Ā Serial.begin(9600);
Ā Ā pinMode(GEARTOOTH_INPUT, INPUT);
Ā Ā attachInterrupt(digitalPinToInterrupt(GEARTOOTH_INPUT), on_gear_tick, CHANGE);
}
 
void loop() {
 
Ā Ā if (millis() - lastTime == 500) {
Ā Ā Ā Ā //Count number of rotations and divide by number of minutes passes (20 micros)
Ā Ā Ā Ā double rpm = ((ticks / teeth_per_rot)/ (500)) * milPerMin;
Ā Ā Ā Ā ticks = 0;
Ā Ā Ā Ā Serial.print(rpm);
Ā Ā Ā Ā Serial.print(", ");
Ā Ā Ā Ā Serial.println(millis());
Ā Ā Ā Ā lastTime = millis();
Ā Ā }
}
 

The code isnā€™t too complicated if youā€™ve used interrupts before. An interrupt is just a function that triggers when a digital pin changes, or is driven high/low. In our case, we detect when the gear tooth sensorā€™s output changes (High-Low or Low-High). When that happens, we increment our variable, ticks.

Each tick corresponds to the sensor passing by a slot in the brake rotor. In the main loop, we evaluate the RPM every 0.5 seconds by dividing the number of ticks by the number of slots in the brake rotor (8). This gives us rotations. We then divide that by how many minutes have elapsed to get the rotations per minute (RPM)!

We print both the calculated RPM and the time in milliseconds so that we can plot our data later!

Results

In order to test our sensor, we drove our car around in a parking lot for a few minutes at a time. We then took the values we printed to the serial monitor and graphed it using Python. The results are shown below: You can see that the output contains quite a bit of noise and a couple peaks that need to be filtered out. By passing the sensor data through a simple low pass filter, we can achieve the output below! Using this method, the Baja team measures the speed of all 4 wheels and the engine. We then use those sensor inputs to control our automatic transmission! Weā€™ll save explaining how we do that for a different article.

By now, if youā€™ve read through the article, you should be able to understand not only how a gear tooth sensor works, but also how to implement it in practice! Happy making!