beautypg.com

Dynamixel dx-116 – Robotis DX-116 User Manual

Page 31

background image

30

English Translation by: Tribotix Pty Ltd

www.tribotix.com

DYNAMIXEL

DX-116

TXD_SHIFT_REGISTER_EMPTY_BIT.

An example program to send an Instruction packet:-

LINE 1

PORT_485_DIRECTION = TX_DIRECTION;

LINE 2

TxDByte(0xff);

LINE 3

TxDByte(0xff);

LINE 4

TxDByte(bID);

LINE 5

TxDByte(bLength);

LINE 6

TxDByte(bInstruction);

LINE 7

TxDByte(Parameter0); TxDByte(Parameter1); …

LINE 8

DisableInterrupt(); // interrupt should be disabled

LINE 9

TxDByte(Checksum); //last TxD

LINE 10

while(!TXD_SHIFT_REGISTER_EMPTY_BIT); //Wait till last data bit has been

sent

LINE 11

PORT_485_DIRECTION = RX_DIRECTION; //485 direction changed to RXD

LINE 12

EnableInterrupt(); // enable interrupt again

Please note the important lines (LINE 8 to LINE12).

Line 8 is necessary since an interrupt here may cause a delay longer than the

return delay time and corruption to the front of the status packet may occur

Byte to Byte Time

The delay time between bytes when sending the instruction packet. If the delay

time is over 100ms, then recognise it as a communication problem and wait for

header(0xff 0xff) of the packet again.

0xFF

0xFF

ID

Length

Byte To Byte Time