Read and Write to an OPC Data Access Server from Simulink
This example shows you how to exchange data between Simulink and OPC Data Access servers.
In the following model, all OPC Toolbox™ blocks are highlighted in blue.
The OPC Config block defines the servers to use in the model, the pseudo-realtime behaviour of the model when it is simulated, and the actions to take when OPC-specific events occur (such as a pseudo-realtime violation, server shutdown, etc.)
The signal from the Sine Wave block is written to the OPC Server using the OPC Write block. The same signal is read back from the server using the OPC Read block, and displayed in the Scope together with the original Sine Wave signal. The OPC data quality is shown in the Display block.
Understanding the Simulation Results
The Scope shows that the Sine Wave signal is delayed by only one sample. The OPC Write block's priority is set higher than the OPC Read block to ensure that the read operation occurs after the write operation. This ensures only one sample delay between the write and read operation.