@@ -21,6 +21,146 @@ value is three. If \fBdebug\fR is set to 1 (the default is 0), some
2121additional HAL parameters will be exported, which might be useful
2222for tuning, but are otherwise unnecessary.
2323
24+ .P
25+ In the following description, it is assumed that we are discussing
26+ position loops. However this component can be used to implement other
27+ loops such as speed loops, torch height control, and others.
28+
29+ .P
30+ Each loop has a number of pins and parameters, whose names begin
31+ with 'pid.N.', where 'N' is the channel number. Channel numbers start
32+ at zero.
33+ .P
34+ The three most important pins are 'command', 'feedback', and 'output'.
35+ For a position loop, 'command' and 'feedback' are in position units.
36+ For a linear axis, this could be inches, mm, metres, or whatever is
37+ relevant. Likewise, for a angular axis, it could be degrees, radians,
38+ etc. The units of the 'output' pin represent the change needed to
39+ make the feedback match the command. As such, for a position
40+ loop 'Output' is a velocity, in inches/sec, mm/sec, degrees/sec, etc.
41+ .P
42+ Each loop has several other pins as well. 'error' is equal
43+ to 'command' minus 'feedback'. 'enable' is a bit that enables the
44+ loop. If 'enable' is false, all integrators are reset, and the output
45+ is forced to zero. If 'enable' is true, the loop operates normally.
46+ .P
47+ The PID gains, limits, and other 'tunable' features of the loop are
48+ implemented as parameters. These are as follows:
49+
50+ .PP
51+ \fB Pgain \fR Proportional gain
52+ .PD 0
53+ .P
54+ .PD
55+ \fB Igain \fR Integral gain
56+ .PD 0
57+ .P
58+ .PD
59+ \fB Dgain \fR Derivative gain
60+ .PD 0
61+ .P
62+ .PD
63+ \fB bias \fR Constant offset on output
64+ .PD 0
65+ .P
66+ .PD
67+ \fB FF0 \fR \fR Zeroth order Feedforward gain
68+ .PD 0
69+ .P
70+ .PD
71+ \fB FF1 \fR \fR First order Feedforward gain
72+ .PD 0
73+ .P
74+ .PD
75+ \fB FF2 \fR \fR Second order Feedforward gain
76+ .PD 0
77+ .P
78+ .PD
79+ \fB FF3 \fR \fR Third order Feedforward gain
80+ .PD 0
81+ .P
82+ .PD
83+ \fB deadband \fR Amount of error that will be ignored
84+ .PD 0
85+ .P
86+ .PD
87+ \fB maxerror \fR Limit on error
88+ .PD 0
89+ .P
90+ .PD
91+ \fB maxerrorI \fR Limit on error integrator
92+ .PD 0
93+ .P
94+ .PD
95+ \fB maxerrorD \fR Limit on error differentiator
96+ .PD 0
97+ .P
98+ .PD
99+ \fB maxcmdD \fR Limit on command differentiator
100+ .PD 0
101+ .P
102+ .PD
103+ \fB maxcmdDD \fR Limit on command 2nd derivative
104+ .PD 0
105+ .P
106+ .PD
107+ \fB maxcmdDDD \fR Limit on command 3rd derivative
108+ .PD 0
109+ .P
110+ .PD
111+ \fB maxoutput \fR Limit on output value
112+ .P
113+ All of the limits (max____) are implemented such that if the parameter
114+ value is zero, there is no limit.
115+ .P
116+ A number of internal values which may be useful for testing and tuning
117+ are also available as parameters. To avoid cluttering the parameter
118+ list, these are only exported if "debug=1" is specified on the insmod
119+ command line.
120+
121+ .PP
122+ \fB errorI \fR Integral of error
123+ .PD 0
124+ .P
125+ .PD
126+ \fB errorD \fR Derivative of error
127+ .PD 0
128+ .P
129+ .PD
130+ \fB commandD \fR Derivative of the command
131+ .PD 0
132+ .P
133+ .PD
134+ \fB commandDD \fR 2nd derivative of the command
135+ .PD 0
136+ .P
137+ .PD
138+ \fB commandDDD \fR 3rd derivative of the command
139+
140+ .P
141+ The PID loop calculations are as follows (see the code in pid.c for
142+ all the nitty gritty details):
143+ .IP
144+ .nf
145+ error = command - feedback
146+ if ( abs(error) < deadband ) then error = 0
147+ limit error to +/- maxerror
148+ errorI += error * period
149+ limit errorI to +/- maxerrorI
150+ errorD = (error - previouserror) / period
151+ limit errorD to +/- maxerrorD
152+ commandD = (command - previouscommand) / period
153+ limit commandD to +/- maxcmdD
154+ commandDD = (commandD - previouscommandD) / period
155+ limit commandDD to +/- maxcmdDD
156+ commandDDD = (commandDD - previouscommandDD) / period
157+ limit commandDDD to +/- maxcmdDDD
158+ output = bias + error * Pgain + errorI * Igain +
159+ errorD * Dgain + command * FF0 + commandD * FF1 +
160+ commandDD * FF2 + commandDDD * FF3
161+ limit output to +/- maxoutput
162+ .fi
163+
24164.SH NAMING
25165The names for pins, parameters, and functions are prefixed as:
26166 \fB pid.N. \fR for N=0,1,...,num\- 1 when using \fB num_chan=num \fR
0 commit comments