~ 13 ~
PEF-
321АВР
NOVATEK-ELECTRO
6.3 Work with interface RS (EIA/TIA)-485 upon the MODBUS protocol
6.3.1 General
321
АВР allows to perform data exchange with external devices via the serial RS (EIA/TIA)-485 interface
using the MODBUS protocol with a limited set of commands (the list of supported functions is shown in Table 12.
Table 12
- List of supported functions
Function (hex)
Purpose
Note
0x03
Reading of one or several registers
Maximum 50
0x06
Writing of one value to the register
----
When designing a network, the principle of the master-slave arrangement is used, where device 321
АВР acts
as a slave. A network can have only one master unit and several slave units. The master unit is a personal
computer or a programmable logic controller. With this setting up, the initiator of the exchange cycles can only be
the master unit.
Requests of the master unit are individual (addressed to a specific device). The 321
АВР device performs
transmission, responding to individual requests of the master unit.
If errors are detected in receiving requests, or if it is impossible to execute the received command, 321
АВР
generates an error message as a response (Table 13).
In 321ABP, all values with a dot are converted to integers. Therefore, when processing data, it is necessary to
apply additional mathematical operations.
When reading a value with a dot (for example,
1.000
) 321
АВР will return an integer value of
1000,
in order to
convert the read value to the correct format, it is necessary to divide by.
Before writing a value with a dot (for example,
1.000
) you must reduce it to an integer value by multiplying the
value by 1000, then write the value to 321
АВР.
The coefficient of reduction to an integer value is determined by a number of decimal places (1,0
– 10; 1,00 –
100; 1,000 - 1000).
Table 13
- Error codes for the MODBUS protocol
Error
code
Name
Error description
01
ILLEGAL FUNCTION
The accepted function code cannot be processed
02
ILLEGAL DATA ADDRESS
The data address specified in the request is not available
03
ILLEGAL DATA VALUE
The value contained in the query data field is not a valid value
04
S
ERВER DEVICE FAILURE
An unrecoverable error occurred while the slave device was
attempting to perform the requested action
05
ACKNOWLEDGE
The slave device has accepted the request and is processing it,
but this is time consuming
06
S
ERВER DEVICE BUСY
The slave device is busy processing the command. The master
unit should retry the message later when the slave is free
07
NEGATIVE_ACKNOWLEDGE
The slave device cannot execute the software function specified in
the request
08
MEMORY PARITY ERROR
When reading the extended memory, the slave device detected a
parity error
6.3.2 Message Formats
The exchange protocol has clearly defined message formats. Compliance with the formats ensures the
correctness and stability of the network.
The data in the message is transmitted in high byte forward.
6.3.2.1 Byte format
321
АВР is configured to work with one of two data byte formats: with parity control (Figure 7) and without
parity control (Figure 8). In the mode of operation with parity control, the type of control is also indicated: parity
(Even) or oddness (Odd). The transmission of data bits is performed by the least significant bits forward.
By default (during manufacture), the device is configured to operate without parity and with two stop bits.
Fig. 7
– Byte format with a parity control
Fig. 8
- Byte format without parity control (2 stop bits)