WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

send

Send a sequence of bytes to one, or all, AX12 servos.
The bytes sent to the servos will be: 0xff, 0xff, id, your data, checksum.
Note that by using ax12_BROADCAST_ID as the id the message will be broadcast to ALL servos.
Syntax
DynamixelAX12Driver. send(id,len,data)
 
Parameters
TypeNameDescription
'id'
The ID of the servo you want to send the command to - or ax12_BROADCAST_ID for all.
'len'
The number of bytes to be sent.
'data'
The start address of the data bytes to be sent.
Returns
None
Example
Assuming you have called your driver 'ax12_driver' in Project Designer and that you want to set the baud rate of all servos to 115200 baud.
Since all of the servos should be working at the same baud rate then we will broadcast the message to all servos.
According to the servo manual we can see that the baud rate parameter is calculated as: (2000000/baud) - 1. For 115200 baud this = (2000000 / 115200) - 1 = 16.36 which, when rounded, is 16.
// The data to send: write, baud, 16
uint8_t data[] = { ax12_WRITE, ax12_BAUD, 16 };
// Broadcast to all servos
ax12_driver.send( ax12_BROADCAST_ID, sizeof(data), data );
NB changing the baud rate is not normally recommended - the main reason being that the UART will still be communicating at the old baud rate so the servos will stop responding. Yes - you could also change the uart to the new baud rate. It just gets very confusing if you don't keep a written note as to what baud rate, and what ID number, you have allocated to each servo and there is no way to reset them back to their defaults.
To make life easier the AX12.h file defines a set of macros for setting individual values on a servo. These macros all start with 'ax12_set_'.
For example to set the position of servo1 to a value of 100 then:
ax12_set_GOAL_POSITION(&servo1, 100);
However: since the AX12 is an actuator then it is recommended that you use the common actuator commands instead:
servo1.setSpeed(100);

 

 

Valid XHTML 1.0 Transitional