0
$\begingroup$

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:

enter image description here

$\endgroup$
  • 1
    $\begingroup$ it is possible that some of the interrupts are not getting serviced. please post your code. (minimal code that demonstrates the observed problem) $\endgroup$ – jsotola Jan 14 '18 at 21:12
  • $\begingroup$ 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. $\endgroup$ – hauptmech Jan 14 '18 at 21:20
  • $\begingroup$ connect just the sensor to your controller. load simple code to control an LED with the sensor, then slowly spin the sensor magnet. $\endgroup$ – jsotola Jan 16 '18 at 2:54
  • $\begingroup$ 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? $\endgroup$ – Chuck Jan 16 '18 at 20:42
1
$\begingroup$

Are you running a PID loop to control the motor? Without a PID loop, the motor is going to be highly dependent on load and will likely stop differently every time. Also, since the sensor is relative position only, you will need a way to home the motor to be able to know absolute position.

If you need accurate absolute position, you could use a hall absolute position sensor.

enter image description here

$\endgroup$
  • $\begingroup$ Looks like my initial problem was had 2 root causes: 1) I should have used both interrupts of the motor hall sensors (one produces some extra signals). 2) Without PID loop it was too inaccurate. I decreased the motor speed and now it looks way much better. Thank you for your answers! $\endgroup$ – borisovke Jan 17 '18 at 19:03
  • $\begingroup$ Glad to hear you are making progress. $\endgroup$ – markshancock Jan 17 '18 at 20:43
  • $\begingroup$ Note: A PID loop is pretty easy to do. One of the biggest questions would be whether you want the PID to control position or error. That is really dependent on your design. It sort of sounds like to me that you are looking for positional control. $\endgroup$ – markshancock Jan 17 '18 at 20:43
  • $\begingroup$ @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 $\endgroup$ – jsotola Jan 19 '18 at 3:14
  • $\begingroup$ @Kons Are trying to decode a quadrature encoder yourself by capturing the edges using interrupts? If so, there are LOTS of things that can go wrong! One classic problem is edge jitter where the encoder produces a very fast chain of edges because the encoder stops right on one of the encoder transitions and ends up quickly going back-and-forth across it. Missing or mishandling the edges thus cause the position to appear to move even though it didn't. $\endgroup$ – markshancock Jan 19 '18 at 4:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.