Results 1 to 4 of 4

Thread: AX-12A - When Reading Present Position Getting Inaccurate Reading

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. Smile AX-12A - When Reading Present Position Getting Inaccurate Reading

    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

  2. #2

    Re: AX-12A - When Reading Present Position Getting Inaccurate Reading

    I would not expect ser.readline() to return a proper response. The response packet has a very similar format as the command packet, and needs to be appropriately decoded.

  3. Re: AX-12A - When Reading Present Position Getting Inaccurate Reading

    Thanks JWatte, I'm only familiar with the Status and Instruction packets, and I'm not familiar with the "response" and "command packets." Are those different types of packets? Also, ser.readline() does return accurate numbers for everything else (temp, angular velocity, voltage, load torque, etc.).

    Thank you,
    Calvin

  4. #4

    Re: AX-12A - When Reading Present Position Getting Inaccurate Reading

    A status packet is a response with zero data. They're pretty much the same thing.
    A command packet and an instruction packet are names for the same thing, too.

    It can't possibly be the case that the default Serial object in Python knows how to decode the response (status) packet.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Servo reading position and lock position CW
    By mkanon in forum DYNAMIXEL & Robot Actuators
    Replies: 5
    Last Post: 03-30-2013, 05:10 PM
  2. Question(s) Reading Wrong Position Values from AX-12 (C++)
    By robotpanda in forum Software and Programming
    Replies: 4
    Last Post: 05-12-2012, 10:30 AM
  3. Question(s) Reading Dynamixel's position in Wheel Mode
    By pauljurczak in forum DYNAMIXEL & Robot Actuators
    Replies: 3
    Last Post: 10-28-2011, 04:04 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •