I’m trying to use analog velocity control and I can’t seem to get it to work.
I’m able run the hoverboard example and that works fine.
I am using version [0.4.10] and the D5065 motor and the CUI AMT102-V encoder.
I have my pot connected to gpio3, I’m using AVCC and AGND to power the pot.
Here’s my steps to try and use analog mapping:
In [451]: odrv0.erase_configuration()
In [452]: odrv0.reboot()
Reconnected to ODrive 20693390304B as odrv0
In [453]: odrv0.axis0.encoder.config.use_index = True
In [454]: odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
In [455]: odrv0.axis0.encoder.config.pre_calibrated = True
In [456]: odrv0.axis0.motor.config.pre_calibrated = True
In [457]: odrv0.axis0.config.startup_encoder_index_search = True
In [458]: odrv0.axis0.config.startup_closed_loop_control = True
In [459]: odrv0.axis0.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL
In [460]: odrv0.save_configuration()
In [461]: odrv0.reboot()
Reconnected to ODrive 20693390304B as odrv0
In [462]: odrv0.config.gpio3_analog_mapping.min = -10000
In [463]: odrv0.config.gpio3_analog_mapping.max = 10000
In [464]: odrv0.config.gpio3_analog_mapping.endpoint = odrv0.axis0.controller._remote_attributes[‘vel_setpoint’]
In [465]: odrv0.save_configuration()
In [466]: odrv0.reboot()
I can check the velocity setpoint and that is always zero:
In [448]: odrv0.axis0.controller.vel_setpoint
Out[448]: 0.0
I can read the adc voltage and that works fine so it looks like the pin is configured correctly:
In [449]: odrv0.get_adc_voltage(3)
Out[449]: 1.8699462413787842
If I run odrv0.config I can see that the min, max and endpoints are set for gpio3_analog_mapping.
In [450]: odrv0.config
Out[450]:
brake_resistance = 0.4699999988079071 (float)
enable_uart = True (bool)
enable_i2c_instead_of_can = False (bool)
enable_ascii_protocol_on_usb = True (bool)
dc_bus_undervoltage_trip_level = 8.0 (float)
dc_bus_overvoltage_trip_level = 25.68000030517578 (float)
gpio1_pwm_mapping:
endpoint = (0, 0) (RemoteProperty)
min = 0.0 (float)
max = 0.0 (float)
gpio2_pwm_mapping:
endpoint = (0, 0) (RemoteProperty)
min = 0.0 (float)
max = 0.0 (float)
gpio3_pwm_mapping:
endpoint = (0, 0) (RemoteProperty)
min = 0.0 (float)
max = 0.0 (float)
gpio4_pwm_mapping:
endpoint = (0, 0) (RemoteProperty)
min = 0.0 (float)
max = 0.0 (float)
gpio3_analog_mapping:
endpoint = (126, 13145) (RemoteProperty)
min = -10000.0 (float)
max = 10000.0 (float)
gpio4_analog_mapping:
endpoint = (0, 0) (RemoteProperty)
min = 0.0 (float)
max = 0.0 (float)
I just don’t seem to have control of velocity with the analog input.
I can run the same thing for the pwm_mapping and it works fine.
Any suggestions on what I’m doing wrong?
Thanks,
Tim