Matlab variable to an OPC server
6 views (last 30 days)
Show older comments
I am having trouble writing values to my OPC server from my matlab workspace. I am able to connect to the OPC server which is an ICONICS OPC server and see the variable that I want to force with 'getnamespace'
Obj = opcda('localhost','MyOPCserver'); connect(Obj);
ns=getnamespace(Obj); Name=ns(2).Nodes(2).Nodes(2)
But when I try to add a group 'Demo' and an item 'Var':
grp = addgroup(Obj, 'Demo'); itm = additem(grp, 'Var');
I get: Error using Callback2 (line 11) The ItemID is not in the server address space.
I have tried the read and write functions but they always say:
Undefined function 'write' or Undefined function 'read' for input argument of type 'char'
what am I missing?
1 Comment
Samuel Vergara
on 3 Jul 2016
Hi. I recommend use the opctool when you are starting with the OPCtoolbox. You can generate a mfile for the connection from there. In the write and read function, I suppose (cause you don't show the code) the error is that you are using as input the variables as string (with ''). Use just the variables. (delete the ''). Good luck!
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!