How to zero encoder counters

6 years 8 months ago #29532117 by mrosenfield
I am using an MDC2230 is closed loop position tracking mode. This is used as a vehicle steering system, to control the steering wheel of a car by RC. Since my hardware is installed and removed a number of times, I can't set a mechanical zero to center the vehicle steering wheel.
I need to figure out a way to turn the steering wheel by RC to the centered position, and push a button to indicate center to the controller.

I have tried zeroing the encoder counter, but this doesn't work very well. The steering wheel jerks maybe 15 degrees, which is not a problem, but it doesn't actually center the wheel accurately.

When I read the encoder counter using Roborun+, it seems to settle out around 600 with a pulsewidth input of 1500 mSec.
But sending !C 1 0 doesn't clear the count.
I tried taking it out of closed loop mode, clearing the counter, and putting it back in closed loop mode, and that doesn't do anything different.
setconfig(_MMOD, 1,0)

Any suggestions as to what I'm doing wrong?
Thank you.

Please Log in or Create an account to join the conversation.

6 years 8 months ago #29532122 by blake
Replied by blake on topic How to zero encoder counters
!C will set the encoder count to any specified value despite the current count of the encoder. However, if the controller is still in closed loop, doing this will cause erratic motor behavior. !C should only be used to reset or change the encoder count when in open loop.

If you are simply trying to return the motor to the zero position, while assuming that the zero position corresponds to the center position of your steering wheel, you can use the command !P (see manual pg 103). So in script that would be setcommand(_p,1,0).

If you have not already you will need to tune your PID gains to get accurate position control.

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.053 seconds