Example Code

Robotis Dynamixel Actuators in LabVIEW

Code and Documents

Attachment

Overview


Servo actuators are a common staple when it comes to creating robotic applications. The most common servo actuators are the PWM servos found in most hobby planes, boats, and cars. These actuators usually offer just position control with limited range of motion. There are also "smart" actuators out on the market that offer precise control and feedback. One of these servo actuators available is the Robotis Dynamixel.

Robotis Dynamixel Acatuators

Here, we present information on the serial break down, LabVIEW programming, and universal Sync Write sample code to get anyone up and running with Dynamixels (Figure 1.1) and LabVIEW. This documents presents the structure in terms of LabVIEW but, the information can also be found in general programming terms in the RX-10,28,64 manuals.

Figure 1.1: Dynamixel actuator.

Robotis is a South Korean company that makes many varying sized actuators based on torque and function. These motors are relying on a daisy chain method of communication (Figure 1.2), link from motor to motor passing the information to respective motor. These motors also have position, velocity, and compliance control to name a few. These motors can also return information such as temperature, load, voltage etc. The servos have finite control to become a joint or continuous rotation for a wheeled vehicle.

We begin by sharing LabVIEW VIs to easily control any number of Dynamixel RX-Series actuators, and then discuss how we achieved this implementation. We use the Sync Write method as documented by Robotis.

Figure 1.2: Overview of communication with Dynamixel actuators.

Front Panel

The Front panel is the only portion of this VI that is needed to be to achieve communication. The Front panel contents are as follows:

    • Orange Numeric Control: Input the number of desired Dynamixel servos  to be used(1-254)
    • Red Array of Clusters: Boolean Dial ON allows for either Dial input or Manual position input (degrees). Numeric Input: Dynamixel servo ID number
    • Blue I/O Control and Numeric Control: Selector for VISA Serial Communication (COM) Ports and Input for Dynamixel Baud Rate (applies to all)
    • Purple String Indicator: Displays Dynamixel  Instruction Packet (Hexadecimal)
    • Stop Ends program and closes Serial Communication

Figure 2.1: Front panel of the Dynamixel-RX Sync Write VI

The software theoretically supports up to 254 Dynamixel actuators; we only tested up to 22. The code natively changes the size of the array of clusters with an input of the Number of Dynamixels control (Figure 2.2).

Figure 2.2: Automatic resizing of VI controls based on the specified number of Dynamixels to control.

 

Block Diagram

3.1 Top-level diagram

The Block diagram (Figure 3.1.1) continually builds and updates the serial communication strings to be sent out to the Dynamixels. There are three main sub VI's: Position, Header, and CheckSUM. Each of these will be described in detail in the following sections. The main while loop accounts for the Number of Dynamixels present to filter the Array size that is fed into the Position Sub VI. The Position VI is indexed by the For Loop dependent on the filtered array size. This allows for the expandability or subtraction of the needed Dynamixels to be addressed for the Sync Write. The data is passed to Header and CheckSUM as the below diagram illustrates. The data finally passes to the VISA Write to be sent to Serial peripheral / Dynamixels. The Property nodes maintain the dynamic resizing of the control arrays and width of the output serial indicator.

Figure 3.1.1: Block diagram of the Dynamixel Sync Write VI

 

The top-level VI is comprised of three sub-VIs, shown below (Figure 3.1.2):

Figure 3.1.2: Sub-VIs used in the Dynamixel Sync Write VI

 

3.2 Position Sub-VI

This sub VI reads the position values from either the Dial Input or Manual Input for each ID and pareses the data into the specific parameters that are needed to control position on the Dynamixel.

Figure 3.2.1: Position sub-VI front panel.

 

Figure 3.2.2: Position sub-VI block diagram.

The data is unbundled by name when it is needed. The red square is a True/False case statement that chooses the input based upon the Dial ON Boolean switch. The Blue box controls the scaled angle and byte control (explore in more detail below). The orange box is the final stage in the position sub VI. The data passed through a type cast to flatten the data to a string. Each parameter is concatenated into an array in the order that will be found in the final serial string. The concatenated string and the pre-type cast data is packed into cluster to be sent to the next two VI's for use.

