matlab opc toolbox video
Post on 01-Jan-2017
276 Views
Preview:
TRANSCRIPT
SoftwareYouneedthefollowingSoftware:• OPCServer(e.g.,MatrikonOPCSimulationServer,FreeDownload)
• MATLAB• MATLABOPCToolbox
www.mathworks.com/products/opc
WhatisMATLAB?• MATLABisatoolfortechnicalcomputing,computationandvisualizationinanintegratedenvironment.
• MATLABisanabbreviationforMATrix LABoratory• ItiswellsuitedforMatrixmanipulationandproblemsolvingrelatedtoLinearAlgebra,Modelling,SimulationandControlApplications
• PopularinUniversities, TeachingandResearch
MATLABSyntax- Exampleclearclcclose all
x=[0, 1, 2, 3, 4 ,5];y=[15, 10, 9, 6, 2 ,0];
for n=1:6 % n = model order
p = polyfit(x,y,n)
ymodel = polyval(p,x);
subplot(3,2,n)plot(x,y,'o',x,ymodel)title(sprintf('Model order %d', n));
end
ForLoop
Built-inFunctions
DefiningVectors
50+Toolboxes
Installation
• MATLABandSimulinkStudentSuite(NOK699)Included:MATLAB+Simulink+StatisticsToolbox+OptimizationToolbox+SymbolicMathToolbox+ControlSystemToolbox+SignalProcessingToolbox+ImageProcessingToolbox,...
• MATLABStudent(NOK350+)IncludesMATLABonly.Add-onproductsmustbepurchasedseparately(NOK70/Toolboxifyoubuythematthesametime,elseNOK200/Toolbox).Selectbetween55differentToolboxes
http://www.mathworks.com/academia/student_version
2differentoptions:
WhatisOPC?• Astandardthatdefinesthecommunicationofdatabetweendevicesfromdifferentmanufactures
• RequiresanOPCserverthatcommunicateswiththeOPCclients
• OPCallows“plug-and-play”,givesbenefitsasreducesinstallationtimeandtheopportunitytochooseproductsfromdifferentmanufactures
• Differentstandards:“Real-time”data(OPCDA),Historicaldata(OPCHDA),Alarm&Eventdata(OPCAE),etc.
OPC-Server
Network
OPC-Client OPC-ClientOPC-Client
Process
ProcessData
DataAcquisitionPLC,PAC,DCS,SCADA
TypicalOPCScenario
Driver
SensorsActuators
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)
MATLABOPCToolbox• OPCToolboxprovidesaccesstoliveandhistoricalOPCdatadirectlyfromMATLABandSimulink
• Youcanread,write,andlogOPCdatafromdevices,suchasdistributedcontrolsystems(DCS),supervisorycontrolanddataacquisitionsystems(SCADA),andprogrammablelogiccontrollers(PLS)
MATLABOPCToolbox
TheMATLABOPCToolboxsupportsthefollowingOPCprotocols:• OPCDA(DataAccess)• OPCHDA(HistoricalDataAccess)• OPCUA(UnifiedArchitecture)
ThisVideo
ALaterVideo
AcquireDatafromanOPCDataAccessServer(withExamples):http://se.mathworks.com/help/opc/examples/acquire-data-from-an-opc-data-access-server.html?prodcode=OT&language=en
RunthiscommandintheMATLABCommandwindow
MATLABOPCToolboxFormoreinformationabouttheMATLABOPCToolbox:
AcquireDatafromanOPCDataAccessServer(withExamples):http://se.mathworks.com/help/opc/examples/acquire-data-from-an-opc-data-access-server.html?prodcode=OT&language=en
www.mathworks.com/products/opc
MatrikonOPCExplorer(OPCClient)
TheMatrikonOPCExplorerisuseful fortesting.YoucanuseitforwritingandreadingOPCTags
MATLAB
OPCServer
OPCClient
MATLABisaTooltypicallyusedforDataAnalysis,soyoutypicallyReadDatafromtheOPCServer.(Butitispossible toconnectDAQdevicesandReadMeasurementDataintoMATLABandthenWritethoseDataValuestoanOPCServer)
WithMATLABOPCToolboxyoucancreateOPCClientsthatWriteorReadtoanOPCServer
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);
% Retrieve Datadata = read(grp);opcdata = data.Value
%Clean Updisconnect(da)delete(da)
MATLABOPCRead
Example1
ThissimpleExamplereadsonlyonevaluefromtheServer
MATLABOPCRead
Example2
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);
% Retrieve DataN=10;for i=1:N
data = read(grp);opcdata(i) = data.Value;pause(2)
end
%Clean Updisconnect(da)delete(da)
plot(opcdata)
ThissimpleExamplereadsvaluesfromtheServer.
ThisExamplesreadsNvaluesusingaForLoop
MATLABOPCRead
Example3
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!
top related