Background: I am new to PID, for my first PID project I am using a simple P-Loop and 300 degree linear potentiometers for position feedback. I am using the roboclaw 2x60A motor controller. The motor controller has 64 speeds between. Sometimes the potentiometers can vary as much as +-4 degrees when not in motion. I am using an Arduino mega with a 10bit ADC to control the motors.
My Question: How can I filter or reduce the variance in the potentiometers? In addition, it takes a certain amount of time for the motors to react to the command, and it seems to throw off the P loop. How do I account for the latency, in my program?
Example: For this example the P loop was run every 33-36 milliseconds. I will tell the motor to go to 250 deg/sec, and it will go to 275 deg/sec, the P loop then reacts by lowering the value sent to the motor however the speed then increase to 400 deg/sec and then the P loop lowers the value again, then the speed will drop to 34 deg/sec.
Thanks so much for any help, Joel