Read-Write in serial communication

Use the following template to help create your post:

  1. What model of servo are you using?
    MX-28AT(2.0)

  2. Describe your control environment. This includes the controller or interface, and any power source.
    U2D2 and MATLAB. SMPG power source

  3. Specify the operating mode for applicable models, and any firmware settings you are using.
    firmware v43 , position control mode

  4. Include pictures if possible.

  5. Include a full description of the issue.
    I am trying to run 3 motors in serial communication using MATLAB. I am giving positions with different amplitude using sine function (A * sin(2pif*t) ) . My issue is when am trying to write goal position and read present position of motor at the same time, time to reach goal position is increased drastically. Why is this happening so and how can I troubleshoot this issue?
    Baud rate was set to 57600.

I’ve experienced a similar issue. The read/write process takes several milliseconds when called from Matlab with the SDK. Use the functions tic and toc with the interest functions in between to determine how long is that i.e.:

tic
write4ByteTxRx(port_num, PROTOCOL_VERSION, ID, ADDR_GOAL_POSITION, goal_position)
toc

When you read and write in the same loop you spend ~twice time in communication what causes the overall code to work ~half the original speed. Now with respect to the troubleshoot you will have to include your sample time in your calculus and/or to speed up the communication using faster baud rates.

1 Like