Modbus Serial communication
 
Modbus Serial Communication Configuration Screen
To access the Modbus serial communication configuration screen, open the Serial Port directory in the project browser ....
The figure below shows the default configuration screen for Modbus serial communication:
These zones are used to configure channel parameters. In offline mode, these zones are accessible. In online mode, the zone is accessible but some parameters are unavailable.
The following table shows the different zones of the Modbus link configuration screen:
Key
Element
Description
1
Application parameters
These parameters are accessible via 3 zones:
  • Type
  • Master
  • Slave
2
Transmission parameters
These parameters are accessible via 5 zones:
  • Transmission speed
  • Delay between frames
  • Data
  • Stop bits
  • Parity
3
Signal and physical line parameters
These parameters are accessible via 3 zones:
  • Physical line
  • Signals
  • RTS/CTS delay
NOTE: When configuring Modbus Serial communication in Master mode, the Slave zone is unavailable for modification and vice-versa.
Accessible Modbus Functions
The table below shows the different functions configurable according to the type of serial link used:
Function
RS485 Link
RS232 Link
Master number of retries
X
X
Master response time
X
X
Slave number
X
X
Transmission speed
X
X
Delay between frames
X
X
Data
  • ASCII (7 bits)
  • RTU (8 bits)
  • ASCII (7 bits)
  • RTU (8 bits)
Stop
  • 1 bit
  • 2 bits
  • 1 bit
  • 2 bits
Parity
  • Odd
  • Even
  • None
  • Odd
  • Even
  • None
RX/TX signals
-
X
RTS / CTS delay
-
X
RX/TX/CTS(DCE Mode)
-
X
X: Accessible function
-: Inaccessible function
NOTE: All Modbus Serial communication parameters have default values.
The table below shows the default values for Modbus Serial communication parameters:
Configuration Parameter
Value
Mode
Master
Physical Line
RS485
Slave number
-
Delay between frames
2 ms
Transmission speed
19,200 bits/s
Parity
Even
Data Bits
RTU (8 bits)
Stop bits
1 bit
Application-linked Modbus Parameters
After configuring the communication channel, enter the application parameters.
These parameters are accessible from three configuration zones:
The following table describes the zones:
Zone
Screen
Description
The Type zone
This zone enables you to select the type of Modbus Serial to be used:
  • Master: When the station concerned is the master.
  • Slave: When the station concerned is a slave.
The Master zone
This zone enables you to enter the following parameters:
  • Number of retries: Number of connection attempts made by the master before defining the slave as absent. The default value is 3. Possible values range from 0…15. A value of 0 indicates no retries by the Master.
  • Answer delay: The time between the Master’s initial request and a repeated attempt if the slave does not respond. This is the maximum time between the transmission of the last character of the Master's request and receipt of the first character of the request sent back by the slave. The default value is 1 second (100*10 ms). Possible values range from 10 ms to 10 s.
NOTE: The Answer delay of the Master must be at least equal to the longest Answer delay of the Slaves present on the bus.
The Slave zone
This zone enables you to enter the processor’s slave number. The default value is 1. Possible values range from 1…247.
Transmission-linked Modbus Parameters
After configuring the communication channel, enter the transmission parameters.
These parameters are accessible from five zones:
The following table describes the zones:
Zone
Screen
Description
The Transmission Speed Zone
This zone allows you to select the transmission speed of the Modbus Serial. The selected speed has to be consistent with the other devices. The configurable values are 300, 600, 1,200, 2,400, 4,800, 9,600 and 19,200 bits per second.
NOTE: The transmission speed of 38,400 bps is not supported (300…19,200 bits/s) for all functions.
The Delay between frames zone
The Delay between frames is the minimum time separating two frames on reception. This delay is managed when the PLC (master or slave) is receiving messages.
NOTE: The default value depends on the selected transmission speed.
NOTE: The delay between frames should be the Default value in order to be Modbus compliant. In case a Slave is not conform, the value can be changed and should be identical for the Master and all Slaves on the Bus.
The Data zone
This zone allows you to enter the type of coding used to communicate using Modbus Serial. This field is set according to the other devices connected on the bus. There are two configurable modes:
RTU mode:
  • The characters are coded over 8 bits.
  • The end of the frame is detected when there is a silence of at least 3.5 characters.
  • The integrity of the frame is checked using a word known as the CRC checksum, which is contained within the frame.
ASCII mode:
  • The characters are coded over 7 bits.
  • The beginning of the frame is detected when the ":" character is received.
  • The end of the frame is detected by a carriage return and a line feed.
  • The integrity of the frame is checked using a byte called the LRC checksum, which is contained within the frame.
The Stop zone
This zone allows you to enter the number of stop bits used for communication. This field is set according to the other devices. The configurable values are:
  • 1 bit
  • 2 bits
The Parity zone
This zone enables you to determine whether a parity bit is added or not, as well as its type. This field is set according to the other devices. The configurable values are:
  • Even
  • Odd
  • None
Signal and Physical Line Parameters in Modbus
After configuring the communication channel, enter the signal and physical line parameters.
These parameters are accessible via three zones:
The following table describes the zones:
Zone
Screen
Description
The Physical line zone
In this zone, you can select the line for the channel 0 of the CPU between:
  • The RS232 line
  • The RS485 line
The Signals zone
In this zone, you can select the signals supported by the RS232 physical line:
  • RX/TX
  • RX/TX + RTS/CTS DCE mode
If the RS485 is configured, the entire zone will be unavailable and the default value is RX/TX.
NOTE: The Modbus Master is the default type. When RS232 is selected, DTE mode is not supported but DCE mode is supported.
The RTS/CTS delay zone
The RTS/CTS delay zone is available only when both RS232 and RX/TX+RTS/CTS check boxes are selected. An RTS/CTS flow control algorithm is selected if the default value is 0 ms. A value different from 0 enables an RTS/CTS modem control algorithm.
The RTS/CTS flow control algorithm (DTE <-> DTE) is different from the RTS/CTS modem control algorithm (DTE <-> DCE) as follows:
  • The RTS/CTS flow control algorithm is related to the overflow reception buffer (full duplex).
  • The RTS/CTS modem control algorithm deals with the shared transmission process, e.g. a radio modem.
Modbus Serial Communication Programming
When used as the master in a Modbus link, MC80 supports several services via the READ_VAR, WRITE_VAR and DATA_EXCH communication functions.
Modbus Request
Function Code
Communication Function
Read bits
16#01 or 16#02
READ_VAR
Read words
16#03 or 16#04
READ_VAR
Write bits
16#0F
WRITE_VAR
Write words
16#10
WRITE_VAR
Other request
all
DATA_EXCH
When used as a slave in a Modbus link, it manages the following requests:
Modbus Request
Function Code
PLC Object
Read n output bits
16#01
%M
Read n output words
16#03
%MW
Write n output bits
16#0F
%M
Write n output words
16#10
%MW