Modbus communication
Jan 11, 2016
Modbus communication
Schneider Electric 2- PMC – C.Alépéé – 2009/01/05
RS485 Modbus
RS232 RS 485
? =S= communication architecture
Ethernet
RS232
Port COM du PC
RS485 Modbus
PC
net
wo
rk b
oar
d
RS485 Modbus
gateways
Internet
Host B
PSIN, ISDN, ADSL
PSIN, ISDN, ADSL@
Internet
Host B
PSIN, ISDN, ADSL
PSIN, ISDN, ADSL@
Schneider Electric 3- PMC – C.Alépéé – 2009/01/05
Communication = exchange of several types of information
Logical, digital information (O/C)
for alarms and testing
● circuit breaker status
● alarms
● protection unit status
● earthing switch status
Sepam Sepam Sepam
Analog information
● measurements
● counters
● remote readings and settings
● disturbance readingsfor power monitoring/management
SCADA
Schneider Electric 4- PMC – C.Alépéé – 2009/01/05
Sepam data exchanged● The measurements presented in a
Sepam depend on the type of Sepam.● Measurement readout● phase currents,● line to line voltages, frequency,● real and reactive power, and power
factor,● accumulated real and reactive energy,● peak demand phase current,● peak demand real and reactive power,● tripping currents,● temperatures, thermal capacity used,● number of starts and inhibit time,● running hours counter.
● Readout of program logic resource status
● event counter values,● logical input status,● status of the remote annunciation bits
(TS).● Remote control● writing of remote control orders (TC)● Other functions● time tagging,● remote reading of Sepam settings
(remote reading),● remote setting of protections and control
logic time delays (remote setting);● transfer of disturbance recording data.
Schneider Electric 5- PMC – C.Alépéé – 2009/01/05
Example: Modbus
Network concept
e.g. TCP/IP
DATA LINKLAYER
2
Data transmission
NETWORKLAYER
3
Data processing
TRANSPORTLAYER
4
SESSIONLAYER
5
APPLICATIONLAYER 7
End-to-end management
Network interconnection
- OSI: 7-layer architectureOSI = Open Systems Interconnection
PHYSICALLAYER
1
PRESENTATION LAYER 6
Bus concept:
RS 485 & 232
Ethernet
Schneider Electric 6- PMC – C.Alépéé – 2009/01/05
- topology between components
Point to point
Star
Bus
Ring
Meshed
Schneider Electric 7- PMC – C.Alépéé – 2009/01/05
- type of transmission
Full duplex transmission: simultaneous two-way
Half duplex transmission: alternating two-way
Simplex transmission: one-way
Schneider Electric 8- PMC – C.Alépéé – 2009/01/05
- transmission mode
Serial bus
0
1
0
Parallel bus
Number of bits sent simultaneously
StartStop
– Synchronous:
– Asynchronous:
10 0 1
clock = continuous transmission
irregular transmission
Data
01 10 0 0 1 1
1 character
Schneider Electric 9- PMC – C.Alépéé – 2009/01/05
Asynchronous transmission mode (cont'd)
Need for a communication format
● start = initializes the communication frame, indicates the start of the message.
● useful data bits = useful data bits of the message.
● error check = to check for transmission errors.
● stop = indicates the end of the message.
0
1 start useful data bits error check stop
communication frame
Schneider Electric 10- PMC – C.Alépéé – 2009/01/05
- medium Distance: maximum length, line losses
Rate = cable capacity
Type of communication chosen: RS 485 or Ethernet
Price
Environment (EMC, Temperature, etc.)
Twisted pair cable
Simple to implement
Low cost
Schneider Electric 11- PMC – C.Alépéé – 2009/01/05
RS232 RS485
RS 485 Modbus
PC COM Port
- physical layer standards: RS232 and RS485
0 +5 +15V 1.5 + 5V1 - 5 - 15V - 1.5 - 5V
19200 Bauds 1Mbauds
30 m 1200 m
RTS/CTS No
Multipoint busHalf duplex
Point to Point
Asynchronous
Electrical levels
Max. rate
Length
(flows)
Control lines
Link
PC devicesDATA LINKLAYER
2
NETWORK LAYER
3
TRANSPORTLAYER
4
SESSIONLAYER 5
APPLICATIONLAYER 7
PHYSICAL LAYER
1
PRESENTATION LAYER 6
Schneider Electric 12- PMC – C.Alépéé – 2009/01/05
2-wire bus topology
Schneider Electric 13- PMC – C.Alépéé – 2009/01/05
4-wire bus topology
Schneider Electric 14- PMC – C.Alépéé – 2009/01/05
RS485 signal
Schneider Electric 15- PMC – C.Alépéé – 2009/01/05
Communication Settings
● Sepam address
● Speed
● Parity
Schneider Electric 16- PMC – C.Alépéé – 2009/01/05
Sepam series 20 40 80 communication Interfaces
Module ACE 949-2
Sepam connection to a Modbus 2 wires network
Module ACE 959
Sepam connection to a Modbus 4 wires network
Module ACE 937
Sepam connection to a Modbus optical fiber network
Schneider Electric 17- PMC – C.Alépéé – 2009/01/05
ACE 969 interface Sepam series 20 40 80double port plus DNP3 and IEC 870 5 103protocol
ACE969-2TP ACE969-2FO
Schneider Electric 18- PMC – C.Alépéé – 2009/01/05
ACE 909-2 Convertor
Division - Na me - Date - L angu age 50
Installation and Quick StartRS485 / RS232 converter - ACE909-2
RS485 2 wire
Remote power source: the ACE909-2 converter supplies 12 V - 24 V ( ACE949 -959 / SEPAM 1000+ )
RS485 connection RS232 link
Ph/N powerSelector 12 or 24vdc
Fuse
Speed SW2/1 SW2/2 SW2/31200 1 1 12400 0 1 14800 1 0 19600 0 0 119200 1 1 038400 0 1 0
strap position functionSW2/4 0 with parity
1 without paritySW2/5 1 2 stop
0 1 stop
SW1/1 ON polarization at 0 V via Rp - 470 Ω
SW1/2 ON polarization at 5 V via Rp +470 ΏSW1/3 ON 150 Ώ impedance matching resistor at end of RS485 Bus
Schneider Electric 19- PMC – C.Alépéé – 2009/01/05
ACE 919 Convertor
Division - Name - Date - Lan guag e 51
Installation and Quick StartRS485 / RS485 converter - ACE919
supply voltageselection switch110 V AC or 220V AC
RS485 2 wire
Remote power source: the ACE919 convertersupplies 12 V - 24 V (ACE949 - 959 / SEPAM 1000+ )
ACE 919 CC 24 - 48 V DCACE 919 CA 110 - 220 V AC
Strap position function
SW1/1 ON polarization at 0V via Rp-470Ώ
SW1/2 ON polarization at 5V via Rp+470Ώ
SW1/3 ON 150 Ώ impedance matching
resistor at end of RS485 bus
Schneider Electric 20- PMC – C.Alépéé – 2009/01/05
Architecture of the RS485 network
●Pear to pear
● bus
Schneider Electric 21- PMC – C.Alépéé – 2009/01/05
Optical network architecture
● pear to pear
● star
● daisy chain
Schneider Electric 22- PMC – C.Alépéé – 2009/01/05
Modbus protocol
Characterization of exchangesModbus protocol may be used to read or write one or more bits, one or more words, the content of the event counter or the contents of the diagnosis counters.
functions available:● reading of n output or internal bits,● reading of n input bits,● reading of n output or internal words,
● reading of n input words,
● writing of 1 bit,
● writing of 1 word,
● fast reading of 8 bits,
● diagnosis of exchanges,
● reading of event counter,
● writing of n bits,
● writing of n words.
master master
slave slave slave slave slave slave
request broadcasting
reply
Schneider Electric 23- PMC – C.Alépéé – 2009/01/05
- for PLC communication
●Created in 1979 by Modicon
Maximum number of slaves: 31
●For RS 485 or RS 232, and other links…
●Half-duplex protocol: one "speaker" at a time
●Master-slaves● query / reply
● broadcasting with no feedback
DATA LINKLAYER
2
NETWORK LAYER
3
TRANSPORTLAYER
4
SESSIONLAYER 5
APPLICATIONLAYER 7
PHYSICAL LAYER
1
PRESENTATION LAYER 6
Schneider Electric 24- PMC – C.Alépéé – 2009/01/05
RTU (Remote Terminal Unit) Modbus
Address CRC CheckDataFunctionsilence silence
- structure of a Modbus frame
● ASCII (American Standard Code of Information Interchange) ModbusAddress LRC CheckDataFunction: CR LF
3A Hex 0D Hex 0A Hex
Tolerance of one second silence between characters
Used more since faster
Silence >= 3.5 characters
Schneider Electric 25- PMC – C.Alépéé – 2009/01/05
N bytes 2 bytes 1 byte
Presentation of request and reply frames
RequestThe code is used to select the available requests
data required for the request, bit or word addresses,bit or word values,number of bits or words
when the message is received by the slave, the slave reads the check word and accepts or refuses the message
1 byte 1 byte N bytes 2 bytes
0 to FFhfunctioncode
data CRC 16
Reply
addresses of bits or words read, value of bits or words read, number of bits or words
0 to FFhfunctioncode
data CRC 16
1 byte
question
Tr < 10 ms reply
The time is given with the following parameters:
● 9600 bauds,
● 8-bit format, odd parity, 1 stop bit.
Schneider Electric 26- PMC – C.Alépéé – 2009/01/05
Modbus protocol: transmission medium occupancy diagram
request
answer
request
answer
to slave 1 to slave N
Analyse and answer
master
slave 1
slave N
physicalmedium
simultaneous execution of the order by all the slaves
analyse and next exchange
wait wait
exchangei - 1
exchangei + 1
broadcasting
exchangei
time
wait
Schneider Electric 27- PMC – C.Alépéé – 2009/01/05
Diagnosis counters
Sepam manages the following diagnosis counters:
● CPT1, first word: number of correct frames received, whether or not the slave is concerned,
● CPT2, second word: number of frames received with CRC errors, or frames received that are greater than 255 bytes and not interpreted, or frames received with at least one character that has a parity error, “overrun”, “framing”, “break” on the line. An incorrect rate causes incrementation of CPT2,
● CPT3, third word: number of exception replies generated (even if not sent, as result of a broadcast request),
● CPT4, fourth word: number of frames specifically addressed to the station (excluding broadcasting),
● CPT5, fifth word: number of broadcast frames received with no errors,
● CPT6, sixth word: not significant,
● CPT7, seventh word: number of “Sepam 2000 not ready” replies generated,
● CPT8, eighth word: number of frames received with at least one character that has a parity error, “overrun”, “framing”, “break” on the line,
● CPT9, ninth word: number of correct requests received and correctly executed.
The counters may be accessed via the dedicated reading function (see Modbus protocol function 11 in appendix).
Schneider Electric 28- PMC – C.Alépéé – 2009/01/05
Read function
Schneider Electric 29- PMC – C.Alépéé – 2009/01/05
Modbus address table in Sepam series 20
Schneider Electric 30- PMC – C.Alépéé – 2009/01/05
Modbus address table in Sepam series 20
Schneider Electric 31- PMC – C.Alépéé – 2009/01/05
Modbus address table in Sepam series 20
Schneider Electric 32- PMC – C.Alépéé – 2009/01/05
Format 16NS and 16S
Schneider Electric 33- PMC – C.Alépéé – 2009/01/05
Format B
Schneider Electric 34- PMC – C.Alépéé – 2009/01/05
Format X
Schneider Electric 35- PMC – C.Alépéé – 2009/01/05
TS remote annunciation list
Schneider Electric 36- PMC – C.Alépéé – 2009/01/05
Write function
Schneider Electric 37- PMC – C.Alépéé – 2009/01/05
Remote control order
Schneider Electric 38- PMC – C.Alépéé – 2009/01/05
Time-sequencing
A date is associated to each event:
● change of status of logic inputs
● change of status of automation data TS
● Internal data necessary for time-sequencing, time-setting, synchronization…
Internal clock in Sepam: year, month, day, hour, minute and milliseconds (0 to 59999).
Schneider Electric 39- PMC – C.Alépéé – 2009/01/05
Time-sequencing, synchronization
Input I21, 10 to 60 s synchronization signal.
Scada
Sepam
Sepam
Modbusnetwork
clock
Sepam
Sepam
Synchronization link
Modbusnetwork
scada
“External synchronization” via a logic input architecture “Internal synchronization via the comunication network” architecture
time-setting
4 words
message
10 s 20 s 30 s
∆ = ± 4 s
Schneider Electric 40- PMC – C.Alépéé – 2009/01/05
Exchange Principle
Request Zone
Reply Zone
Master
4events
3-Acknowledgement
1-Request
2-Reading
Status Change64 events
Storage zone
Schneider Electric 41- PMC – C.Alépéé – 2009/01/05
Exchange principle
Master 1
Acknowledgment
Reading
Master 2
Acknowledgment
Reading
64 eventzone
Inside SepamExchange word
4 e
v en
t zo
ne
4
ev e
nt
zon
e
4
0
Exchange word8
0
64 eventzone
Inside Sepam
Schneider Electric 42- PMC – C.Alépéé – 2009/01/05
Time-sequencingExchange table
exchangenumber
number of events
pollingword
event 1
event 2
event 3
event 4
incrementedupon each exchange
0 = empty tablex = x events4 maximum
1/reading if ≠ 0 in the event table2/writing to 0 for the following exchange
type of channel: 0 for input/800 for others
modbus data address
reserved: Ø
data status 0/1
not used year
month day
hour minutes
milliseconds 0 to 599998
mot
sMax. stock: 64 events.
Schneider Electric 43- PMC – C.Alépéé – 2009/01/05
Remote reading and remote setting
Protection and parameter settings available
• Setting of protection functions
• Sepam general characteristics
Schneider Electric 44- PMC – C.Alépéé – 2009/01/05
Reading of the settingsExchange principle
Request Zone
Reply Zone
Master
1-Request
2-Reading
Protection setting zone
50/51 overccurrent
50N/51N eath fault
27 under volltage
Schneider Electric 45- PMC – C.Alépéé – 2009/01/05
Remote parameter reading function
Request frameThe request is made by the supervisor, by means of a modbus "write words" command (code 6 or 16) at the address D080h of a 1-word frame which consists of the following:
D080h
function code
B15 B14 B13 B12 B11 B10 B09 B08 B07 B06 B05 B04 B03 B02 B01 B00
unit number
Reply frameThe reply sent back by Sepam is contained in a zone with a maximum length
of 125 words at the address D000h, which consists of the following: D00h
function code
B15 B14 B13 B12 B11 B10 B09 B08 B07 B06 B05 B04 B03 B02 B01 B00
unit numbersettings
…………
(specific fields for each function)
…………
Schneider Electric 46- PMC – C.Alépéé – 2009/01/05
Protection function parameters
Schneider Electric 47- PMC – C.Alépéé – 2009/01/05
Data Format
Schneider Electric 48- PMC – C.Alépéé – 2009/01/05
Remote settingsExchangePrinciple
Writing zone
Reply zone
Master
1-Writing request
3-check
Protection setting zone
50/51 overccurrent
50N/51N eath fault
27 under volltage
2- reading request
Schneider Electric 49- PMC – C.Alépéé – 2009/01/05
Remote reading of settings
function code = 01
B15 B14 B13 B12 B11 B10 B09 B08 B07 B06 B05 B04 B03 B02 B01 B00
unit number = 01type of curve = 00 00 (most significant)
type of curve = 00 00 (constant itme)
set point = 00 00 (most significant)
set point = 00 64 (set point at 100 A)
time delay = 00 00 (most significant)
time delay = 00 0A (time delay set to 10 x 10 = 100 ms)
00 00 (most significant)
00 00 (following values not significant, initalized to 0)
Data formatAll the settings are transmitted in the form of signed 32-bit integers (encoded, as a complement of 2).
Particular setting valuesA value equal to 7FFF FFFFh means that the setting is out of its validity range.
To inhibit a protection function, simply set the inhibition parameter to 8000 0000h, the other parameters stay the same. If all the setting values are read as 8000 0000h, it means that the protection function concerned is inhibited.
Schneider Electric 50- PMC – C.Alépéé – 2009/01/05
Disturbance recording
PresentationDisturbance recording is used to store analog and logical values.Sepam records a maximum of two disturbance records.Each record contains two files:
configuration file with suffix .CFG,data file with suffix .DAT.
The files are read by the supervision system via the Jbus link.A record may be transferred until it is overwritten by a new record.
Schneider Electric 51- PMC – C.Alépéé – 2009/01/05
Disturbance recordsExchange principle
Request zone
Aswer zone
Master
4-Acknoledgement
1-reading of available OPG
3-reading
EventsDisturbance 19 files max. *.cfg *.dat
Record zone
125 words
2-request
Identification zone
3-reading3-reading4-Acknoledgement
Schneider Electric 52- PMC – C.Alépéé – 2009/01/05
Communication diagnostics help (Modbus)
Check list
3) Asynchronous link (RS485)- Is the 2-wire/4-wire configuration correctly taken into account?- Are the L+ and L- connections OK (not inverted)?- Is the line polarised at the interface level (470 )?- Does the line have terminating resistors at each end (120 )?- Is the network length within the prescribed limit (EMC requirements)?
4) Connected products- Are the frames received and sent compatible with the functions supported by the supervision system and the products?- Are parameters correctly set (Baud rate, address, 2-wire/4-wire, etc.)?- Check on frame transmission and reception (control LED on modules).- Consistency of module addressing?