C to IEC 61131-3 IL compiler

Peter M picture Peter M · Apr 16, 2009 · Viewed 11.6k times · Source

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.

Answer

luc picture luc · Oct 15, 2009

Maybe this answer comes too late but it is possible to call C code from CoDeSys thanks to an external library.

You can find documentation on the CoDeSys forum at http://forum-en.3s-software.com/viewtopic.php?t=620

That would give you to use your C code into the PLC with minor modifcations. You'll just have to define the functions or function blocks interfaces.