Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Implicit Addressing of ANY_BIT

Chapter contents : Implicit Addressing


Implicit addressing of ANY_BIT variables......................................................................................1

Implicit addressing in graphical worksheets.................................................................................2


Implicit addressing in graphical worksheets (FBD)..............................................................2
Implicit addressing for LD objects........................................................................................3

Implicit addressing in textual worksheets.....................................................................................5


Implicit addressing in textual worksheets (applies to IL and ST)..........................................5

Online display of implicitly addressed variables and handling in the Logic Analyzer..............6

i
Implicit addressing of ANY_BIT variables
This feature is an IEC extension and allows to access specific parts of an already declared variable
of the data type ANY_BIT by implicit addressing. Since ANY_BIT variables could be compared to
"bit structures", it is possible to access (read or write) only one specific Bit, Byte or Word of the
variable (depending on the length of the accessed variable).

Implicit addressing is easily done by entering the variable name followed by a suffix specifying the
part of the bit structure to be read or written. (In principle this is similar to the access of array
elements.)

Example

Let us assume, you have a variable named 'MyVar' of the data type DWORD. The DWORD data
type consists of two words or four bytes or 32 bits. If you want for example access bit 7 of the
DWORD, you have to address this specific bit by the string 'MyVar.X6' (suffix '.X6' addresses bit 7).
To access the first Byte, enter 'MyVar.B0' and to address the second word use 'MyVar.W1'
accordingly.

Syntax (by means of a DWORD example)

The following table shows which suffixes have to be used to access the specific parts of a variable
that is of data type DWORD. The same way the parts of the other data types WORD, BYTE or
BOOL have to be addressed.

Component Access Description


to access by variable name
and suffix

Word MyVar.W0, '.W0' addresses the least significant word and '.W1' the
MyVar.W1 most significant word of the variable 'MyVar'.

Byte MyVar.B0, '.B0' addresses the least significant byte and '.B3' the most
MyVar.B1, ..., significant byte of the variable 'MyVar'.
MyVar.B3

Bit MyVar.X0, '.X0' addresses the least significant bit and '.X31' the most
MyVar.X1, ..., significant bit of the variable 'MyVar'.
MyVar.X31

Implicit addressing is independent of the used PLC type, i.e. it doesn't matter whether the byte
order is Little Endian or Big Endian. In both cases always the correct part of a variable is accessed.

Implicit addressing can be used in the graphical editor as well as in the text editor and is therefore
available in all IEC programming languages. Even online display and the use in the Logic Analyzer
are supported.

1
Implicit addressing in graphical worksheets
Implicit addressing, i.e. accessing a specific part of a variable of the data type ANY_BIT, is done in
graphical worksheets using the properties dialog of the variable or contact/coil. Here, the variable
name followed by the suffix specifying the component of the data type to be accessed has to be
entered in the format 'VarName.Component' (for example 'VarName.X0', addresses the first bit of
the variable 'VarName').

Information about the suffixes used to access the individual components of the ANY_BIT data type
is available in the topic Implicit addressing of ANY_BIT variables.

The following procedures, which describe how to access a specific part of a variable in graphical
worksheets, assume that you have an already declared variable named 'MyWordVar' of the data
type WORD. The declaration of this variable is represented as follows in the variables grid
worksheet:

Implicit addressing in graphical worksheets (FBD)


• Place the cursor at the position you want to insert the declared variable 'MyWordVar'
(either anywhere or directly at an FP).

• Press <F5> or click the icon 'Variable' in the toolbar.


The dialog 'Variable Properties' appears.

• In the list box 'Name' you can select all variables with the matching data type including the
suitable ANY_BIT variables for implicit addressing.
Select the variable as usual.

• Press the <.> key to open the IntelliSense list box and then select the desired part of the
bit structure (alternatively you can of course type in the bit suffix, e.g. 'X2', 'B1', 'W0').
In our example we implicitly address the third bit of the bit structure, i.e. the name
'MyWordVar.X2' has to be entered.

• Confirm the dialog 'Variable Properties'.

The code then looks as follows:

2
Implicit addressing for LD objects

Implicit addressing for LD objects


Even when working with contacts and coils in LD networks you can implicitly address ANY_BIT
variables.

When inserting a variable for a contact or coil, it is possible to assign one bit of a DWORD, WORD
or BYTE variable to the LD object:

• As usual double click on the respective contact or coil.


The dialog 'Contact/Coil Properties' appears.

• In the list box 'Name' you can now select not only Boolean variables but also all declared
ANY_BIT variables.
Select the variable as usual.

• Press the <.> key to open the IntelliSense list box and then select the desired Bit
(alternatively you can of course type in the bit suffix, e.g. 'X2' ).

• Confirm the dialog 'Contact/Coil Properties'.

The LD object then looks as follows:

3
Implicit addressing for LD objects

4
Implicit addressing in textual worksheets
Implicit addressing, i.e. accessing a specific part of a variable of the data type ANY_BIT, is done in
textual worksheets either using the properties dialog of the variable or by typing the component to
be accessed. The variable name followed by the suffix specifying the component of the data type to
be accessed has to be entered in the format 'VarName.Component' (for example 'VarName.X0',
addresses the first bit of the variable 'VarName').

Information about the suffixes used to access the individual components of the ANY_BIT data type
is available in the topic Implicit addressing of ANY_BIT variables.

The following procedure, which describes how to access a specific part of a variable in textual
worksheets, assumes that you have an already declared variable named 'MyWordVar' of the data
type WORD. The declaration of this variable is represented as follows in the variables grid
worksheet:

Implicit addressing in textual worksheets (applies to IL and ST)


• Set the cursor at the code body position where the variable 'MyWordVar' is to be inserted.

• Click the icon 'Variable' in the toolbar.


The dialog 'Variable Properties' appears.

• In the list box 'Name' mark the variable 'MyWordVar'.

• Press the <.> key to open the IntelliSense list box and then select the desired part of the
bit structure (alternatively you can of course key in the bit suffix, e.g. 'X2', 'B1', 'W0').
In our example we implicitly address the first byte of the WORD variable, i.e. the name
'MyWordVar.B0' has to be entered.

• Confirm the dialog 'Variable Properties'.

You can of course directly type the variable name followed by the <.> key and the desired part of
the bit structure into the textual worksheet. Also in this case the IntelliSense list box appears when
you type the <.> key as shown in the following figure.

5
Online display of implicitly addressed variables and
handling in the Logic Analyzer
Online display of implicitly addressed variables

In online mode, the value of an implicitly addressed Bit, Byte or Word of the ANY_BIT variable is
displayed.
Example: If you have addressed the first bit of the variable 'MyWordVar' (data type WORD) using
the access name 'MyWordVar.X0', the value of the bit is displayed in online mode but not the online
value of the Word.

Handling implicitly addressed variables in the Logic Analyzer

Implicitly addressed variables used to access a specific Bit, Byte or Word of the ANY_BIT variable
can be inserted from textual or graphical worksheets into the Logic Analyzer in the usual way, i.e.
by switching the system to online mode, displaying the Logic Analyzer window and selecting the
context menu item 'Add to Logic Analyzer' of the variable concerning.

You might also like