📄 pid.9
字号:
.TH PID "9" "2007-01-16" "EMC Documentation" "HAL Component".de TQ.br.ns.TP \\$1...SH NAMEpid \- proportional/integral/derivative controller.SH SYNOPSIS\fBloadrt pid num_chan=\fInum\fR [\fBdebug=\fIdbg\fR].SH DESCRIPTION\fBpid\fR is a classic Proportional/Integral/Derivative controller,used to control position or speed feedback loops for servo motors andother closed-loop applications..P\fBpid\fR supports a maximum of sixteen controllers. The number thatare actually loaded is set by the \fBnum_chan\fR argument whenthe module is loaded. If \fBnumchan\fR is not specified, the defaultvalue is three. If \fBdebug\fR is set to 1 (the default is 0), someadditional HAL parameters will be exported, which might be usefulfor tuning, but are otherwise unnecessary..SH FUNCTIONS.TP \fBpid.\fIN\fB.do-pid-calcs\fR (uses floating-point)Does the PID calculations for control loop \fIN\fR..SH PINS.TP\fBpid.\fIN\fB.command\fR float inThe desired (commanded) value for the control loop..TP\fBpid.\fIN\fB.feedback\fR float inThe actual (feedback) value, from some sensor such as an encoder..TP\fBpid.\fIN\fB.error\fR float outThe difference between command and feedback..TP\fBpid.\fIN\fB.output\fR float outThe output of the PID loop, which goes to some actuator such as a motor..TP\fBpid.\fIN\fB.enable\fR bit inWhen true, enables the PID calculations. When false, \fBoutput\fR is zero,and all internal integrators, etc, are reset..SH PARAMETERS.TP\fBpid.\fIN\fB.Pgain\fR float rwProportional gain. Results in a contribution to the output that is the errormultiplied by \fBPgain\fR..TP\fBpid.\fIN\fB.Igain\fR float rwIntegral gain. Results in a contribution to the output that is the integralof the error multiplied by \fBIgain\fR. For example an error of 0.02 thatlasted 10 seconds would result in an integrated error (\fBerrorI\fR) of 0.2,and if \fBIgain\fR is 20, the integral term would add 4.0 to the output..TP\fBpid.\fIN\fB.Dgain\fR float rwDerivative gain. Results in a contribution to the output that is the rate ofchange (derivative) of the error multiplied by \fBDgain\fR. For example anerror that changed from 0.02 to 0.03 over 0.2 seconds would result in an errorderivative (\fBerrorD\fR) of of 0.05, and if \fBDgain\fR is 5, the derivativeterm would add 0.25 to the output..TP\fBpid.\fIN\fB.bias\fR float rw\fBbias\fR is a constant amount that is added to the output. In most casesit should be left at zero. However, it can sometimes be useful to compensatefor offsets in servo amplifiers, or to balance the weight of an object thatmoves vertically. \fBbias\fR is turned off when the PID loop is disabled,just like all other components of the output. If a non-zero output is neededeven when the PID loop is disabled, it should be added with an external HALsum2 block..TP\fBpid.\fIN\fB.FF0\fR float rwZero order feed-forward term. Produces a contribution to the output that is\fBFF0\fR multiplied by the commanded value. For position loops, it shouldusually be left at zero. For velocity loops, \fBFF0\fR can compensate forfriction or motor counter-EMF and may permit better tuning if used properly..TP\fBpid.\fIN\fB.FF1\fR float rwFirst order feed-forward term. Produces a contribution to the output that\fBFF1\fR multiplied by the derivative of the commanded value. Forposition loops, the contribution is proportional to speed, and can be usedto compensate for friction or motor CEMF. For velocity loops, it isproportional to acceleration and can compensate for inertia. In bothcases, it can result in better tuning if used properly..TP\fBpid.\fIN\fB.FF2\fR float rwSecond order feed-forward term. Produces a contribution to the output that is\fBFF2\fR multiplied by the second derivative of the commanded value. Forposition loops, the contribution is proportional to acceleration, and can beused to compensate for inertia. For velocity loops, it should usually beleft at zero..TP\fBpid.\fIN\fB.deadband\fR float rwDefines a range of "acceptable" error. If the absolute value of \fBerror\fRis less than \fBdeadband\fR, it will be treated as if the error is zero.When using feedback devices such as encoders that are inherently quantized,the deadband should be set slightly more than one-half count, to preventthe control loop from hunting back and forth if the command is between twoadjacent encoder values. When the absolute value of the error is greaterthan the deadband, the deadband value is subtracted from the error beforeperforming the loop calculations, to prevent a step in the transfer functionat the edge of the deadband. (See \fBBUGS\fR.).TP\fBpid.\fIN\fB.maxoutput\fR float rwOutput limit. The absolute value of the output will not be permittedto exceed \fBmaxoutput\fR, unless \fBmaxoutput\fR is zero. When the outputis limited, the error integrator will hold instead of integrating, to preventwindup and overshoot..TP\fBpid.\fIN\fB.maxerror\fR float rwLimit on the internal error variable used for P, I, and D. Can be used toprevent high \fBPgain\fR values from generating large outputs under conditionswhen the error is large (for example, when the command makes a step change).Not normally needed, but can be useful when tuning non-linear systems..TP\fBpid.\fIN\fB.maxerrorD\fR float rwLimit on the error derivative. The rate of change of error used by the\fBDgain\fR term will be limited to this value, unless the value iszero. Can be used to limit the effect of \fBDgain\fR and prevent largeoutput spikes due to steps on the command and/or feedback. Not normallyneeded..TP\fBpid.\fIN\fB.maxerrorI\fR float rwLimit on error integrator. The error integrator used by the \fBIgain\fRterm will be limited to this value, unless it is zero. Can be used to preventintegrator windup and the resulting overshoot during/after sustained errors.Not normally needed..TP\fBpid.\fIN\fB.maxcmdD\fR float rwLimit on command derivative. The command derivative used by \fBFF1\fR willbe limited to this value, unless the value is zero. Can be used to prevent\fBFF1\fR from producing large output spikes if there is a step change on thecommand. Not normally needed..TP\fBpid.\fIN\fB.maxcmdDD\fR float rwLimit on command second derivative. The command second derivative used by\fBFF2\fR will be limited to this value, unless the value is zero. Can beused to prevent \fBFF2\fR from producing large output spikes if there is astep change on the command. Not normally needed..TP\fBpid.\fIN\fB.errorI\fR float ro (only if debug=1)Integral of error. This is the value that is multiplied by \fBIgain\fR to produce the Integral term of the output..TP\fBpid.\fIN\fB.errorD\fR float ro (only if debug=1)Derivative of error. This is the value that is multiplied by \fBDgain\fR to produce the Derivative term of the output..TP\fBpid.\fIN\fB.commandD\fR float ro (only if debug=1)Derivative of command. This is the value that is multiplied by \fBFF1\fR to produce the first order feed-forward term of the output..TP\fBpid.\fIN\fB.commandDD\fR float ro (only if debug=1)Second derivative of command. This is the value that is multiplied by\fBFF2\fR to produce the second order feed-forward term of the output..SH BUGSSome people would argue that deadband should be implemented such that error istreated as zero if it is within the deadband, and be unmodified if it is outsidethe deadband. This was not done because it would cause a step in the transferfunction equal to the size of the deadband. People who prefer that behavior arewelcome to add a parameter that will change the behavior, or to write their ownversion of \fBpid\fR. However, the default behavior should not be changed.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -