Hey everybody,
I want to control a DC motor into making it spin a certain number of spins and then stop.
I have the encoder perfectly working and I'm able to see and use its results (so no problems with code considering encoder).
My problem is accuracy. My encoder is quite accurate and the results are fine. Though when I tell it to run till a certain encoder value is reached, it, logically, spins a few rotations more than wanted. I think that my motor shield v2 from Adafruit applies +12V on both motor poles when setting the speed to 0 with the designed function for that. It seems different from the release function which obviously just let's the motor spin till it stops.
Now my question is:
Can I some how control the motor to spin to only that certain position by applying some kind of controller (I tried to read about the Arduino PID library but it didn't seem the right thing for me)?
My idea is to make the motor spin slower and slower till it reaches the desired position (and probably make it spin back if it gets far away). This seem unprofessional though ![]()
My idea is to make the motor spin slower and slower till it reaches the desired position (and probably make it spin back if it gets far away). This seem unprofessional though
Your idea is how the pro's do it so hope they aren't offended. PID does exactly that. If the difference between the desired and actual is large the motor would spin fast. As the difference becomes smaller the motor is slowed. Improving the Beginner’s PID – Introduction « Project Blog is a good PID tutorial.