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

Post on 22-Apr-2018

368 Views

Category:

Documents

26 Downloads

Preview:

Click to see full reader

TRANSCRIPT

IntroductiontoOPC

Hans-PetterHalvorsen,M.Sc.

withExamples

Contents• ShortIntroductiontoOPC– ClassicOPCvs.NextGenerationOPC

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

• OPCUAExamples– LabVIEW

OPC

Hans-PetterHalvorsen,M.Sc.

WhatisOPC?• Astandardthatdefinesthecommunicationofdatabetweendevicesfromdifferentmanufactures

• RequiresanOPCserverthatcommunicateswiththeOPCclients

• OPCallows“plug-and-play”,givesbenefitsasreducesinstallationtimeandtheopportunitytochooseproductsfromdifferentmanufactures

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

OPC

OPCServer OPCClientRead/WriteData

DataStorage

OPCServer

OPCClient

WriteData

DataStorage

OPCClient

ReadData

MeasurementData

Monitoring andAnalysis

OPC-Server

Network

OPC-Client OPC-ClientOPC-Client

Process

ProcessData

DataAcquisitionPLC,PAC,DCS,SCADA

TypicalOPCScenario

Driver

SensorsActuators

OPCSpecifications

OPCDA

OPCHDA

OPCA&E

OPCUA

“Classic”OPC “NextGeneration”OPC

...(Manyothers)

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)

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)

NextGenerationOPC

OPCClassicServer OPCClassicClient

OPCUAServer OPCUAClientNetwork/Internet

ToopenDCOMthrough firewallsdemandedalargehole inthefirewall!Impossible torouteoverInternet!

Nohole infirewall(UAXML)orjustasimpleneedlestick(UABinary)isnecessaryEasytorouteoverInternet!

Network

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.

MatrikonOPCSimulationServer

Hans-PetterHalvorsen,M.Sc.

Matrikon OPCExplorer– ConnecttoServer

1

2

Matrikon OPCExplorer- AddTags

1

2

3

4

5

Double-click

Finished

MatrikonOPCExplorer(OPCClient)

TheMatrikonOPCExplorerisusefulfortesting.YoucanuseitforwritingandreadingOPCTags

PracticalExamples

Hans-PetterHalvorsen,M.Sc.

ProgrammingExamples• YoucancreateOPCClients(andOPCServers)inmostProgrammingLanguages

• YoucancreateittotallyfromScratchusingtheOPCspecifications

• OryoucancreatethemusingexistingLibrariesandAPIs– WewillshowsomeexamplescreatedinLabVIEW,VisualStudioandMATLAB

TheOPCFunctionsinLabVIEW

TheDataSocketpaletteinLabVIEW: WriteDatatoOPC

ReadDatafromOPC

OpenConnectiontoOPCServer CloseConnection

toOPCServer

BrowseOPCServersandOPCItems

YoucanuseLabVIEWasanOPCclientbyconnecting toanOPCserverthrough aDataSocket connection.

MATLABOPCToolbox• OPCToolboxprovidesaccesstoliveandhistoricalOPCdatadirectlyfromMATLABandSimulink

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

MeasurementStudio• Add-onpackagetoVisualStudiocreatedbyNationalInstruments

• SamevendorasLabVIEW• MakesitpossibletocommunicatewithanOPCDAServerfromVisualStudioCode

• UsestheDataSocket Library(sameasinLabVIEW)

OPCReadExamples

Hans-PetterHalvorsen,M.Sc.

ReadfromOPCServerusingLabVIEW

1 2 3 4

WhileLoop

WhileLoopOrspecifyURLdirectly:

ReadOPC- VisualStudioExample

ClickButtontogetlatestValuefromOPCServer

MatrikonOPCServer/OPCExplorer VisualStudioApp

OPCWriteExamples

Hans-PetterHalvorsen,M.Sc.

WritetoOPCServerusingLabVIEW

OrspecifyURLdirectly:

1 2 3 4

WhileLoop

WhileLoop

UsetheBucketBrigade Items– becausetheycanbeusedforbothreadingandwriting

WriteOPC– VisualStudioExampleMatrikonOPCServer/OPCExplorer

VisualStudioApp

OPCWrite/ReadExample

Hans-PetterHalvorsen,M.Sc.

Write/ReadExample

Example:TrendingDatafromOPC

Hans-PetterHalvorsen,M.Sc.

VisualStudioExample

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

OPCUAExample

Hans-PetterHalvorsen,M.Sc.

UA– UnifiedArchitecture

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

OPCUAinLabVIEW

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

Module”

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

DSC– DataloggingandSupervisoryControl

WriteDatatoOPCUAServer ReadDatafromOPCUAServer

LabVIEWApplication#2 LabVIEWApplication#3

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

LabVIEWApplication#1

OPCUAServer

OPCUAClient OPCUAClient

OPCUAServer

OPCUAClient

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

Hans-PetterHalvorsen,M.Sc.

UniversityCollegeofSoutheastNorwaywww.usn.no

E-mail:hans.p.halvorsen@hit.noBlog:http://home.hit.no/~hansha/

top related