Closed_loop_control problem

hello,

My v3.6 Odrive is configured properly and running v0.5.1 firmware. There is no issue when I run odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE, and rotating properly clock-wise and Anticlock-wise.

But when I put the requested state in CLOSED LOOP CONTROL, it starts twitching or vibrating a little but not HOLDING the position or not fighting back. And when I tried to control using inp_pos=1 after setting the control mode to Position control it is not functioning. I have no errors.

In [84]: dump_errors(odrv0)
axis0
axis: no error
motor: no error
fet_thermistor: no error
motor_thermistor: no error
encoder: no error
controller: no error
axis1
axis: no error
motor: no error
fet_thermistor: no error
motor_thermistor: no error
encoder: no error
controller: no error

config:
enable_watchdog = False (bool)
turns_per_step = 0.0009765625 (float)
startup_motor_calibration = True (bool)
watchdog_timeout = 0.0 (float)
can_heartbeat_rate_ms = 100 (int)
startup_homing = False (bool)
step_gpio_pin = 1 (int)
dir_gpio_pin = 2 (int)
enable_step_dir = False (bool)
step_dir_always_on = False (bool)
calibration_lockin: …
startup_encoder_offset_calibration = True (bool)
sensorless_ramp: …
general_lockin: …
startup_encoder_index_search = True (bool)
can_node_id = 0 (int)
startup_sensorless_control = False (bool)
startup_closed_loop_control = True (bool)
can_node_id_extended = False (bool)
current_state = 1 (int)
controller:
torque_setpoint = 0.5 (float)
config: …
input_vel = 2.0 (float)
error = 0x0000 (int)
input_torque = 0.5 (float)
move_incremental(displacement: float, from_input_pos: bool)
pos_setpoint = 5.0 (float)
trajectory_done = True (bool)
input_pos = 5.0 (float)
anticogging_valid = False (bool)
vel_setpoint = 2.0 (float)
vel_integrator_torque = 20.58928680419922 (float)
start_anticogging_calibration()
loop_counter = 33731836 (int)
error = 0x0000 (int)
clear_errors()
fet_thermistor:
config: …
temperature = 30.60628318786621 (float)
error = 0x0000 (int)
max_endstop:
endstop_state = False (bool)
config: …
trap_traj:
config: …
step_dir_active = False (bool)
encoder:
vel_estimate_counts = 0.0 (float)
pos_estimate = 2.6570589542388916 (float)
error = 0x0000 (int)
is_ready = True (bool)
spi_error_rate = 0.0 (float)
pos_abs = 0 (int)
hall_state = 0 (int)
vel_estimate = 0.0 (float)
pos_cpr = 0.6570586562156677 (float)
interpolation = 0.5 (float)
pos_circular = 0.6585586071014404 (float)
pos_cpr_counts = 2628.234619140625 (float)
count_in_cpr = 2628 (int)
shadow_count = 10628 (int)
config: …
index_found = True (bool)
set_linear_count(count: int)
phase = -1.6788647174835205 (float)
pos_estimate_counts = 10628.2353515625 (float)
calib_scan_response = 2898.0 (float)
watchdog_feed()
motor_thermistor:
config: …
temperature = 0.0 (float)
error = 0x0000 (int)
requested_state = 0 (int)
sensorless_estimator:
config: …
vel_estimate = -0.002478180453181267 (float)
phase = -0.47704246640205383 (float)
error = 0x0000 (int)
pll_pos = -0.4721834659576416 (float)
is_homed = False (bool)
min_endstop:
endstop_state = False (bool)
config: …
motor:
config: …
error = 0x0000 (int)
current_control: …
DC_calib_phB = -0.32668256759643555 (float)
phase_current_rev_gain = 0.02500000037252903 (float)
current_meas_phC = -0.15527701377868652 (float)
armed_state = 0 (int)
is_calibrated = True (bool)
DC_calib_phC = 0.3563731014728546 (float)
timing_log: …
effective_current_lim = 10.0 (float)
gate_driver: …
current_meas_phB = 0.2062206268310547 (float)
lockin_state = 0 (int)

What mistake or why it is not happening please help.

Hi Varkala,

Which motor and encoder are you using? The default controller gains (pos_gain, vel_gain, vel_integrator_gain) are set up to work for the ODrive D5065 and D6374 motors with the 8192 cpr encoder from the shop. There is a short guide for tuning here: https://docs.odriverobotics.com/control at the bottom of the page. If, after tuning, the motor still doesn’t hold a position very well, change odrv0.axis0.motor.config.current_lim to a value that makes sense for your motor. The stock setting of 10A is not very strong.

1 Like

thanks it is solved by changing the torque contant to 1

1 Like