1
$\begingroup$

Let's say, for example, I am controlling a motor's speed by adjusting how much power I feed into it. The motor shaft is connected to some physical device with varying amounts of torque, so in order to keep the speed the same I implement a PID control loop.

Let's say that the base power I am sending the motor is X. The PID outputs an adjustment value, say Y.

Should I add Y to X for every loop through the PID? Or, should I add only changes in Y to X? For example, if Y changes from 5 to 10, then add 5 to X.

$\endgroup$
1
$\begingroup$

Using the same terms as your question, the PID contoller should provide a new X, not an incremental value that gets summed to the previous one. The input to the PID controller should be the difference between desired speed and measured speed in the example you describe. We call this velocity control, compared with the more typical position control in which the difference between desired position and actual position becomes the input to the PID loop.

$\endgroup$
-1
$\begingroup$

I recently implemented a PID loop for speed control of a treadmill. I used a position encoder to find the speed of the treadmill and used it to find error from a desired speed for the PID controller. The output of the PID controller, called the control signal, is the PWM for the motor. You should see your motors' documentation for speed commands and then serially communicate those to the motor. These speed commands can go from 0% to 100% PWM. 100% would mean that your motor is running at the highest rated voltage meaning highest rated rpm. 50% would mean it is running at half the rated voltage and resulting into half the rated maximum rpm respectively.

You have to map the speed (m/s) into PWM values. You can do this as follows: Maximum speed = 100% PWM (Must have a value that the motor interprets as full PWM, see motor documentation)

then,

1 = (100% PWM) / Maximum Speed)

and your final PID output should be like:

PID_OUT = (100 % PWM / Maximum Speed)*(Error * Kp + Sum_of_Erros * Ki * Loop_Time + Kd*(Error - Last_Error) / Loop_Time)

Lastly, I am just a noobie. Wait for experienced people for some detailed answers :) .

Hope it helps.

$\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.