introduction to opc - halvorsen.blog€¦ · contents • short introduction to opc – classic opc...

45
Introduction to OPC Hans-Petter Halvorsen, M.Sc. with Examples

Upload: vokhue

Post on 22-Apr-2018

368 views

Category:

Documents


26 download

TRANSCRIPT

Page 1: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

IntroductiontoOPC

Hans-PetterHalvorsen,M.Sc.

withExamples

Page 2: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

Contents• ShortIntroductiontoOPC– ClassicOPCvs.NextGenerationOPC

• OPCServer:MatrikonOPCSimulationServer• OPCDAExamples– LabVIEW,VisualStudio,MATLAB

• OPCUAExamples– LabVIEW

Page 3: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPC

Hans-PetterHalvorsen,M.Sc.

Page 4: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

WhatisOPC?• Astandardthatdefinesthecommunicationofdatabetweendevicesfromdifferentmanufactures

• RequiresanOPCserverthatcommunicateswiththeOPCclients

• OPCallows“plug-and-play”,givesbenefitsasreducesinstallationtimeandtheopportunitytochooseproductsfromdifferentmanufactures

• Differentstandards:“Real-time”data(OPCDA),Historicaldata(OPCHDA),Alarm&Eventdata(OPCAE),etc.

Page 5: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPC

OPCServer OPCClientRead/WriteData

DataStorage

Page 6: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCServer

OPCClient

WriteData

DataStorage

OPCClient

ReadData

MeasurementData

Monitoring andAnalysis

Page 7: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPC-Server

Network

OPC-Client OPC-ClientOPC-Client

Process

ProcessData

DataAcquisitionPLC,PAC,DCS,SCADA

TypicalOPCScenario

Driver

SensorsActuators

Page 8: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCSpecifications

OPCDA

OPCHDA

OPCA&E

OPCUA

“Classic”OPC “NextGeneration”OPC

...(Manyothers)

Page 9: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCSpecifications• OPCDA(DataAccess)ThemostcommonOPCspecificationisOPCDA,whichisusedtoreadandwrite“real-time”data.WhenvendorsrefertoOPCgenerically,theytypicallymeanOPCDA.• OPCHDA(HistoricalDataAccess)• OPCA&E(Alarms&Events)• ...(manyothers)TheseOPCspecificationarebasedontheOLE,COM,andDCOMtechnologiesdevelopedbyMicrosoftfortheMicrosoftWindowsoperatingsystemfamily.ThismakesitcomplicatedtomakeitworkinamodernNetwork!TypicallyyouneedaTunneller SoftwareinordertosharetheOPCdatainanetwork(betweenOPCServersandClients)

• OPCUA(UnifiedArchitecture)OPCUAeliminatingtheneedtouseaMicrosoftWindowsbasedplatformofearlierOPCversions.OPCUAcombinesthefunctionalityoftheexistingOPCinterfaceswithnewtechnologiessuchasXMLandWebServices(HTTP,SOAP)

Page 10: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

NextGenerationOPC

OPCClassic OPCUA

OPCDAServer

OPCHDAServer

OPCA&EServer

COM/DCOM XML,HTTP,SOAP

Cross-platformWindowsonly Allspecificationscollectedinone(DA,HDA,A&E)

NextGenerationOPC

OPCClient(DCOM)

OPCDAOPCHDA

OPCA&E

OPCUAServer OPCUAClient

Protocols:“UABinary”or“UAXML”

Windows,Linux,Mac,Embedded,VxWorks

Simpler!!

(everything builtintoone)

Page 11: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

NextGenerationOPC

OPCClassicServer OPCClassicClient

OPCUAServer OPCUAClientNetwork/Internet

ToopenDCOMthrough firewallsdemandedalargehole inthefirewall!Impossible torouteoverInternet!

Nohole infirewall(UAXML)orjustasimpleneedlestick(UABinary)isnecessaryEasytorouteoverInternet!

Network

Page 12: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

ClassicOPCvs.OPCUAClassicOPC(DCOM) OPCUA

OPCServer

OPCClient

OPCClient

OPCClient

Windows

Windows

Windows

WindowsOPCUAServer

OPCUAClient

OPCUAClient

ClassicOPCrequiresaMicrosoftWindowsoperatingsystemtoimplementCOM/DCOMserverfunctionality.ByutilizingSOAandWebServices,OPCUAisaplatform-independentsystemthateliminatesthepreviousdependencyonaWindowsoperatingsystem.ByutilizingSOAP/XMLoverHTTP,OPCUAcandeployonavarietyofembeddedsystemsregardlessofwhetherthesystemisageneralpurposeoperatingsystem, suchasWindows,oradeterministicreal-timeoperatingsystem. http://www.ni.com/white-paper/13843/en/

OPCUAClient

Theserver(orclients)canbeanembeddedsystem,LINUX,Windows, etc.

Page 13: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

MatrikonOPCSimulationServer

Hans-PetterHalvorsen,M.Sc.

Page 14: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

Matrikon OPCExplorer– ConnecttoServer

1

2

Page 15: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

Matrikon OPCExplorer- AddTags

1

2

3

4

5

Double-click

Finished

Page 16: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

MatrikonOPCExplorer(OPCClient)

TheMatrikonOPCExplorerisusefulfortesting.YoucanuseitforwritingandreadingOPCTags

Page 17: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

PracticalExamples

Hans-PetterHalvorsen,M.Sc.

