Marius196
Hello,

I used the matiec compiler to generate c code out of structured text. Now, after transpiling the code, I get the sourcecode files:

Config0.c
Config0.h
LOCATED_VARIABLES.h
Pous.c
Pous.h
Res0.c
 
I would now like to execute the generated C-code to test the functionality of the code.
 
As far as I see, the functional code is genrated in the file Pous.c.
 
My goal is to embed the C-Code in other applications for testing purposes, because PLC Code isnt compatible with this applications.
 
Or is it only possible to execute the Code with the OpenPLC Runtime?

Thanks in advance.
Reply 0 0
thiagoralves
The OpenPLC Runtime is the missing piece that glues MatIEC output together. What MatIEC generates is a C representation of your original structured text code. Without a runtime there is no way for you to execute this. You can create your own runtime around those files or use OpenPLC Runtime, it's up to you.
Reply 0 0
Marius196
Thank you for your answer. I understand your advice but I would like to run an executable softplc directly after building the code. I found the repo Felipeasg/matiec_examples: Simple examples about how to use MATIEC compiler for IEC 61131-3 (github.com) where it is possible to run a softplc direct after building the code. This is just what I searched. Something like this is also in the test folder of the matiec compiler. The plc.c and the main.c can generate the softplc, which you can execute directly without runtime. Now the problem is, if want to print out some (Located) Variables in the Run() function they are always TRUE and dont change der values. Do you have an idea how to print the values of the variables in the plc.c programm?

Reply 0 0
thiagoralves
The main.c and plc.c files you are talking about are a diminutive runtime to execute the transpiled code. That's what I told you would need to compile the matiec code. I don't know what you wrote on your runtime, so the fact that your variables are printing TRUE all the time could be caused by a number of things, including failing to call the config_run function, not printing variables correctly, not initializing variables properly, or even your PLC program being static with static inputs...
Reply 0 0
xiaohh
I run the generated C code together with 2 files, it seems to be simple.
  1. editor\arduino\examples\Baremetal\Baremetal.ino, just rename the .ino to .c,
  2. Develop one main.c which initialize the MCU periphael and call setup() and loop().
Reply 0 0
Reply