PID processing with optional PWM output
PID processing is performed to keep the process value PV as close as possible to the set point value SP. In contrast to FP_PID_BASIC, this instruction enables a PWM output (on-off output). Auto-tuning is also available to automatically calculate the PID control data Kp, Ti, and Td.
Input
Start condition
Control data
Process value (-30000–30000)
PID control parameters
Input/output
Data table of PID parameters
When you execute the instruction for the first time, i.e. when the execution condition specified at Run turns to TRUE, the default values are written to the DUT members 1 to 9 of DUT .
Before the second execution of FP_PID, you need to change the DUT members 1 to 9 of the DUT to the required values.
Output
Pulse-width modulated output (optional, can be used instead of manipulated value output)
The period (cycle) of the PWM output is the sampling time Ts (the frequency of the PWM output is 1/Ts) and the duty is the manipulated value MV in 0.01% units, e.g. MV = 10000 means a duty of 100%.
The instruction has to be executed twice. The first execution resets the values in PID_WORK_AREA_DUT, then the correct values for the DUT members 1 to 9 in PID_WORK_AREA_DUT need to be set so that the second execution of the instruction uses the correct values.
if the area specified using the index modifier exceeds the limit.
if a value specified for a parameter of PID_Parameters_DUT is outside the permissible range
if the area specified using the index modifier exceeds the limit.
if a value specified for a parameter of PID_Parameters_DUT is outside the permissible range
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
Automatic: BOOL:=TRUE;
dutControl: PID_Control_DUT;
PV: INT:=0;
ParametersHold: PID_Parameters_DUT;
ParametersNonHold: PID_Work_Area_DUT;
bPWMOutput: BOOL:=FALSE;
END_VAR
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 7 ;
NETWORK_BODY
B(B_VARIN,,dutControl,15,2,17,4,);
B(B_VARIN,,ParametersHold,15,4,17,6,);
B(B_CONTACT,,Automatic,6,1,8,3,);
B(B_VARIN,,ParametersNonHold,15,5,17,7,);
B(B_F,FP_PID!,,17,0,30,7,,?DRun?Ds1_Control?Ds2_ProcessValue?Ds3_Parameters?Ds4_WorkArea?As4_WorkArea?APWM);
B(B_VARIN,,PV,15,3,17,5,);
B(B_VAROUT,,bPWMOutput,30,1,32,3,);
L(1,2,6,2);
L(8,2,17,2);
L(1,0,1,7);
END_NETWORK_BODY
END_NET_WORK
END_BODY
bPWMOutput := FP_PID(Run := Automatic,
s1_Control := dutControl,
s2_ProcessValue := PV,
s3_Parameters := ParametersHold,
s4_WorkArea := ParametersNonHold);