How to control a brushed motor by position feedback?

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.

But,this code don’t Implement position control.

So, I add the motor type to Brushed motor and control it with current feedback.
image

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

@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.

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.

@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.

@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.