Hello,
I am a new member. Recently, I was studying how to make ODrives control two motors with Hall at the same time. But it doesn’t seem to go well. I did it directly according to the order. Reference linkhttps://docs.odriverobotics.com/hoverboard.html.
I use GPIO 3 and GPIO4 as PPM input port, 3 controls M0, 4 controls M1.
Only one can be controlled, and the other is not moving, but you can see the “setpoint” throttle value. The “setpoint” of a non-rotating motor can always change with the change of PPM. Can you give me some hints?
This is the order I wrote.
Configuration motor 1:
odrv0.axis1.motor.config.pole_pairs = 7
odrv0.axis1.motor.config.resistance_calib_max_voltage = 4
odrv0.axis1.motor.config.requested_current_range = 25
odrv0.save_configuration()
odrv0.reboot()
odrv0.axis1.motor.config.current_control_bandwidth = 100
odrv0.axis1.encoder.config.mode = ENCODER_MODE_HALL
odrv0.axis1.encoder.config.cpr = 42
odrv0.axis1.encoder.config.bandwidth = 100
odrv0.axis1.controller.config.pos_gain = 1
odrv0.axis1.controller.config.vel_gain = 0.02
odrv0.axis1.controller.config.vel_integrator_gain = 0.1
odrv0.axis1.controller.config.vel_limit = 1000
odrv0.axis1.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL
odrv0.save_configuration()
odrv0.reboot()
odrv0.axis1.requested_state = AXIS_STATE_MOTOR_CALIBRATION
odrv0.axis1.motor
odrv0.axis1.motor.config.pre_calibrated = True
odrv0.axis1.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION
odrv0.axis1.encoder
odrv0.axis1.encoder.config.pre_calibrated = True
odrv0.save_configuration()
odrv0.reboot()
odrv0.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv0.axis1.controller.vel_setpoint = 120
odrv0.axis1.controller.vel_setpoint = 0
odrv0.axis1.requested_state = AXIS_STATE_IDLE
The command of motor 0 is the same as that of motor 1.
Setting PPM input:
odrv0.config.gpio3_pwm_mapping.min = -200
odrv0.config.gpio3_pwm_mapping.max = 200
odrv0.config.gpio3_pwm_mapping.endpoint = odrv0.axis0.controller._remote_attributes['vel_setpoint']
odrv0.config.gpio4_pwm_mapping.min = -200
odrv0.config.gpio4_pwm_mapping.max = 200
odrv0.config.gpio4_pwm_mapping.endpoint = odrv0.axis1.controller._remote_attributes['vel_setpoint']
odrv0.save_configuration()
odrv0.reboot()
odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv0.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv0.axis0.config.startup_closed_loop_control = True
odrv0.axis1.config.startup_closed_loop_control = True
odrv0.save_configuration()
odrv0.reboot()