Configuration | Rules Sample: Rule 166 is configured with the following parameters: Maximum number of inputs: 0 Maximum number of outputs: 10 Maximum number of inputs/outputs: 1 The following function block therefore reports two SA0166 errors, since too many inputs (> 0) and too many inputs/outputs (> 1) are declared. Function block FB_Sample: FUNCTION_BLOCK FB_Sample // => SA0166 VAR_INPUT bIn : BOOL; END_VAR VAR_OUTPUT bOut : BOOL; END_VAR VAR_IN_OUT bInOut1 : BOOL; bInOut2 : BOOL; END_VAR 4.2.1.7.6 SA0167: Report temporary FunctionBlock instances | SA0167: Report temporary FunctionBlock instances Samples: Method FB_Sample.SampleMethod: METHOD SampleMethod :
INT VAR_INPUT END_VAR VAR fbTrigger : R_TRIG; // => SA0167 END_VAR Function F_Sample: FUNCTION F_Sample : INT VAR_INPUT END_VAR VAR fbSample : FB_Sample; // => SA0167 END_VAR MAIN program: PROGRAM MAIN VAR_TEMP fbSample : FB_Sample; // => SA0167 nReturn : INT; END_VAR nReturn := F_Sample(); TE1200 75 Version: 2.11.1 Function Determines function block instances that are declared as temporary variables. This applies to instances that are declared in a method, in a function or as VAR TEMP, and _ which are reinitialized in each processing cycle or each function block call. Reason • Function blocks have a state that is usually retained over several PLC cycles.
An instance on the stack exists only for the duration of the function call. It is therefore only rarely useful to create an instance as a temporary variable. • Secondly, function block instances are frequently large and require a great deal of space on the stack (which is usually limited on controllers). • Thirdly, the initialization and often also the scheduling of the function block can take up quite a lot of time. Importance Medium