Driving the XL_320 with a custom C++ library

Hi,

I am trying to operate an XL_320 servo via the GPIO header of a Raspberry Pi 4. I do not use a Robotis interface, just a level shifter to operate the Servo with 5V logic and a line driver (SN74LS241N) to convert the serial communication to the half-duplex protocol (TTL) used by the servo. I then use a custom-made C++ library to control the servo at 1MHz baud rate. The servo is powered by a table-top adjustable power supply set at 7.40V.

I will not extend myself on the Raspberry setup and the wiring here since this part seems to work: I can control the servo and get the correct output from a ping command. For all the following test the servo has been factory reset and the return delay time set to 100 (200µs).

Here is the digital sequence of a ping command:


Legend: Line 1 is TX, Line 2 is RX, Line 3 is TX_ENABLE and Line 4 is the Data line of the Servo.

And here is the software output from the library upon a ping command, which seems all fine:

→ |    Header   | ID | Size  | In |  CRC  |
  | FF FF FD 00 | 01 | 03 00 | 01 | 19 4E |

Read 14 bytes.
← |    Header   | ID | Size  | In | Er | Param    |  CRC  |
  | FF FF FD 00 | 01 | 07 00 | 55 | 00 | 5E 01 1E | 15 47 |
Result: 5E 01 1E
Model 350 (30)

I can also write in the EEPROM and the RAM registers without any trouble: set the LED color, change position etc.

Now, the trouble come when I start to use the read command (0x02): the device always return an error 0x07, whatever the register I try to read (EEPROM or RAM). For instance:

→ |    Header   | ID | Size  | In | Param |  CRC  |
  | FF FF FD 00 | 01 | 05 00 | 02 | 02 00 | 7F 29 |

Read 11 bytes.
← |    Header   | ID | Size  | In | Er |  CRC  |
  | FF FF FD 00 | 01 | 04 00 | 55 | 07 | B0 8C |
Result: Error (7)

From the Dynamixel Protocol 2.0 documentation this means that I attempt to read a value in an Address that is Write Only or has not been defined, but that sound strange to me since it have the exact same response for all read commands, whatever the address (LED status, position, etc).

Second, I have tried to set the Status Return Level to 1 instead of the default value of 2, and in this case the ping commands still works but for read commands no status packet is returned. For instance with a read on the LED register (0x18):


Legend: Line 1 is TX, Line 2 is RX, Line 3 is TX_ENABLE and Line 4 is the Data line of the Servo.

Am I doing something wrong ? Is there a setting that I have missed ? Or is my device broken ?

Thanks for your advices.

Hi @RaphaelCandelier

Please see the command detail of the Read instruction.
You need at least four byte params in the Read instruction.

Thanks.

Hi @willson

Thanks for the hint, I added the number of parameters for the status packet and it works flawlessly now.

Regards,