Hi. I want to test my 2 Maxon motor model of M120675 003 and 036 with ODESC 3.6 dual drive .but I am facing my problem to interface my both motor to drive . As I tried to connect drive with Arduino Uno yet I am facing the same problem as the motor is not running , as the code is running properly. Below is the complete code as i have attached the Arduino Tx & Rx pin to driver pin GPIO pin 1 & 2. the motor hall sensor wires are connected to drive A,B,Z<5v and GND pins.
Note: I have just used 1 motor to check it is running or not. below the code is for 1 motor. For releasing the brake of motor i have attached the brake wires to a separate power source which I have given 24V. And i have also tried to interface the dual drive to pycharm as same code is running but the motor is not.
post edited to include [CODE] tags—Moderator
Note: I have just used 1 motor to check it is running or not. below the code is for 1 motor. For releasing the brake of motor i have attached the brake wires to a separate power source which I have given 24V. And i have also tried to interface the dual drive to pycharm as same code is running but the motor is not.
C++:
#include <ODriveUART.h>
#include <SoftwareSerial.h>
SoftwareSerial odrive_serial(1, 2); // RX, TX
unsigned long baudrate = 19200; // Must match what you configure on the ODrive
ODriveUART odrive(odrive_serial);
void setup() {
void loop() {
odrive_serial.write("Test");
while (odrive_serial.available()) {
char c = odrive_serial.read();
Serial.print(c);
}
//}
//Serial.println("Waiting for ODrive...");
//while (odrive.getState() == AXIS_STATE_UNDEFINED) {
//delay(100);
//}
Serial.println("found ODrive");
Serial.print("DC voltage: ");
Serial.println(odrive.getParameterAsFloat("vbus_voltage"));
Serial.println("Enabling closed loop control...");
while (odrive.getState() != AXIS_STATE_CLOSED_LOOP_CONTROL) {
odrive.clearErrors();
odrive.setState(AXIS_STATE_CLOSED_LOOP_CONTROL);
delay(10);
}
Serial.println("ODrive running!");
}
void loop() {
float SINE_PERIOD = 2.0f; // Period of the position command sine wave in seconds
float t = 0.001 * millis();
float phase = t * (TWO_PI / SINE_PERIOD);
odrive.setPosition(
sin(phase), // position
cos(phase) * (TWO_PI / SINE_PERIOD) // velocity feedforward (optional)
);
ODriveFeedback feedback = odrive.getFeedback();
Serial.print("pos:");
Serial.print(feedback.pos);
Serial.print(", ");
Serial.print("vel:");
Serial.print(feedback.vel);
Serial.println();
}
Last edited by a moderator: