L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 1100

Advertising
background image

L-force | PLC Designer

Programming Reference

1098

DMS 4.1 EN 03/2011 TD29

If the variable type does not allow bit accessing, the following error message will be
issued: "Invalid data type '<type>' for direct indexing".
A bit access must not be assigned to a VAR_IN_OUT variable!

Bitaccess via a global constant:
If you have declared a global constant defining the bit-index, you can use this constant
for a bitaccess.

Examples for a bit access via a global constant:
1.on a variable and 2. on a structure variable:

Declaration in global variables list for both examples:
Variable enable defines which bit should be accessed:

VAR_GLOBAL CONSTANT
enable:int:=2;
END_VAR


Example 1, Bit access on an integer variable:
Declaration in POU:

VAR
xxx:int;
END_VAR
Bitaccess:
xxx.enable:=true; (* -> the third bit in variable xxx will be set TRUE *)


Example 2, Bit access on an integer structure component:
Declaration of structure stru1:

TYPE stru1 :
STRUCT
bvar:BOOL;
rvar:REAL;
wvar:WORD;
{bitaccess enable 42 'Start drive'}
END_STRUCT
END_TYPE

Advertising