0

I want to design a graphical user interface in MATLAB that can read data continuously using the MATLAB's object linking and embedding for process control (OPC) toolbox. How can I implement this?

I have designed the graphical user interface, but I'm not able to read the data into the graphical user interface.

Sam Roberts
  • 23,951
  • 1
  • 40
  • 64
  • Do you have the OPC toolbox (http://www.mathworks.co.uk/products/opc/)? Have you tried the `read` function (http://www.mathworks.co.uk/help/opc/ug/read.html)? – am304 Nov 13 '13 at 12:36

2 Answers2

0

Take a look at this submission of mine from the MATLAB Central File Exchange. It gives a full example of how to read and write data from an OPC server, and how to create and compile a GUI interface with this functionality as well.

The submission used to have recorded webinar associated with it - unfortunately that seems to have been taken down as it was a bit old. Nevertheless, there's a demonstration script included in the files that walks through the entire process, and I think should give you a good idea of what's going on.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Sam Roberts
  • 23,951
  • 1
  • 40
  • 64
  • the file has been removed can you give the correct link here or can you send it to my mail abitha.vs16@gmail.com? thanks in advance :) – user2987586 Nov 14 '13 at 16:23
  • Hey @sam-roberts can you help me in this https://stackoverflow.com/questions/64803478/dymola-matlab-how-to-write-initialize-tag-for-this-model-realtime-opc – Rohit gupta Nov 12 '20 at 22:13
0

just do this

type opctool inside MATLAB

  • click create new host

  • select Localhost

enter image description here

  • Click add client

enter image description here

  • click add group and add item

enter image description here

  • Now you can see the actual name of variable you want to call like SimControl.Run, SimControl.Stop , ..etc

  • Now you have to code it like this in MATLAB

             %====================================VARIABLE VALUE===============================
             volume_val=app.VolumeVEditField.Value;
             area_val=app.AreaAEditField.Value;
    
    
    
             %====================================CONNECTION====================================
             global hostInfo ;
             hostInfo = opcserverinfo('localhost');
             global da;
             da = opcda('localhost','Dymosim.OPCServer.1');
             connect(da);
             pause(2);
    
    
             %====================================INITIAL VARIABLE=============================
             grp=addgroup(da,'Demo');
             grp2=addgroup(da,'Demo2');
             Initialize=additem(grp2,{'SimControl.Initialize'});
             Run=additem(grp2,{'SimControl.Run'});
             Status=additem(grp2,{'SimControl.Status'});
             Stop=additem(grp2,{'SimControl.Stop'});
             Pause=additem(grp2,{'SimControl.Pause'});
             %=================================================================================
             write(Initialize,1);
    
             %you can use write(area,area_val) 
    
  • Then you can use deploytool to create app

Rohit gupta
  • 211
  • 3
  • 18