Position control to multiple motors

Hello everyone,
I am using MX-28AT(2.0) motors connected in serial controlled by U2D2. I am trying to run the motors in position control mode. 3 motors are given different position commands at the same time. How to do that in C++ using sync read-write program.
Please let me know how to do that.
Thank you in advance.

1 Like

Hi Raj,

If you would like to control multiple DYNAMIXEL at the same time, but give different value all DYNAMIXEL. Use Bulk instruction. For SDK, bulk_read_write.cpp may be solution to your requirement.

Make sure you have to optimize the code according to the MX(2.0) firmware.

Hello @Yogurt_Man ,
Thank you for directing towards bulk read write, I will look into it.
Meanwhile I have some other questions,

  1. Please elaborate on optimize the code according to firmware.
  2. If I want to give goal positions of type float lets say a function generating positions as
    A* sin(w*t) , generates numbers with decimals. Whereas in C++ code there is a type conversion of int to uint. How can I give positions of type float then?
1 Like

@raj

  1. Please elaborate on optimize the code according to firmware.
  • Unfortunately, the question is bit vague for me to understand. Hope you clarify details. (Not too details, just throw me over the points only for me to help you)
  1. As far as I know, you do not have to assign the types like C++.

Just use floating numbers. But the Goal Position should be assigned as integer, not point. Maybe you should remap the value to 0 to 4096 after your formular.

@Yogurt_Man
You mentioned in your previous reply

I was wondering how can that be achieved.
And thank you for the insight regarding converting my output points from the formula into integers between 0-4096. I will try that way.

1 Like

Oh… this is my bad.

  1. Optimizing the code means that you should modify the code according to a control table of its DYNAMIXEL. For instance, the preprocessor is now defined as DYNAMIXEL-Pro series.
#define ADDR_PRO_TORQUE_ENABLE          562               
#define ADDR_PRO_LED_RED                563
#define ADDR_PRO_GOAL_POSITION          596
#define ADDR_PRO_PRESENT_POSITION       611

But you should follow the rule as MX(2.0)'s control table as below for example.

#define ADDR_PRO_TORQUE_ENABLE          64               
#define ADDR_PRO_LED_RED                65
#define ADDR_PRO_GOAL_POSITION          116
#define ADDR_PRO_PRESENT_POSITION       132
  • This is not a complete solution to code optimization. You might be required to edit more lines.

Sorry for wrongly pointing out. As I try to help out many community users here, sometime I miss what I advised.

Good day,

Ok got it.
And thank you for helping out users, it truly means so much when someone directs you to answer when you are stuck with questions.

1 Like