CoDeSys V3 - Quick Start 6/6
Testing the Application
Now that we have programmed our complete garage door application we need to do some testing to make
sure that everything functions correctly. Yet, as we do not have a real garage door drive at hand
with all the sensors and actuators required we have to simulate them manually. CoDeSys offers a
completely integrated and comprehensive debugging functionality which will help us test our
application.
First of all we have to log in to the controller and download the code created
by our application. During this process, CoDeSys turns the graphical FBD code into real machine
code using its integrated compilers, which support all kinds of different CPUs and OS platforms.
Our device is the SoftPLC on our PC which we configured in the project configuration before we
started to program our application (see unit 2). Of course, we can later operate our application on
any desired device/controller programmable with CoDeSys.
We get logged in to the controller
with the command ‘Login to Application [name]’ from the menu ‘Online’. CoDeSys now checks whether
an application is already running on our target device (SoftPLC) and if so, which application this
is. A dialogue window with the text: “Application does not exist on device. Do you want to create
it and proceed with download?” appears upon the first download.
If we confirm this window,
CoDeSys compiles the programmed application code and starts to download it to the device. What is
currently happening and the state of progress is displayed in the status bar on the bottom
left-hand side.
As soon as the download is complete the following happens:
If it is not possible to establish an online connection as shown above, we have to check the
communication settings described at the end of the Configuration of the project .
Should we have made syntactical errors in
our application code so that it cannot be compiled, CoDeSys will issue the following message:
“There are compile errors. Do you want to login without download?“
This message box is
closed by clicking on the ‘No’ button and we can then try to fix the error or errors. All errors
detected by CoDeSys and their location are listed in the message window (usually located in the
lower part of our screen). The best thing to do is to go through the errors (or messages) listed
step by step. If we press the ”F4” key, CoDeSys jumps from one message to the next and
displays the erroneous lines in the application code.
We
can now thoroughly check the erroneous code parts and correct them. A typical error would be for
example an FBD block with an open, unassigned input pin. Once we have corrected a detected error,
we can jump to the next one by pressing ”F4”.
After fixing all errors detected we
can test our application by pressing the ”F11”key. The application is compiled but the
native code not yet downloaded on to the controller. If no further errors are found the following
message appears in the message window:
“Compile complete -- 0 errors, 0
warnings”.
With ‘Login to Application [name]’ from the menu ‘Online’ or by pressing the
button
in
the tool bar we can log in to the controller again. And then, in order to be able to test the
application, we have to start it by pressing the “F5“ key or via the menu ‘Online/Start
Application [Device: PLC Logic]’. The word [run]
now appears in brackets behind the application in the device tree and in capital letters in
the bottom status bar (RUN). In the application
code, i.e. in the POU PLC_PRG all Boolean variables are set FALSE. Only the blinking signal for the
error monitoring in the last network changes from TRUE to FALSE every second.
In order to be
able to test the functionality of our application we have to change the global variables set in the
Declaration of the variables :
Actuation and the sensors DoorOpen, DoorClosed and DriveOverload. This
can be done in our variable list ’SimulationSignals’ from where we can directly operate the
application.
By clicking in the column ‘Prepared value’ we can change the Boolean variable.
Attention:
Such a prepared value has not yet been written onto the controller! It could
well be possible that several values have to be changed simultaneously within one controller cycle
to avoid damage to the machine or in the process. That is why the command ‘Online/Write Values’
(shortcut “Ctrl + F7”) has to be executed in order to write our value
Actuation.
Once Actuation has been written the garage door will start to close
because all variable values of the application were set FALSE or 0 after the first download (if no
other initial values were defined in the declaration).
As
the garage door is closing the value of DoorDown is set TRUE by the application. The same
applies for our lighting and its variable Lighting. Just as desired the light goes on when
the garage door is in operation.
In order to be able to follow every single step
programmed, we now have to manually reset Actuation to FALSE and then simulate the sensor
DoorClosed by setting it to TRUE (and then back to FALSE). The actuator DoorDown is
then set FALSE by the application and the door is closed. After 10 seconds the light is
automatically turned off and the variable Lighting is set FALSE.
By once more
pressing the control button, i.e. by setting the variable Actuation TRUE we can test the
opening procedure of the gate. The variables involved are now the variables needed for opening the
gate DoorUp and DoorOpen.
If we do not manually end the opening or closing
procedure by simulating the sensor variables DoorClosed or DoorOpen, the application
recognizes an error after the predefined time of 20 seconds, allowed for these procedures, has
elapsed. As a consequence, the actuator DoorDown or DoorUp is set FALSE and the light
starts to blink and the variable Lighting changes from TRUE to FALSE. By once more pressing
the control button (Actuation is set TRUE) the error is acknowledged, the light stops
blinking and we have returned to our initial state. The error DriveOverload can be tested by
manually setting it TRUE while the gate is opening or closing. Again the garage door is stopped and
the error is signalled by the blinking light.
Download the complete application as a CoDeSys V3 project archive
A CoDeSys V3 project archive can be opened in CoDeSys V3 using the menu command “File/Project
Archive/Extract Archive…”.
Please note:
Our sample application can only be executed in
CoDeSys V3.3 (or higher).
Please rename the archive after download: the file extension *.zip has to be changed back to *.projectarchive.
Please do NOT open the file within the browser, but save it on your computer with "Save Target under".
We have prepared two different versions of the project for you:
1. The original version, as introduced in our Quickstart example and in the accompanying YouTube videos:
Download the project archive
2. The original version with an integrated garage simulation.
Download the project archive
In addition to the code needed to control the garage door, this project contains a simulation module. The integrated visualization makes it easier to test the application. Little tip: You can move the car in the visualization by clicking on the wheels.
We are aware of the fact that the simulation and the visualization are very basic and leave room for your own creativity. Have fun! :-)



