PID Saia
PID Saia
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
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
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
Reference Wn
The reference (setpoint) is written to the register (R+4) by the user program. The reference should be
maximum 'm' bits.
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:
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:
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
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