Controlling Motor with Potentiometer Feedback

Hello,

I have a linear actuator with an internal potentiometer and I need to be able to stop the actuator in a certain position according to the resistance value from the potentiometer. Does any one know any code that could be of use? I remember finding something on the internet but cannot for the life of me find it again.

Any help would be greatly appreciated.

Thanks!

Wire the pot as voltage divider, use analogRead.
Don't know how you're driving the actuator.

I am using a L298 motor controller with a enable connected to PWM and two digital output pins for direction

This is an example of negative feedback. From the pot you get a current position, from the code controlling the device you'll have a notion of wanted position. error = wanted position - current position.

Now use the error value to control the speed and direction of the motor. Be prepared to tune the gain of the feed back loop (too high it will overshoot, too low and its slow). If there are delays / hysteresis in the mechanics you may get instability (oscillation) - this can be cured by various ways - perhaps a PID style feedback response.

I've built such a thing before with a powerful gear motor and it worked with only a little jitter (this I cured by adding slight hysteresis in the feedback loop). Its how servo motors normally work.

If this posting sounds too technical there's probably someone that can explain it more clearly than me!