Write Array into OPC blocks in Simulink
Show older comments
How can i write array into OPC write blocks in Simulink?
I tried writing an array into Bucket Brigade.ArrayOfReal8 through the OPC Write Block provided by OPC Toolbox, but it appears that the OPC Write Block can only take in one element.
I also noticed that the dcumentation does not shows writing of array in simulink so is it not feasible to write array?
Methods i tried:
1) [1,2,3,4,5] from embedded matlab function and input into write block.
2) creating 5 constant block and using mux to combine them.
1 Comment
Attilio
on 29 Jan 2019
I had the same problem, which is strange as using MATLAB commands instead I could write arrays in the same kind of item, e.g.:
%% Initialization of an OPC client for data access by models
% (one array input)
Nsignals = 2; % number of signals array components
% Step 1 - Creating a data access client object, named 'da'
da = opcda('localhost','Matrikon.OPC.Simulation.1');
connect(da)
% Step 2 - Creating two groups in the client object, named 'grp'
grp = addgroup(da);
% Step 3 - creating one item in 'grp', with fully qualified item IDs
% given second argument of additem function
itm = additem(grp,'Bucket Brigade.ArrayOfReal8');
% Step 4 - reading the values of the two items of grp1
array_ini = zeros(1, Nsignals);
write(itm, array_ini);
r_grp = read(grp)
% Step 5 - disconnecting and saving the client for access from OPC Data Access Explorer and
disconnect(da)
save opcda_client da
Answers (0)
Categories
Find more on Unified Architecture in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!