The sub green box (Figure 3.2.3) defines motor position in real world terms.  The Dynamixel movement is defined as travel from 0-1023 (10 bit number). The dial or manual input supplies the angle in the form of Degrees. This value must relate in order to mix real values with Dynamixel values. That value is multiplied by a conversion number 3.41. This determined by the max motor position value of 1023 (Figure 3.2.4) divided by the max angle of 300.

Figure 3.2.3: Breakdown of the Position sub-VI

 

Figure 3.2.4: Diagram of position values of the Dynamixel actuator.

The Dynamixel Goal Position Instruction has to have two bytes present, so the purple box pareses the position input into the high and low bytes.  In other terms the quotient & remainder splits the decimal input number into usable integer numbers to be feed to the motors. The range 0-1023 is a 10 bit unsigned integer, but the motor when addressed wants two, 8 bit bytes of information. This 10 bit integer is split up into two parts; the following example shows how this is done.

Example 1: If the input was 150 degrees or 511.5, what would be the Low and High bytes?

Solution: The value 511.5 will be divided by 256 which is the same number of values that an unsigned 8 bit integer can contain (0-225). 511.5 / 256 = 1.998. This result will be split into an integer, 1, the High byte and the decimal, .998, the low byte.  The decimal .998 must be scaled to become an unsigned 8 bit number. 0.998 x 256 = 255.5. Finally the resultant needs to be an integer therefore an absolute value is taken to retrieve the lower byte 255. Therefore the Low byte is 255 and the high byte is 1. (Hex - FF01)

3.3 Header sub-VI

This VI builds the header that is attached to the front of position data. It also passes through data from the position sub VI.  The front panel (Figure 3.3.1) input looks different than the output on the Position Sub VI due to the For Loop in the main VI indexes the cluster into a 1D array.

Figure 3.3.1: Header sub-VI front panel.

 

Figure 3.3.2: Header sub-VI block diagram.

To the right of the dotted line in the block diagram (Figure 3.3.2), the structure of the header sub VI is similar to position sub VI, the data is bundled/unbundle, flattened, concatenated, and passed to final bundled output. Two things to take notice the build array in line with the cluster output and the For Loop. The build array allows for easy addition later in the in the CheckSUM sub VI. The For Loop indexes the ID, L Byte, and H Byte per Dynamixel being used.

The left of the dotted line is where the Sync Write header parameters are calculated and built. The basic structure of the sync write command is as follows (Figure 3.3.3):

 
 

START: (Hex 0XFF 0XFF) The double FF initializes communication between the COM and the Dynamixels.  
ALL: Broadcast ID (Hex-0XFE
) to all Dynamixels, disables return of status packets
T.LEN: Total Length, Uses the formula (NxL)+N+4, where N is number of Dynamixels, L is the length of the Control Table Bytes, and 4 is the length of the header bytes to be used by the checksum (Manual uses the formula (L+1)xN+4 this achieves the same solution as the formula used).
SYNC: The Sync Write (Hex 0x83) defines the command being used
INSTRUCTION: Starting Byte Address from Control Table (Goal Position (L) 0X1E).
LENGTH: L is the length of the Control Table bytes used
ID P1 P2 IDN P1 P2: Dynamixel ID and Position Control (Position sub VI)
C.SUM: (CheckSUM sub VI)

Figure 3.3.3: Structure of a Sync Write instruction.

The control table (Figure 3.3.4) can be found on page 21 of the RX-28 Manual. This table houses all the Hex addresses of the possible commands to be sent to a Dynamixel. Remember L is defined by the number of addresses that is being accessed from the control table. For example if L is a LENGTH of 2 and INSTRUCTION is set to 0X1E, Goal Position (L) followed by Goal Position (H) would only be accessed. 

Figure 3.3.4: Control table for Dynamixel actuator.

 

3.4 CheckSum sub-VI

The checkSUM sub VI is in place to check if the proper information is sent to the Dynamixels. It is a summation of all data other than the Initialize FF FF addresses.  The number is attached to the end of the of the serial write.

Figure 3.4.1: Checksum sub-VI front panel.

 

Figure 3.4.2: Checksum sub-VI block diagram.

The checkSUM applies array summations to the  built array from Header sub VI and the Indexed data from the Position sub VI. Each is added together and applied to the not operator to invert the final output.

See Also

Robotis Bioloid CM-5 and AX-12 actuators in LabVIEW

 

Author: RJ Gross

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
marioequi
Member
Member
on

Muchas gracias por el código me sirve bastante

Contributors