How to use codesys standard functions in PLC coder (e.g. TON/TOF/SR)

12 views (last 30 days)
Is it possible to generate structured text in Simulink PLC coder using the native codesys standard functions?
We have implemented some of the standard functions in the library, for example TON/TOF/SR, and would like to use the native functions when the PLC code is generated. Is this possible, or do we have to "make do" with our own implementations of these functions in Simulink.
CODESYS Online Help - link to example timer functions in Codesys.

Answers (1)

SANKALP DEV
SANKALP DEV on 17 Nov 2023
Dear David,
I understand that you are seeking information on the feasibility of generating structured text within Simulink PLC Coder while utilizing the native CODESYS standard functions.
Certainly, it is indeed possible to generate structured text code in Simulink PLC Coder while harnessing the native CODESYS standard functions. Simulink PLC Coder provides support for generating structured text code that adheres to the IEC 61131-3 standard, which includes the programming environment of CODESYS.
With the right configuration in Simulink PLC Coder, you can seamlessly incorporate native CODESYS standard functions like TON, TOF, and SR directly into your Simulink models. This negates the need to develop your custom implementations of these functions and empowers you to leverage the established and widely used CODESYS versions.
For further insights on designing and testing control systems using CODESYS and Simulink, please refer to this resource:
Additionally, to get started with Simulink PLC Coder in MATLAB, you can consult this link:
I hope that this information will be beneficial for you.
Regards,
Sankalp
  1 Comment
David
David on 20 Nov 2023
Hi Sankalp,
% Certainly, it is indeed possible to generate structured text code in Simulink PLC Coder while harnessing the native CODESYS standard functions.
Is there a tutorial or video to guide me on how to do this please? I have found examples that use the TON functions for example in plcladderlib, but can't seem to understand how to create one from scratch.
web(fullfile(docroot, 'plccoder/ug/modeling-and-simulation-of-ladder-diagrams-in-simulink.html'))

Sign in to comment.

Categories

Find more on Simulink PLC Coder in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!