I guess a PLC is programmed and run by a micro-controller at its centre. But normally we use C language to program micro-controllers.
When we program PLC, is the ladder logic first converted to C or compiled directly by a special compiler?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityThere are various methods used by different manufacturers. The oldest kind of ladder was consisted by an array of gate logic already running as main program in the MCU. With a ladder program you just enabled or disabled the elements (contacts) and with regard on their position AND or OR operations were executed. This had limitations.
The newer approach is to make a intermediary pseudo program, similar as assembler (Instruction list). The main program in MCU runs an interpreter, each rung is evaluated and executed at once. With this kind, you have the possibility to have more elements of different types and a rung not limited to few elements. The downside is the slow execution due to interpreter. A good thing is that the program does not need to be compiled, it can be input at the PLC itself (small LCD), a program can be edited online with changes, it can be also uploaded from PLC in original aspect.
The latest kind of PLC uses a compiler to generate code. The program can't be uploaded from PLC as original if the source wasn't downloaded into PLC, also. The compiler makes an intermediate results, that are used for online monitoring. If the generated block is tested and it doesn't need to be monitored any further, the compiler can be set to generate the optimised code, you loose the ability to monitor it, but it executes fast. The downside is a complex copy/move program memory if the program is changed, also it is almost impossible to make a big change of program without re initialising the static memory (RAM).
Many modern PLCs have (sometimes multicore) Intel or AMD processors with 64bit. Micro-controllers are rarely used nowadays for high-performance PLCs. These PLCs have their own operating system, mostly based on Linux, or for example Beckhoff is running on Windows Embedded. Ladder logic can be compiled directly, but I don't know who is doing it and who not.
Check this link: https://www.quora.com/How-is-PLC-ladder-logic-converted-to-machine-code-Does-it-really-convert-into-machine-language
EDIT
Some manufacturers have their own processors, not sure, but Siemens I think too. Modern PLCs are more like (real-time) computers than the classic PLCs from the 90s.