Stepper Motor Angle Changing depending on Feedback

So I have a Ball on Beam Project and I'm quite new to the Arduino however I have managed to complete a project prior to this so I have some experience. Basically the project demands that a ball is balanced at a point on a beam and the beam has to rotate clockwise and counter clockwise to raise or lower the beam to move the ball closer to the set point. We have a feedback system that will give an analog input, using the ADC we plan on getting it close to a set resolution number. For example if the position we require translates to the resolution number of 771, then when the analogread is > 771 the motor drives clockwise and vice versa.

The problem is that for every bit of resolution it is away from the set resolution, I would like the angle to change. For example if the set point is 771 and the analog read is reading 800 then the angle will be 'x', but as it decreases towards 771 and reaches say 780, then the angle decreases because it is closer to the set point, it can be considered a method of damping I guess, instead of leaving the angle the same and letting the system overshoot and compensating with changing the motor direction, it reduces the overshoot by reducing the angle.

Unfortunately I'm no pro at this and I am a bit lost on what to do. If anyone can guide me at least on the concept of what i should be doin or what commands to look into it would be much appreciated.

Al

Here's another person with a very similar project. Perhaps you two should collaborate. http://forum.arduino.cc/index.php?topic=170358.msg1266670#msg1266670

thats a previous post of mine but good thinking ^^

alainagius: thats a previous post of mine but good thinking ^^

Did you hear something go "Whoosh!" just now? That was PaulS's point sailing over your head.

As others most definitely mentioned earlier PID is what you want to use here. Start reading about it. If you have had calculus it should make some sense, if not... well you should take calculus. Depending on the physical response of your system you may only need a p controller. This just takes the difference from your desired position, multiplies it by a scaler, and uses this number to set the response (a motor speed). Its only if this is unstable, too slow, or never reaches the final position when you would need to add the integral (I) and derivative (D) terms.

Since you are using a stepper that has some built in predictability, you might be able to make use of the AccelStepper library found here. http://www.airspayce.com/mikem/arduino/AccelStepper/