Your first CODESYS program

Before you get started

Data security: In order to minimize the risk of data security breaches, we recommend the following organizational and technical measures:

  • Avoid access to the PLC and control networks from open networks and the Internet.
  • Use a VPN for remote access.
  • Install a firewall.
  • If you want to publish your visualization on the web, set a password to prevent unauthorized access.
  • Use the latest versions of gateway server and web server.

Installing CODESYS:

Note

The installation includes the development system and the CODESYS Gateway and CODESYS Control Win V3, whose services are accessible using the Windows taskbar. These three programs are necessary in order to simulate a controller on your computer.

About the contents of your first project

In this tutorial you will program a simple refrigerator controller. The finished project RefrigeratorControl.project_archive can be found in the CODESYS installation directory in the “Projects” directory. In addition to the sample project, which you will create here step by step, the finished project contains a complete visualization with operation and diagnosis.

  • As with a conventional refrigerator, the temperature is specified by the user via a rotary control.
  • The refrigerator determines the actual temperature via a sensor. If it is too high, the refrigerator starts the compressor with an adjustable delay.
  • The compressor cools until the desired temperature is reached, minus a hysteresis of 1 degree. The hysteresis is intended to prevent the actual temperature from fluctuating too much around the temperature setpoint, which would result in the compressor constantly switching itself off and on.
  • If the door is open, a lamp lights up in the interior of the refrigerator. If the door is open too long, an intermittent acoustic signal is output.
  • If the compressor does not reach the temperature setpoint despite activity of the motor over a long period, the buzzer emits a constant acoustic signal.

Project planning:

The cooling activity is controlled in the main program of the application, the signal management in a further program block. The required standard function blocks are available in the Standard library. Since no real temperature sensors and no real actuators are connected in this sample project, you will additionally write a program to simulate the rise and fall of the temperature. This will allow you to monitor the operation of the refrigerator controller afterwards in online mode.

Variables that are to be used by all function blocks must be defined in a global variables list.

Preparation

You have installed CODESYS Development System and launched it with the default profile “CODESYS V<current version>”. The frame window of the development system opens with the standard menu bar; no project is open as of yet.

Creating the project and selecting the PLC device

  1. Select the command File ‣ New Project .

  2. In the Templates window, select the Standard Project template.

  3. Enter a name and a storage location for the project and click on the OK button.

    ⇒ The Standard Project dialog opens for entering the device type and the implementation language of the main program.

  4. In the Device list, select the entry CODESYS Control Win V3.

  5. Select the entry Continuous Function Chart (CFC) in the PLC_PRG list and click on the OK button.

    ⇒ The project opens in the CODESYS frame window.

On the left-hand side of the frame window, in the Devices view, you will see the “device tree”, which is a view entitled “Devices”. The previously selected PLC device is displayed with the default name Device.

The Application object for the application to be programmed by you is already suspended under the PLC Logic object.

Application already contains an object for the PLC_PRG main program and the library manager.

The library manager already contains the IoStandard and Standard libraries. IoStandard is required for I/O configurations. The Standard library contains all functions and function blocks that are described by the IEC 61131-3 standard.

The Task Configuration object is suspended at the end of the device tree with the main task, which controls the processing of PLC_PRG. The objects for a visualization, for example, can be inserted below the Task Configuration at a later time.

In addition to the IoStandard and Standard libraries, you need the Util library for this sample project:

  1. Double-click on the Library Manager object in the device tree.

    ⇒ The library manager opens in its editor.

  2. In the header bar of the editor, click on Add library and select the Util library in the Add Library dialog box.

    Confirm the selection with OK

    ⇒ The Util library is added to the library manager and the function blocks from the library are available to you for use in the project.

Declaring the global variables

First of all, declare the variables that you wish to use in the entire application. To do this, create a global variables list under Application:

  1. Select the entry Application and select the command Add Object ‣ Global Variables List in the context menu. Change the automatically entered name GVL to Glob_Var and confirm with Add.

    ⇒ The object Glob_Var appears under Application. The GVL Editor opens to the right of the device tree.

  2. When the textual view appears, it already contains the keywords VAR_GLOBAL and END_VAR. For our example, activate the tabular view by clicking on the button in the right sidebar of the editor.

    ⇒ An empty row appears. The cursor is in the column Name.

  3. Select the command Insert in the context menu.

    ⇒ An input field opens. At the same time the ScopeVAR_GLOBAL and the Data typeBOOL are automatically entered in the row.

  4. Type rTempActual in the field Name.

  5. Double-click in the field in the column Data type.

    ⇒ The field is now editable and the button appears.

  6. Click on the button and choose Input assistant.

    ⇒ The Input assistant dialog box opens.

  7. Select the data type REAL and click on the OK button.

  8. Enter a numerical value in the column Initialization, for example 8.0.

