We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you've provided to them or that they've collected from your use of their services.

Coding the PLC

CoDeSys, delivered with the starter-kit, allows to program in a few ‘languages’.  The most transparent to a person who knows Pascal, Basic or even PHP is the ‘Structured Text’.

The outputs and inputs should receive their distinctive names (for example IN1, OUT1).  Their value is set with a simple equation like: OUT1:=IN1.  The typical conditional commands (IF, CASE) and loops (FOR, WHILE, REPEAT) are also available.

Initially I had a great problem with understanding how a PLC program works.  The program is not executed/red once as it happens in a ‘normal’ application.  The PLC executes it continuously at a defined frequency. 

As a consequence it is not possible to do the following: IF IN1==TRUE (meaning if the button connected to IN1 is pressed) THEN OUT1=-OUT1 (meaning, change the state of the OUT1).  If we assume the button was pressed for 0.5 sec and the program is executed 60 times a second, the state of the OUT1 would be changed 30 times!  For experts of PLC programming such a remark must seem naïve.  For me, however, repetitive execution of the program was a difficult thing to get used to.

For most of the building applications WAGO deliveres dedicated libraries. Additionally one should check out the open-source libraries available at www.oscat.de.

More details about programming are available at "Functions".