Linking Matlab/Simulink with B&R Automation Studio - ST code transfer

Hi,

I have a question regarding transfering Code from Matlab Simulink model that’s generated from Simulink PLC Coder.

Let’s say i have a very simple model in Simulink that i transferred to Automation Studio generated in C code (basic addition):

After transfering to Automation Studio, I check how it works using Watch function:

Is it possible to transfer ST code (generated by Simulink PLC Coder) from the model to Automation Studio using Target for Simulink the same way I transferred C code?

Or is it possible to transfer C code from Matlab to Automation Studio with Target for Simulink, and then somehow convert C code to ST all in one program?

Best Regards,

Adam

Hi Adam,

To my knowledge, Simulink is only able to generate C or C++ code. There is also no way to easily convert C code to ST code. The code generated by Simulink relies on libraries and structures that are only available in C.

Why do you want to convert the program to Structured Text? You will not need to edit it in Automation Studio as you can make changes in Simulink and rebuild when needed. If you define your Simulink variables globally within Automation Studio, you can then access them with a separate Structured Text program that you write yourself.

1 Like

Thanks for response,

I wanted to check whether it’s possible for code generated by Simulink PLC coder to be transferred to Automation Studio.

If it’s not possible through BR target for simulink, would it work fine if the generated IEC 61131-3 was copied and pasted into Automation Studio ST all in one program (into cyclic branch)?

Best Regards,

Adam

Ah I understand now; sorry for the confusion. I thought you were asking about the Embedded Coder or Simulink Coder which are used to turn the Simulink model into C code.

I’m not familiar with the PLC Coder tool in Simulink. According to Mathworks’ documentation, this tool can be used to deploy Structured Text code to Automation Studio. However, as far as I know this is not a tool developed by B&R so I can’t say for sure how it works.

1 Like