Write Array into OPC blocks in Simulink

조회 수: 12 (최근 30일)
Tan Edwin
Tan Edwin 2011년 4월 8일
댓글: Attilio 2019년 1월 29일
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
Attilio
Attilio 2019년 1월 29일
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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Unified Architecture에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by