Declare the following variables in the same way.

Name Data type Initialization
rTempActual REAL Numerical, for example 8.0
rTempSet REAL Numerical, for example 8.0
rDoorOpen BOOL FALSE
timAlarmThreshold TIME T#30S Compressor running time after which a signal sounds
rDoorOpenThreshold TIME T#10S Time from opening the door after which a signal should sound
bCompressor BOOL FALSE
bSignal BOOL FALSE
bLamp BOOL FALSE

Creating the main program for the cooling control in the CFC editor

You will now describe the main function of the application program in the main program block PLC_PRG, which is created by default: the compressor is activated and cools if the actual temperature is higher than the temperature setpoint plus a hysteresis. The compressor is switched off if the actual temperature is lower than the setpoint minus the hysteresis.

In order to describe this functionality in the implementation language CFC, perform the following steps:

  1. Double-click on PLC_PRG in the device tree.

    ⇒ The CFC editor opens with the PLC_PRG tab. The declaration editor appears above the graphical editor field in textual or tabular form. To the right is the Tools window.

  2. Click on the element Input in the Tools window and drag it with the mouse to a point in the CFC editor to insert it.

  3. Click on the element in the CFC editor and open the input assistant by clicking on . From the category Variables, select the variable rTempActual under Application ‣ Glob_Var . In this way you reference the global variable rTempActual here.

  4. As in 3., create a further input with the name of the global variable rTempSet.

  5. Create a further input, then click on the three question marks ??? and replace them with the name rHysteresis.

    ⇒ Because this is not the name of an already known variable, the Auto Declare dialog box appears. The name is already adopted into the dialog box.

  6. Fill the fields in the Declare variable dialog box with the Data typeREAL and the Initialization value 1. Click on the OK button.

    ⇒ The variable rHysteresis appears in the declaration editor.

  7. Now insert an addition function block: Click on the Box element in the Tools window and drag it with the mouse to a point in the CFC editor.

    ⇒ The function block appears in the CFC Editor.

  8. Replace ??? with ADD.

    ⇒ The ADD function block is provided by the Standard library. It adds all inputs that are connected to it.

  9. Connect the Glob_Var.rTempSet input to the ADD function block. To do this, click on the output connector of the input and drag it to the upper input of the ADD function block.

  10. In the same way, connect the input rHysteresis with the lower input of the ADD function block.

    ⇒ The two inputs rHysteresis and rTempSet are now added by ADD.

  11. If you wish to move an element in the editor, click on an empty space in the element or on the frame, so that the element is selected (red border, red shaded). Keep the mouse button pressed and drag the element to the desired position.

  12. Create a further function block to the right of the ADD function block. Its function is to compare Glob_Var.rTempActual with the sum of Glob_Var.rTempSet+rHysteresis. Give the function block the function GT (greater than).

    ⇒ The GT function block also originates from the Standard library and works as follows: IF (upper input > lower input) THEN output

  13. Connect the input Glob_Var_rTempActual to the upper input of the GT function block.

  14. Connect the output of the ADD function block to the lower input of the GT function block.

  15. Now create a function block to the right of the GT function block that starts or stops the cooling compressor depending on the input conditions (Set – Reset). Type the name SR in the ??? field. Close the open input field above the function block (SR_0) with the Enter key.

    ⇒ The dialog box Declare variables opens.

  16. Declare the variable with the name SR_0 and the data type SR. Click on the OK button.

    ⇒ The SR function block, which is also defined in the Standard library, serves to define the THEN at the output of the GT function block. The inputs SET1 and RESET appear.

  17. Connect the output connection on the right of the GT function block to the SET1 input of the SR_0 function block.

    SR can set a Boolean variable from FALSE to TRUE and back again. If the condition at the input SET1 is satisfied, the boolean variable is set to TRUE. The variable is reset again if the condition at RESET is satisfied. The boolean (global) variable in our example is bCompressor.

  18. Create an element Output and assign it to the global variable Glob_Var.Compressor. Draw a connecting line between Glob_Var.Compressor and the output connector Q1 of SR.

