alexp
October 17, 2022, 12:39pm
1
In 2019 there was the answer:
“No, you need to have correct offset to do any type of control. This is because this is needed to commutate the motor.”
opened 03:44AM - 14 Nov 19 UTC
closed 03:55AM - 14 Nov 19 UTC
Is there a way to avoid encoder offset calibration after startup if there is no … index pulse? I am able to run the motor after offset calibration but want to eliminate that. I have HW version 3.6 (variant=56) and FW version 0.4 (revision=10). I tried many combinations including the following final form but the settings produce INVALID_STATE error regardless until offset calibration after every startup. Any help would be much appreciated.
```
drive = odrive.find_any()
drive.erase_configuration()
# First, a bunch of settings
drive.axis0.motor.config.pole_pairs = 15
drive.axis0.motor.config.current_lim = 10.0
drive.axis0.motor.config.resistance_calib_max_voltage = 4
drive.axis0.motor.config.requested_current_range = 25
drive.axis0.motor.config.current_control_bandwidth = 1000
drive.config.brake_resistance = 2.0
drive.axis0.encoder.config.mode = ENCODER_MODE_INCREMENTAL
drive.axis0.encoder.config.cpr = 3200
drive.axis0.encoder.config.bandwidth = 1000
drive.axis0.controller.config.pos_gain = 1
drive.axis0.controller.config.vel_gain = 0.001
drive.axis0.controller.config.vel_integrator_gain = 0.05
drive.axis0.motor.config.phase_resistance = 0.85
drive.axis0.controller.config.vel_limit = 5000
drive.axis0.motor.config.motor_type = MOTOR_TYPE_GIMBAL
# This is where the sequence of operations matters I guess
drive.axis0.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL
drive.axis0.encoder.config.use_index = False
drive.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
while self.drive.axis0.current_state != AXIS_STATE_IDLE:
time.sleep(0.1)
self.drive.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION
while self.drive.axis0.current_state != AXIS_STATE_IDLE:
time.sleep(0.1)
drive.axis0.motor.config.pre_calibrated = True
drive.axis0.encoder.config.pre_calibrated = True
drive.axis0.config.startup_encoder_index_search = False
drive.axis0.config.startup_closed_loop_control = True
drive.save_configuration()
drive.reboot()
time.sleep(10)
drive = odrive.find_any()
# The following shows INVALID_STATE error
drive.axis0.error
drive.axis0.error = False
# The following attribute is already True
drive.axis0.motor.config.pre_calibrated = True
# The following attribute cannot be set to True, this just won't take effect
drive.axis0.encoder.config.pre_calibrated = True
# The following won't change state
drive.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
# The following will resolve the problem
drive.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION
# Now, I can change the state to closed loop control
drive.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
# It all works fine now
drive.axis0.controller.vel_setpoint = 200
```
Is it still so?
Lars
October 17, 2022, 12:58pm
2
No, you either need to do an encoder index search if you have an encoder with index signal or you can avoid all of these steps if you have an absolute encoder.
1 Like
alexp
October 17, 2022, 2:26pm
3
Lars, thank you for the answer!
1 Like