Want to run the Maxon motor with ODESC3.6 dual drive but facing problems

Thread Starter

ADBLED

Joined Dec 24, 2024
8
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.

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();
}
post edited to include [CODE] tags—Moderator
 
Last edited by a moderator:

Sensacell

Joined Jun 19, 2012
3,767
Have you verified that the serial data is being transmitted correctly? baud rate? command structure? polarity etc.- using an oscilloscope?
Have you verified the sensor signals on the board- with an oscilloscope?
 

Thread Starter

ADBLED

Joined Dec 24, 2024
8
Have you verified that the serial data is being transmitted correctly? baud rate? command structure? polarity etc.- using an oscilloscope?
Have you verified the sensor signals on the board- with an oscilloscope?
baud rate and command structure both are verified .and no i haven't verified the sensor signal with an oscilloscope . can you tell how i should verify it using an oscilloscope.
 

Sensacell

Joined Jun 19, 2012
3,767
baud rate and command structure both are verified .and no i haven't verified the sensor signal with an oscilloscope . can you tell how i should verify it using an oscilloscope.
HOW did you verify the commands? - I mean in the real world, not just the code?


Probe the signals from the hall sensors with the scope, do you see the signals change when you rotate the shaft? on all 3?
 

Thread Starter

ADBLED

Joined Dec 24, 2024
8
HOW did you verify the commands? - I mean in the real world, not just the code?


Probe the signals from the hall sensors with the scope, do you see the signals change when you rotate the shaft? on all 3?
what do you mean by real world? and i have another issue that now i am not attaching my driver to ardunio ..i just want it to connect to PC through pycharm python code i want to operate my motor and below is the code so can you guide me that as my code is transfering to my odesc3.6 dual drive or not as code is running properly but how i know that my driver is recognizing the code.
import odrive
from odrive.enums import *
import time

# Find an ODrive
print("Finding an ODrive...")
odrv0 = odrive.find_any()
print("ODrive found: ", odrv0)

# Set the motor parameters
odrv0.axis0.controller.config.control_mode = CONTROL_MODE_POSITION_CONTROL
odrv0.axis0.controller.config.pos_gain = 100 # Set position gain (tune as necessary)

# Function to run the motor forward
def run_motor_forward(duration):
print("Running motor forward...")
odrv0.axis0.controller.move_to_pos(100000) # Move to position (in encoder counts)
time.sleep(duration)
odrv0.axis0.controller.move_to_pos(0) # Move back to the starting position

# Function to run the motor backward
def run_motor_backward(duration):
print("Running motor backward...")
odrv0.axis0.controller.move_to_pos(-100000) # Move to negative position
time.sleep(duration)
odrv0.axis0.controller.move_to_pos(0) # Move back to the starting position

# Main loop
try:
while True:
run_motor_forward(2) # Run forward for 2 seconds
time.sleep(1) # Wait for 1 second
run_motor_backward(2) # Run backward for 2 seconds
time.sleep(1) # Wait for 1 second
except KeyboardInterrupt:
print("Program interrupted. Stopping motor...")
odrv0.axis0.controller.move_to_pos(0) # Stop the motor
 

Thread Starter

ADBLED

Joined Dec 24, 2024
8
HOW did you verify the commands? - I mean in the real world, not just the code?


Probe the signals from the hall sensors with the scope, do you see the signals change when you rotate the shaft? on all 3?
i am receiving step signal as oscilloscope 1 pin is gnd and other pin is attached to pin a of encoder. so can you tell me it is correct or not
 

MisterBill2

Joined Jan 23, 2018
27,159
Have you tried it with only the second motor connected?? Could it be a power supply problem??? Is it possible that the controller is only able to control one motor at a time?
 

MisterBill2

Joined Jan 23, 2018
27,159
Do you actually have any instructions for the drive package?? It seems that the place to start is with the drive, NOT with a control computer. If the drive can not run the motor than the computer does not matter.
 
Top