I'm using the pigpio library to run my motor in my Raspberry Pi like below.
ESC = 18 esc_pi = pigpio.pi() esc_pi.set_servo_pulsewidth(ESC, 2000)
I'm wondering is there any way to detect the motor is STILL rotating when I set the pulse width to mid value from max value? (no current so the motor will stop)
The reason why I ask this is because I want to input an opposite pulse value to increase the decceration for stopping the motor if detecting the motor rotation is possible like below.
# Assume 1000 is min value, 1500 is mid value and 2000 is max value # so 1501-2000 is forward and 1000-1499 is backward def get_current_motor_pulse(): ... return current_motor_pulse esc_pi.set_servo_pulsewidth(ESC, 2000) // Forward sleep(10) // Keep forward esc_pi.set_servo_pulsewidth(ESC, 1500) // STILL forward for few seconds while get_current_motor_pulse() > 0: esc_pi.set_servo_pulsewidth(ESC, 1400) // Increase the decceration
Here is the pigpio library, but I am not sure which function is the best fit for my case.