OPC DA Write issues

10 次查看(过去 30 天)
Pablo
Pablo 2025-1-20
回答: Aravind 2025-1-29
Hi I used to program on Simulink using the OPC DA Config, OPC Write/Read blocks and till version 2017 it worked just fine. Now I implemented it on 2024b version and by the time I want to test it there's this error that says:
Error:The corresponding 'opcslwrite.tlc' file for the MATLAB S-function 'opcslwrite' in block 'hardprog/OPC Write' must be located in the current working directory, the MATLAB S-function directory 'C:\Program Files\MATLAB\R2024b\toolbox\icomm\opc\opcblks\opcblks', or the directory 'C:\Program Files\MATLAB\R2024b\toolbox\icomm\opc\opcblks\opcblks\tlc_c'
I can configure the OPC DA Config Real-Time block, but when I try to add a tag there's a sound of error and the Browse Name Space shows up but I can't click in OK nor Cancel it remains there and then I can't do a thing.
Thank you!

回答(1 个)

Aravind
Aravind 2025-1-29
Hi @Pablo,
Based on the error shared, it looks like you are encountering an issue with code generation for a Simulink model containing OPC DA Read/Write blocks in R2024b, which previously worked in R2017a or R2017b. The likely reason it worked in the earlier versions is that the OPC Read/Write blocks were part of the “OPC Toolbox.” Since then, they have been moved to the “Industrial Communication Toolbox,” which no longer supports code generation for these blocks. Consequently, the necessary TLC files for code generation are not included, resulting in the error you are experiencing.
As a workaround, you can try to implement the OPC DA Read/Write logic outside of MATLAB in C, and then use the “C Caller Block” in Simulink to execute their functionality. You can refer to https://www.mathworks.com/help/simulink/c_caller.html for more information on how to include custom C code into Simulink models using the "C Called block".
Additionally, be aware that future releases of the Industrial Communication Toolbox will phase out support for OPC DA technology, with a shift towards enhancing OPC UA (Unified Architecture) capabilities. This is highlighted in the R2024a Release notes: https://www.mathworks.com/help/releases/R2024a/icomm/release-notes.html#mw_9fc36dd2-9e06-4421-b6e4-1f2264b09a40.
Starting with the R2024a release, OPC UA Simulink blocks have been introduced. It would be advisable to transition your model to use OPC UA blocks instead of OPC DA blocks, as the former will receive more support and may be compatible with code generation.
I hope this answers your question.

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by