I have a Carbot with 4 XL-320s (ID = 1 to 4), and I modified the ROBOTIS "scan_dynamixel.ino" for my needs. See code below:
`#include // for OpenRB-150
//OpenRB does not require the DIR control pin.
define DXL_SERIAL Serial1
define DEBUG_SERIAL Serial
define MAX_BAUD 5
const int32_t baud[MAX_BAUD] = {57600, 115200, 1000000, 2000000, 3000000};
Dynamixel2Arduino dxl(DXL_SERIAL); // OpenRB-150 does not need DXL_DIR_PIN
void setup() {
// put your setup code here, to run once:
int8_t index = 0;
int8_t found_dynamixel = 0;
// Use UART port of DYNAMIXEL Shield to debug.
DEBUG_SERIAL.begin(115200); //set debugging port baudrate to 115200bps
while(!DEBUG_SERIAL); //Wait until the serial port is opened
for(int8_t protocol = 1; protocol < 3; protocol++) {
// Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
dxl.setPortProtocolVersion((float)protocol);
DEBUG_SERIAL.print("SCAN PROTOCOL ");
DEBUG_SERIAL.println(protocol);
for(index = 0; index < MAX_BAUD; index++) {
// Set Port baudrate.
DEBUG_SERIAL.print("SCAN BAUDRATE ");
DEBUG_SERIAL.println(baud[index]);
dxl.begin(baud[index]);
for(int id = 0; id < 12; id++) {
//iterate until all ID in each baudrate is scanned.
if(dxl.ping(id)) {
DEBUG_SERIAL.print("ID : ");
DEBUG_SERIAL.print(id);
DEBUG_SERIAL.print(", Model Number: ");
DEBUG_SERIAL.println(dxl.getModelNumber(id));
found_dynamixel++;
}
}
}
In the FOR Loop for pinging the DXLs, I found that I cannot use beyond 12 for the upper limit, if I want the sketch to report finding my 4 DXLs properly. If I used the usual Broadcast Limit for DXL ID, then the code kept on reporting that it could not detect any DXLs at all. A similar code for the same Carbot, but using a MKR ZERO with DXL MKR Shield, would behave normally using the Broadcast Limit. The weird thing is if I used the "usb_to_dynamixel.ino" sketch, I can use the DXL Wizard V.2 with the OpenRB-150 to detect my 4 DXLs as normal.
On another piece of code shown below - loop to set DXLs to Velocity Control mode:
// Get DYNAMIXELs information for (uint8_t i = 0; i < dxlCount; i++) { if (dxl_Car.ping(dxlIDs[i]) == true) { Serial.println("Setting Operating Mode for DXL = " + String(i)); dxl_Car.torqueOff(dxlIDs[i]); dxl_Car.setOperatingMode(dxlIDs[i], OP_VELOCITY); dxl_Car.torqueOn(dxlIDs[i]);; } else { Serial.println("Communication Error with DXL = " + String(i)); } }
Ping() would always return FALSE, but in the rest of the sketch, where I have regular Goal Velocity commands to turn the XL-320s CW or CCW, they worked fine as normal.
I don't know if these issues are particular to my specific OpenRB-150 beta test board or not. It will be interesting to see if other beta testers have the same problem. Right now, I just continue my other tests and I am going to ignore what PING() tells me!
I have a Carbot with 4 XL-320s (ID = 1 to 4), and I modified the ROBOTIS "scan_dynamixel.ino" for my needs. See code below:
`#include // for OpenRB-150
//OpenRB does not require the DIR control pin.
define DXL_SERIAL Serial1
define DEBUG_SERIAL Serial
define MAX_BAUD 5
const int32_t baud[MAX_BAUD] = {57600, 115200, 1000000, 2000000, 3000000}; Dynamixel2Arduino dxl(DXL_SERIAL); // OpenRB-150 does not need DXL_DIR_PIN
void setup() { // put your setup code here, to run once: int8_t index = 0; int8_t found_dynamixel = 0;
// Use UART port of DYNAMIXEL Shield to debug. DEBUG_SERIAL.begin(115200); //set debugging port baudrate to 115200bps while(!DEBUG_SERIAL); //Wait until the serial port is opened
for(int8_t protocol = 1; protocol < 3; protocol++) { // Set Port Protocol Version. This has to match with DYNAMIXEL protocol version. dxl.setPortProtocolVersion((float)protocol); DEBUG_SERIAL.print("SCAN PROTOCOL "); DEBUG_SERIAL.println(protocol);
}
DEBUG_SERIAL.print("Total "); DEBUG_SERIAL.print(found_dynamixel); DEBUG_SERIAL.println(" DYNAMIXEL(s) found!"); }`
In the FOR Loop for pinging the DXLs, I found that I cannot use beyond 12 for the upper limit, if I want the sketch to report finding my 4 DXLs properly. If I used the usual Broadcast Limit for DXL ID, then the code kept on reporting that it could not detect any DXLs at all. A similar code for the same Carbot, but using a MKR ZERO with DXL MKR Shield, would behave normally using the Broadcast Limit. The weird thing is if I used the "usb_to_dynamixel.ino" sketch, I can use the DXL Wizard V.2 with the OpenRB-150 to detect my 4 DXLs as normal.
On another piece of code shown below - loop to set DXLs to Velocity Control mode:
// Get DYNAMIXELs information for (uint8_t i = 0; i < dxlCount; i++) { if (dxl_Car.ping(dxlIDs[i]) == true) { Serial.println("Setting Operating Mode for DXL = " + String(i)); dxl_Car.torqueOff(dxlIDs[i]); dxl_Car.setOperatingMode(dxlIDs[i], OP_VELOCITY); dxl_Car.torqueOn(dxlIDs[i]);; } else { Serial.println("Communication Error with DXL = " + String(i)); } }
Ping() would always return FALSE, but in the rest of the sketch, where I have regular Goal Velocity commands to turn the XL-320s CW or CCW, they worked fine as normal.
I don't know if these issues are particular to my specific OpenRB-150 beta test board or not. It will be interesting to see if other beta testers have the same problem. Right now, I just continue my other tests and I am going to ignore what PING() tells me!