hello everyone;
I currently have an OpenCR1.0 card.
I’m trying to program this board with the Arduino IDE. But I’m facing an interesting problem.
-If I load any of the DynamixelWorkbench examples, there is no problem, but if I load a code I created myself —OpenCR1.0 is no longer recognized by the Arduino ide and I get the following errors.
Fail to open port 1 : COM32
Fail to jump to boot
If I put the OpenCR card into Recovery mode (Sw2 + Reset button) and load any of the Dynamixelworkbench examples. It doesn’t error anymore. But until I try to load the sample code I created again.
Why could this code cause this error?
#include <DynamixelWorkbench.h>
#if defined(__OPENCM904__)
#define DEVICE_NAME "3" // Dynamixel on Serial3(USART3) <- OpenCM 485EXP
#elif defined(__OPENCR__)
#define DEVICE_NAME ""
#endif
#define BAUDRATE 57600
#define DXL_ID_1 1
#define DXL_ID_2 2
DynamixelWorkbench dxl_wb;
uint8_t dxl_id[2] = { DXL_ID_1, DXL_ID_2 };
int32_t goal_position[2] = { 0, 1023 };
const uint8_t handler_index = 0;
void setup() {
Serial.begin(57600);
// while(!Serial); // Wait for Opening Serial Monitor
const char *log;
bool result = false;
uint16_t model_number = 0;
result = dxl_wb.init(DEVICE_NAME, BAUDRATE, &log);
if (result == false) {
Serial.println(log);
Serial.println("Failed to init");
} else {
Serial.print("Succeeded to init : ");
Serial.println(BAUDRATE);
}
for (int cnt = 0; cnt < 2; cnt++) {
result = dxl_wb.ping(dxl_id[cnt], &model_number, &log);
if (result == false) {
Serial.println(log);
Serial.println("Failed to ping");
} else {
Serial.println("Succeeded to ping");
Serial.print("id : ");
Serial.print(dxl_id[cnt]);
Serial.print(" model_number : ");
Serial.println(model_number);
}
result = dxl_wb.jointMode(dxl_id[cnt], 0, 0, &log);
if (result == false) {
Serial.println(log);
Serial.println("Failed to change joint mode");
} else {
Serial.println("Succeed to change joint mode");
}
}
result = dxl_wb.addSyncReadHandler(handler_index, "Present_Current", &log);
if (result == false) {
Serial.println(log);
Serial.println("Failed to add sync read handler");
}
result = dxl_wb.addSyncReadHandler(handler_index, "Present_Velocity", &log);
if (result == false) {
Serial.println(log);
Serial.println("Failed to add sync read handler");
}
}
void loop() {
const char *log;
bool result = false;
int32_t present_position[2] = { 0, 0 };
int32_t present_current[2] = { 0, 0 };
int32_t present_velocity[2] = { 0, 0 };
result = dxl_wb.syncWrite(handler_index, &goal_position[0], &log);
if (result == false) {
Serial.println(log);
Serial.println("Failed to sync write position");
}
result = dxl_wb.syncRead(handler_index, &log);
if (result == false) {
Serial.println(log);
Serial.println("Failed to sync read data");
}
result = dxl_wb.getSyncReadData(handler_index, &present_position[0], &log);
if (result == false) {
Serial.println(log);
}
result = dxl_wb.getSyncReadData(handler_index, &present_current[0], &log);
if (result == false) {
Serial.println(log);
}
result = dxl_wb.getSyncReadData(handler_index, &present_velocity[0], &log);
if (result == false) {
Serial.println(log);
}
Serial.print("[ID ");
Serial.print(dxl_id[0]);
Serial.print(" ]");
Serial.print(" Goal Position : ");
Serial.print(goal_position[0]);
Serial.print(" Present Position : ");
Serial.print(present_position[0]);
Serial.print(" Present Current : ");
Serial.print(present_current[0]);
Serial.print(" Present Velocity : ");
Serial.print(present_velocity[0]);
Serial.print(" [ID ");
Serial.print(dxl_id[1]);
Serial.print(" ]");
Serial.print(" Goal Position : ");
Serial.print(goal_position[1]);
Serial.print(" Present Position : ");
Serial.print(present_position[1]);
Serial.print(" Present Current : ");
Serial.print(present_current[1]);
Serial.print(" Present Velocity : ");
Serial.println(present_velocity[1]);
// Set new goal positions for the servos (you can modify these values)
goal_position[0] = 512;
goal_position[1] = 256;
}
Not:I would like to give additional information that may be useful for a better understanding of the problem:
-This problem especially occurs when you load Dynamixel related samples. In general, the codes installed for Dynamixel sometimes work and sometimes cause such problems.
-One more additional information: If this dynamixel-related code is installed on the card, when I give additional power to the card (from the SMPS port) and plug the USB port into the computer, the computer does not detect the USB port. But if I remove the power from the SMPS port and plug in the USB, the computer detects a USB port, but the code still cannot be loaded. .
Does anyone know the cause of this problem?