odriverobotics / ODrive

High performance motor control
https://odriverobotics.com
MIT License
2.9k stars 1.51k forks source link

Unable to override the default current limit. #373

Closed anubhav1772 closed 5 years ago

anubhav1772 commented 5 years ago

I am fairly new to ODrive. I want to increase the maximum current limit that passes through my motor. I tried to use below python code but didn't succeed:

my_drive.axis0.motor.config.requested_current_range=50
my_drive.save_configuration()
try:
     my_drive.reboot()
except ChannelBrokenException:
     print('Lost connection because of reboot...')

After saving above configuration, when I tried to run below code, I was able to caliberate my BLDC motor successfully, but unfortunately, my code is running infinitely without moving the motor. An encoder is attached to one end of my BLDC motor.

print("finding an odrive...")
my_drive = odrive.find_any()

#Calibrate motor and wait for it to finish
print("starting calibration...")
#my_drive.axis0.motor.config.calibration_current = 30.0
my_drive.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
while my_drive.axis0.current_state != AXIS_STATE_IDLE:
    time.sleep(0.1)

print('check if motor is calibrated: ', my_drive.axis0.motor.is_calibrated)

my_drive.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL

# To read a value, simply read the property
print("Bus voltage is " + str(my_drive.vbus_voltage) + "V")

# Or to change a value, just assign to the property
my_drive.axis0.controller.pos_setpoint = 3.14

# And this is how function calls are done:
for i in [1,2,3,4]:
    print('voltage on GPIO{} is {} Volt'.format(i, my_drive.get_adc_voltage(i)))

print('check if encoder is ready:', my_drive.axis0.encoder.is_ready)

# A sine wave to test
t0 = time.monotonic()
my_drive.axis0.controller.current_setpoint = 15.0
while True:
    setpoint = 10000.0 * math.sin((time.monotonic() - t0)*2)
    print("goto " + str(int(setpoint)))
    my_drive.axis0.controller.pos_setpoint = setpoint    
    time.sleep(0.01)

After running above code, I am getting below result:

finding an odrive...
starting calibration...
check if motor is calibrated: true
Bus voltage is: 24.40
...
check if encoder is ready: true
...

The strange thing is that when I set my_drive.axis0.controller.current_setpoint = 10, above code is working and I'm able to caliberate and also run the motor, but when I set my_drive.axis0.controller.current_setpoint > 10, I'm able to caliberate but not run the motor. What I want is to maximize current through my motor(which is more than safe default value). So, I want to override my current limit through my both axis. Your guidance will be highly appreciated. Thank you!

Wetmelon commented 5 years ago

my_drive.axis0.motor.config.current_lim

See https://docs.odriverobotics.com/#configure-m0