Вы находитесь на странице: 1из 5

0:02 This video will go over the basic characteristics of the Modbus protocol,

0:06 with special emphasis for Rockwell Automation users.


0:10 We'll be covering some of the broad differences between Modbus over serial
0:15 and over Ethernet.
0:16 We'll also discuss the different wiring standards for serial communications.
0:21 Next, we'll cover the dynamics of Modbus as a Master and Slave network
0:26 over serial and as a Client and Server over Ethernet.
0:30 We'll delve into my Modbus data addressing and the associated
0:35 function codes and breakdown coils, bits, bytes,
0:39 and registers. We'll also talk about float
0:42 and double integer values and how they're handled by my Modbus.
0:46 First, a brief history lesson.
0:49 Modbus is a serial communications protocol developed by Modicon in 1979.
0:57 It was created specifically for use in Modicon PLC's
1:01 for industrial applications. Today it is an
1:05 open protocol, used by a wide range of automation products.
1:09 Modbus can be used over Ethernet as well as serial cable.
1:14 There are three major types or variations of the Modbus protocol:
1:19 Modbus ASCII, Modbus RTU,
1:23 and Modbus TCP/IP. Modbus was originally developed using ASCII characters to encode messages
1:31 and this version of the protocol is still in use today.
1:35 Modbus RTU is, by far, the most common implementation,
1:40 using binary coding and CRC error checking.
1:44 The two modes are incompatible so a device configured for ASCII mode cannot
1:49 communicate with one using RTU.
1:51 Modbus RTU devices typically use one of three electrical interfaces,
1:58 RS232, RS485
2:02 and RS422. RS232 is a simple point to point arrangement.
2:08 If you only need to connect one device to another,
2:11 and the distance between the two devices is less than 50 feet,
2:15 or 15 meters, then RS232 will do the job.
2:19 To connect more than two devices on the same line,
2:23 and/or have a distance greater than 50 feet,
2:26 you should use RS485 or RS422
2:29 For a master communicating with multiple slave devices,
2:35 RS485 is by far the most popular method.
2:38 This standard can support up to 32 nodes over a range up to 4,000 feet,
2:44 roughly 1200 meters without a repeater.
2:47 The speed that Modbus messages are sent at is referred to as the baud rate
2:52 or bit per second. All devices on an RTU network must use the same baud rate.
2:59 Different devices support different transmission speeds, but between 9,600
3:04 and 19,200 bps is a typical range.
3:08 Modbus modules can be configured from as low as 300 to as high as
3:13 over a 100,000. A Modbus serial network has a master device that issues
3:20 commands to the slave devices.
3:22 The slaves will not transmit information unless they receive a command to do so
3:28 from the master. There can only be one master on a network
3:32 and a maximum up 247 slaves,
3:35 each with a unique slave ID from 1 to 247.
3:41 RS485 cannot drive
3:44 more than 32 nodes in a single single segment;
3:47 so for the rare application that needs more than 32 nodes,
3:51 a repeater is required. The master, can write data to the slaves as well as read
3:57 data from them.
3:58 SCADA/HMI systems, typically would be the master, communicating with a series
4:03 of Modbus slave devices.
4:06 Here is a diagram of a serial network where the master is connected to a slave which is then
4:11 daisy chained along to all the other slaves on the line.
4:16 The devices must be connected in a daisy chain manner;
4:20 they cannot be connected in a star topology.
4:24 Modbus over Ethernet operates exactly like it sounds:
4:28 Modbus devices using regular Ethernet cables and switches to communicate with each other.
4:35 The big difference with Modbus TCP/IP is
4:38 that an MBAP header or Modbus application header
4:42 is added to the star each message. The slave ID at the beginning at the message is removed
4:48 as well as the cyclic redundancy check at the end.
4:52 The MBAP header contains all the identifying information needed to route
4:56 the data to the addressed device.
4:59 Modbus uses port 502 for TCP/IP communication.
5:04 this is important if your data needs to go through a firewall.
5:08 ProSoft uses that port for MBAP messaging specifically.
5:12 Modbus serial messages can also be sent as regular RTU messages encapsulated
5:18 inside and Ethernet TCP/IP packet.
5:22 Encapsulated messages can use any port, but ProSoft products are set to use
5:27 port 2,000 by default.
5:29 Note that MBAP and RTU encapsulation are not compatible;
5:34 devices must be set to use one or the other.
5:38 MBAP messaging is by far the most popular Modbus TCP/IP communication method.
5:44 So, for this video, we will be focusing on Modbus RTU
5:48 and Modbus TCP/IP using the MBAP.
5:52 Modbus TCP/IP uses the terms client and server
5:57 instead of master and slave. The TCP/IP network consists of the client
6:02 connected to a switch or series of switches,
6:05 to which all the servers on the network are also connected.
6:11 Modbus TCP/IP devices use Internet Protocol addressing
6:15 and require a subnet mask. The IP address and subnet mask are both
6:20 represented by for 8-bit numerical group or
6:24 octets. The IP addresses the location
6:27 of a particular device on a network and the subnet masks serves to simplify the task
6:33 of routing traffic within the network. If you don't know your IP addressing
6:38 your IT group or network administrator will let you know the IP addresses and
6:43 subnet mask your devices will need.
6:46 The default gateway is optional and not required for networks that do not use a
6:51 default gateway.
6:52 Again you can consult your IT group or network administrator.
6:57 Now let's talk about modbus' eccentric
7:01 addressing system and the different data tables.
7:05 There are four tables where information is stored.
7:08 Two tables store simple discrete values called coils
7:13 and two store numerical 16-bit values
7:16 known as registers. For each type data there
7:20 is one read only table and one
7:23 read write table. There are no tables for 32-bit data types because back when
7:28 Modbus was defined,
7:30 double integers and floating-point values were not available in PLC's.
7:35 There is a way to use those data types though,
7:38 we'll get to that in a moment. Each table has a maximum love 9,999 addresses.
7:46 Data table addresses 1 through 9,999
7:50 are the read write table for coils,
7:53 addresses 10,001 through 19,999
7:58 are the read only for discrete inputs.
8:01 Data table addresses 30,001 through 39,999
8:07 are the read only for input registers
8:10 and addresses 40001 through 49,999
8:15 are the read write table for holding registers.
8:18 At this point it might be helpful to explain the terms used for data types
8:22 in Modbus. Coils in discrete inputs
8:26 are the Modbus vernacular for 1-bit of data or
8:29 in Rockwell terms a bool; basically on or off.
8:35 A register is the term for 1 word
8:37 or 16-bits or 2-bites of data
8:41 or in Rockwell terms an INT. There are no
8:44 registers for floats or double integers although, they can be sent
8:48 by dividing them into two registers. Float values are
8:53 any real number with a decimal point that is represented by a
8:57 32-bit register. Double integers, or DINT's
9:01 are simply two 16-bit values stacked together,
9:05 also represented by 32-bits. This presents a small problem since Modbus does not
9:11 have a float
9:12 or DINT data type. The solution,
9:15 obviously enough, is that did 32-bit value is broken into 2 separate 16-bit registers
9:22 and then recombined into a 32-bit real value.
9:26 This is accomplished by copying the two 16-bit registers to 1 REAL tag
9:31 in the Rockwell processor. Modbus function codes are simple
9:36 numerical codes that tell the slave which table to
9:39 access and whether to read or write to that table.
9:42 Each function code relates to a specific data table address range.
9:47 For instance, function code 1 is the code to read and individual bit status
9:52 Function code 16 is the code to write
9:55 multiple holding registers. Here are some of the most commonly used
10:01 function codes. Modbus as a protocol does not define exactly how the data
10:07 should be stored in registers.
10:09 Different vendors have different ways of storing and transmitting data.
10:13 Some devices will transmit the higher byte first,
10:17 followed by the lower byte. Others will do it the other way around.
10:21 By the same token, when registers are combined to represent 32-bit real values,
10:26 some devices will transmit the higher 16-bit
10:30 in the first register and the lower 16-bits in the second register.
10:34 Other vendors do it the other way around. The order that bytes or words are sent
10:39 in doesn't matter as long as the receiving device knows which way they
10:44 are ordered.
10:44 If the data is not appearing correctly
10:48 because the byte or word order is incorrect; ProSoft products feature
10:52 a byte and words swap function which will reverse the order in which the data is stored
10:59 and sent, resolving the issue instantly.
11:02 To wrap up, we'll take a look at Modbus RTU message being sent from a master
11:09 out to a slave device. The message contains the slave ID
11:13 of the device the command is intended for, the function code to read or write data
11:18 and the message data itself. Once the slave receives the command, it will
11:23 return the requested data to the master in the case
11:27 of read command, or it will write the data to its own database and send an echo of
11:32 the original message back to the Master
11:34 to confirm that the message was received. We hope this video gives you a better
11:39 understanding of Modbus serial
11:42 and TCP/IP. For additional training videos using Modbus and other protocols
11:48 in Rockwell Automation Systems,

Вам также может понравиться