I am trying to control the motor by UART but it is going to undefined us . how can i solve this problem?
AXIS_STATE_UNDEFINED has a value of 0, which is the same thing that odrive.getState()
will return if the ODrive is disconnected or there is a communications error. So, in brief, this code:
while (odrive.getState() == AXIS_STATE_UNDEFINED) {
delay(100);
}
will loop forever until the ODrive responds. The ODrive will never enter state UNDEFINED by itself, it’ll always be in IDLE or similar. So likely you have an issue in your wiring or ODrive configuration that’s preventing the ODrive and Arduino from communicating. Feel free to send some pictures of your wiring and ODrive configuration!
odrv = odrv0
odrv.config.dc_bus_overvoltage_trip_level = 50
odrv.config.dc_bus_undervoltage_trip_level = 10.5
odrv.config.dc_max_positive_current = 40
odrv.config.dc_max_negative_current = -0.01
odrv.config.brake_resistor0.enable = True
odrv.config.brake_resistor0.resistance = 2
odrv.axis0.config.motor.motor_type = MotorType.HIGH_CURRENT
odrv.axis0.config.motor.pole_pairs = 7
odrv.axis0.config.motor.torque_constant = 0.04135
odrv.axis0.config.motor.current_soft_max = 40
odrv.axis0.config.motor.current_hard_max = 60
odrv.axis0.config.motor.calibration_current = 5
odrv.axis0.config.motor.resistance_calib_max_voltage = 3
odrv.axis0.config.calibration_lockin.current = 2
odrv.axis0.motor.motor_thermistor.config.enabled = False
odrv.axis0.controller.config.control_mode = ControlMode.VELOCITY_CONTROL
odrv.axis0.controller.config.input_mode = InputMode.VEL_RAMP
odrv.axis0.controller.config.vel_limit = 300
odrv.axis0.controller.config.vel_limit_tolerance = 1.0333333333333334
odrv.axis0.config.torque_soft_min = -93
odrv.axis0.config.torque_soft_max = 93
odrv.axis0.trap_traj.config.accel_limit = 300
odrv.axis0.controller.config.vel_ramp_rate = 300
odrv.can.config.protocol = Protocol.NONE
odrv.axis0.config.enable_watchdog = True
odrv.axis0.config.watchdog_timeout = 3
odrv.axis0.config.load_encoder = EncoderId.RS485_ENCODER0
odrv.axis0.config.commutation_encoder = EncoderId.RS485_ENCODER0
odrv.rs485_encoder_group0.config.mode = Rs485EncoderMode.AMT21_EVENT_DRIVEN
odrv.config.enable_uart_a = True
odrv.config.gpio7_mode = GpioMode.UART_A
odrv.config.gpio6_mode = GpioMode.UART_A
odrv.config.uart_a_baudrate = 115200
I shared my motor datasheet and configuration. Are both compatible with each other . Please help me to troubleshoot it ASAP.
Yes, the ODrive will be compatible with that motor. This is likely an issue with the wiring between the ODrive and the Arduino. Can you send some pictures of the wiring, and also send the code you’re using for the Arduino?