Remote Control Sensorless motor code

Hi all,

This is the code I used for my project that uses 270 KV motors running sensorless being controlled by an RC Receiver and transmitter

odrv0.axis1.controller.config.vel_gain = 0.05
odrv0.axis1.controller.config.vel_integrator_gain = 0.05
odrv0.axis1.controller.config.control_mode = 0
odrv0.axis1.controller.vel_setpoint = 1000
odrv0.axis1.motor.config.direction = 1
odrv0.axis1.motor.config.pole_pairs = 7
odrv0.axis1.motor.config.current_lim = 15
odrv0.axis1.sensorless_estimator.config.pm_flux_linkage = 5.51328895422 / 1860
odrv0.axis0.controller.config.vel_gain = 0.02
odrv0.axis0.controller.config.vel_integrator_gain = 0.05
odrv0.axis0.controller.config.control_mode = 0
odrv0.axis0.controller.vel_setpoint = 1000
odrv0.axis0.motor.config.direction = 1
odrv0.axis0.motor.config.pole_pairs = 7
odrv0.axis0.motor.config.current_lim = 15
odrv0.axis0.sensorless_estimator.config.pm_flux_linkage = 5.51328895422 / 1860
odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION
odrv0.axis1.requested_state = AXIS_STATE_MOTOR_CALIBRATION
odrv0.save_configuration()
odrv0.reboot()
odrv0.axis0.motor.config.pre_calibrated = True
odrv0.axis1.motor.config.pre_calibrated = True
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_SENSORLESS_CONTROL
odrv0.axis1.requested_state = AXIS_STATE_SENSORLESS_CONTROL
odrv0.axis0.config.startup_sensorless_control = True
odrv0.axis1.config.startup_sensorless_control = True
odrv0.save_configuration()
odrv0.reboot()
odrv0.axis1.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL
odrv0.axis1.controller.vel_setpoint = 150
odrv0.axis0.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL
odrv0.axis0.controller.vel_setpoint = 150
odrv0.save_configuration()
odrv0.reboot()

Just posting it here for anyone who needs it.

3 Likes