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

capitnakl
  • 23
  • 5

1 Answers1

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.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147