Now specify the condition under which the compressor should switch off again, i.e. the RESET input of the SR function block receives a TRUE signal. To do this, you formulate the opposite condition to that above. Use the function blocks SUB (subtract) and LT (less than) to do this.

Finally the following CFC chart is created:

Creating a program block for signal management in the ladder diagram editor

In a further program block you will now implement the signal management for the alarm buzzer and for switching the lamp on and off. The Ladder Diagram (LD) implementation language is suitable for this.

Handle each of the following signals in their own networks:

  • If the compressor runs too long because the temperature is too high, attention is drawn to this by a continuous acoustic signal.
  • If the door is open too long, attention is drawn to this by an intermittent signal.
  • The light is on as long as the door is open.
  1. Below the Application in the device tree, create a POU object of type Program using the Ladder Diagram (LD) implementation language.

    Call it Signals.

    ⇒ The Signals object appears in the device tree below PLC_PRG. The ladder diagram editor opens with the Signals tab. The Declaration editor appears in the upper part, the Tools window to the right. The LD contains an empty network.

  2. Create a program in the network so that an acoustic signal sounds when the compressor runs too long without reaching the temperature setpoint. To do this, insert a timer function block TON. It switches a boolean TRUE signal to TRUE only after a specified time: Select a TON under Function blocks in the Tools window and drag it with the mouse into the empty network and onto the appearing rectangle Start here. Release the mouse button when the field turns green.

    ⇒ The function block appears as a rectangle with inputs and outputs and is automatically given the instance name TON_0. The upper input is already displayed by default as a contact upstream of the function block.

    Note

    If you wish to read the online help for the function block, place the cursor in/on the function block in the string “TON” and press F1.

  3. Program so that the function block is activated as soon as the cooling compressor starts to run: For this purpose, name the contact at the upper input of the function block Glob_Var.Compressor. You have already defined this boolean variable in the GVL Glob_Var.

    Note

    When you begin to type a variable name at the input position, you automatically get a list of all variables with names that begin with the typed characters and can be used at this point. This aid is a standard setting in the CODESYS options for intelligent coding.

  4. Insert the signal that is to be activated. To do this, drag a Coil from the tool category Ladder elements to the output Q of the TON function block. Name the coil Glob_Var.bSignal.

  5. Define the time period from the activation of the TON function block until the signal should sound: This definition takes place via the variable Glob_Var.timAlarmThreshold, which you insert for this purpose at the input PT of TON_0. To do this, click on the fine-edged rectangle to right of the input connection and enter the variable name.

  6. Click on the TON function block and select the command Remove unused FB call parameters in the context menu.

    ⇒ The unused output ET was removed.

  7. In the second network of the LD, program so that the signal sounds intermittently if the door is open too long.

    Click below the first network in the Editor window and select the command Insert network in the context menu.

    ⇒ An empty network with the number 2 appears.

  8. As in the first network, implement a TON function block for time-controlled activation of the signal, this time triggered by the global variable Glob_Var.rDoorOpen at the IN input. At the PT input, add the global variable GlobVar.timDoorOpenThreshold.

  9. In addition, add a BLINK function block from the Util library at the output Q of the TON function block in this network and name it Blink_0.

  10. The BLINK function block clocks the signal forwarding Q and thus GlobVar.bSignal.

    For this, first of all drag two contact elements from the Tools view to the OUT output of the function block. Assign the variable TON_1.Q to the contact directly behind the output Q and the global variable Glob_Var.rDoorOpen to the second contact.

  11. Insert a coil element behind the two contacts and assign the global variable Glob_Var.bSignal to it.

  12. To do this, declare the local variable timSignalTime : TIME := T#1S; and insert this variable at the inputs TIMELOW and TIMEHIGH; the cycle time is thus 1 second for TRUE and 1 second for FALSE.

  13. Click on the TON function block and select the command Remove unused FB call parameters in the context menu.

    ⇒ The unused output ET was removed.

  14. In the third network of the LD, program so that the lamp lights up as long as the door is open. To do this, insert another network and in it, on the left, a contact GlobVar.rDoorOpen, which leads directly to an inserted coil Glob_Var.bLamp.

  15. CODESYS processes the networks of an LD in succession. Now install a jump to Network 3 at the end of Network 1 in order to ensure that either only Network 1 or only Network 2 is executed:

    Select Network 3 by clicking with the mouse in the network or in the field with the network number. Select the command Insert label in the context menu. Replace the text Label: of the label in the upper left part of the network by DoorIsOpen:

    Select Network 1. Drag the Jump element from the General category of the Tools window into the network. Place it here on the appearing rectangle Add output or jump here.

    ⇒ The jump element appears. The jump destination is still specified as ???.

  16. Select ??? and click on the button . Select DoorIsOpen from the possible label identifiers and confirm with OK.

    ⇒ The label to Network 3 is implemented.

