This function writes data to a specific memory address of DYNAMIXEL with a specific ID.
NOTE
DXL_MAX_NODE
: 16
DXL_MAX_NODE_BUFFER_SIZE
: 12
#include <Dynamixel2Arduino.h>
SoftwareSerial soft_serial(7, 8); //RX,TX
#define DXL_SERIAL Serial
#define DEBUG_SERIAL soft_serial //define proper serial debugging port for the board
const uint8_t RS485_DIR_PIN = 2; //DYNAMIXEL Shield
ParamForSyncWriteInst_t sync_write_param;
const int DXL_DIR_PIN = 2;
int32_t velocity = 0;
Dynamixel2Arduino dxl(DXL_SERIAL, RS485_DIR_PIN);
void setup() {
dxl.begin(1000000);
dxl.scan();
sync_write_param.addr = 104; //Goal Velocity of DYNAMIXEL-X series
sync_write_param.length = 4;
sync_write_param.xel[0].id = 1;
sync_write_param.xel[1].id = 3;
sync_write_param.id_count = 2;
dxl.torqueOff(1);
dxl.setOperatingMode(1, OP_VELOCITY);
dxl.torqueOn(1);
dxl.torqueOff(3);
dxl.setOperatingMode(3, OP_VELOCITY);
dxl.torqueOn(3);
memcpy(sync_write_param.xel[0].data, 200, sizeof(velocity));
memcpy(sync_write_param.xel[1].data, -200, sizeof(velocity));
dxl.syncWrite(sync_write_param);
}
void loop() {
}