CODESYS PLC Programming: Tips for Maximizing Performance
RealPars RealPars
1.06M subscribers
16,815 views
0

 Published On Sep 4, 2023

▶ The easiest way to learn industrial automation:
https://realpars.com

▶ You can read the full post here:
https://realpars.com/codesys-plc-prog...

⌚Timestamps:
00:00 - Intro
00:25 - Introduction to optimization
01:34 - Application introduction
02:04 - Optimization
05:10 - Test and benchmark
06:02 - Conclusion

In this video, you will learn how to optimize your PLC code for performance.

Before we talk about how to optimize your PLC code, let’s quickly define what optimization is in the context of PLC programming.

In this video, you will see how we can refactor, or update, a CODESYS PLC application to optimize it for performance.

In PLC programming, performance optimization usually aims to lower PLC cycle times and reduce the memory usage of the application.

Low cycle times are important because we want to control processes at near real-time. High cycle times may lead to the loss of control of a process which can create dangerous situations.

Low memory usage is important because PLCs have limited memory resources. Unlike computers which have a lot of memory available, a typical PLC, like the “Wago CC100”, has only 32 megabytes available to store an application.

In this video, we will optimize a CODESYS application that monitors a temperature and controls a fan.

When the temperature reaches an upper limit, the fan turns on, and when the temperature reaches a lower limit, the fan turns off.

This sounds like a simple application but it will highlight how many opportunities there are to optimize even the easiest of applications.

Optimization starts with an analysis of the current code.

The aim here is to identify parts of the code that we can refactor to simplify calculations, consolidate logic, and improve memory usage by reducing the number of variables used.

By simplifying calculations and removing duplicate logic from an application, we can significantly reduce the cycle time of the application.

Starting with a complex three-rung calculation, we optimize the conversion from Celsius to Fahrenheit, initially using memory-consuming intermediate variables.

We will introduce an efficient method using the “Function Block Diagram” to replace the current process, thereby removing several rungs and intermediate variables.

Instead of converting values twice, we directly scale the analog input to Fahrenheit, saving cycle time. Duplicate calculations and excess intermediate variables for fan control are eliminated.

The result? A streamlined, more comprehensible program.

After this, we'll test and benchmark the outcome. After optimizing an application, you should check how much of an impact your changes have made to understand the value of the optimization and if the performance targets were reached.

The first thing to check is the reduction in memory use. You can see the memory use of an application when you build the application.

You can also check the reduction in cycle time by downloading the project to a PLC and opening the Monitor tab of the Task Configuration object.

This tab gives some statistics about the cycle time of the PLC including the last cycle time, average cycle time, max cycle time, and min cycle time.

=============================

If you want to learn more about programming PLCs using CODESYS, check out the course CODESYS 1 - Introduction to PLC Programming: https://learn.realpars.com/courses/co...

You can purchase your WAGO StarterKit through this link:
https://www.wago.com/global/lp-wago-c...

=============================

Did you miss out on the latest and greatest? Catch up now by watching our videos right here:

https://realpars.com/ladder-logic-vs-...

http://realpars.com/Static-IP-Address...

https://realpars.com/predictive-maint...

=============================

TWEET THIS VIDEO: https://ctt.ac/QT_od

=============================

Follow us on Facebook 👉   / therealpars  

Follow us on Twitter 👉   / realpars  

Follow us on LinkedIn 👉   / realpars  

Follow us on Instagram 👉   / realparsdotcom  

#PLCProgramming #RealPars #CODESYS

show more

Share/Embed