A-3 Variable Memory Allocation Methods; A-3-1 Data Type Alignment And Memory Allocation Amounts; Data Type Alignment And Memory Allocation Amounts - Omron NX-series User Manual

Safety network controller communication control unit built-in function
Hide thumbs Also See for NX-series:
Table of Contents

Advertisement

Appendices

A-3 Variable Memory Allocation Methods

You must be aware of the way in which memory is allocated to variables to align the memory locations
of the members of structure or union variables with variables in other devices. Adjustments are neces-
sary mainly when structure variables are used in the communications with other devices.
The amount of memory and the memory locations that are allocated for a variable depend on the data
type of the variable. The amount of memory and the memory locations that are allocated for array ele-
ments, structure members, and union members depend on the data types, but also on the declara-
tions that are made for the arrays, structures, and unions.
A-3-1

Data Type Alignment and Memory Allocation Amounts

The data size is determined for each data type. The data size is the minimum amount of memory that
is required to store the value or values of that data type.
On the other hand, memory for variables is automatically structured by the Communication Control
Unit for the most efficient access. Therefore, the total amount of memory that is required for variables
is not necessarily the total of the data sizes of the variables. For example, if WORD and DWORD vari-
ables are declared, the total of the data sizes is six bytes, but eight bytes are allocated in memory, as
shown in the following figure.
Variable A
First byte
First byte + 1
First byte + 2
First byte + 3
Variable B
First byte + 4
First byte + 5
First byte + 6
First byte + 7
This information for determining the location of a variable in memory is called the alignment. The align-
ment is determined for each data type. The amount of memory and the memory locations for the varia-
bles are given below.
Item
Amount of memory that is allo-
cated
Locations in memory
The alignments and the amounts of memory that are allocated for the basic data types and enumera-
tions are given below.
BOOL
BYTE, USINT, or SINT
A - 16
Memory
Bytes
WORD, 2 bytes
Not used: 2 bytes
DWORD, 4 bytes
An integral multiple of the alignment. However, the minimum amount of
memory is the data size.
At an integral multiple of the alignment starting from the start of the variable
in memory.
Data type
NX-series Communication Control Unit Built-in Function User's Manual (Z396)
Variable Table
Name
A
B
Specification
Amount of memory that is al-
Alignment [bytes]
2
2
1
1
Data type
WORD
DWORD
located [bytes]

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Nx-csg series

Table of Contents