How can I improve the performance of a model so that I do not receive pseudo real-time violations when using OPC blocks in Simulink?

14 views (last 30 days)
I have a Simulink model with an OPC Configuration block which has pseudo real-time simulation enabled. When I run the simulation I receive warnings similar to the following.
Warning: block 'opc_test/OPC Configuration': Pseudo real-time violation at simulation time 3.98

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 26 Jan 2017
These warnings are the result of the simulation step taking longer to compute than the time between steps. This could also occur if the computer is busy performing other tasks. Here are the best ways to minimize pseudo real-time violations (roughly in order of impact/value):
a) Perform asynchronous OPC read and write operations. In the OPC Read/Write block parameter dialog box choose "Asynchronous" for the read or write mode. This change has minimal impact on the model fidelity.
b) Try to perform the OPC read and/or write operations at slower rates. Your simulation can run at fast rates, with data written at slower rates than the simulation is running. This is very application-dependent, but will increase latency some. This also has the probability of having a small impact on the model fidelity.
c) Try using the acceleration modes in Simulink. This will accelerate your models, but will keep the model running within the Simulink environment. The OPC Toolbox works with the acceleration mode. This will have no impact on the model fidelity, and may give significant benefits if the model is reasonably complex. More information on the Simulink accelerator mode is available at:
d) Close all scopes in the model. This can improve simulation time significantly.
e) Try increasing the sample times of the model. Again, this is application-dependent, but fixed-step solvers are quicker than variable-step (for most applications) and if you have to use variable-step solvers, try to increase the minimum and maximum step sizes. This is quite a drastic step and may affect your model's output.
If you need to take some action based on pseudo real-time violations, you can choose to output the "pseudo real-time latency" from the OPC Configuration block. This will show you how many seconds in each sample the OPC Toolbox waits to synchronize the model with the system clock. A positive number is good (Simulink is running faster than system clock time) while a negative number implies that Simulink is not keeping up with the system clock. By examining this signal, you may be able to find where the model is causing pseudo real-time violations, and focus your efforts on those parts of the behavior.
If none of these suggestions work, but your pseudo real-time violations are not serious (the latency doesn't run away to some very large negative number, but oscillates around zero) then you should consider turning off the warning and living with the latency issues. You can do this from the OPC Configuration dialog by setting "Pseudo real-time violation" to "off".
Additional tips for improving simulation performance can be found in the Simulink documentation at:

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!