Controlling Dynamixel 12A by Sending Packets Serially

Introduction: Controlling Dynamixel 12A by Sending Packets Serially

DYNAMIXEL 12A

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Components Required

HARDWARE:

1.Dynamixel 12A or any Dynamixel motor

2.USB to Dynamixel.

SOFTWARE:

1.Robotis Dynamixel wizard.

2.Python ---Serial package installed

Step 2: Introduction to Dynamixel 12A

Dynamixel motors are highly precise and mostly used in Robotics. Every Dynamixel motor has STM microcontroller inside. You can read current torque, voltage, current draw, temperature, position, etc.., from Dynamixels Motors.

Specifications of Dynamixel 12A:

Operating Voltage --12v

Weight--55g

Max current --900mA

Stall Torque--15.3 Kg.cm

Step 3: Communicating/controlling Dynamixel 12A

  • Dynamixel 12A isn't like normal servo motors that have 3pin GND, PWM, VCC, give power supply and PWM signal and control the motor.
  • We can control Dynamixel motors using Half Duplex UART communication protocol.

What is Half Duplex Communication Protocol?

Half-duplex data transmission means that data can be transmitted in both directions on a signal carrier, but not at the same time.

Now we learn about Protocol 1.0 for Dynamixels from Robotis to control Dynamixel motors.

  • You can communicate with Dynamixel motors by sending packets from your laptop/microcontroller like Arduino,r-pi, etc.., to the microcontroller that is present inside the Dynamixel motors.
  • Every Dynamixels have ID's that can be modified.
  • A packet is nothing but Set of bytes.

Incase of Dynamixel protocol 1.0 you will have two types of packets

  • Instruction packets
  • Status packets

Instruction Packet is the command data sent to the Device.

Instruction packet look like this:

Header1,Header2,ID,Length,Instruction,Param 1…Param ,NChecksum

0xFF , 0xFF ,ID ,Length ,Instruction Param 1…Param, NCHKSUM

Instruction byte tells what to do, whether to read data or write to the Dynamixel motor.

CONTROL TABLE OF A DYNAMIXEL MOTOR.-The Control Table is a structure that consists of multiple Data fields to store status or to control the device.

Read more about Control table HereControl Table Robotis.

We can access data in the control table from its address and also we can write.

Step 4: Writing Goal Position to Dynamixel Motor

Instruction Packet to Write Goal position

every packet starts with a header

H1 H2 ID LEN INST P1 P2 P3 CKSM

0xFF, 0xFF, 0x01, 0x05, 0x04, 0x1E, 0xF4 ,0x01, 0xE2

LEN-instruction byte+p1+p2+p3+chk sum=5 bytes

ID=Dynamixel motor ID 1-you can set dynamixel id using robotis dynamixel wizard software

INST=reg write-specifying that your'e writing to the motor.

P1=Starting address of the Data-In the control table Goal position is having an address 30(0x1E in hexadecimal).

P2=lower byte of data

P3=higher byte of data

Checksum calculation will be explained shortly......................

If you send the above packet to Dynamixel Serially using USB2Dynamixel, Dynamixel motor goal position will be set to 500.

Step 5: PYTHON CODE

#Developed by Madhu. Last update on 19/07/2019

import Serial

import time

ser=serial.Serial('com36','57142')

#change com port accordingly,my dynamixel motors baud rate is 57142,you can set it using Dynamixel wizard software.

while(1):

gp1=input('enter ID1 goal position(0-1023)')

l=gp1&255 #low byte

h=(gp1>>8)&255 #high byte

li=[0xff,0xff,0x01,0x05,0x04,0x1e,l1,h1]

#check sum calculation

crc=sum(li[2:])

low1=crc & 255

chksum=255-low1

li.append(chksum) #adding check sum

a=bytearray(li) #converting list into bytearray

ser.write(a) #Serially send using usb2dynamixels.

time.sleep(0.5)

#Copy the code paste in python IDE. Install pyserial package. connect usb2dynamixel's USB side to laptop's USB port and another end to Dynamixel motor. Give an external 12v supply to USB2DYNAMIXEL.

RUN the code, enter the goal position value. See motor running.

Be the First to Share

    Recommendations

    • LED Strip Speed Challenge

      LED Strip Speed Challenge
    • Sculpting Challenge

      Sculpting Challenge
    • Clocks Contest

      Clocks Contest

    Discussions