Writing Data into OPC Simulink Blocks
4 views (last 30 days)
Show older comments
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
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
Accepted Answer
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
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
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!