Ladder Logic Best Practices: Optimizing Your PLC Programs

preview_player
Показать описание
▶ The easiest way to learn industrial automation:

▶ Get a membership for your team:

▶ You can read the full post here:

⌚Timestamps:

00:00 - Intro
01:48 - Application example
03:00 - Naming
03:58 - Variable comments
04:56 - Rung comments
05:48 - Engineering units and constants
07:15 - Conclusion

In today’s video, we are going to talk about optimizing your Ladder Diagram programs for readability.

Sometimes, when PLC programmers talk about optimization, they are talking about performance optimization. With performance optimization, you want to improve the performance of your PLC code to reduce scan times and improve memory utilization.

Other times, we are talking about readability optimization. With readability optimization, you are optimizing your PLC programs for the people who have to work with them.

Readability optimization focuses on making your code more understandable so that it is easier to debug, maintain, and extend.

It is very important to make sure that your PLC programs are optimized for readability because in many cases, the PLC program is the only documentation available for a machine after it has been running for many years.

Unreadable PLC code can lead to lost production time for factories and late-night service phone calls for PLC programmers.

In this video, we will see how to optimize a program for readability and highlight what a big difference optimization can make to the readability of your programs.

We will optimize the code for a simple PLC program that controls a mixing tank.

In this application, an operator can press a start button to start a mixing process.

When the process is started, two valves open to fill a mixing tank with input liquids to be mixed.

Once the tank is filled, the valves close and an agitator turns on to mix the liquids.

After a predefined mixing time, the agitator stops rotating and a discharge valve is opened to drain the tank.

The first step that we can take toward optimizing a program is to define logical names for all of the variables that are used in the program. This will help to provide some context about what is happening in the program.

In general, you should use a naming convention to name all of your variables to ensure that variable names are consistent throughout your projects.

Next, we can add comments to the variables to provide more information about them such as the range of values that a variable can have, the unit of measure of the variable’s value, and information about the hardware that is associated with the variable.

If you trying to debug an unfamiliar program, variable comments can be a lifesaver for helping you understand what each variable represents quickly and without needing to dig through drawings.

As well as variable comments, we can use rung comments to make our programs more understandable.

Where variable comments document variables in a project, rung comments can be used to document logic. You can use rung comments to explain what is happening in a particular piece of code and give more context about why it's programmed that way.

As well as adding comments to our code, we can make our code easier to understand by scaling raw data to use engineering values and avoiding the use of hardcoded constants.

Instead of using hardcoded numbers like 4.0 and 20.0, we can use constants in their place. Constants let us give a logical name to values while ensuring that they cannot be changed at runtime.

@Codesys-AutomationSoftware

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

If you want to learn how to write your own PLC applications from scratch, then I encourage you to check out our course CODESYS 1: Introduction to PLC Programming:

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

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

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

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

#plcprogramming #RealPars #ladderlogic #ladderdiagram
Рекомендации по теме
Комментарии
Автор

From Brazil, I say thanks Realpars for one more amazing video! Even not being fluent in English I can understand you perfectly

Celsomadeira
Автор

Iove codesys it's the first software I was introduced to when starting PLC

iamtwig
Автор

Great video we all need to make sure the PLC programs that we code are easy to understand. And always try to make sure what the program is doing and what it should be doing is known and understood .
keep the program as simple as possible. ( Use the KISS method ) but

Ander
Автор

Thanks for the team realpars. From Uzbekistan

АдхамжонМамаджонов
Автор

This video is super great thanks so much #real_pars for this #engineering lesson ❤❤❤

Gumballation
Автор

thank you from Mexico good lesson, Im learning

IngDzib
Автор

There should be feedbacks from all actuators to ensure that the process is truly running as designed. The same feedbacks can be used as interlocks Incase of actuator failure.

lawliet
Автор

Great lesson. Thank you very much, guys!

RS_
Автор

Is it really normal to receive a value of 4..20 (mA) from a WAGO analog input card? Kinda surprised me 'cause I'm used to work with 0..27648 in Siemens or 0..10000 in Modicon PLCs

simxschl
Автор

Hello, you explained about gas turbines in your channel, so could you explain about compressors?

BakytbekIzgaliyev
Автор

Abdullah i am from pakistan i work electrical in secret line and want to learn plc programming❤

abdullahnaheedofficial
Автор

Lots of OEMs don´t want their customers to read and modify their code, and only give out protected versions of their machine programs, so the customer can only download the program to the PLC in case the CPU has to be replaced.

fernandlust
visit shbcf.ru