MATLAB Answers


Writing Data into OPC Simulink Blocks

Asked by Tan Edwin on 6 Apr 2011
Im totally new to these OPC blocks and was trying out the functions
I noticed that when i tried to write things into the OPC Write block and read it, the output from the reading always give me a slight delay (abt 0.1s).
Is it because the OPC blocks are programmed this way? And is there any ways to bypass this problem such that whatever i write will be shown in the read ouput instantly?
And also how do i write array into the OPC write block in simulink? I used (1x3) array but it says that the input for write block is 1 only when it should be able to take an array of any size. (Tested out in the OPC GUI and it can take any (1xn) array size)


I don't know anything about OPC, but upon reading your query, I skimmed the documentation.
I'm wondering what the scan rate shows up as in your configuration?
I'm also wondering if the delay stays constant if you use a speed-up?
For the scan rate, i cant actually access it in simulink. But through MATLAB interface, the scan rate is 0.1.
And by changing the rate of speed up the delay still stay constant @ 0.1, which i think could be related to my choice of fixed time step solver (with time step of 0.1).
By the way, im using Matrikon.OPC.Simulation.1 (free OPC simulation from Matrikon) for this simulation.

Sign in to comment.



1 Answer

Answer by Arnaud Miege
on 6 Apr 2011
 Accepted Answer

Yes, I believe your 0.1s delay is because of your chosen fixed-step sample time. The output of the read block will only update every sample time, i.e. every 0.1s. Simulink needs to write to the server before it can read from it, hence the delay. If you change your sample time, you should see a different delay.
The write block will accept signals of dimension >1, but you must specify as many items in the block dialog as the width of the input port.


so there is no way to remove that delay?
i tried continuous time step as well and there the delay is still there and it was worst 0.4s.
As for the dimension, MatrikonOPC simulation server has a tag that can take in array when used in the GUI (Bucket Brigade.ArrayOfReal8) but i cant write an array inside this tag in Simulink though.
The delay could come either from the sample rate of the block or the update rate of the OPC server, it's impossible to tell without looking at both. What you could try is changing your fixed time step to something smaller, say 0.01s and you should see a smaller delay if the block sample time is the root cause. The 0.4s is probably because your stop time is 20s and by default, the maximum step size for a variable-step solver is the stop time divide by 50. Simulink tries to take a big a step size as it can and since there are no dynamics in your model requiring a smaller time step, it uses 0.4s.

Sign in to comment.