1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Odriveセットアップコマンド解説(ver,ホールセンサ)

Last updated at Posted at 2022-11-02

Odriveセットアップコマンド

odrv0.config.brake_resistance = xxx

brake_resistance : 回生電力消費用の抵抗

odrv0.axis1.motor.config.pole_pairs = xxx

pole_pairs : 使用するモーターの極数

odrv0.axis1.motor.config.resistance_calib_max_voltage = xxx

resistance_calib_max_voltage:
電流検出用のシャント抵抗に流れるの最大値の設定
電流(キャリブレーション時)×抵抗値 < max_voltage < 0.5 × vbus_voltage

odrv0.axis1.motor.config.requested_current_range = xxx

requested_current_range :
測定されうる最小の電流値(0Aってことではない)
これによってシャント抵抗についたアンプの増幅率が変わるらしい
なるべく、低い方がいい

odrv0.axis1.motor.config.current_control_bandwidth= xxx

current_control_bandwidth :
これよくわからん、ベクトル制御勉強すればわかるかも
"""Sets the PI gains of the Q and D axis FOC control according to phase_resistance and phase_inductance to create a critically-damped controller with a -3dB bandwidth at this frequency."""

odrv0.axis1.motor.config.torque_constant = 8.27 / (measured KV)

torque_constant :
モーターのトルク定数
トルク制御するときにしか使われないから無視してもいいかも

encoder config

odrv0.axis1.encoder.config.mode = ENCODER_MODE_HALL

mode :
SPIのエンコーダー、RS485とかのエンコーダーに対応してるらしい
今回はホールセンサで

odrv0.axis1.encoder.config.cpr = xxx

cpr :
ホールセンサが3つなので組み合わせは6パターン
だからモーターの極数×6

odrv0.axis1.encoder.config.calib_scan_distance = xxx

calib_scan_distance :
わけわかめ

odrv0.axis1.encoder.config.bandwidth = xxx

bandwidth :
わけわかめ

odrv0.axis1.controller.config.pos_gain = xxx

pos_gain :
わけわかめ
"""units = (turn/s) / turn"""らしい

odrv0.axis1.controller.config.vel_gain = xxx * odrv0.axis1.motor.config.torque_constant * odrv0.axis1.encoder.config.cpr

vel_gain :
xxx = 0.02がちょうどいい感じ?
速度制御のPゲインの値かな?

odrv0.axis1.controller.config.vel_integrator_gain = xxx * odrv0.axis1.motor.config.torque_constant * odrv0.axis1.encoder.config.cpr

vel_integrator_gain :
xxx = 0.1がちょうどいい感じ?
速度制御のIゲインの値かな?

odrv0.axis1.controller.config.vel_integrator_gain = xxx * odrv0.axis1.motor.config.torque_constant * odrv0.axis1.encoder.config.cpr

vel_integrator_gain :
xxx = 0.1がちょうどいい感じ?
速度制御のIゲインの値かな?

odrv0.axis1.controller.config.vel_limit = xxx

vel_limit :
回転数の最大値を定義(大事)
単位[turn/s]

odrv0.axis1.controller.config.control_mode = CONTROL_MODE_VELOCITY_CONTROL

control_mode :
速度制御

回すとき

速度制御

odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv0.axis0.controller.input_vel = 2

注意

CPR間違えると指令値与えても動かない

最後に、いつも使ってるセットアップコマンド

odrv0.axis1.motor.config.pole_pairs = 15
odrv0.config.brake_resistance = 0.5
odrv0.axis1.motor.config.resistance_calib_max_voltage = 4
odrv0.axis1.motor.config.requested_current_range = 25 #Requires config save and reboot
odrv0.axis1.motor.config.current_control_bandwidth = 100
odrv0.axis1.motor.config.torque_constant = 8.27 / <measured KV>
odrv0.axis1.encoder.config.mode = ENCODER_MODE_HALL
odrv0.axis1.encoder.config.cpr = 90
odrv0.axis1.encoder.config.calib_scan_distance = 150
odrv0.config.gpio9_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio10_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio11_mode = GPIO_MODE_DIGITAL
odrv0.axis1.encoder.config.bandwidth = 100
odrv0.axis1.controller.config.pos_gain = 1
odrv0.axis1.controller.config.vel_gain = 0.02 * odrv0.axis1.motor.config.torque_constant * odrv0.axis1.encoder.config.cpr
odrv0.axis1.controller.config.vel_integrator_gain = 0.1 * odrv0.axis1.motor.config.torque_constant * odrv0.axis1.encoder.config.cpr
odrv0.axis1.controller.config.vel_limit = 10
odrv0.axis1.controller.config.control_mode = CONTROL_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_HALL_POLARITY_CALIBRATION
odrv0.axis1.encoder
odrv0.axis1.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION
odrv0.axis1.encoder
odrv0.axis1.encoder.config.pre_calibrated = True
odrv0.save_configuration()
odrv0.reboot()
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?