Application Example AC500
Scalable PLC
for Individual Automation
AC500 Modbus RTU
Communication - One Job
Content
1 Disclaimer ..................................................................................................................3
1.1 For customers domiciled outside Germany/
Für Kunden mit Sitz außerhalb Deutschlands........................................................................ 3
1.2 Nur für Kunden mit Sitz in Deutschland ........................................................................ 3
2 AC500 Modbus programming and testing ..............................................................4
2.1 Used PC software and Hardware.................................................................................... 4
2.2 RS485 Connection........................................................................................................... 5
3 PM581 Modbus RTU master – PC as Modbus RTU slave – one job......................6
3.1 Example 1 Modbus data exchange over a ST step chain: write one word to the slave
……………………………………………………… ……………………………………… ……6
3.1.1 PM581 as modbus master. ...................................................................................... 6
3.1.2 Programming and online acces over ETH................................................................ 6
3.1.3 Load Modbus library ................................................................................................ 7
3.1.4 Writing the PLC program.......................................................................................... 8
3.1.5 Call of the COM_MOD_MAST ................................................................................. 8
3.1.6 DONE-ERR-EN relationsship................................................................................... 9
3.1.6.1 DONE-ERR-EN Diagram at no communication error................................................... 9
3.1.6.2 DONE-ERR-EN Diagram with communication error, slave not present .......................10
3.2 Data exchange – POU MODBUS_RTU ......................................................................... 11
3.3 Error handling ............................................................................................................... 11
3.3.1 Global variables ..................................................................................................... 12
3.3.2 PLC online ............................................................................................................. 12
3.4 COM_MOD_MAST online .............................................................................................. 13
3.5 COM_MOD_MAST online in the variable list. .............................................................. 13
4 PC as modbus slave................................................................................................14
4.1 ModSim32 ...................................................................................................................... 14
4.2 ModSim32 Online .......................................................................................................... 15
4.3 Modbus Telegrams........................................................................................................ 15
4.4 Telegram example ......................................................................................................... 16
Application Example -1- AC500/Issue: 09.2011
5 Usefull tips ...............................................................................................................17
5.1 Analyse the request telegrams sent by the AC500 CPU............................................. 17
5.2 Analyse the request telegrams sent by the CP400 operator panel............................ 18
5.2.1 Serial line settings.................................................................................................. 19
5.2.2 Request telegrams sent by the CP400 master ....................................................... 19
6 Related documents .................................................................................................21
Application Example -2- AC500/Issue: 09.2011
1 Disclaimer
1.1 For customers domiciled outside Germany/
Für Kunden mit Sitz außerhalb Deutschlands
"Warranty, Liability:
The user shall be solely responsible for the use of this application example described within this file.
ABB shall be under no warranty whatsoever. ABB's liability in connection with this application example or the
files included within this file, irrespective of the legal ground, shall be excluded. The exclusion of liability shall
not apply in the case of intention or gross negligence. The present declaration shall be governed by and
construed in accordance with the laws of Switzerland under exclusion of its conflict of laws rules and of the
Vienna Convention on the International Sale of Goods (CISG)."
"Gewährleistung und Haftung:
Der Nutzer ist allein für die Verwendung des in dieser Datei beschriebenen Anwendungsbeispiels
verantwortlich.
ABB unterliegt keiner Gewährleistung. Die Haftung von ABB im Zusammenhang mit diesem
Anwendungsbeispiel oder den in dieser Datei enthaltenen Dateien - gleich aus welchem Rechtsgrund - ist
ausgeschlossen. Dieser Ausschluß gilt nicht im Falle von Vorsatz oder grober Fahrlässigkeit. Diese
Erklärung unterliegt Schweizer Recht unter Ausschluß der Verweisungsnormen und des UN-Kaufrechts
(CISG)."
1.2 Nur für Kunden mit Sitz in Deutschland
"Gewährleistung und Haftung:
Die in diesem Anwendungsbeispiel enthaltenen Dateien beschreiben eine mögliche Anwendung der
Steuerung AC500 bzw. zeigen eine mögliche Einsatzart der Steuerung. Sie stellen nur Beispiele für
Programmierungen dar, sind aber keine fertigen Lösungen. Eine Gewähr kann nicht übernommen werden.
Der Nutzer ist für die ordnungsgemäße, insbesondere vollständige und fehlerfreie Programmierung der
Steuerungen selbst verantwortlich. Im Falle der teilweisen oder ganzen Übernahme der
Programmierbeispiele können gegen ABB keine Ansprüche geltend gemacht werden.
Die Haftung von ABB, gleich aus welchem Rechtsgrund, im Zusammenhang mit den Anwendungsbeispielen
oder den in dieser Datei enthaltenen Dateien wird ausgeschlossen. Der Haftungsausschluß gilt jedoch nicht
in Fällen des Vorsatzes, der groben Fahrlässigkeit, bei Ansprüchen nach dem Produkthaftungsgesetz, im
Falle der Verletzung des Lebens, des Körpers oder der Gesundheit oder bei schuldhafter Verletzung einer
wesentlichen Vertragspflicht. Im Falle der Verletzung einer wesentlichen Vertragspflicht ist die Haftung
jedoch auf den vertragstypischen, vorhersehbaren Schaden begrenzt, soweit nicht zugleich ein anderer der
in Satz 2 dieses Unterabsatzes erwähnten Fälle gegeben ist. Eine Änderung der Beweislast zum Nachteil
des Nutzers ist hiermit nicht verbunden.
Es gilt materielles deutsches Recht unter Ausschluß des UN-Kaufrechts."
Application Example -3- AC500/Issue: 09.2011
2 AC500 Modbus programming and testing
This document explains how to configure/program a PM581 CPU as Modbus master or modbus slave and
how to check the basic modbus functionality with a PC modbus software.
The modbus communication is RTU.
2.1 Used PC software and Hardware
http://www.win-tech.com/
Modbus Master PC software
Modbus slave PC software
USB – RS485 convertor: USB Nano from www.cti-lean.com
AC500 Programming software
Application Example -4- AC500/Issue: 09.2011
2.2 RS485 Connection
The USB Nano was installed as COM6 in PC
Application Example -5- AC500/Issue: 09.2011
3 PM581 Modbus RTU master – PC as Modbus RTU
slave – one job
3.1 Example 1
Modbus data exchange over a ST step chain: write one
word to the slave
3.1.1 PM581 as modbus master.
The PM581 CPU from the AC500 family will be configured as Modbus RTU master over COM1 with the
parameters 19200,8,1,even parity, RS485.
3.1.2 Programming and online acces over ETH.
Application Example -6- AC500/Issue: 09.2011
3.1.3 Load Modbus library
Application Example -7- AC500/Issue: 09.2011
3.1.4 Writing the PLC program
The function block COM_MOD_MAST will control the data exchange with the Modbus RTU slave.
It will send the corresponding modbus request telegrams to the PC and will receive the reply telegrams from
the modbus slave, handling the send and receive data.
The PLC program is divided in two POU: the call of the COM_MOD_MAST FB is written in FBD, the data
and telegram handling in written ST.
All variables are global.
3.1.5 Call of the COM_MOD_MAST
Application Example -8- AC500/Issue: 09.2011
3.1.6 DONE-ERR-EN relationsship
3.1.6.1 DONE-ERR-EN Diagram at no communication error
Application Example -9- AC500/Issue: 09.2011
3.1.6.2 DONE-ERR-EN Diagram with communication error, slave not
present (no answer, or no data).
1. 1st JOB : the slave is responding with an modbus error telegram ( e.g. : no data under this address ),
but is present.
2. 2nd Job : the slave is not present, no answer. The master is waiting for an answer for the period =
Timeout. After that he will signalise an error with error code (e.g.: slave is not answering )
Application Example - 10 - AC500/Issue: 09.2011
3.2 Data exchange – POU MODBUS_RTU
The data exchange is realised over a step chain ( variable Chain ): write one word to the slave (=one job).
(*write data = counter*)
WORD_WRITE:=WORD_WRITE+1;
(*step chain to handle the communication*)
CASE Chain OF
0: (*send request telegram to the slave*)
IF NOT RTU_Master.DONE THEN (*COM_MOD_MAST has finished the previous job *)
RTU_Master.EN:=TRUE; (*set EN to TRUE *)
RTU_Master.COM:=1; (* send request over COM1 *)
RTU_Master.SLAVE:=3; (* slave number of the PC slave is 3 *)
RTU_Master.FCT:=16; (* FCT=read n word*)
RTU_Master.TIMEOUT:=1000; (* set TIMEOUT to 1000 ms*)
RTU_Master.ADDR:=100; (* register address in slave*)
RTU_Master.NB:=1; (* 1 word *)
RTU_Master_DATA:=WORD_WRITE;(* send one word WORD_WRITE*)
Chain:=10; (*next step in the chain*)
END_IF
10: (*reply from slave has been received*)
IF RTU_Master.DONE THEN (* reply telegram from slave is arrived*)
RTU_master.EN:=FALSE; (* set EN to FALSE*)
Chain:=0; (* next step in the chain*)
END_IF
END_CASE
3.3 Error handling
Store (in case of errors) the error number into the variable Modbus_Error_NB:
IF RTU_Master.ERR THEN
Modbus_Error_NB:=RTU_Master.ERNO;
END_IF
This minimal example can be easily expand to any number of slaves, data and kind of telegrams by keeping
the same strategy of working RTU_Master.DONE and increasing the number of step to the number of
worked jobs.
Application Example - 11 - AC500/Issue: 09.2011
3.3.1 Global variables
VAR_GLOBAL
RTU_Master: COM_MOD_MAST;
RTU_Master_DATA: WORD;
Chain: WORD;
Modbus_Error_NB: WORD;
WORD_WRITE: WORD;
END_VAR
3.3.2 PLC online
Application Example - 12 - AC500/Issue: 09.2011
3.4 COM_MOD_MAST online
3.5 COM_MOD_MAST online in the variable list
Application Example - 13 - AC500/Issue: 09.2011
4 PC as modbus slave.
4.1 ModSim32
We have used in this example the program ModSim32.
Go online with the Set the same communication parameters as the PM 582 master :
Modbus slave , 8, 1 even, 19200
Application Example - 14 - AC500/Issue: 09.2011
4.2 ModSim32 Online
In the communication window you will see the data written from master ( address=100 + 1 --- Modbus offset )
– address 40101 (=100 ) – data : 07792.
4.3 Modbus Telegrams
You can also visualise the data traffic in order to analyse the modbus telegram structures:
Application Example - 15 - AC500/Issue: 09.2011
4.4 Telegram example
request from master (hex)
03 10 00 64 00 01 02 2C 97 EA 7A
slave FCT address one word 2 byte value=2C97 CRC
reply from slave (hex)
03 10 00 64 00 01 41 F4
slave FCT address one word CRC
Application Example - 16 - AC500/Issue: 09.2011
5 Usefull tips
5.1 Analyse the request telegrams sent by the AC500 CPU
Disconnect the slave, you will get on the analyser the request telegrams sent by the AC500 CPU.
Application Example - 17 - AC500/Issue: 09.2011
5.2 Analyse the request telegrams sent by the CP400 operator
panel
The connection cable is the CP programming cable TK501.
Start the analyser software Docklight on the PCset the Baudrate, parity, data birs, start bits, according to the
CP4xx configuration.
CP4xx
RS 232, 19200, 8,1, N PC
Modbus RTU master request
Modbus RTU slave
reply
COM 1 COM 1
TxD 3 2 RxD
RxD 2 3 TxD
SGND 5 5 SGND
docklight analyser
Application Example - 18 - AC500/Issue: 09.2011
5.2.1 Serial line settings
5.2.2 Request telegrams sent by the CP400 master
You will get the request telegrams set by the CP.
Application Example - 19 - AC500/Issue: 09.2011
Request telegram
01 = slave 1
03 = FCT – read n words
00 00 = address 0
00 01 = one word
84 0A = CRC
Application Example - 20 - AC500/Issue: 09.2011
6 Related documents
Part Document DocNo / Rev
ABB Control Builder
AC500 CPU
Modbus master PC software
from
WinTech Modbus RTU http://www.wintech.com/
Software
Modbus slave PC software
from
WinTech Modbus RTU http://www.wintech.com/
Software
Modbus protocol
description
Application Example - 21 - AC500/Issue: 09.2011
Application Example - 22 - AC500/Issue: 09.2011
Doc. kind: No. o. p.:
Helpline document 23
Title: Lang.:
AC500 Modbus RTU Communication – One Job EN
Manual No. 2CDC 125 164 M0201
ABB Automation Products GmbH
Wallstadter Str. 59
D-68526 Ladenburg
Tel. : +49 62 21 / 701-1444
Fax : +49 62 21 / 701-1382
E-Mail :
[email protected]www.abb.com/plc