Illustration

This illustration shows some examples of DFB parameters

Description of the Parameters

This table shows the role of each parameter

Parameter

Maximum number

Role

Inputs

32 (1)

These parameters can be used to transfer the values of the application program to the internal program of the DFB. They are accessible in read-only by the DFB, but are not accessible by the application program.

Outputs

32 (2)

These parameters can be used to transfer the values of the DFB to the application program. They are accessible for reading by the application program except for ARRAY-type parameters.

Inputs/Outputs

32

These parameters may be used to transfer data from the application program to the DFB, which can then modify it and return it to the application program. These parameters are not accessible by the application program.

Legend:

(1) Number of inputs + Number of inputs/outputs less than or equal to 32

(2) Number of outputs + Number of inputs/outputs less than or equal to 32

NOTE: The IODDT related to CANopen devices for Modicon M340 cannot be used as a DFB I/O parameter. During the analyse/build step of a project, the following message:"This IODDT cannot be used as a DFB parameter" advises the limitations to the user.

Parameters that Can Be Accessed by the Application Program

The only parameters that can be accessed by the application program outside the call are output parameters. To make this possible, the following syntax must be used in the program: DFB_Name.Parameter_name

DFB_Name represents the name of the instance of the DFB used (maximum of 32 characters).

Parameter_Name represents the name of the output parameter (maximum 32 characters).

Example: Control.Accel indicates the output Accel of the DFB instance called Control

EN and ENO Parameters

EN is an input parameter, and ENO is an output parameter. They are both of BOOL type, and may or may not be used (optional) in the definition of a DFB type.

Where the user wishes to use these parameters, the editor sets them automatically: EN is the first input parameter and ENO the first output parameter.

Example of implementation of EN\ENO parameters.

If the EN input parameter of an instance is assigned the value 0 (FALSE), then:

  • the section(s) that make up the code of the DFB is/are not executed (this is managed by the system),

  • the ENO output parameter is set to 0 (FALSE) by the system.

If the EN input parameter of an instance is assigned the value 1 (TRUE), then:

  • the section(s) that make up the code of the DFB is/are executed (this is managed by the system),

  • the ENO output parameter is set to 1 (TRUE) by the system.

If an error is detected (for example a processing error) by the DFB instance, the user has the option of setting the ENO output parameter to 0 (FALSE). In this case:

  • either the output parameters are frozen in the state they were in during the previous process until the fault disappears,

  • or the user provides a function in the DFB code whereby the outputs are forced to the required state until the fault disappears.

VAR_IN_OUT Variable

Function blocks are often used to read a variable at an input (input variables), to process it and to output the updated values of the same variable (output variables). This special type of input/output variable is also called a VAR_IN_OUT variable.

The following special features are to be noted when using function blocks/DFBs with VAR_IN_OUT variables.

  • All VAR_IN_OUT inputs must be assigned a variable.

  • VAR_IN_OUT inputs may not have literals or constants assigned to them.

  • VAR_IN_OUT outputs may not have values assigned to them.

  • VAR_IN_OUT variables cannot be used outside the block call.

Calling a function block with a VAR_IN_OUT variable in IL:

CAL MY_FBLOCK(IN1:=V1, IN2:=V2, IO1:=V3, 
               OUT1=>V4, OUT2=>V5)

Calling the same function block in FBD:

VAR_IN_OUT variables cannot be used outside the function block call.

The following function block calls are therefore invalid:

Invalid call, example 1:

LD V1

Loading a V1 variable in the accumulator

CAL InOutFB

Calling a function block with the VAR_IN_OUT parameter.

The accumulator now contains a reference to a VAR_IN_OUT parameter.

AND V2

AND operation on accumulator contents and V2 variable.

Error: The operation cannot be performed since the VAR_IN_OUT parameter (accumulator contents) cannot be accessed from outside the function block call.

Invalid call, example 2:

LD V1

Loading a V1 variable in the accumulator

AND InOutFB.inout

AND operation on accumulator contents and a reference to a VAR_IN_OUT parameter.

Error: The operation cannot be performed since the VAR_IN_OUT parameter cannot be accessed from outside the function block call.

The following function block calls are always valid:

Valid call, example 1:

CAL InOutFB (IN1:=V1,inout:=V2

Calling a function block with the VAR_IN_OUT parameter and assigning the actual parameter within the function block call.

Valid call, example 2:

LD V1

Loading a V1 variable in the accumulator

ST InOutFB.IN1

Assigning the accumulator contents to the IN1 parameter of the IN1 function block.

CAL InOutFB(inout:=V2)

Calling the function block with assignment of the actual parameter (V2) to the VAR_IN_OUT parameter.