20 Video Views·Apr 22, 2025
Learn the Basics of Binary/Boolean Bit logic by writing some PLC code for controls and automation engineering applications! This video covers the majority of basic true/false bit logic that could be used across standard PLC platforms!! Output Energized, Output Latched, Output Unlatched, Examine If Open, Examine If Closed, One shot and numerous real life examples of why this code and programming is important!
Common PLC platforms include Rockwell RSLogix 5, 500, 5000/ Studio 5000, Siemens PCS7, Aveva Wonderware, Emerson DeltaV, Automation Direct and so many more! The world of industrial controls and automation uses Ladder logic, structured text, function block and Sequential flow charts interchangeably so it's important to have a strong knowledge of all these concepts and how to apply them universally!
Be sure to check out our channel for more if you found this useful and be sure to like and subscribe to help the channel out! If you have any questions or want to see something specific just let us know about it in the comments!
Thanks for watching!!
hello welcome back to the channel
today's video is going to be the start
of a new series where we touch on some
concepts of controls engineering and the
software i'll be using is rslogix
which is rockwell and bradley's
controls engineering design language for
plcs but
the what we'll be doing most of this in
is ladder logic and that's pretty
generic across a lot of plc
manufacturers so in general the concepts
covered here will really help you
writing plc code in any format that uses
ladder logic and a lot of the concepts
extend to general programming so
controls engineering is fairly niche so
if you want more general code like
python or something like that i suggest
you check out the other playlists on
this channel but assuming you know why
you're here let's dive right into it
um today we'll be looking at the basics
of boolean functions which in controls
and code in general boolean means binary
means zero or one true or false it's
also called digital a lot and it's also
called discrete a lot it's essentially a
game of semantics you'll need to be
familiar with all those terms because it
could be called any of those at any
given time
but in general there's really only five
or six things that you can do with a one
or a zero in most plc software so and
when i say plc i mean programmable logic
controller that's the driver for most
controls engineering so let's go ahead
and dive right into it the most
common um
bit
uh the two commands that you'll see for
checking conditions are going to be a
true or a false so
in rockwell
they're called xic and xio that's
examine if open examine if closed
examine if open
is also called examine when off because
that's when the bit that you're looking
at right true false one or zero is
reading a zero
and examine if closed closed is on which
is also when the bit is reading a one so
what i have here is an in xic we're
checking when this bit is on and one of
the most common examples i can use for a
true false would be let's think of a
light switch okay
so let's say that this is a light switch
and when the light switch is in position
on what do we want to do we want the
light to be on so now we need to start
talking about an output condition so
pretty much every rung of code and the
reason we have an error on this
every rung of code needs input
conditions and then output instructions
so like what are you checking to see if
it's true
and then
what will that rung actually do
so here we're basically saying if the
light switch is on right a one
then what we actually want to do is turn
on the light
so we're using an instruction here
that's called an ote
which is essentially
only true
while it's energized so while the light
switch is a one and stays a one the
whole time that's when the light is on
but what's nice about that using this
format is that as soon as the light
switch goes off in this code that ote
ceases to be true so an important thing
about otes is you can only use one in a
program because you can't have two
different spots that are trying to turn
the same thing on i mean think if there
was a second light switch down here that
could be turned on independently from
the first one
how would they know
whether or not they are supposed to be
active or that's supposed to be active
so if you're going to use otes there
needs to only be one spot that you use
it
but let's go ahead and add another
instruction and this time we're going to
use an xio
and say what we want to have happen when
the light switch is off
i'm just using this to demonstrate why
you would want
um to use an xio you don't need to to
have one of each right you can have just
this rung of code that's perfectly valid
but let's say when we turn the light
switch off now that the room is kind of
dark we're going to energize a night
light when that's true
and so this is essentially saying if the
light switch is off our night light is
going to be on if the light switch is on
then the overhead light is on but what's
important to understand is just with
these two rungs of code we've also made
it so the opposite will be off so the
light switch is off then the overhead
light is off just by having an ote
because it's only active while the
conditions on that rung are true
so let's go ahead and take a look at
what if you don't want to use an ote
because there's obvious limitations to
it only being active while the input
conditions are active
let's take a look at an example as if
you were in a car with like a push to
start functionality
so you press a start button right so now
your start button is a one you push the
start button we're going to turn on the
engine
but it would be really
inefficient to have an engine that was
only running while you were actively
holding down the push to start button
right
you can think of the example of a key
where the key needs to be forward and
fully engaged the whole time the engine
is running that's a situation you would
want to use an ote you're checking the
status of a key but if you have a button
based engine command then when the
engine starts you want the engine to
turn on and stay on even after we've
stopped pushing the button
so what's kind of nice is there are
instructions called otl and otu
and those are going to be output latch
and unlatch commands so this is saying
when i've pushed the start button
latch the engine make it a one make it
true but when i release that button
there's no code currently that is going
to make the engine stop which is exactly
what you want you don't want a car that
you just drive around and the whole time
you have to be holding the button in to
have it running
so obviously now you're thinking well
what makes the engine stop then and
let's say you push
the stop button
to get the engine to stop
and then the associated command is an
otu so typically with boolean with
digital on off logic you can either code
things as an ote which handles turn on
and turn off conditions for for most
things
or you can use otl otu pairs so like in
this instance we're saying when the
start button is pressed then the engine
is going to turn on when the stop button
is pressed the engine is going to turn
off a quick thing about
just general logic formatting in most
plc programs they do scan top to bottom
so if you do have two pieces of code
where think someone was pushing both
these buttons simultaneously
then
you would want the stop button second
because if someone's holding down both
these buttons you probably don't want
the car to run you should make
whatever's the safety condition what's
going to win out and override so putting
stop button second is going to be good
but this is basically saying the only
way to turn the engine off is push the
stop button the only way to turn the
engine on is to push the start button
but you don't have to hold it down the
whole time the the car doesn't
have to be
you don't have to be holding down the
stop button to have the engine dead if
you use an otu it turns the engine off
the engine stays off until you push the
start button so
that's kind of the difference between
otes and ot l and u pairs
but then let's look at another situation
let's say you have just one button
right which is the normal in most cars
um there's only one button for start and
stop right
and so what you need to do is you need
to check like yes i need to see what the
status of this button is but what you're
going to do
is going to depend on the current state
of the engine
so if you have a start or stop button
it's going to either start or stop the
car but you have to check the current
state of the engine
so it's an important thing to note
even if you have something that you're
controlling like an engine or like a
light you can still use xic's and xios
to check the status of those things
so let's say we have two different
let's say we have two different checks
we're saying if the engine is off
and in if the engine is on
and we're gonna do two different things
based on that right so if the engine
is
off then when we push the button we're
going to turn it on right
let me drop this in place and uh i'll
get into like some general formatting
and style rules for writing uh
code aft
in a separate video so if you're
unfamiliar with like the purpose of
these branches or how code actually
scans through this program i'll get into
that in a separate video
but for now understand this rung of code
is basically saying if this button is
being pressed
and the engine is off
turn the engine on and leave it on but
if the button is pressed and the engine
is on
then turn the engine off and leave it
off
um this is useful for like a momentary
button that does two different things
depending on the state of your car
but you can think of this as still
having a limitation because what if
you're holding that button down right if
you're holding that button down and the
engine is off you turn the engine on but
as soon as the engine is running this
code is going to turn the engine off
so
this is pretty cool code but there is
something in uh rslogix and most plc
software that actually help you catch
this scenario called a one shot saying
when something happens i basically only
want to run this code one time
so let's say instead of this being an x
i
see
we have a one shot which is essentially
saying
check
as soon as this is true and do the
following code once
so this means if you push the button and
hold it down you're not going to end up
in a weird cycle where you're holding
this button down engine's off you turn
the engine on and it immediately turns
the engine off because this code is true
it's going to come through and whichever
one of these tooth states is true at
that time it's going to do the following
only once
so that's the purpose of a one shot
that's the difference between x ics and
xios and that's the difference between
otes otls and otus i know there's a lot
in this video but that really is the
basics of using bitlogic using boolean
binary on off true false logic and plc
programming there's obviously a million
different iterations and problems you
can run into doing these things but
that's really the core concept of how
you can use
bits so
hopefully that was a useful introduction
for you if you have any questions on
something specific go ahead and let me
know about in the comments and i can try
to get back to you as soon as possible
with some help but in the meantime if
you found this or anything else on the
channel useful please go ahead and leave
a like on the video and subscribe to the
channel really helps me out a lot and as
always good luck with your code and
thanks for watching thanks bye