Digital Pid Controller 175
Digital Pid Controller 175
Digital Pid Controller 175
The digital PID controller described in gram. The program determines the
this article, based on a PIC microcon- control error relative to the set value
troller, is on the one hand very well (target value) for each actual value and,
suited to studying how based on this, calculates the control
the controller operates value that is output to the external D/A
Specifications: with various parameter converter. The control parameters,
➤ controller type: PID values, using simple con- which are entered by a keypad, are
➤ parameter entry: hexadecimal keypad trol loops. On the other stored in a non-volatile memory (EEP-
➤ parameter display: alphanumeric LCD hand, it can of course ROM).
also be used for specific In order to manage with the pro-
➤ adjustable parameters: - set value
control tasks. A complete gram memory of the PIC, which is only
- initial control quantity value control loop requires an 1 kB, the parameters are entered as
- upper limit appropriate actuator and hexadecimal codes. They are however
- lower limit a suitable sensor, in addi- displayed on the LCD as text, which is
- sampling interval (100 ms to 25 s) tion to the controller easier to understand.
➤ parameter storage: EEPROM itself.
➤ A/D and D/A conversion: 8 bit The core of the circuit BASIC THEORY
(measured value, control quantity) is an inexpensive PIC Control circuits are encountered very
➤ microcontroller: PIC 16C71 16C71 microcontroller, often in electronics. For instance, a
whose built-in A/D con- voltage regulator is present in almost
verter digitizes the mea- every circuit. More elaborate con-
sured value (actual value) and pro- trollers for dealing with other physical
Design By D. Kohtz vides the result to the controller pro- quantities, such as rotational speed,
5V 5V
5V
4 D1 C4
C7
R10
9k53
100n 1%
R5 R1 100n
14 6
10k
1k5
11 R7
7
IC5b 10Ω
2 6 RB0 RB0 1 16 5
R8 RB0 D0 VOUT
1 17 7 RB1 RB1 2 15
R12 IC5a 1k RA0 RB1 D1 SA
IC3
10k0
3 18 8 RB2 RB2 3 14
10k RA1 IC2 RB2 D2 SB R11
1 9 RB3 RB3 4
RA2 RB3 D3
C8 2 PIC 10 RB4 RB4 5 1%
R13 RA3 RB4 D4
1M
16C71 8V4
3 11 RB5 RB5 6 AD557
RA4 RB5 D5 R9 5V
10n 12 RB6 RB6 7 10
RB6 D6 CS 10k
4 13 RB7 RB7 8 9
MCLR RB7 D7 CE
8 C11
5V R6 OSC1 OSC2
12 13 IC5 = TLC272 IC5
100Ω
16 15 5
4 100n
270Ω
C5 R4
C6 X1
P1 S1 4MHz
K1 10µ
10µ 10V
1 10V 10k C2 C3
RB4
RB5
RB6
RB7
VSS RESET
2
VDD
3 22p 22p S15 S16 S17 S18
VO
4
RS
R/W
5 C D E F
RB3
6 5V 5V
E S11 S12 S13 S14
7 RB0
D0 C1
8 RB1
D1 8 9 A B
9 RB2 +8V4 5V 100n R2 R3 RB2
D2
10k
10k
10 RB3 S7 S8 S9 S10
D3 IC4 8
11 RB4
D4 7805
12 RB5 +9V D2 +5V 1
A0 4 5 6 7
D5 2 5 RB7 RB1
13 RB6 A1 IC1 SDA
D6 1N4001 3 6 RB6 S3 S4 S5 S6
14 RB7 A0 SCL
D7 C9 C10
7 24C01
WP 0 1 2 3
LM16A211 100µ 25V 10µ 10V RB0
4
S2
SET
990038 - 11
H2
C1 D1
C6 R7 Capacitors:
C4 C5
C11 C1,C4,C7,C11 = 100nF ceramic
IC1
C2,C3 = 22pF ceramic
R9
IC2 R1
OUT
R8 C5,C10 = 10µF radial
IC5
R10
C7
T C6 = 10µF 10V
C8 C8 = 10nF MKT (Siemens)
R4 T
IC3 C3 R13 C9 = 100µF 26V radial
X1 R12
C2
R11
T Semiconductors:
D1 = LED, red, high efficiency
S15 S16 S17 S18 D2 = 1N4001
0 IC1 = 24C01
C D E F IC4 IC2 = PIC16C71, order code
R6
996504-1
S11 S12 S13 S14 +5V IC3 = AD557JN (Analog Devices)
IC4 = 7805
8 9 A B IC5 = TL272CP
C9
R3
R2
C10
S7 S8 S9 S10 0
Miscellaneous:
4 X1 = 4MHz quartz crystal
5 6 7 D2
+9V K1 = LM16A211 LCD module,2 x 16
characters (Sharp)
S3 S4 S5 S6 S2 S1 S1-S18 = pushbutton, PCB mount,
Set Reset ITC type D6-R-RD
1 2 3
0 PCB, order code 990038-1
H3
H4
1-830099
Disk, contains PIC source code,
990038-1 ROTKELE )C(
order code 996003-1
CONSTRUCTION AND
OPERATION
Constructing the circuit on the printed
circuit board does not require any
unusual skills. Since the circuit board is
single-sided, a few jumpers are
unavoidable. Do not overlook them
when stuffing the board.
The keypad module specified in the
list of components must be used for the
parameter input pushbuttons, due to
the internal connections. An unregu-
lated 9 V mains adapter can be used for
the power supply, as long as it can sup-
ply at least 200 mA.
When setting up the board, first
adjust P1 to set the contrast of the dis-
Figure 5. PCB track play for optimum readability.
parameters, since the layout and component than one purpose. In A simple circuit, shown in Figure 7,
values that were previ- mounting plan (board principle, this is not a has been designed for testing the con-
ously stored in the EEP- available ready-made). problem, since (for troller and experimenting with it. This
ROM can be used again. example) the registers circuit simulates the process to be con-
Since the program used for performing trolled. The step response of the
needs a very large number of registers, calculations are never used during process is determined by the time con-
some registers must be used for more parameter input. The only disadvan- stants of three RC low-pass circuits
q0 = 13.5D = 0D80H
q1 = –18.5D = ED80H
q2 = 6.5D = 0680H
sampling interval = 0.4 s (enter ‘04’)
target value = 80H (approx. 2.5 V)
initial control value = A0H (approx.
3.1 V)
Figure 6. Finished pro-
totype of the digital Since the electrolytic capacitors in the
controller. simulation circuit have quite large tol-
erances, it is possible that the controller
will not operate optimally with the
above values. In this case the values of
q0 through q2 should be empirically
adjusted.
connected in series. The time constants tion ‘INTERVAL’) is determined by The output signal of the controller
of this ‘electronic process’ can thus be multiplying a basic increment of 0.1 s is set to 0 V during parameter entry.
easily changed, and interference can be (fixed in software) by the entered hexa- After parameter entry has been com-
easily simulated by loading the output decimal value. pleted by pressing SET, the control
with the switchable resistor. To use the The parameters q0, q1 and q2, which value (CONTROL VAL) is output at a
simulation circuit, connect its input to are important for the control algo- level equal to its entered initial value
the output of the controller and its out- rithm, are entered as fixed-point num- until the entered target value (SET-
put to the input of the controller. bers, with one byte (two hex charac- VALUE) is reached. After this, the
Control parameter values can be ters) before the decimal point and one actual control process starts up and,
entered only immediately after the cir- byte after the decimal point. The bits depending on the selected control
cuit is switched on or directly follow- after the decimal point are weighted parameter values, more or less exactly
ing a reset. They are entered in hexa- according to 1/2n, where n represents maintains the controlled variable at the
decimal form by means of the keypad. the bit position (MSB = 1, LSB = 8). A set value, even in the presence of inter-
Two characters will be displayed after hex value of 80 after the decimal point ference. During the control process, the
two keys have been pressed in turn. thus corresponds to 1/2 (0.5 decimal). current levels of the control value
The SET button must be pressed for Since q1 is always negative, a short (CONTROL VAL) and the actual value
the entered value to be accepted and explanation of the representation of (ACT.VAL) are continuously displayed.
stored in EEPROM. The target value negative binary numbers is in order. A If either the upper or lower limit
and the initial value of the control negative binary number is formed by value (UPPER LIMIT or LOWER
quantity can be set between 00H and bitwise inverting a positive number LIMIT) is exceeded, the alarm lamp
FFH, which corresponds to a voltage and adding one to the result. An exam- (LED D1) blinks for the duration of
range of 0 to 5 V. The upper and lower ple is: out-of-limits condition. No new values
limit values can also be set between are displayed during this interval. The
00H and FFH. The 13D = 0000 1101B = 0DH controller output goes to zero if the
Figure 7. This little cir- length of the inverted: 1111 0010B = F2H upper limit is exceeded, and to FFH
cuit simulates a sampling interval +1: 1111 0011B = F3H (5 V) if the lower limit is exceeded.
‘process’ for testing (display indica- If the controller is started anew by
the controller. pressing Reset, the parameter entry
process must be run through again by
pressing SET after each parameter
value is displayed. SETVALUE appears
1k 4k7 10k
first on the display, with the last saved
7 value. The values of CONTROL VAL,
100k
∫e( τ)dτ
pling interval).
u(t ) = K PR ⋅e(t )+ K DR ⋅de(t )/ dt + K IR ⋅ The finite sum is defined as the discrete-time equivalent of
the continuous-time integral of a function. It is given by the
0
formula
In this equation, KPR, KDR and KIR represent the
(adjustable) gains of the three controllers (P, D and I con-
trollers) shown in Figure 3. This equation can also be rep- b
resented in the frequency domain by applying the Laplace
transform, as follows: ∫ f( τ) = T[f(a +T)+ f(a +2T)+ . . . + f(b)]
a