Page 18: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

ProgrammingExamples• YoucancreateOPCClients(andOPCServers)inmostProgrammingLanguages

• YoucancreateittotallyfromScratchusingtheOPCspecifications

• OryoucancreatethemusingexistingLibrariesandAPIs– WewillshowsomeexamplescreatedinLabVIEW,VisualStudioandMATLAB

Page 19: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

TheOPCFunctionsinLabVIEW

TheDataSocketpaletteinLabVIEW: WriteDatatoOPC

ReadDatafromOPC

OpenConnectiontoOPCServer CloseConnection

toOPCServer

BrowseOPCServersandOPCItems

YoucanuseLabVIEWasanOPCclientbyconnecting toanOPCserverthrough aDataSocket connection.

Page 20: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

MATLABOPCToolbox• OPCToolboxprovidesaccesstoliveandhistoricalOPCdatadirectlyfromMATLABandSimulink

• Youcanread,write,andlogOPCdatafromdevices,suchasdistributedcontrolsystems(DCS),supervisorycontrolanddataacquisitionsystems(SCADA),andprogrammablelogiccontrollers(PLS)

Page 21: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

MeasurementStudio• Add-onpackagetoVisualStudiocreatedbyNationalInstruments

• SamevendorasLabVIEW• MakesitpossibletocommunicatewithanOPCDAServerfromVisualStudioCode

• UsestheDataSocket Library(sameasinLabVIEW)

Page 22: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCReadExamples

Hans-PetterHalvorsen,M.Sc.

Page 23: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

ReadfromOPCServerusingLabVIEW

1 2 3 4

WhileLoop

WhileLoopOrspecifyURLdirectly:

Page 24: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

ReadOPC- VisualStudioExample

ClickButtontogetlatestValuefromOPCServer

MatrikonOPCServer/OPCExplorer VisualStudioApp

Page 25: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC
Page 26: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCWriteExamples

Hans-PetterHalvorsen,M.Sc.

Page 27: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

WritetoOPCServerusingLabVIEW

OrspecifyURLdirectly:

1 2 3 4

WhileLoop

WhileLoop

UsetheBucketBrigade Items– becausetheycanbeusedforbothreadingandwriting

Page 28: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

WriteOPC– VisualStudioExampleMatrikonOPCServer/OPCExplorer

VisualStudioApp

Page 29: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC
Page 30: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCWrite/ReadExample

Hans-PetterHalvorsen,M.Sc.

Page 31: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

Write/ReadExample

Page 32: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC
Page 33: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

Example:TrendingDatafromOPC

Hans-PetterHalvorsen,M.Sc.

Page 34: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

VisualStudioExample

Page 35: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC
Page 36: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

clear, clc% Connect to OPC Serverda = opcda('localhost', 'Matrikon.OPC.Simulation.1');connect(da);% Create Groupgrp = addgroup(da, 'DemoGroup');%Add TagsitmIDs = {'Random.Real8'};itm = additem(grp, itmIDs)% Set PropertieslogDuration = 60;logRate = 0.2;numRecords = ceil(logDuration./logRate)grp.UpdateRate = logRate;grp.RecordsToAcquire = numRecords;% Acquire Datastart(grp), wait(grp)% Retrieve Data[logIDs, logVal, logQual, logTime, logEvtTime] = getdata(grp, 'double');% Plot Dataplot(logTime, logVal);axis tightdatetick('x', 'keeplimits')legend(logIDs)%Clean Updisconnect(da)delete(da)

ThissimpleExampleusessomeofthemoreadvancedfeaturesintheMATLABOPCToolbox.NoFor/WhileLoopneeded!

MATLABExample

Page 37: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC
Page 38: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCUAExample

Hans-PetterHalvorsen,M.Sc.

UA– UnifiedArchitecture

Page 39: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCUA• UA– UnifiedArchitecture• TheNextGenerationOPC• BasedonModernSoftware/NetworkArchitecture(NoDCOMproblems!)

Page 40: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCUAinLabVIEW

Note!Youneed toinstallthe“LabVIEWDSCModule”orthe“LabVIEWReal-Time

Module”

http://zone.ni.com/reference/en-XX/help/371618J-01/TOC9.htm

DSC– DataloggingandSupervisoryControl

Page 41: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

WriteDatatoOPCUAServer ReadDatafromOPCUAServer

LabVIEWApplication#2 LabVIEWApplication#3

InthisExampleLabVIEWApplication#1,#2and#3areonthesamecomputer.NormallytheyarelocatedondifferentcomputersordevicesinaNetwork.

LabVIEWApplication#1

OPCUAServer

OPCUAClient OPCUAClient

Page 42: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

OPCUAServer

OPCUAClient

Page 43: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC
Page 44: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

Summary• ThisVideohasgivenyouanOverviewofOPC• SomeExampleshasbeenshown–MatrikonOPCSimulationServer– LabVIEW,VisualStudio,MATLABExamples– IgothroughtheseExamplesindetailinasetofVideos

Page 45: Introduction to OPC - halvorsen.blog€¦ · Contents • Short Introduction to OPC – Classic OPC vs. Next Generation OPC • OPC Server: Matrikon OPC Simulation Server • OPC

Hans-PetterHalvorsen,M.Sc.

UniversityCollegeofSoutheastNorwaywww.usn.no

E-mail:[email protected]:http://home.hit.no/~hansha/