Boolean Logic to PLC Function Blocks | FundamentalsLearn about some basic mathematical concepts that are used to create Function Block programs.
Have you ever wondered how skilled PLC Programmers create, install and test programs when presented with complex system requirements? Today’s successful PLC programmers possess knowledge and skills in electrical, mechanical, and software engineering. In addition to having expert-level skills in vendor-specific PLC programming software, PLC programmers rely on Boolean Logic and mathematical concepts to optimize their designs.
In this article, we’re going to have a look at some basic mathematical concepts that are used to create Function Block programs.
Earlier we said that PLC programmers rely on mathematical concepts to optimize their designs. PLC programmers use Boolean Algebra, also called Boolean Logic every time they create a program.
Don’t let the term Algebra scare you because the concepts of Boolean Logic aren’t terribly difficult.
Boolean Logic centers around the fundamental concept that all values are either True or False. Going one step further, True and False can be represented by either a 1 bit or a 0 bit.
You’ve likely noticed that most PLC programming languages use the term BOOL to represent a digital input or output. BOOL is short for Boolean. Every digital I/O can be represented by a 1 or a 0.
Basic function blocks
Let’s look at the two basic Function Blocks in FBD and investigate the Boolean Algebra associated with each.
OR function block
The OR Function Block has at least two inputs. Earlier we said in Boolean Logic, all values are either True or False and can be represented by either a 1 or a 0 bit.
The OR Function Block has a Truth Table that does two things.
First of all, it lays out all of the possible input conditions.
Secondly, it indicates how the output reacts to the input conditions.
From the Truth Table, we can see that the C is True when A OR B is True.
OK… Here’s where we get into the Boolean Algebra part. The mathematical expression for the OR function block is A OR B equals C. A plus sign is used to indicate the OR function.
In primary school, we were taught that the plus sign is used for addition. So… it would appear that the OR function block performs Boolean addition.
AND function block
Ok… Let’s move on to the AND Function Block. The AND Function Block has at least two inputs.
From the AND Truth Table, we can see that C is True when A AND B are True.
The mathematical expression for the AND function block is A AND B equals C.
Notice the multiplication symbol used to indicate the AND function. So, it would appear that the AND function block performs Boolean multiplication.
We can drop the multiplication symbol and the expression looks like this: AB = C
FBD optimization example
As we said earlier, PLC programmers rely on Boolean Logic to optimize their designs. Let’s look at a simple example of Boolean Logic optimization.
On the first pass of converting a system requirement into a FUNCTION BLOCK DIAGRAM, a programmer ended with three function blocks.
The programmer would ask herself… Can I optimize this FUNCTION BLOCK DIAGRAM and eliminate any of the function blocks using Boolean Algebra? The answer is Yes. So, let’s see how.
The Boolean Logic expression for this program is: D = AB + AC
Using a little high school math, we use the Distributive Law, and a transformation occurs.
Alright… now let’s rebuild our FUNCTION BLOCK DIAGRAM and see if we’ve made some progress towards optimization.
After using some basic algebra, we’ve gone from three function blocks to two function blocks.
I’ve given you just a glimpse of how Boolean Logic can be used in the optimization of PLC programs. Like it or not, seasoned PLC programmers have become mathematicians.
I recommend checking the following related articles, if you haven’t already, to have a better understanding of PLC Function Blocks:
OK… let’s review:
– PLC programmers possess a variety of knowledge and skills in electrical, mechanical, and software engineering.
– PLC Programmers have expert-level skills in vendor-specific PLC programming software and rely on mathematical concepts to optimize their designs.
– Boolean Logic centers around the fundamental concept that all values are either True or False and can be represented by either a 1 bit or a 0 bit.
– Function Block Diagram (FBD) is rapidly replacing Ladder Logic as the programming language of choice amongst PLC programmers.
– The two basic Function Blocks in FUNCTION BLOCK DIAGRAM are OR and AND.
– Boolean Logic can be used by PLC programmers in the optimization of PLC programs.
If you have any questions about the Boolean Logic or about PLC Function Blocks in general, add them in the comments below and we will get back to you in less than 24 hours.
Got a friend, client, or colleague who could use some of this information? Please share this article.
The RealPars Team
By Ted Mortenson
Posted on Mar 22nd, 2021
By Ted Mortenson
Posted on Mar 22nd, 2021
In this blog post, you’ll learn about the mindset that helped me getting a PLC programming job with NO experience. This is my personal experience as someone who searched for a job in this field and as an employer who reviews resumes and interviews candidates for a variety of projects. So let’s get started!
In this article, we will be talking about contactors. We will explain what a contactor is and how they work. We will also explain how to wire a contactor and the difference between a contactor and a relay.What is a contactor?A contactor is a device that is for making...
In this article, we will be talking about capacitive proximity sensors. We will explain what a capacitive proximity sensor is and how they work. We will also talk about some of the different types of materials these sensors can detect, explain the main parts of these...
Learn how to program PLCs, install and wire industrial devices, and at the same time purchase them online.
+31 10 316 6400
Mon - Fri 8:30 am to 5:30 pm (CET)
Rotterdam Science Tower, Marconistraat 16,
3029AK Rotterdam, Netherlands
© 2021 RealPars B.V. All rights reserved.
Created with coffee and tea in Rotterdam.