Need matlab code for negative rotation of Dynamixel AX-12+

I'm currently working on PID control of Dynamixel AX-12+ servos. Things are going fairly well at the moment except that I seem to only be able to command the servos to rotate in ONE DIRECTION ONLY.

I'm programming the servos using Matlab and interfaced using USB2Dynamixel. The matlab code for controlling the speed of the servos are as follows:

calllib('dynamixel','dxl_write_word', id, address, required_speed)

where address = 32 (from control table, note that this refers to the lower byte only?)

I try to set the required speed to be of maximum magnitude i.e. 1023; The problem now is setting it to -1023 doesn't get it to rotate in the opposite direction.
(Note: setting the speed to -1023 using Dynamixel Configurator (a separate program) does make it turn in the opposite direction).

Re: Need matlab code for negative rotation of Dynamixel AX-12+

That's because -1023 is not a valid value. Any negative goal position value entered in the configurator will cause the motor to move to goal position zero.

Check out the following link. DualDynamixel180Phase allows you to control 2 AX-12s in opposite directions offset by phase. For example to control 2 dynamixels moving in opposite directions use. DualDynamixel180Phase(id, theta, speed)http://www.agaverobotics.com/product...urce-code.aspx

Simply type the following in the command window after adding the files to Matlab.

Code:

id=[1,2]
DualDynamixel180Phase(id, sin(30), 512)

Where id is an array of ids, sine(30) is the degrees to move the Dyanmixels from center (512) and speed is how fast (0 to 1023).

To move one you could actually do this...

Code:

id=[1]
DualDynamixel180Phase(id, sin(30), 512)

There's another other SyncWrite file in the download provided that demos hows to build a SyncWrite command in Matlab.

I'm not sure how you plan to implement PID control, I need more information. The AX-12 already has a control system and the ability to query the control table registers. Error is controlled by the compliance properties.

Re: Need matlab code for negative rotation of Dynamixel AX-12+

Thanks for the replies. I discussed the problem with my project supervisor and from the entry in the manual regarding the goal speed direction, we replaced -1023 with 1023+4*256 = 2047; that seemed to do the trick.