# Using hall sensors to calculate position

I have a geared DC motor with hall speed sensors. I want to count signals from the sensor to get position of the motor. Hall sensor has resolution of 12 CPR. Gear ratio is 1:810, which means that I don't really need very precise measurement to get close to the desired position.

But in reality it doesn't work. I run the motor at the same direction trying to get exactly 360 degrees. Sometimes I am close to the position I set, sometimes I am too far (like 300 degrees instead of 360).

The code is simple. I just attached the hall sensor to an interrupt pin and count raises of the signal.

Has anybody tried that? Does anybody knows some obvious problem which causes me to fail such miserably?

Here is the motor I am using:

• it is possible that some of the interrupts are not getting serviced. please post your code. (minimal code that demonstrates the observed problem) Jan 14 '18 at 21:12
• The hall sensor may need external circuitry to produce a good signal. If you put a schematic of the pcb in your question (or hi-res photos of front and back of the pcb if there is no schematic in the documentation from the manufacturer) and post it on electronics.stackexchange you should get a good answer. Jan 14 '18 at 21:20
• connect just the sensor to your controller. load simple code to control an LED with the sensor, then slowly spin the sensor magnet. Jan 16 '18 at 2:54
• Welcome to Robotics, Kons. You said, "The code is simple. I just attached the hall sensor to an interrupt pin and count raises of the signal." What code? Where is the code? Are you trying to drive the motor for X number of counts, or are you running the motor at full speed and counting the number of pulses? Have you checked the pulse train with an oscilloscope or similar? Are you seeing variable results under the same loading, or are your angles varying under load or at different speeds? What troubleshooting have you done? Jan 16 '18 at 20:42

• @Kons, one produces some extra signals ... not "extra signals" .... you need to fully understand what you are dealing with if you want to have success Jan 19 '18 at 3:14