The LD program now looks like this:

Calling the Signals program in the main program

In our program example the main program PLC_PRG should call the Signals program for signal processing.

  1. Double-click on PLC_PRG in the device tree.

    ⇒ The PLC_PRG program opens in the editor.

  2. Drag a function block element from the Tools view into the editor of PLC_PRG.

  3. Using the input assistant, add this function block from the Function block calls category to the call of the Signals program.

Creating an ST program block for a simulation

Since the application in this example project is not linked to real sensors and actuators, you must now also write a program for the simulation of rises and falls in temperature. This will allow you to monitor the operation of the refrigerator controller afterwards in online mode.

You create the simulation program in structured text.

The program increases the temperature until the main program PLC_PRG determines that the temperature setpoint has been exceeded and activates the cooling compressor. The simulation program then lowers the temperature again until the main program deactivates the compressor once more.

  1. Under the application, insert a POU of the type Program and the implementation language ST and with the name Simulation.

  2. Implement the following in the ST editor:

PROGRAM Simulation
VAR
    T1: TON;                            //The temperature is decreased on a time delay, when the comepressor has been activated
    P_Cooling: TIME:=T#500MS;
    xReduceTemp: BOOL;                  //Signal for dereasing the temperature
    T2: TON;                            //The temperature is increased on a time delay, when the compressor has been activated
    P_Environment: TIME:=T#2S;          //Delay time when the door is closed
    P_EnvironmentDoorOpen: TIME:=T#1S;  //Delay time when the door is open
    xRaiseTemp: BOOL;                   //Signal for increasing the temperature
    timTemp: TIME;                      //Delay time
    iCounter: INT;
END_VAR

iCounter := iCounter+1;     // No function, just for demonstration purposes.

// After the compressor has been activated due to TempActual being too high, the temperature decreases.
// The temperature is decremented by 0.1°C per cycle after a delay of P_Cooling
IF Glob_VAR.bCompressor THEN
    T1(IN:= Glob_Var.bCompressor, PT:= P_Cooling, Q=>xReduceTemp);
    IF xReduceTemp THEN
        Glob_Var.rTempActual := Glob_Var.rTempActual-0.1;
        T1(IN:=FALSE);
    END_IF
END_IF

//If the door is open, the warming occurs faster; SEL selects P_EnvironmentDoorOpen
timTemp:=SEL(Glob_Var.rDoorOpen, P_Environment, P_EnvironmentDoorOpen);

//If the compressor is not in operation, then the cooling chamber becomes warmer.
//The  temperature is incremented by 0.1°C per cycle after a delay of tTemp
T2(IN:= TRUE, PT:= timTemp, Q=>xRaiseTemp);
IF xRaiseTemp THEN
    Glob_Var.rTempActual := Glob_Var.rTempActual + 0.1;
    T2(IN:=FALSE);
END_IF

Note

The use of a visualization is recommended for convenient operation and monitoring of the entire control program. A visualization created with CODESYS Visualization is installed in the finished sample project for this tutorial, which is provided with the standard CODESYS installation (Projects directory). You can load this project to the controller and start it to see it working together with the visualization. On starting, the Live_Visu starts up with an illustration of the refrigerator that reproduces the operation of the simulation program without you having to make any entries. However, you can bring about the opening and closing of the door with a mouse click on the on/off switch and it is possible to adjust the temperature preset on the needle of the rotary control. We will not deal with the creation of the visualization in the context of this tutorial. An appropriate tutorial is planned in the context of the CODESYS Visualization online help.

Specification of the programs to be executed in the task configuration

The preset task configuration contains the call for the main program PLC_PRG. For our example project you must also add the call for the Simulation program.

  1. In the device tree, drag the Simulation entry with the mouse onto MainTask under the Task Configuration.

    ⇒ The Simulation function block is inserted in the task configuration.

  2. If you wish to see the task configuration, double-click on the MainTask entry to open the editor.

    ⇒ In the table in the lower part of the editor you will see the POUs that are called by the task: PLC_PRG (entered by default) and Simulation. The call type of the task is Cyclic at intervals of 20 milliseconds. In online mode the task will execute the two function blocks once per cycle.

