en:software:qview:qview_6:qcl_library:ot21pidreg

This is an old revision of the document!


OT21PidReg

O = Digital Output

T = Control functions

The OT21PidReg function implements a generic PID controller. In addition to providing the regulation value, the function operates two digital signals are modulated pulse width to handle positive and negative representation of control output.

OT21PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, gfEnaReg, aglOutReg )

Parametri:

IN/OUTVARIABLE TYPEEXAMPLE NAMEDIM
INARRSYSaswParReg [1]WSample time PID controller (msec) [0÷32767].
INARRSYSaswParReg [2]WMaximum scale limit of process variable (UM) [-32768÷32767]
INARRSYSaswParReg [3]WMinimum scale limit of process variable (UM) [-32768÷32767]
INARRSYSaswParReg [4]WMaximum value control output [-32768 ÷32767]
INARRSYSaswParReg [5]WMinimum value control output [-32768 ÷32767]
INARRSYSaswParUsr [1]WProportional gain.()[0÷9999]
INARRSYSaswParUsr [2]WIntegral time (msec) [0÷9999]
INARRSYSaswParUsr [3]WDerivative time (msec) [0÷9999]
INARRSYSaswParUsr [4]WSample time of the derivative [0÷255]
0=sample time PID controller
1=2*sample time PID controller


n=(n+1)*sample time PID controller
INARRSYSaswParUsr [5]WDerived filter time constant (msec.) [0÷9999]
INARRSYSaswParUsr [6]WFeed Forward (‰) [0÷2000]
INGLOBALgwSetPointWAdjustment setpoint (UM)
INGLOBALgwMeasureWValue of the process variable (UM)
INGLOBALgfEnaRegFEnabling regulation [0÷1]
0=regulator disabled
1=regulator enabled
OUTARRGBLaglOutReg[1]LPID output log
OUTARRGBLaglOutReg[2]LProportional output log
OUTARRGBLaglOutReg[3]LIntegral output log
OUTARRGBLaglOutReg[4]LDerivative output log
OUTARRGBLaglOutReg[5]LFeedforward output log
OUTARRGBLaglOutReg[6]LError log
OUTARRGBLaglOutReg[7]LRegulator states:
bit 0 = State pwm output for positive adjustment
bit 1 = State pwm output for negative regulation
bit 2 = positive saturation state
bit 3 = negative saturation state
bit 4 + executing state regulation
OUTARRGBLaglOutReg[8]LError code

Once call the function, the “Error Code” variable in aglOutReg[8] assumes certain values, the meaning of these values is summarized below:
0: No error
1: Error setting sampling time
2: Error setting lower limit and/or greater of scale
3: Error setting value proportional gain
4: Error setting integral time
5: Error setting derivative time
6: Error setting feed-forward percentage value
7: Error setting minimum and/or maximum value regulator output
8: Error setting sampling time derivative
9: Error setting derived filter time constant

Example

;---------------------------------------------
;	Example
;---------------------------------------------
	aswParReg [0]=500			; Sampling time = 500ms
	aswParReg [1]=10000			; full scale over  = 10000
	aswParReg [2]=0			        ; full scale less  = 0
	aswParReg [3]=500			; Maximum value output regulator
	aswParReg [4]=0			        ; Minimum value output regulator
 
        aswParUsr[1] = 100			; Proportional gain = 0.1
        aswParUsr[2] = 200			; Integral time = 0.2 sec.
 
        gfEnaReg = 1				;Enable regulation
MAIN:
	gwSetPoint = 800
        OT20PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, gfEnaReg, aslOutReg )
        ofOutPow = aslOutReg[7] ANDB &H01
WAIT 1
JUMP MAIN

A regulator reads an (gwMeasure) input variable, compares with to a reference signal (gwSetPoint) and change the value of the (aslOutReg[7]) output to achieve equality of the variable with the reference.

One of the most popular types of regulator is the PID (Proportional, Integral, Derivative).

Proportional action

This control action establishes a relationship of direct proportionality between the error (aglOutReg[6]) and the value at the regulator output. The gain proportional parameter (aswParUsr [1]) defines the degree of proportional controller; It's expressed in milliseconds for which to set a gain of 0.5 it should enter the value 500.
The rule that establishing the output value (aslOutReg[7]) defines: with unity gain (1000), the control output will be maximum when the error is equal to the difference between “Maximum scale limit” and “Maximum scale limit” that is the result between aswParReg [2] - aswParReg [3].

Azione integrale

L'azione integrale del regolatore PID calcola l'integrale dell'errore su un intervallo di tempo impostabile dall'utente tramite il parametro aswParUsr [2] (espresso in ms). Il segnale di uscita viene aggiornato in modo particolare: ogni volta che l'integratore da un valore in uscita questo è sommato al valore che si trova sul registro, quindi esso continuerà ad incrementarsi o decrementarsi (a seconda del segno dell'errore). Il valore d'uscita è calcolato così: con guadagno proporzionale unitario, il tempo di integrazione (aswParUsr [2]) è il tempo necessario affinché lil registro integrale (aglOutReg[3]) raggiunga il valore del registro proporzionale (aglOutReg[2]). Da quest'ultima affermazione si deduce che l'azione integrale è legata all'azione proporzionale.

Azione derivativa

L'azione derivativa cerca in un certo senso di “anticipare” il comportamento del sistema che si sta controllando. L'uscita prodotta è proporzionale alla variazione del segnale di ingresso. L'entità dell'effetto derivativo è impostabile tramite il parametro tempo derivativo (aswParUsr [3]). Il calcolo dell'azione derivativa si basa sulla seguente convenzione: il tempo derivativo è il tempo necessario affinché, con variazione di errore costante, il registro derivativo (aglOutReg[4]) raggiunga un valore pari al registro proporzionale (aglOutReg[2]). Come per l'azione integrale si evince che anche per l'azione derivativa c'è un legame con l'azione proporzionale. Più alto è il tempo di derivazione dell'errore e più veloce è il sistema nel recupero dell'errore nei transitori. E' evidente comunque che l'azione derivativa non può mai essere utilizzata da sola perché in presenza di errori costanti il suo effetto sarebbe nullo.

Azione feed-forward

In aggiunta al regolatore PID è presente anche l'azione feed-forward: essa genera un'uscita proporzionale al valore di setpoint (come si può dedurre dal nome non sfrutta alcuna retroazione dell'errore). La sua funzione è di ridurre il tempo di risposta del sistema fornendo un'uscita già vicina a quella che il regolatore dovrebbe raggiungere. Il contributo di questa azione è regolabile mediante il parametro feed forward (aswParUsr [6]): questo parametro è espresso come porzione millesimale (quindi per introdurre, ad esempio, 98.5% è necessario impostare il valore 985).

DIFFERENZE RISPETTO ALLE VECCHIE RELEASE

  • (dalla 20 alla 21) Aggiunto uno stato di esecuzione regolazione. ? Evitato un errore ““division by zero” alla prima esecuzione ? Evitato di azzerare l'uscita integrale OUTI se ti=0. Questo serve per poter sospendere l'esecuzione del pid e riprenderla senza che il registro integrale venga alterato.
  • Last modified: 2019/08/29 17:18