takijo
February 14, 2021, 4:55am
1
Hi, I want to control a brushed motor by position feedback.
Of cource, I know the Odrive is for BLDC motor controller.
But, I need to use brushed motor and BLDC motor in same time.
If it can be done on one board, that’s very good!
I referred to the topic here.
Hello!
I have an application that requires control of one brushless motor and one brushed motor. I’ve already got an Odrive V3.6 driving the brushless motor, but I see that brushed motors don’t appear to be part of the software. I’m familiar with embedded C/C++ programming and github pull requests.
Would anyone be able to generally advise me on what would need to change? Commutation is easy, but I suppose auto-identification may need to change.
If someone could point me in the right direction…
But,this code don’t Implement position control.
So, I add the motor type to Brushed motor and control it with current feedback.
But
odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
dump_errors(odrv0)
I got AXIS_ERROR_INVALID_STATE
Anyone, please advise for me.
INVALID state menas you didn’t work your way through motor calibration and encoder calibration.
You’ll need to force it to set motor.is_ready and encoder.is_ready, as the ACIM mode does, for example:
1 Like
takijo
February 15, 2021, 11:46pm
3
@Wetmelon
Thank you for your reply.
I set both is_ready,But, I got same error.
So, I want to try it with sensor less.
Do you have any ideas to spin brushed motor with sensor less simply?
regard.
Hello! My code does support position control of brushed motors. That is how I have been using it.
But I also have a setup script for current control, which may help you get something working.
What happens if you delete everything after line 58 in this script and run it? Be careful! You may need to update some variables based on your motor size. We use a medium sized motor.
reverse = False reverse_start_time = 0 reverse_duration_allowed_sec = 4 ctrl = odrv0.axis1.motor.current_control start_time = time.time() reverse_position = 0 print(odrv0.axis1.encoder.pos_estimate) print(odrv0.axis1.encoder.pos_estimate) odrv0.axis1.controller.current_setpoint = 3 # This is a current-based hard block homing routine. while True: print("Iq_measured {}, bus voltage {}, vel estimate {}, max_vel {}.".format(ctrl.Iq_measured, odrv0.vbus_voltage, odrv0.axis1.encoder.vel_estimate, max_vel)) if reverse: if odrv0.axis1.encoder.pos_estimate - reverse_position > 400 or time.time() - reverse_start_time > reverse_duration_allowed_sec: reverse = False odrv0.axis1.controller.current_setpoint *= -1 max_vel = 0 start_time = time.time()
If that works, you can run the rest of the script which will set up position control. But another warning, Lines 60 to 83 run hard block homing (move the motor until it stops) and this might not be right for your setup.
Note that with my firmware I force the encoder to be ready with:
odrv0.axis1.requested_state = AXIS_STATE_ENCODER_INDEX_SEARCH
At least I am pretty sure that is the important part. I haven’t modified this stuff in a while and I can be a bit fuzzy on it.
takijo
February 16, 2021, 1:48pm
6
@tlalexander
Thank you for your great support.
I finished your code and I ran odrive_brushed.py.
But no current flow to motor.
Do you have any ideas?
Are you using axis0 or axis1? My code by default is using axis1 because that’s how my robot is constructed.
takijo
February 19, 2021, 2:59pm
8
@tlalexander
Sorry I had set vel_lim very small.
How import your configuration json file in python script?
1 Like
The normal way to import a config file is:
odrivetool restore-config config.json
So you could do that once manually and youd be good.