Defining the “active application” for the communication with the PLC

The name of application Application is shown in bold in the Devices window. This means that this application was set as the “active application”. The communication with the controller then refers to this application.

If there is only one application in a project, it automatically becomes the active application. If your application is not yet active, activate it as follows:

  1. Click with the right mouse button on Application and select the command Set Active Application in the context menu.

    ⇒ The application Application is now shown in bold in the Devices view.

Debugging the application program

During the input of code, CODESYS immediately alerts you to syntax errors by a red wavy line underneath the text concerned. Press F11 to have the entire application checked for syntax. The result of the check is shown in the message window. If necessary, open the message window using the View ‣ Messages command. You can then select a message and jump to the corresponding point in the code with the F4 key.

You can only load an error-free application to the controller afterwards.

Starting the Gateway server and the PLC

Caution

Check controller accessibility For security reasons, controllers should not be accessible from the Internet or untrusted Networks under any circumstances! In particular, the TCP/IP programming ports (usually UDP-Ports 1740..1743 and TCP-Ports 1217 + 11740 or the controller specific ports) should not be accessible from the internet without protection. In case Internet access to the controller is needed, using a a safe mechanism is absolutely mandatory, such as VPN and password protection of the controller.

see also: Handling User Management on the Controller

Starting the gateway server:

The program GatewaySysTray is installed as standard with CODESYS. You can communicate with the gateway server via this program. The gateway server is automatically started as a service on starting up the system. Check that the Windows taskbar contains the program icon . If the gateway server is not running, the icon looks like this: . In this case you can open the Gateway menu by clicking on the icon and choose the Start Gateway command.

Starting the PLC:

The program CODESYSControlSysTray is also installed as standard with CODESYS. You can communicate with the CODESYS Control Service via this program. From CODESYS V3.5 SP2 the control service is no longer automatically started on starting up the system. This is to protect against unauthorized access. Start the PLC as follows: Open the PLC menu with a mouse click on in the Windows taskbar and select the command Start PLC. If the PLC is running, the icon changes to . A dialog box that appears at startup indicates to you that the started PLC allows programming access. Be sure to observe the above security instructions!

During the very first communication configuration: addition of the gateway

  1. Double-click on the entry Device (CODESYS Control Win V3) in the Devices view.

    ⇒ The Device dialog box appears with the Communication Settings tab.

Note

If this is your first communication configuration with CODESYSV3, you must now define the local gateway server. If you have already defined the gateway server, it will be shown on the Communication tab. In this case, you can now continue with the step Setting the communication channel.

The gateway server is provided with the CODESYS installation.

  1. Select the command Gateway ‣ Add Gateway .

    ⇒ The Gateway dialog box appears.

  2. Enter a symbolic name for the gateway in the input field Name.

  3. Select the TCP/IP entry in the Drivers list.

  4. Double-click on the right column of the IP-Address row and enter localhost in the input field.

  5. Click on the OK button.

    ⇒ The gateway is entered on the Communication Settings tab (1) of the device editor. If the gateway is running correctly, a green-filled circle appears on the graphic of the gateway:

Setting the communication channel

Now define the communication channel to the device, which is then used via the gateway that you have set. To do this, open the Communication Settings tab of the device editor by double-clicking on the Device entry in the device tree.

  1. Click on the Scan network button to search the local network for all available devices.

    ⇒ The Select device dialog box (1) appears with a list of all devices with which you can establish a connection.

  2. Select the tree entry with the name of your computer.

  3. Click on OK.

    ⇒ The channel is now active and the associated information appears below the device graphic on the Communication Settings tab.

Note

All communication actions now relate precisely to this channel. Remember this later if you have multiple communication channels in the project.

Loading the application to the PLC

Requirement: The application has been compiled without errors. See step Debugging the application program.

  1. Select the command Online ‣ Login .

    ⇒ A dialog box appears asking whether the application should be loaded to the controller.

  2. Click on the Yes button.

    ⇒ The application is loaded to the controller. The entries for the controller and the application in the Devices window have a green background. Stop appears behind the Application object. The current status of the controller appears in the taskbar: .

