Writing Data into OPC Simulink Blocks

3 views (last 30 days)
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)
  2 Comments
Walter Roberson
Walter Roberson on 6 Apr 2011
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? http://www.mathworks.com/help/toolbox/opc/ug/f0-6823.html
I'm also wondering if the delay stays constant if you use a speed-up? http://www.mathworks.com/help/toolbox/opc/ug/f5-136562.html#f5-136643
Tan Edwin
Tan Edwin on 6 Apr 2011
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.

Accepted Answer

Arnaud Miege
Arnaud Miege on 6 Apr 2011
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.
HTH,
Arnaud
  2 Comments
Tan Edwin
Tan Edwin on 6 Apr 2011
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.
Arnaud Miege
Arnaud Miege on 7 Apr 2011
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.
HTH,
Arnaud

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!