C to IEC 61131-3 IL compiler

2019-02-18 12:25发布

I have a requirement for porting some existing C code to a IEC 61131-3 compliant PLC.

I have some options of splitting the code into discrete function blocks and weaving those blocks into a standard solution (Ladder, FB, Structured Text etc). But this would require carving up the C code in order to build each function block.

When looking at the IEC spec I realsied that the IEC Instruction List form could be a target language for a compiler. The wikepedia article lists two development tools:

  1. CoDeSys
  2. Beremiz

But these seem to be targeted compiling IEC languages to C, not C to IEC.

Another possible solution is to push the C code through a C to Pascal translator and use that as a starting point for a Structured Text solution.

If not any of these I will go down the route of splitting the code up into function blocks.

Edit

As prompted by mlieson's reply I should have mentioned that the C code is an existing real-time control system. So the programs algorithms should already suit a PLC environment.

7条回答
戒情不戒烟
2楼-- · 2019-02-18 12:56

If the amount of code to convert is a few thousand lines, recoding by hand is probably your best bet.

If you have lots of code to convert, then an automated tool might be very effective. Using the DMS Software Reengineering Toolkit we've built translators to map mechanical motion diagrams into RLL (PLC) code. DMS also has full C parser/analyzers/front ends. The pieces are there to build a C to RLL code.

This isn't an easy task. It likely takes 6-12 man-months to configure DMS to something resembling what you want. If that's less than what it takes to do by hand, then its the right way to do it.

查看更多
登录 后发表回答