Starting the application

If you have followed this tutorial to the letter up to this point, you can now use the application Application on the PLC Device (CODESYS Control Win V3).

  1. Right-click on the Application object in the Devices window and select the Start command in the context menu.

    ⇒ The program runs. The entries for the controller and the application in the Devices window have a green background. run appears behind the Application object. The current status of the controller appears in the taskbar: .

Monitoring and once-only writing of variable values at runtime

In the following you can see the “monitoring” of the variable values in the various program function blocks and you can set a particular variable value on the controller once only from CODESYS.

You can see the actual values of the application variables in the online views of the function block editors or in monitoring lists. In the example here we shall restrict ourselves to the monitoring in the function block editor.

Requirement: the application is running on the controller.

  1. Open the online views of the editors with double-clicks on the objects PLC_PRG, Signals, Simulation and Glob_Var in the device tree.

    ⇒ In the declaration section of each view, the actual value of the variable (1) on the controller appears in the table of expressions in the Value column (3) (see illustration).

    Monitoring in the implementation section depends on the implementation language: in the case of non-boolean variables, the value is always located in a rectangular field to the right of the identifier. In the ST editor this also applies to boolean variables. We call this display “Inline monitoring”. In the graphical editors, the value of a boolean variable is shown by the color of the output connecting line: black for FALSE, blue for TRUE:

  2. Observe the changing of the variable values in the various function blocks. For example, you can see in the GVL Glob_Var how the values of rTempActual and Compressor change due to the processing of the simulation program.

Once-only setting of variable values on the controller:

  1. Set the focus in the online view of the GVL Glob_Var.

  2. To set a new setpoint value, double-click in the column Prepared value (2) next to the expression rTempSet.

    ⇒ An input field opens.

  3. Enter the value 9 and leave the input field.

  4. To specify an open door, click once in the field Prepared value next to the expression rDoorOpen. The value TRUE is entered. Click 3 more times in order to see that by doing so you can switch the prepared value to FALSE, then back to empty and then back to TRUE.

  5. To write the prepared value TRUE once only to the variable, press Ctrl+F7.

    ⇒ The two values are each transferred to the Value column (3). The variable rDoorOpen now no longer changes its value and the temperature setpoint is now 9 degrees. The variable timTemp changes to the value 1s because the refrigerator door is now “open” and the heating due to the Simulation should be faster than before (2s).

Setting breakpoints and stepping through at runtime

“Debugging”: for troubleshooting purposes you wish to check the variable values at certain points in the code. You can define breakpoints for the execution and initiate a step-by-step execution of the instructions.

Requirement: the application has been loaded to the controller and is running.

  1. Open the program in the editor by double-clicking on Simulation.

  2. Place the cursor in the code line iCounter := iCounter+1; and press F9

    ⇒ The icon appears in front of the code line. It indicates that a breakpoint is set on this line. The icon immediately changes to . The yellow arrow always points to the next instruction to be processed. appears in the taskbar instead of .

  3. Observe the value of the variable iCounter in the inline monitoring or in the declaration section of the simulation program.

    ⇒ The value of the variable no longer changes. The processing was stopped at the breakpoint.

  4. Press F5 to restart the processing.

    ⇒ After one cycle the program stops again at the breakpoint. iCounter was incremented by 1.

  5. Press F8 to execute the next processing step.

    RETURN at the end of the line iCounter := iCounter+1; instruction is highlighted in yellow.

  6. Press F8 again to execute the next processing step.

    ⇒ The processing jumps to the editor of PLC_PRG. Repeatedly pressing F8 shows how the program is executed step-by-step. The instruction to execute is once again marked each time with a yellow arrow.

  7. In order to deactivate the breakpoint and return to normal processing, set the cursor once again in the code line and press F9. Then press F5 to place the application once again in the mode .

Executing a single cycle at runtime

Requirement: the application has been loaded to the controller and is running.

  1. As above in the step-by-step execution, observe once again the line iCounter:=iCounter+1 in the simulation program.

  2. Press Ctrl+F5 or select the command Debug ‣ Single Cycle in order to execute a single cycle.

    ⇒ The processing runs through one cycle and stops at the breakpoint again. iCounter was incremented by 1.

  3. Press Ctrl+F5 a few more times to see single cycles. Then press F5 again.

    ⇒ The program runs again without stopping and without forced values. The variable temp once again has the value 1s. appears once again in the status bar.