Feedback from a Hall Effect Sensor With Video

Hall Effect Sensor

Hall effect sensors can detect the presence of magnetic field and produce an output voltage when one is detected. Hall effect sensors, when used with linear actuators, are typically positioned inside the gearbox of the actuator along with a magnetic disc. As the linear actuator extends or retracts, this disc rotates pass the hall effect sensor which causes the sensor to produce a digital output in the form of a pulse of voltage. These pulses can be counted and used to determine how far the actuator has moved.

How to Read Feedback from a Linear Actuator

Positional Feedback from a Hall Effect Sensor

A downside of using a hall effect sensor for positional feedback is that they do not measure an absolute position. Instead they produce pulses that can be counted to determine how far the actuator has moved. To utilize these pulses for positional feedback, you’ll need to use a micro-controller to count the produced pulses. To do so, you’ll need to make use of external interrupt pins of your micro-controller to count these pulses as they occur. External interrupts are pins that detect a change in voltage and in our case can be used to detect the voltage pulse from the hall effect sensor. You will need to consult your micro-controller’s datasheet to ensure what pins of your micro-controller can be used as interrupt pins. Using an Arduino Uno for example, pins 2 and 3 can be used for external interrupts. Once you have selected an appropriate interrupt pin, you can connect the wire of the hall effect sensor output to that pin as well as connect the input voltage to 5V and ground to a ground pin.

Connecting Hall Effect Sensor to Arduino 

The code example below shows how to setup an interrupt in the Arduino IDE where the interrupt will be triggered on the rising edge of the voltage pulse. You can set up your interrupt to be triggered at different points in a voltage change and should consult your micro-controller’s datasheet to determine the available options. The last aspect you need to do to set up your interrupt is to write your interrupt service routine, which is the function that the code will run every time the interrupt is triggered. This function should be short and only perform simple tasks like counting the number of pulses from our hall effect sensor. The function countSteps() in the code example below is used to count the number of pulses from the hall effect sensor.

To utilize these pulses to determine a positional value, you’ll need to know the previous position of the linear actuator and the direction that linear actuator is travelling in. Your micro-controller will already know which way you’re driving your linear actuator, so you can simply set up a variable to track the direction of the actuator in your code which will be used to determine whether you add or subtract the pulses from your previous position. Once you have updated your position, you’ll need to reset the counted pulses to zero. The code example below shows you a function that updates the position based on the number of pulses counted. Once you have a position in terms of pulses you can convert into inches using the pulse per inch specification of your linear actuator. In the code sample below, the pulse per inch travel is 3500.

Homing your Linear Actuator

To accurately utilize positional feedback from a hall effect sensor, you need to always know the starting position of your linear actuator. Although when you first turn on your system, your micro-controller will not be able to tell whether the actuator is extended or not. This will require you to home your linear actuator to a known position.To home your linear actuator, you will need to drive it to a known position, like fully retracted. You could also make use of external limit switches to set your known position to somewhere other than fully extended or retracted. Using the Arduino code below as an example, we will want to set up a WHILE loop that will drive our linear actuator towards your known position, in this case fully retracted. We know that you are at our known position because the interrupt of the hall effect sensor won’t trigger. In this case, we check whether or not the steps variable has changed to determine if the interrupt has been triggered. We also need to make sure that enough time has passed to expect the interrupt to be triggered, for this we make use of the millis() function which outputs the time in milliseconds since the code has started and we compare that to the previous time stamp. Once we have determined that the linear actuator is at our home position, we stop driving the actuator, reset the steps variable, and exit the WHILE loop.

Dealing with False Triggers

While hall effect sensors are not as sensitive to electrical noise as a potentiometer, electrical noise could still impact the output signal. Switch bouncing can also be an issue with hall effect sensors that may trigger false pulses to be counted, which would affect how far your micro-controller thinks your linear actuator has moved. A few extra pulses won’t affect the positioning very much as there are 1000s of pulses per inch, but over time it may be a bigger issue. You can combat these issues by making use of an internal timer to filter out false triggers. As you can determine how frequent you would expect new pulses to be detected, you can filter out when the interrupt was triggered by noise. In the code sample below, trig-Delay is the time delay between each pulse. If the interrupt was triggered before this delay, then the pulse won’t be counted.

The length of time of this delay will vary based on your application, but if it is too short it will not filter out the noise properly and if it is too long it will miss actual pulses from the linear actuator. The speed of the linear actuator will also impact this delay and if you want to adjust the speed, this variable may need to change to adjust to the new frequency of the pulses expected. To accurately determine an exact delay between each pulse, you can use a logic analyzer to view the actual signal from the hall effect sensor. While this is not required in most applications, if you require very exact positioning, you may want to determine a precise delay.

Another way to combat false triggers is to correct the positional value every time the actuator reaches a known position. Like homing the linear actuator, if you have driven the linear actuator to a fully retracted or extended position or if you make use of external limit switches, you’ll know how far the actuator has moved. As you know how many steps the hall effect sensor should sent to reach your known position, you can simply correct the value when we reach it. In the code sample below, this is done for the fully extended and fully retracted positions. As the actuator won’t move once it reaches one of those positions, if we try to drive the actuator and the position value doesn’t change, we know we are at the limit. This method provides a practical solution to ensure your positional value stays accurate, especially if you are fully retracting or fully extending your actuator at some point during operation. You can use this method in conjunction with the method described above which should help maintain the accuracy of your positional value.

Summary

Utilizing a hall effect sensor for positional feedback provides much greater resolution compared to the feedback from a potentiometer. As there can be 1000s of pulses per inch of movement, hall effect sensors provide precision and reliability in positioning your linear actuator. Hall effect sensors also provide greater ability to ensure multiple linear actuators move together simultaneously as the pulse counts are more accurate than the changing voltage of the potentiometer. Utilizing our FA-SYNC-X actuator controller, you can even ensure the actuators move in unison irrespective of load. For DIYers, you can check how ensure your actuators move in unison using an Arduino here.

Below is the complete sample code used in this blog and was built to control a 14” stroke length Bullet Series 36 Cal. Linear Actuator. The linear actuator is driven using a motor driver, which you can learn how to set up here

[1] Monari, G. (June, 2013) Understanding Resolution In Optical And Magnetic Encoders. Retrieved From: https://www.electronicdesign.com/technologies/components/article/21798142/understanding-resolution-in-optical-and-magnetic-encoders

Tags:

Share this article

Featured Collections

Need Help Finding the Right Actuator?

We precision engineer and manufacture our products so you get direct manufacturers pricing. We offer same day shipping and knowledgeable customer support.

Give us a call or email us and we'll be happy to help you find the best actuator for your project.