4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ You should move your update into an answer to your own question so that we can upvote it. $\endgroup$ – Ian Jan 16 '15 at 17:42
3
$\begingroup$

Having only the proportional term of the PID regulator will most definitely leave you with oscillations. If you think about it, it's quite similar to a linear harmonic oscillator F=k*x (formula for spring motion). Adding a derivative term should damp out those oscillations. If after waiting for the system to stabilize you see it stabilized with some offset and not the value you've instructed it to, you'll need to add integral term as well in order to remove that constant error.

As for the shaky ground, try separating logic power supply from the motors' power supply, and using optocouplers where possible. It's a common problem.

Regards, Damjan

$\endgroup$
0
$\begingroup$

Update: After more debugging I have traced the variance in the potentiometer to a shaky ground in the Roboclaw 2x60a motor controller. When I connect the ground to the Roboclaw the potentiometers vary by +-4 through +-6 degrees when the ground is not connected to the Roboclaw the pots vary by +- 1 sometimes rarely +- 2. I have tried using the arduino as a logic battery and it doesn't help.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.