Quote:
Originally Posted by 3DWolf
And all the while, I don't really see a need for all that math, couldn't you do something such as
|
What you've shown here is the "P" portion of a PID loop (the motor output is proportional to the difference between where you are and where you want to go).
This is where most people start when working on a control loop, and in some cases it will be good enough. What you will likely find, however, is that when p1 starts to get close to p2, your motor output will be so small that the motor may not actually move. Your instinct may then be to multiply "dist" by 2 to make the motor run faster, but if you keep doing this you'll eventually get to the point where your arm continuously overshoots it's target (this would be the equivalent of increasing the "P" constant in a PID loop).
PID is all about trying to make a control loop that moves a motor to a desired position as quickly as possible but also have it stop when it's supposed to without overshooting.