1- .TH PID "9" "2007-01-16" "LinuxCNC Documentation" "HAL Component"
1+ .TH AT_PID "9" "2007-01-16" "LinuxCNC Documentation" "HAL Component"
22
33.SH NAME
4- pid \- proportional/integral/derivative controller
4+ at_pid \- proportional/integral/derivative controller
55.SH SYNOPSIS
6- \fB loadrt pid [num_chan= \fI num \fB | names= \fI name1 \fB [, \fI name2... \fB ]] [ \fB debug= \fI dbg \fR ]
6+ \fB loadrt at_pid [num_chan= \fI num \fB | names= \fI name1 \fB [, \fI name2... \fB ]] [ \fB debug= \fI dbg \fR ]
77
88.SH DESCRIPTION
99\fB NOTE: \fR The auto-tuning part of this component have seen
1010no development since 2011.
1111.P
12- \fB pid \fR is a classic Proportional/Integral/Derivative controller,
12+ \fB at_pid \fR is a classic Proportional/Integral/Derivative controller,
1313used to control position or speed feedback loops for servo motors and
1414other closed-loop applications.
1515.P
16- \fB pid \fR supports a maximum of sixteen controllers. The number that
16+ \fB at_pid \fR supports a maximum of sixteen controllers. The number that
1717are actually loaded is set by the \fB num_chan \fR argument when
1818the module is loaded. Alternatively, specify names= and unique names
1919separated by commas.
@@ -31,7 +31,7 @@ loops such as speed loops, torch height control, and others.
3131
3232.P
3333Each loop has a number of pins and parameters, whose names begin
34- with 'pid .N.', where 'N' is the channel number. Channel numbers start
34+ with 'at_pid .N.', where 'N' is the channel number. Channel numbers start
3535at zero.
3636.P
3737The three most important pins are 'command', 'feedback', and 'output'.
@@ -141,7 +141,7 @@ command line.
141141\fB commandDDD \fR 3rd derivative of the command
142142
143143.P
144- The PID loop calculations are as follows (see the code in pid .c for
144+ The PID loop calculations are as follows (see the code in at_pid .c for
145145all the nitty gritty details):
146146.IP
147147.nf
@@ -189,78 +189,78 @@ Auto tuning can be aborted at any time by setting \fBenable\fR or
189189
190190.SH NAMING
191191The names for pins, parameters, and functions are prefixed as:
192- \fB pid .N.\fR for N=0,1,...,num\- 1 when using \fB num_chan=num \fR
192+ \fB at_pid .N.\fR for N=0,1,...,num\- 1 when using \fB num_chan=num \fR
193193 \fB nameN. \fR for nameN=name1,name2,... when using \fB names=name1,name2,... \fR
194194
195- The \fB pid .N.\fR format is shown in the following descriptions.
195+ The \fB at_pid .N.\fR format is shown in the following descriptions.
196196
197197.SH FUNCTIONS
198198
199- \fB pid .\fI N \fB .do \- pid \- calcs \fR (uses floating-point)
199+ \fB at_pid .\fI N \fB .do \- pid \- calcs \fR (uses floating-point)
200200Does the PID calculations for control loop \fI N \fR .
201201
202202.SH PINS
203203
204204.TP
205- \fB pid .\fI N \fB .command \fR float in
205+ \fB at_pid .\fI N \fB .command \fR float in
206206The desired (commanded) value for the control loop.
207207.TP
208- \fB pid .\fI N \fB .Pgain \fR float in
208+ \fB at_pid .\fI N \fB .Pgain \fR float in
209209Proportional gain. Results in a contribution to the output that is the error
210210multiplied by \fB Pgain \fR .
211211.TP
212- \fB pid .\fI N \fB .Igain \fR float in
212+ \fB at_pid .\fI N \fB .Igain \fR float in
213213Integral gain. Results in a contribution to the output that is the integral
214214of the error multiplied by \fB Igain \fR . For example an error of 0.02 that
215215lasted 10 seconds would result in an integrated error (\fB errorI \fR ) of 0.2,
216216and if \fB Igain \fR is 20, the integral term would add 4.0 to the output.
217217.TP
218- \fB pid .\fI N \fB .Dgain \fR float in
218+ \fB at_pid .\fI N \fB .Dgain \fR float in
219219Derivative gain. Results in a contribution to the output that is the rate of
220220change (derivative) of the error multiplied by \fB Dgain \fR . For example an
221221error that changed from 0.02 to 0.03 over 0.2 seconds would result in an error
222222derivative (\fB errorD \fR ) of of 0.05, and if \fB Dgain \fR is 5, the derivative
223223term would add 0.25 to the output.
224224.TP
225- \fB pid .\fI N \fB .feedback \fR float in
225+ \fB at_pid .\fI N \fB .feedback \fR float in
226226The actual (feedback) value, from some sensor such as an encoder.
227227.TP
228- \fB pid .\fI N \fB .output \fR float out
228+ \fB at_pid .\fI N \fB .output \fR float out
229229The output of the PID loop, which goes to some actuator such as a motor.
230230.TP
231- \fB pid .\fI N \fB .command \- deriv \fR float in
231+ \fB at_pid .\fI N \fB .command \- deriv \fR float in
232232The derivative of the desired (commanded) value for the control loop. If no
233233signal is connected then the derivative will be estimated numerically.
234234.TP
235- \fB pid .\fI N \fB .feedback \- deriv \fR float in
235+ \fB at_pid .\fI N \fB .feedback \- deriv \fR float in
236236The derivative of the actual (feedback) value for the control loop. If no
237237signal is connected then the derivative will be estimated numerically. When
238238the feedback is from a quantized position source (e.g., encoder feedback
239239position), behavior of the D term can be improved by using a better velocity
240240estimate here, such as the velocity output of encoder(9) or hostmot2(9).
241241.TP
242- \fB pid .\fI N \fB .error \- previous \- target \fR bit in
242+ \fB at_pid .\fI N \fB .error \- previous \- target \fR bit in
243243Use previous invocation's target vs. current position for error calculation,
244244like the motion controller expects. This may make torque-mode position loops
245245and loops requiring a large I gain easier to tune, by eliminating
246246velocity\- dependent following error.
247247.TP
248- \fB pid .\fI N \fB .error \fR float out
248+ \fB at_pid .\fI N \fB .error \fR float out
249249The difference between command and feedback.
250250.TP
251- \fB pid .\fI N \fB .enable \fR bit in
251+ \fB at_pid .\fI N \fB .enable \fR bit in
252252When true, enables the PID calculations. When false, \fB output \fR is zero,
253253and all internal integrators, etc, are reset.
254254.TP
255- \fB pid .\fI N \fB .index \- enable \fR bit in
256- On the falling edge of \fB index \- enable \fR , pid does not update the
255+ \fB at_pid .\fI N \fB .index \- enable \fR bit in
256+ On the falling edge of \fB index \- enable \fR , at_pid does not update the
257257internal command derivative estimate. On systems which use the encoder
258258index pulse, this pin should be connected to the index\- enable signal.
259259When this is not done, and FF1 is nonzero, a step change in the input
260260command causes a single-cycle spike in the PID output. On systems which use
261261exactly one of the \fB \- deriv \fR inputs, this affects the D term as well.
262262.TP
263- \fB pid .\fI N \fB .bias \fR float in
263+ \fB at_pid .\fI N \fB .bias \fR float in
264264\fB bias \fR is a constant amount that is added to the output. In most cases
265265it should be left at zero. However, it can sometimes be useful to compensate
266266for offsets in servo amplifiers, or to balance the weight of an object that
@@ -269,36 +269,36 @@ just like all other components of the output. If a non-zero output is needed
269269even when the PID loop is disabled, it should be added with an external HAL
270270sum2 block.
271271.TP
272- \fB pid .\fI N \fB .FF0 \fR float in
272+ \fB at_pid .\fI N \fB .FF0 \fR float in
273273Zero order feed-forward term. Produces a contribution to the output that is
274274\fB FF0 \fR multiplied by the commanded value. For position loops, it should
275275usually be left at zero. For velocity loops, \fB FF0 \fR can compensate for
276276friction or motor counter-EMF and may permit better tuning if used properly.
277277.TP
278- \fB pid .\fI N \fB .FF1 \fR float in
278+ \fB at_pid .\fI N \fB .FF1 \fR float in
279279First order feed-forward term. Produces a contribution to the output that
280280is \fB FF1 \fR multiplied by the derivative of the commanded value. For
281281position loops, the contribution is proportional to speed, and can be used
282282to compensate for friction or motor CEMF. For velocity loops, it is
283283proportional to acceleration and can compensate for inertia. In both
284284cases, it can result in better tuning if used properly.
285285.TP
286- \fB pid .\fI N \fB .FF2 \fR float in
286+ \fB at_pid .\fI N \fB .FF2 \fR float in
287287Second order feed-forward term. Produces a contribution to the output that is
288288\fB FF2 \fR multiplied by the second derivative of the commanded value. For
289289position loops, the contribution is proportional to acceleration, and can be
290290used to compensate for inertia. For velocity loops, the contribution is
291291proportional to jerk, and should usually be left at zero.
292292.TP
293- \fB pid .\fI N \fB .FF3 \fR float in
293+ \fB at_pid .\fI N \fB .FF3 \fR float in
294294Third order feed-forward term. Produces a contribution to the output that is
295295\fB FF3 \fR multiplied by the third derivative of the commanded value. For
296296position loops, the contribution is proportional to jerk, and can be
297297used to compensate for residual errors during acceleration. For velocity
298298loops, the contribution is proportional to snap(jounce), and should usually
299299be left at zero.
300300.TP
301- \fB pid .\fI N \fB .deadband \fR float in
301+ \fB at_pid .\fI N \fB .deadband \fR float in
302302Defines a range of "acceptable" error. If the absolute value of \fB error \fR
303303is less than \fB deadband \fR , it will be treated as if the error is zero.
304304When using feedback devices such as encoders that are inherently quantized,
@@ -309,112 +309,112 @@ than the deadband, the deadband value is subtracted from the error before
309309performing the loop calculations, to prevent a step in the transfer function
310310at the edge of the deadband. (See \fB BUGS \fR .)
311311.TP
312- \fB pid .\fI N \fB .maxoutput \fR float in
312+ \fB at_pid .\fI N \fB .maxoutput \fR float in
313313Output limit. The absolute value of the output will not be permitted
314314to exceed \fB maxoutput \fR , unless \fB maxoutput \fR is zero. When the output
315315is limited, the error integrator will hold instead of integrating, to prevent
316316windup and overshoot.
317317.TP
318- \fB pid .\fI N \fB .maxerror \fR float in
318+ \fB at_pid .\fI N \fB .maxerror \fR float in
319319Limit on the internal error variable used for P, I, and D. Can be used to
320320prevent high \fB Pgain \fR values from generating large outputs under conditions
321321when the error is large (for example, when the command makes a step change).
322322Not normally needed, but can be useful when tuning non-linear systems.
323323.TP
324- \fB pid .\fI N \fB .maxerrorD \fR float in
324+ \fB at_pid .\fI N \fB .maxerrorD \fR float in
325325Limit on the error derivative. The rate of change of error used by the
326326\fB Dgain \fR term will be limited to this value, unless the value is
327327zero. Can be used to limit the effect of \fB Dgain \fR and prevent large
328328output spikes due to steps on the command and/or feedback. Not normally
329329needed.
330330.TP
331- \fB pid .\fI N \fB .maxerrorI \fR float in
331+ \fB at_pid .\fI N \fB .maxerrorI \fR float in
332332Limit on error integrator. The error integrator used by the \fB Igain \fR
333333term will be limited to this value, unless it is zero. Can be used to prevent
334334integrator windup and the resulting overshoot during/after sustained errors.
335335Not normally needed.
336336.TP
337- \fB pid .\fI N \fB .maxcmdD \fR float in
337+ \fB at_pid .\fI N \fB .maxcmdD \fR float in
338338Limit on command derivative. The command derivative used by \fB FF1 \fR will
339339be limited to this value, unless the value is zero. Can be used to prevent
340340\fB FF1 \fR from producing large output spikes if there is a step change on the
341341command. Not normally needed.
342342.TP
343- \fB pid .\fI N \fB .maxcmdDD \fR float in
343+ \fB at_pid .\fI N \fB .maxcmdDD \fR float in
344344Limit on command second derivative. The command second derivative used by
345345\fB FF2 \fR will be limited to this value, unless the value is zero. Can be
346346used to prevent \fB FF2 \fR from producing large output spikes if there is a
347347step change on the command. Not normally needed.
348348.TP
349- \fB pid .\fI N \fB .maxcmdDDD \fR float in
349+ \fB at_pid .\fI N \fB .maxcmdDDD \fR float in
350350Limit on command third derivative. The command third derivative used by
351351\fB FF3 \fR will be limited to this value, unless the value is zero. Can be
352352used to prevent \fB FF3 \fR from producing large output spikes if there is a
353353step change on the command. Not normally needed.
354354.TP
355- \fB pid .\fI N \fB .saturated \fR bit out
355+ \fB at_pid .\fI N \fB .saturated \fR bit out
356356When true, the current PID output is saturated. That is,
357357.RS 12
358358\fB output \fR = \(+- \fB maxoutput \fR .
359359.RE
360360.TP
361- \fB pid .\fI N \fB .saturated \- s \fR float out
361+ \fB at_pid .\fI N \fB .saturated \- s \fR float out
362362.br
363363.ns
364364.TP
365- \fB pid .\fI N \fB .saturated \- count \fR s32 out
365+ \fB at_pid .\fI N \fB .saturated \- count \fR s32 out
366366When true, the output of PID was continually saturated for this many seconds
367367(\fB saturated \- s \fR ) or periods (\fB saturated \- count \fR ).
368368
369369.SS Additional auto tuning pins
370370.TP
371- \fB pid .\fI N \fB .tune \- mode \fR bit in
371+ \fB at_pid .\fI N \fB .tune \- mode \fR bit in
372372When true, enables auto tune mode. When false, normal PID calculations are
373373performed.
374374.TP
375- \fB pid .\fI N \fB .tune \- start \fR bit io
375+ \fB at_pid .\fI N \fB .tune \- start \fR bit io
376376When set to true, starts auto tuning. Cleared when the auto tuning completes.
377377.TP
378- \fB pid .\fI N \fB .tune \- type \fR u32 rw
378+ \fB at_pid .\fI N \fB .tune \- type \fR u32 rw
379379When set to 0, \fB Pgain/Igain/Dgain \fR are calculated. When set to 1,
380380\fB Pgain/Igain/FF1 \fR are calculated.
381381.TP
382- \fB pid .\fI N \fB .tune \- cycles \fR u32 rw
382+ \fB at_pid .\fI N \fB .tune \- cycles \fR u32 rw
383383Determines the number of cycles to run to characterize the process.
384384\fB tune \- cycles \fR actually sets the number of half cycles. More cycles results
385385in a more accurate characterization as the average of all cycles is used.
386386.TP
387- \fB pid .\fI N \fB .tune \- effort \fR float rw
387+ \fB at_pid .\fI N \fB .tune \- effort \fR float rw
388388Determines the effort used in setting up the limit cycle in the process.
389389\fB tune \- effort \fR should be set to a positive value less than \fB maxoutput \fR .
390390Start with something small and work up to a value that results in a good
391391portion of the maximum motor current being used. The smaller the value, the
392392smaller the amplitude of the limit cycle.
393393.TP
394- \fB pid .\fI N \fB .ultimate \- gain \fR float ro (only if debug=1)
394+ \fB at_pid .\fI N \fB .ultimate \- gain \fR float ro (only if debug=1)
395395Determined from process characterization. \fB ultimate \- gain \fR is the ratio of
396396\fB tune \- effort \fR to the limit cycle amplitude multiplied by 4.0 divided by Pi.
397397.TP
398- \fB pid .\fI N \fB .ultimate \- period \fR float ro (only if debug=1)
398+ \fB at_pid .\fI N \fB .ultimate \- period \fR float ro (only if debug=1)
399399Determined from process characterization. \fB ultimate \- period \fR is the period
400400of the limit cycle.
401401
402402.SH PARAMETERS
403403.TP
404- \fB pid .\fI N \fB .errorI \fR float ro (only if debug=1)
404+ \fB at_pid .\fI N \fB .errorI \fR float ro (only if debug=1)
405405Integral of error. This is the value that is multiplied by \fB Igain \fR to produce the Integral term of the output.
406406.TP
407- \fB pid .\fI N \fB .errorD \fR float ro (only if debug=1)
407+ \fB at_pid .\fI N \fB .errorD \fR float ro (only if debug=1)
408408Derivative of error. This is the value that is multiplied by \fB Dgain \fR to produce the Derivative term of the output.
409409.TP
410- \fB pid .\fI N \fB .commandD \fR float ro (only if debug=1)
410+ \fB at_pid .\fI N \fB .commandD \fR float ro (only if debug=1)
411411Derivative of command. This is the value that is multiplied by \fB FF1 \fR to produce the first order feed-forward term of the output.
412412.TP
413- \fB pid .\fI N \fB .commandDD \fR float ro (only if debug=1)
413+ \fB at_pid .\fI N \fB .commandDD \fR float ro (only if debug=1)
414414Second derivative of command. This is the value that is multiplied by
415415\fB FF2 \fR to produce the second order feed-forward term of the output.
416416.TP
417- \fB pid .\fI N \fB .commandDDD \fR float ro (only if debug=1)
417+ \fB at_pid .\fI N \fB .commandDDD \fR float ro (only if debug=1)
418418Third derivative of command. This is the value that is multiplied by
419419\fB FF3 \fR to produce the third order feed-forward term of the output.
420420
@@ -424,7 +424,7 @@ treated as zero if it is within the deadband, and be unmodified if it is outside
424424the deadband. This was not done because it would cause a step in the transfer
425425function equal to the size of the deadband. People who prefer that behavior are
426426welcome to add a parameter that will change the behavior, or to write their own
427- version of \fB pid \fR . However, the default behavior should not be changed.
427+ version of \fB at_pid \fR . However, the default behavior should not be changed.
428428
429429Negative gains may lead to unwanted behavior. It is possible in some
430430situations that negative FF gains make sense, but in general all gains
0 commit comments