Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Scalable PLC
for Individual Automation
abb
Content
1 Disclaimer ..................................................................................................................3
2 Introduction ...............................................................................................................4
4 Appendix ..................................................................................................................21
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)."
Der Nutzer ist allein fr die Verwendung des in dieser Datei beschriebenen Anwendungsbeispiels
verantwortlich.
ABB unterliegt keiner Gewhrleistung. 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 Fahrlssigkeit. Diese
Erklrung unterliegt Schweizer Recht unter Ausschlu der Verweisungsnormen und des UN-Kaufrechts
(CISG)."
Die in diesem Anwendungsbeispiel enthaltenen Dateien beschreiben eine mgliche Anwendung der
Steuerung AC500 bzw. zeigen eine mgliche Einsatzart der Steuerung. Sie stellen nur Beispiele fr
Programmierungen dar, sind aber keine fertigen Lsungen. Eine Gewhr kann nicht bernommen werden.
Der Nutzer ist fr die ordnungsgeme, insbesondere vollstndige und fehlerfreie Programmierung der
Steuerungen selbst verantwortlich. Im Falle der teilweisen oder ganzen bernahme der
Programmierbeispiele knnen gegen ABB keine Ansprche 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 Fllen des Vorsatzes, der groben Fahrlssigkeit, bei Ansprchen nach dem Produkthaftungsgesetz, im
Falle der Verletzung des Lebens, des Krpers 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 erwhnten Flle gegeben ist. Eine nderung der Beweislast zum Nachteil
des Nutzers ist hiermit nicht verbunden.
This application describes how it is possible to build up a simple low cost visualisation and operation station
with AC500 and one PC with MS Windows XP and MS Excel.
The idea of this application based on the example in the OPC Book. In this book described Frank Iwanitz
and Jrgen Lange how it is possible to communicate with VBA (MS Visual Basic for Application), witch is
included in most of the MS Office programs, with the OPCServer via an Automation Interface.
There is already an example on the CD AC500 Control Builder PS501 Version 1.3.2 in the folder
\CD_AC500\CoDeSys\ServicePack\ProgramFiles\Projects\Examples\OPC\EXCEL_Client\, but it seems
that it is not so user-friendly and therefore little known/popular.
Used documents:
1. Online help documentation of the AC500 Control Builder PS501 Version 1.3.2
2. OPC Book. "OPC - Fundamentals, Implementation and Application", third edition, revised and extended,
2006; Written by: Frank Iwanitz, Jrgen Lange; Published by: Hthig Fachverlag ISBN 3-7785-2904-8)
AC500 PC
Excel
PLC OPC
VBA Sheet
project Server
RS485 USB
TK503
If you liked to insert this example in an existing program, you can continue with step Import of the example
to this project (or to your existing project)
Further information about useable drivers for OPC communication is on AC500 Control Builder PS501, Help,
chapter 1.2 Fields of application of the OPC server.
When the AC500 is running, all of the previous steps were right.
After that, there are a program Process_Simulation_OPC(PRG) and a folder of global OPC variables.
The program Process_Simulation_OPC(PRG) is only for the demonstration, that the OPC variables are on
life.
With collecting of the OPC variables in a extra folder is it easier to reduce the number of variables, which
have to be communicated. Only this folder must be added later to the symbol file.
(See AC500 Control Builder PS501, Help, chapter 4 Behaviour of the OPC server)
Important !
Do not configure the program as a freewheeling program, please use a task configuration.
NOTICE Call the PLC Browser and have a look to the task time (command tsk in the command
line). For example the program has a cycle time of 40ms, use a task time of 50 or 60ms. So
the CPU has time to answer the OPC request from the Server between the tasks.
Rename the task to e.g Main, insert the interval to e.g. t#20ms
Select the task name, right mouse click, Append Program Call
When the AC500 is running and some of the OPC variables are on life, all of the previous steps were right.
First deselect all check boxes, with it all variables are deselected.
It is important specially in older existing projects.
<OK>
<OK>
Mark Program and Variables (multiple choice with <Ctrl> + mouse Click)
Please mark only this Variables, which will be needed in the control or visual software to avoid a high load on
data transmission from PLC to OPC Server.
<OK>
<OK>
Store the program with CoDeSys <Online> <Create boot project> in the Flash memory of the AC500.
In the Single-PLC and Multi-PLC configuration are the prefixes of the OPC variables
different. When there is a configured OPC Client (how in this example), then use Multi-PLC
configuration with PLC name PLC1, otherwise the variables of the OPC Client must be
NOTICE renamed, too.
The easiest way to do it, is the using of a freeware OPC Client/Tool like e.g. Matrikon OPC Explorer, Softing
OPC Demo Client, etc.
A successful test makes sure that the OPC Server and its configuration are correct.
NOTICE
Next
Next
Next
Next to Start Installation
If the Matrikon OPC Explores displays the quality Good, nonspecific, the OPC configuration is in order.
The following chapter Check of the OPC configuration files can be jumped over and be gone on working
with the chapter MS Excel Project.
Important ! The identical names and spellings of the OPC server (CoDeSys.OPC.02) and
OPC variables (e.g. PLC1:.word_out_00 or PLC1:.word_in_04) must be used by the
application OPC_Excel_Client.xls to avoid error messages in Excel.
NOTICE
The worksheet CoDeSys.OPC.02 is the Control panel for the communication with the OPC-Server.
2. Initialization of the communication. VBA program reads from cell B1 (column B, row 1) the name of the
OPC-Server and from cell B11 to B1000 (empty cell are ignored) the names of the OPC items.
3. Data exchange. VBA program asks the OPC server for the values and writes those in the green cells.
4. Writing values into AC500. With push the button e.g Write_06 the value, in the cell on the left of
Write_06, will be written into the AC500. The blue cells are for enter the values.
5. Stop of the application. With push the button Disconnect the application stops and so the
communication with the OPC-Server.
When the example is loaded in the PS501 programming system into the AC500, then the file
AC500_to_OPC_Excel_Client.SDB is also stored in the folder C:\WINNT\Gateway Files\
AC500_to_OPC_Excel_Client.SDB. The OPCServer uses this file for the communication with the AC500.
.Array_out[146]:WORD:4:492:2:b:16#02000020
.Array_out[147]:WORD:4:494:2:b:16#02000020
.Array_out[148]:WORD:4:496:2:b:16#02000020
.Array_out[149]:WORD:4:498:2:b:16#02000020
.rel_out_01:REAL:5:1552:4:b:16#02000040
.word_in_00:WORD:5:1512:2:b:16#02000040
.word_in_01:WORD:5:1514:2:b:16#02000040
.word_in_02:WORD:5:1516:2:b:16#02000040
.word_in_03:WORD:5:1518:2:b:16#02000040
.word_in_04:WORD:5:1520:2:b:16#02000040
.word_in_05:WORD:5:1522:2:b:16#02000040
.word_in_06:WORD:5:1524:2:b:16#02000040
.word_in_07:WORD:5:1526:2:b:16#02000040
.word_in_08:WORD:5:1528:2:b:16#02000040
.word_in_09:WORD:5:1530:2:b:16#02000040
.word_out_00:WORD:5:1532:2:b:16#02000040
.word_out_01:WORD:5:1534:2:b:16#02000040
.word_out_02:WORD:5:1536:2:b:16#02000040
.word_out_03:WORD:5:1538:2:b:16#02000040
.word_out_04:WORD:5:1540:2:b:16#02000040
.word_out_05:WORD:5:1542:2:b:16#02000040
.word_out_06:WORD:5:1544:2:b:16#02000040
.word_out_07:WORD:5:1546:2:b:16#02000040
.word_out_08:WORD:5:1548:2:b:16#02000040
.word_out_09:WORD:5:1550:2:b:16#02000040
[PLC:PLC1]
active=1
motorola=1
nologin=1
timeout=10000
tries=3
waittime=10
reconnecttime=10
buffersize=4800
project=AC500_to_OPC_Excel_Client
gateway=Local
device=Serial (RS232)
instance=TK503_USB_To_Serial
parameters=6
parameter0=Port
value0=COM13
parameter1=Baudrate
value1=19200
parameter2=Parity
value2=No
parameter3=Stop bits
value3=1
parameter4=Motorola byteorder
value4=Yes
parameter5=Flow Control
value5=Off
NOTICE
Set SvrSample = New OPCServer 'Provide the OPCServer object with memory
SvrSample.Connect CStr(Cells(1, 2)) 'Takes the name of the cell (row 1, column B)
'as OPCServer name.
'With AC500 OPC-Server: "CoDeSys.OPC.02" = CoDeSys OPC Server V2.3
'"WinCoDeSysOPC" = CoDeSys OPC Server V3
'allow Subscriptions
SmplSvrGroup.IsSubscribed = True
'set Group active state with Checkboxvalue
SmplSvrGroup.IsActive = True
'set updaterate with value in Excel sheet
SmplSvrGroup.UpdateRate = CLng(Cells(7, 2))
'write to sheet, revised updaterate may be different
Cells(7, 2) = SmplSvrGroup.UpdateRate '500
'There was a group name created, if no name was given
Cells(6, 2) = SmplSvrGroup.Name 'VBASample
'This loop generates from the Excel sheet the items for the collection object
i = 11 'from row 11
Do While i < 1001 'to row 1000
szItemId = CStr(Cells(i, 2)) 'Item from row i, column B
If szItemId <> "" Then 'If cell is not empty,
'add item to collection
Set SMPLItem(i - 10) = ItemColl.AddItem(szItemId, i)
End If
i=i+1
Loop
End Sub
chbSampleGroupActive.Value = False
Cells(2, 2) = "" 'clear vendorinfo
Cells(3, 2) = ""
End Sub
Call StartSampleServer
End Sub
Call StopSampleServer
End Sub
'Subroutine writes the value, from the cell on the left of the button
'into the addressed item of the collection object.
Private Sub cmdWrite_00_Click() 'ObjectName of the CommandButton
SMPLItem(11 - 10).Write CLng(Cells(11, 4)) 'Writes value from cell (row 11, column 4 (=D) into
'OPCItem-Object 1 (row 11 - offset)
End Sub
Private Sub SmplSvrGroup_DataChange(ByVal TransactionID As Long, ByVal NumItems As Long, ClientHandles() As Long,
ItemValues() As Variant, qualities() As Long, TimeStamps() As Date)
Dim ItemColl As OPCItems
Dim Item As OPCItem
Set ItemColl = SmplSvrGroup.OPCItems
On Error Resume Next 'For avoid "run time error 50290"
'The reason is unknown, it happened sometimes with mouse clicks. chja
For Each Item In ItemColl
Cells(Item.ClientHandle, 3) = Item.Value 'The values read out of the OPC server
'are wrote into culumn 3 (= C)
Next Item
End Sub
Helpline document 29
Title: Lang.:
abb
ABB STOTZ-KONTAKT GmbH
Eppelheimer Strae 82 Postfach 101680
69123 Heidelberg, Germany 69006 Heidelberg, Germany
Telephone (06221) 701-0
Telefax (06221) 701-240
E-Mail automation-helpline.desto@de.abb.com
Internet http://www.abb.com/plc