0% found this document useful (0 votes)
50 views4 pages

PID Saia

This document describes a PID control algorithm that implements PID control using 13 registers. It explains what each register represents, such as the new result, previous result, controlled variable, reference variable, and proportional, integral and derivative factors. It provides details on how the PID instruction calculates the new result and describes other components like the dead range, cold start value, resolution and sampling time.

Uploaded by

Miguel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views4 pages

PID Saia

This document describes a PID control algorithm that implements PID control using 13 registers. It explains what each register represents, such as the new result, previous result, controlled variable, reference variable, and proportional, integral and derivative factors. It provides details on how the PID instruction calculates the new result and describes other components like the dead range, cold start value, resolution and sampling time.

Uploaded by

Miguel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

PID - PID Control Algorithm Page 1 of 4

PID - PID Control Algorithm


Description
Implements a PID algorithm using data defined in an array of 13 Registers.

Register Meaning Symbol


+0 New Result Yn * size is 'm' bits
+1 Previous Result Yn 1 *
+2 New Controlled Variable Xn w size is 'm' bits
+3 Prev. Controlled Variable Xn 1 *
+4 Reference Variable Wn w size is 'm' bits
+5 Prev. Set point Variable Wn 1 *
+6 Proportional Factor Fp w * 256
+7 Integral Factor Fi w * 256
+8 Derivative Factor Fd w * 256
+9 Dead Range Dr w
+10 Cold Start Y Ys w Starting value for Yn
+11 Precision in bits m w m = 8, 12 or 16 bits
+12 Workspace Zs *

* These values are handled by the PID instruction.


w These values must be written into the register by the user program.

Format
PID    [=] reg    ;reg is the lowest address of 13 Registers

Example
PID    R 1000     ;use R 1000..1012 for the PID control data

Flags
Unchanged.

Practical example
Flowchart of typical PID control loop:

mk:@MSITStore:C:\Program%20Files%20(x86)\SBC\PG5%20V2.3.175\Sasm52.chm::/id... 13/8/2021
PID - PID Control Algorithm Page 2 of 4

PID Instruction Details

New Result Yn:


This is the actual result to control the process determined by the system program from the following
equation with Zs = Zs + (Wn - Xn):

If the result exceeds the declared precision in bits, it will be limited to its maximum value (m bits) or, in case
of a negative result, it will be set to 0.

mk:@MSITStore:C:\Program%20Files%20(x86)\SBC\PG5%20V2.3.175\Sasm52.chm::/id... 13/8/2021
PID - PID Control Algorithm Page 3 of 4

Previous Result Yn1


This is the old result determined in the previous operation.

Controlled Variable Xn
The controlled variable Xn is read from the process and written to the register (R+2) by the user program.
The controlled variable should be maximum 'm' bits

Previous Controlled Variable Xn1


This is the old controlled variable used in the previous arithmetic operation.

Reference Wn
The reference (setpoint) is written to the register (R+4) by the user program. The reference should be
maximum 'm' bits.

Previous Reference Wn1


This is the old reference used in the previous arithmetic operation.

Proportional Factor FP
This factor determines the proportional (amplification) characteristic of the regulator and is written to the
register (R+6) by the user program.
When calculating, only the 16 lower bits are used (0..65535)
The Proportional factor is determined as follows:

where Xp = Proportional band


Note: To enter a proportional band of 5%, the Fp factor must be set to:
(1 / 0.05) * 256 = 5120

A cold start of the PID must be executed after a modification of Fp or Fi

Integral Factor Fi
This factor determines the integral characteristic of the regulator and is written to the register (R+7) by the
user program.
When calculating, only the 16 lower bits are used (0..65535)
The Integral factor is determined as follows:

Fi = (To / Ti) * 256

where
To : sampling time of the PID instruction
Ti : integral time
A cold start of the PID must be executed after a modification of Fp or Fi

Derivative Factor Fd
This factor determines the derivative characteristic of the regulator and is written to the register (R+8) by the
user program.
When calculating, only the 16 lower bits are used (0..65535)
The Derivative factor is determined as follows:

where
To : sampling time of the PID instruction
Td : derivative time

Dead Range Dr
The dead range defines the range in which the variations of the controlled variable may occur without
causing a modification of the Result variable (Yn).

Cold Start YS

mk:@MSITStore:C:\Program%20Files%20(x86)\SBC\PG5%20V2.3.175\Sasm52.chm::/id... 13/8/2021
PID - PID Control Algorithm Page 4 of 4

This value is used as starting value for Yn by the system program.


As soon as the user program writes a value other than 0 to the cold start register, a cold start calculation is
made: Yn = Ys

Yn1 = Ys
Zs = [(Ys * 256/Fp) (Wn Xn)] *256/Fi
Wn1 = Wn
Xn1 = Xn

The value of Ys is automatically reset to 0 by the system program after being used once and will not be
used again.

For a Cold Start with an output value of 0, the Ys register must be set to -1.

When Fi = 0, the Yn value can not be initialised with a Cold Start. A Cold Start is however recommended to
initialise the workspace register.
In this case, the Ys value is ignored, the Zs register is set to 0 and Yn takes the value of the proportional
part of the algorithm.

Note: Changing from manual to automatic control is a typical application of a cold start calculation. In order
to achieve a smooth transition, Ys may be set equal to the currently output variable (Yn).

Resolution m
The maximum values of X, W, Yn and Ys are determined by the resolution.
If m = 8: 8 bits are used (0..255)
If m = 12: 12 bits are used (0..4095)
If m = 16: 16 bits are used (0..65535)
The resolution is mostly defined by the analog module used for the Result variable output.
If the resolution for the input and output are not the same, the Yn value must be adapted after the PID
instruction.

Sampling Time
The sampling time To must be done outside the PID instruction with a timer.
In practice: To » 0,1 time constant of the process (To must be at least 80 ms)

Calculation capacity
The workspace register Zs has a maximum capacity of 231.
When using 16 bits values (m = 16), an overflow can occur; in this case the PID will not work properly.
To avoid this problem, the factor Fp must be ³ 2 if m = 16 (There is no problem when m = 8 or 12).

mk:@MSITStore:C:\Program%20Files%20(x86)\SBC\PG5%20V2.3.175\Sasm52.chm::/id... 13/8/2021

You might also like