2

I am measuring a hall sensor included in a motor.

A Raspberry Pi 3b+ controls a Sabertooth 2x32 motor controller through radio Signal (ppm) and the Sabertooth output is connected to the motor. I get wrong measurements, I am using pin risings to count the hall readings and but the read is much faster (x50) than the real turns. Weird is that if I connect the motor to a power source, the readings will be perfect.

Any ideas of what could be causing this? I have a 24V and a 12V batteries. The raspberry is powered after a DC step-down from the 12V one. The motor controller is connected directly to the 24V battery. I had tried with pigpio and RPi.GPIO libraries and they behaved the same.

[Update]: I tested moving the wheel with the hand and the lectures were correct. Even with the Sabertooth connected but now powering the motors.

[Update 2]: Code deleted as it had nothing to do. PWM signal generated from the motor makes interference. That's why with the power source or manual movement everything worked. Also, the interference is being captured in the hall sensor. When optical encoders were used no interference was measured.

[Conlcusion]: Powering motors with PWM and measuring with hall sensors is a bad combination (at least in this set-up which doesn't address the interference) Thanks, everyone!

Motor: Bosch motor CDP 0 986 337 250 24V 6A rated geared 54:1

Controller Sabertooth 2x32

System diagram:

enter image description here

8
  • 1
    1) That is not a pigpio script. 2) Your description of the problem suggests you have not connected a ground wire between the Pi and the motor/hall sensor.
    – joan
    Aug 30 at 16:04
  • 1
    Updated the post with the pigpio code. The hall sensor is grounded to the RPi, the motor is not connected to the Rpi ground. The hall sensor feeds independent from the motor. Should I connect them? How? Aren't the motors dangerous as they are running on a much higher Voltage? They work also rated with 6A.
    – capitnakl
    Aug 30 at 16:11
  • 1
    You need to add a wiring diagram which shows how the various parts are connected.
    – joan
    Aug 30 at 16:17
  • 1
    Diagram added batteries don't share the groud
    – capitnakl
    Aug 30 at 16:51
  • Your story is a bit vague. Please confirm the following. (1) Is you motor geared 1:50? (2) How many lines per revolution? (3) Any links to your motor?
    – tlfong01
    Aug 31 at 1:28
2

This seems to be the wiring diagram for your motor:

enter image description here

Your drawing doesn't show how you power the hall sensors, but just in case: you need to power them separately, with stable DC. If you power them with the motor itself (Gr/Br wires), then the PWM signal from the controller will be mixed with the output from the sensors, and you will see garbage on your S1/S2 outputs.

I don't know if you are allowed to power the hall sensors with just 3.3V. Many sensors require at least 5V, and you have to pay attention to output signal: if it's proportional to VCC, you'll have to shift it down to 3.3V to make it compatible with the Pi.

It could also be that the EM noise from PWM lines is strong enough to alter the hall sensor signals. Keep the cables further apart if possible.

Another point that should be obvious is the connection between hall sensor GND and Pi GND. If it's not there, the edge detection will not work, and there's a risk of damaging the Pi.

3
  • 1
    The hall is powered with the 3.3V and the GND from the pi. According to the guide the hall sensor support from 3 to 24 V. Maybe is tricky to be just in the limit. I could try to read it with an Arduino so I could use 5V. Still it wouldnt explain why i have correct lectures when I power the motor from a power source or move it with my hand. What means the dashed square? Does it represents the physical end of the motor? Would the capacitor be connected to where? And yes, sorry not the best diagram.
    – capitnakl
    Aug 31 at 19:47
  • 1
    @capitnakl The noise from PWM interfering with hall signals is still a plausible explanation. I suppose the dashed square represents the motor case. If your controller supports it, you could try to configure it to have the PWM only on Br terminal, with Gr being constant GND or VCC, depending on the rotation direction: that could reduce the coupling between signals and PWM noise. Another idea is to try pull-ups or pull-downs on the hall data lines. or powering the hall sensors with 12/24V and using a divider on the Pi side: that divider will also apply to the noise voltage. Sep 1 at 8:43
  • I already tried with pull-ups. The ones of the GPIO and with a 1k one. Maybe I should try with higher values. Now I get the PWM part and it completely make sense as the times that they were ok I powered them with the power source and with the motors themselves. So if I manage to send a DC current it would be solved, or dealing directly with the interference. Right now we have switched to optical encoders that are working great. So the interference was captured probably in the hall sensor itself.
    – capitnakl
    Sep 1 at 14:13

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.