Académique Documents
Professionnel Documents
Culture Documents
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
Introduction
Modbus = Modicon Bus (1979)
is an application layer messaging protocol for client/server communication between devices connected on the bus. Independent from the other layers Openly published and royalty-free Relatively easy industrial network to deploy It moves raw bits or words without placing many restrictions on vendors
Various versions
Modbus RTU (Serial), Modbus ASCII, Modbus Ethernet TCP/IP, Modbus Plus (Proprietary of =S=)
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
Physical Layer
RS485 2 wire RS485 4 wire
Required
Multi-point and point-to-point To integrate into an existing installation without modification Point-to-point mode 15 meter max.
Optional
Optional
9600 bps and 19200 bps required with 19.2 Kbps by default
Other speeds: 1200, 2400, 4800, 38400, 56 Kbps, 115 Kbps optional
RS485 is the most common physical layer used on Modbus. 32 devices included the master can be connected on the bus.
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010 5
Slave pair
650 ohms
120 ohms 1 nF
5V
120 ohms 1 nF
Master pair
120 ohms 1 nF
Common PG
T R T R
120 ohms 1 nF
Slave 1
Slave n
Max. number of devices: 32 including master without a repeater Max. length: Main segment: 1,000 m at 19,200 bits/s Drops: 40 m in total (20 m for one tap link)
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
Balanced pair
120 ohms 1 nF
Common PG
T R T R
650 ohms
120 ohms 1 nF
Slave 1
Slave n
Max. number of devices: 32 including master without a repeater Max. length: Main segment: 1,000 m at 19,200 bits/s Drops: 40 m in total (20 m for one tap link)
Data Transmission
Method of accessing the medium
Master slave
Transmission method:
Client / Server
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
Adr 1
Adr 2
Adr 3
Adr 4
Adr 5
Adr n
Response 5
Funct. Code Response data CRC
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
Adr 1
Adr 2
Adr 3
Adr 4
Adr 5
Adr n
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
10
Transmission Modes
ASCII transmission mode
Every data item is encoded in two ASCII characters (7 bits) allows time intervals of up to 1 second to occur between characters without causing an error. Used with Modem / Barcodes
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
11
Address
Function Code
Data
CRC or LRC
Validity check
Unicast Broadcast
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
12
Address Field
Address Function Data Checksum
Valid device addresses : 0 to 247 decimal. Value 0 reserved for broadcast message (no reponse)
Request
A master addresses a slave by placing the slave address in the address field of the message.
Response
When the slave sends its response, it places its own address in this address field of the response to let the master know which slave is responding.
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
13
Function Field
Address Function Data Checksum
Request
The function code field tells the slave what kind of action to perform.
Response
For a normal response, the slave simply echoes the original function code. For an exception response, the slave returns a code that is equivalent to the original function code with its most significant bit set to a logic 1.
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
14
Data Field
Address Function Data Checksum
Request
The data field contains additional information which the slave must use to take the action defined by the function code. This can include items like register addresses, quantity of items to be handled, etc...
Response
If no error occurs, the data field contains the data requested. If an error occurs, the field contains an exception code that the master. Application used to determine the next action to be taken.
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
15
Checksum Field
Address Function Data Checksum
Request
The checksum is calculated by the master and sends to the slave.
Response
The checksum is re-calculated by the slave and compared to the value sent by the master. If a difference is detected, the slave will not construct a response to the master.
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
16
Function Codes
Code 01 02 03 04 05 06 07 08 15 16 23 43 (0x01) (0x02) (0x03) (0x04) (0x05) (0x06) (0x07) (0x08) (0x0F) (0x10) (0x17) (0x2B) Function Read n consecutive output bits Read n consecutive input bits Read n consecutive output words Read n consecutive input words Write 1 output bit Write 1 output word Read exception status Access diagnostic counters Write n output bits Write n output words Read/Write n output words Read identification
http://www.modbus.org
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010 17
CRC16
Response
1 byte 1 byte 2 bytes 2 bytes 2 bytes 2 bytes
CRC16
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
18
Inputs Registers: read only (status) Outputs Registers: read / write (commands)
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010 19
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
20
1 Platform, 3 Target
3 PLC Targets
M340, Premium, Quantum
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
21
BMXNOM0200
Safety screw (1) Display block with 4 LEDs: (2)
RUN (green) and ERR (red): Module status SER COM (green): Activity on the serial link (lit) or fault (flashing).
Channel 1 (4)
RS 485 connection, marked COM Port 1 RS485
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
22
BMXNOM0200 Configuration
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
23
Request Programming
Dedicated Function Blocks for M340
ADDM Address Conversion READ_VAR Execute a read request WRITE_VAR Execute a write request DATA_EXCH Execute a user defined request OUT_IN_MBUS Change from Slave to Master mode
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010 24
ADDM FB
IN:
String variable: r.m.c.e.MBS
Out
Converted table of words, to be used in the others FB
r.m.c.e.MBS
r = the rack number where the Modbus module is located, m = the slot number of the Modbus module, c = the channel used e = the equipment address (slave address) of the target MBS = used to indicates to use Modbus Serial (optional)
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
25
READ_VAR FB
IN:
ADR: to be linked to the output of the ADDM block. OBJ: defining object to read (in the case of Modbus register: %MW) NUM: starting register to read NB: number of consecutive register to read
OUT
RECP: reception zone of the block, delivering the value read (table of words)
IN/OUT
GEST: table of 4 words to manage the communication block (errors, timeout, length, etc..)
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
26
WRITE_VAR FB
IN:
ADR: to be linked to the output of the ADDM block. OBJ: defining object to read (in the case of Modbus register: %MW) NUM: starting register to read EMIS: source table to write from the PLC
IN/OUT
GEST: table of 4 words to manage the communication block (errors, timeout, length, etc..)
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
27
GEST Variable
Structured Variable
Table of 4 words
Most Significant Byte GEST[1] Exchange number (updated each time the request is executed) Operation report Timeout Length Least Significant Byte Activity bit: 1 = exchange in progress, 0 = exchange terminated. Communication Report
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
28
Exercise
Add & Configure Modbus Module (p 2-13) Add a module Configure the channel Set the Modbus Slave Insert the ADDM block Create the READ_VAR request Test the application
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
29
Optimizing Communication
Beware of Communication Buffer Overload Usage of the Activity Bit (GEST[1].X0)
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
30
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
31
Fallback Mode
Mode activated when communication is lost Behaviour to define (start a motor, stop a process, switch off outputs..)
No answers great, lets go party!
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
32
Exercise
Optimizing the Communication (2-16) Insert the Activity Bit as condition Insert the WRITE_VAR function Test the communication Testing the TimeOut (2-20) Use WRITE_VAR to change the Timeout parameter Test the communication
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
33
Industrial Communication Course with Unity Pro - Modbus Schneider Electric | Industry Business | Training | E. Pauchet V5.0 May 2010
34