Hello folks,
I have a problem trying to drive a couple of “75:1 Metal Gearmotor 25Dx54L mm HP with 48 CPR Encoder” with a Roboclaw 2x5A v4.0.5 controller.
I am using a Raspberry pi b+ and Python. When I try to reset the encoders absolute counter and then read their state, it only works in encoders Quadrature Mode. It reads 0 counts for both motors. Everything’s correct so far. But then, if I just change the encoders mode mode to Absolute Mode and then read again, it shows something between 12 and 14 (around 2052 if I swap the encoders cables). My question is: is this normal? Why I am not able to reset the encoders to zero in absolute mode? I got the same results when I tried with an Arduino Uno and the arduino library provided by roboclaw.
An exemplepiece of python code is shown below. It resets correctly when in Quadrature mode, but when I uncomment the lines for changing to Absolute mode, it doesn’t work anymore and it gives that value around 12-14 or 2052 if the encoders cables are swapped.
import controller
import time
print "Roboclaw Encoders Test \r\n"
#Get version string
controller.sendcommand(128,21);
rcv = controller.port.read(32)
print repr(rcv)
# Setting encoders mode to Quadrature Mode
controller.SetM1EncModeQuad()
controller.SetM2EncModeQuad()
# Read the encoders counter values and print them
enc1 = controller.readM1encoder()
enc2 = controller.readM2encoder()
print "Encoder 1 before reset : ", enc1
print "Encoder 2 before reset : ", enc2
# Reset the encoders counter
controller.ResetEncoderCnts()
# Change the encoders mode to Absolute Mode
##print "Encoders Mode before = ", controller.readEncoderMode()
##controller.SetM1EncModeAbs()
##controller.SetM2EncModeAbs()
##print "Encoders Mode after = ", controller.readEncoderMode()
# Read the encoders counter values and print them
enc1 = controller.readM1encoder()
enc2 = controller.readM2encoder()
print "Encoder 1 after reset : ", enc1
print "Encoder 2 after reset : ", enc2
Thanks!
Inigo