About Slicing
About Slicing
About Slicing
You create a custom PLC data type structure using the same editing methods that are used in
the data block editor. Add new rows for any data types that are necessary to create the data
structure that you want.
If a new PLC data type is created, then the new PLC type name will appear in the data type
selector drop-down lists in the DB editor and code block interface editor.
You can potentially use PLC data types in the following ways:
● As a data type in a code block interface or in data blocks
● As a template for the creation of multiple global data blocks that use the same data structure
● As a data type for PLC tag declarations the I and Q memory areas of the CPU
For example, a PLC data type could be a recipe for mixing colors. You can then assign this PLC
data type to multiple data blocks. You can adjust the variables within each data block to create
a specific color.
The data type Variant can point to variables of different data types or parameters. The Variant
pointer can point to structures and individual structural components. The Variant pointer does
not occupy any space in memory.
PLC tags and data block tags can be accessed at the bit, byte, or word level depending on their
size. The syntax for accessing such a data slice is as follows:
● "<PLC tag name>".xn (bit access)
● "<PLC tag name>".bn (byte access)
● "<PLC tag name>".wn (word access)
● "<Data block name>".<tag name>.xn (bit access)
● "<Data block name>".<tag name>.bn (byte access)
● "<Data block name>".<tag name>.wn (word access)
A double word-sized tag can be accessed by bits 0 - 31, bytes 0 - 3, or word 0 - 1. A word-sized
tag can be accessed by bits 0 - 15, bytes 0 - 1, or word 0. A byte-sized tag can be accessed by
bits 0 - 7, or byte 0. Bit, byte, and word slices can be used anywhere that bits, bytes, or words
are expected operands.
Valid data types that can be accessed by slice are Byte, Char, Conn_Any, Date, DInt, DWord,
Event_Any, Event_Att, Hw_Any, Hw_Device, HW_Interface, Hw_Io, Hw_Pwm,
Hw_SubModule, Int, OB_Any, OB_Att, OB_Cyclic, OB_Delay, OB_WHINT, OB_PCYCLE,
OB_STARTUP, OB_TIMEERROR, OB_Tod, Port, Rtm, SInt, Time, Time_Of_Day, UDInt, UInt,
USInt, and Word. PLC Tags of type Real can be accessed by slice, but data block tags of type
Real cannot.
In the PLC tag table, "DW" is a declared tag of type DWORD. The examples show bit, byte, and
word slice access:
IF "DW".x11 THEN
...
END_IF;
IF "DW".b2 = "DW".b3
THEN
...
END_IF;