Sorry for the double post. I posted this in the wrong area before.


Hi, so on my Raspberry Pi, I'm reading the position on my AX-12A (via instruction packet) of servo 01 and it comes back and tells me that "Present Position" is 770 (decimal) when in fact the present position is 818 (decimal, 0x332).


===========================
I position the servo with the following code:
===========================


import serial
import time
import RPi.GPIO as GPIO
channel = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.OUT)
ser = serial.Serial("/dev/ttyS0", baudrate=1000000, timeout=3.0)


# 0x332 = 818 (decimal)
GPIO.output(channel, GPIO.HIGH)
ser.write(bytearray.fromhex("FF FF 01 07 03 1E 32 03 78 00 29"))
time.sleep(0.1)
GPIO.output(channel, GPIO.LOW)
time.sleep(3)

ser.close()
GPIO.cleanup()


===================================
and then read the position with the following code:
===================================


import serial
import time
import RPi.GPIO as GPIO


channel = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.OUT)
ser = serial.Serial("/dev/ttyS0", baudrate=1000000, timeout=3.0)
sleep_time = 2
time.sleep(sleep_time)


### READ CURRENT POSITION
GPIO.output(channel, GPIO.HIGH)
ser.write(bytearray.fromhex("FF FF 01 04 02 24 02 D2"))
GPIO.output(channel, GPIO.LOW)
x = ser.readline()
print(x, ' is POSITION')


ser.close()
GPIO.cleanup()


===============================


Funny thing is, when I set the servo position to 1023 (decimal) or 0 (decimal), it reads those positions accurately. Is there a reason that it's off by 48 (818 - 770) when reading that position? I'm okay if you tell me that the servo is buggy and that I have to live with that discrepancy. I'm just curious if I need to update the firmware or do something else to get an accurate reading.


My Setup:
Raspberry Pi 3B
AX-12A
Using Breadboard with octal tri-state buffer (74LS241)
UART


Sincerely,
Calvin