Step 5: Assigning the function block IN/OUT variables

Variables are connected to the required inputs/outputs of the PLCopen FB that can be written with values later, thus commanding motion. Refer to the table for the initialisation values:

Variables to link to inputs/outputs of PLCopen FBs

Variable

Data type

Initialisation value

MC_Power_1 instance

 

 

EnablePower

BOOL

FALSE

EnablePositive

BOOL

FALSE

EnableNegative

BOOL

FALSE

MC_ReadActualPosition_1 instance

 

 

EnableReadActPos

BOOL

TRUE

Position

REAL

 

MC_MoveRelative_1 instance

 

 

Distance

REAL

100000.0

Velocity

REAL

10000.0

Acceleration

REAL

2000.0

deceleration

REAL

2000.0

Jerk

REAL

2000.0

Done

BOOL

 

The variables are created in the variables definition area and some of them are initialised with default values. The CFC editor shows that the variables are already linked to the corresponding input/output pins of the function blocks:

Input/output variables linked to PLCopen-FBs
Input/output variables linked to PLCopen-FBs