Big names like Volkswagen, Moderna, and Bosch are already improving their teams
with RealPars' industrial automation training.
Click the link below for a free consultation.
Learn how easy it is to train your team with RealPars.
Hello and welcome back to another free video from RealPars,
the world's largest online learning platform for cutting-edge industrial technologies.
In today’s video, we are going to learn about Breakpoints in CODESYS.
Breakpoints are a powerful but underutilized tool for debugging PLC programs.
In this video,
I will show you how you can use breakpoints in CODESYS to debug difficult problems.
This video covers the process of debugging an existing CODESYS application,
if you want to learn more about developing applications with CODESYS,
then I suggest you check out our course,
“CODESYS 1: Introduction to PLC Programming”
which explains how to write and test your first PLC program with CODESYS.
You can find a link to that course in the description below this video.
Before we dive into how we use breakpoints, I will quickly explain what breakpoints are.
In programming, a breakpoint is a defined point in a program
where the code will halt execution.
In CODESYS, a breakpoint can be set on any box, rung, or line of code in a project.
When the breakpoint is activated, the application is halted.
This gives you the chance to inspect the value of variables
and the call stack at a particular moment of application execution.
After a breakpoint has been activated,
you can resume the execution of your application as normal
or you can single step through the application to continue debugging.
Now that we know what a breakpoint is,
let’s see how we can use breakpoints in CODESYS.
Throughout this video,
I will show you how to work with breakpoints using an example CODESYS project.
In this project, we scale an analog input to a temperature in degrees Celsius
and then convert that value to a temperature in Fahrenheit using the formula shown here.
Let’s start by adding a breakpoint to the first Network in the program.
To add a breakpoint, you can right-click on the left edge of the network
and select Toggle Breakpoint or select the network and use the keyboard shortcut F9
while logged in to the PLC.
All of the breakpoints that have been added to a CODESYS project
can be viewed in the Breakpoint Window.
The Breakpoint Window can be opened from the View menu as shown here.
In the Breakpoint Window,
you can see all of the Breakpoints that have been added to the project.
You can double-click on any of the Breakpoints listed here
to go to the location in the project where the breakpoint is installed.
Now that we have installed a breakpoint, let’s run our application and see how it behaves.
When you start running the application from the Debug menu,
the breakpoint is immediately activated and execution is halted.
You can see that the breakpoint is active
because there is a Yellow Arrow inside the breakpoint symbol
and the application status has been updated to HALT ON BP
in the status bar at the bottom of the window.
Note that this network hasn’t been executed yet
the yellow arrow indicates that it is the next line to execute.
I modify the value of rTempInput to 10
and execute the rung using the Step Over command in the Debug menu
or the keyboard shortcut F10 as shown here.
As I continue to step through the application,
I see that the value of the variable rConversionFactor is 1.
This is not correct
the result of 9 divided by five should be 1.8.
Single-stepping through the application like this
makes it easy to spot where the application’s logic is not working as expected and correct it.
In this case, I correct the logic by updating the inputs of the DIV block to 9.0
and 5.0 so that the result is a REAL value.
After downloading this change, I can step through the application again
and verify that the calculation is working correctly.
In this video, you got a quick introduction to Breakpoints in CODESYS.
Breakpoints are powerful debugging tools that every PLC programmer should leverage
to verify PLC logic and calculations.
In this video, we barely scratched the surface of the power of Breakpoints in CODESYS.
CODESYS offers many advanced options to configure breakpoints
such as conditional breakpoints
which only activate when certain conditions are met,
and execution points which allow you to write messages to a log file
without halting the application when certain conditions are met.
Keep an eye out for our course,
“CODESYS Debugging Techniques for Controls Engineers”
which will be launched soon and will be available to all of our Pro members.
If you are interested in becoming a Pro member,
check out the link in the description below this video
to learn more about all of the great benefits that you can get
from a RealPars Pro membership.
Do you use breakpoints in your CODESYS applications?
Let us know in the comments what you use them for.