Results 1 to 8 of 8

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

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

    Hello everyone,

    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).

    Thanks in advance

  2. #2

    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.
    Last edited by MikeG; 03-10-2010 at 07:02 AM.

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

    The AX-12 manual isn't very clear on that specific entry. Use the sign convention as documented in the "Present Load" entry:

    bits 0 - 9 : 10 bit value
    bit 10 : 0 for CCW, 1 for CW

    - Jon
    "The best way to predict the future is to invent it." - Alan Kay, inventor of Smalltalk

  4. #4

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

    Sorry, read your post wrong. I was thinking goal position. I was helping someone else... and got confused.. old age.

    Jon is right, that part of the manual is unclear. You want the section on Goal Speed setting. It's on page 17-18. But that only comes into play in endless turn mode.
    Last edited by MikeG; 03-10-2010 at 07:42 AM.

  5. 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.

  6. #6

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

    Create a mask 1024 (0x400) and XOR the mask with the speed magnitude. You can change direction while keeping the speed the same. It just flips the 10th bit.

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

    Hi,
    Is it correct to say that a value greater than 2^10 signifies a negative rotation?

  8. #8
    Join Date
    Aug 2008
    Location
    Iowa City, IA
    Posts
    390
    Rep Power
    43

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

    No. Only if bit 10 is set which it is not for all values greater than 2^10.

    [ame="http://www.youtube.com/watch?v=qdFmSlFojIw"]YouTube- Binary Numbers in 60 Seconds[/ame]

Thread Information

Users Browsing this Thread

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

Posting Permissions

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