24.01.2015 Views

PLC Programming

  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Project Components...<br />

In FBD :<br />

<strong>PLC</strong>_PRG<br />

Action<br />

Example for a possible call sequence for <strong>PLC</strong>_PRG:<br />

LD 0<br />

ST PRGexample.PAR (*Default setting for PAR is 0*)<br />

CAL IL call (*ERG in IL call results in 1*)<br />

CAL ST call (*ERG in ST call results in 2*)<br />

CAL FBD call (*ERG in FBD call results in 3*)<br />

If the variable PAR from the program PRGexample is initialized by a main program with 0, and then one after<br />

the other programs are called with above named program calls, then the ERG result in the programs will have<br />

the values 1, 2, and 3. If one exchanges the sequence of the calls, then the values of the given result<br />

parameters also change in a corresponding fashion.<br />

The <strong>PLC</strong>_PRG is a special predefined POU. Each project must contain this special program. This<br />

POU is called exactly once per control cycle.<br />

The first time the 'Project' 'Object Add' command is used after a new project has been created, the<br />

default entry in the POU dialog box will be a POU named <strong>PLC</strong>_PRG of the program type. You should<br />

not change this default setting!<br />

If tasks have been defined, then the project may not contain any <strong>PLC</strong>_PRG, since in this case the<br />

procedure sequence depends upon the task assignment.<br />

Attention: Do not delete or rename the POU <strong>PLC</strong>_PRG (assuming you are not using a Task Configuration)!<br />

<strong>PLC</strong>_PRG is generally the main program in a single task program.<br />

Actions can be defined and assigned to function blocks and programmes ('Project' 'Add action'). The<br />

action represents a further implementation which can be entirely created in another language as the<br />

"normal" implementation. Each action is given a name.<br />

An action works with the data from the function block or programme which it belongs to. The action<br />

uses the same input/output variables and local variables as the "normal" implementation uses.<br />

Example for an action of a function block<br />

In the example given, calling up the function block Counter increases or decreases the output variable<br />

"out", depending on the value of the input variable "in". Calling up the action Reset of the function<br />

block sets the output variable to zero. The same variable "out" is written in both cases.<br />

2-6 CoDeSys V2.3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!