Yaskawa
eLearning
You're watching the IEC 61131 Basics
Video Tutorial Series
on the topic of Timers and Sequencing
Hi, I'm Matt Pelletier
and we'll continue in this section to develop
our parking gate control example project
with a simple application of IEC 61131 Timers
and look at Function Block Sequencing
Let's add some Timer functionality now
to our application.
We have the Sensor and as the car
hits that Sensor and drives forward
we would like to have some Delay time
between when the gate actually closes
and the car moves off the Sensor
this way we would be more sure that
the car doesn't get hit by the closing gate.
With any of the timers in IEC 61131
and there is a PT Input
and this is the Time Input
which uses the Time Data Type
We have seen this here before let's
just go through it, here's a few examples
of the correct initial value or the
values that you can use
for the Time Data Type
T#5s
T#5.0s
even the word Time#
and for 5 seconds 5s
We could look at the Help
and under Literals
you would see other formats
so what I'd like to do as a
preliminary exercise is let's create
a new LD (ladder) POU called Timers
in Fast Task
and then let's add one of each Timer
you can see the three basic
IEC 61131 Timers
and then you have a way to test
each these out and see how they work
and go through and turn on the input
with the same Delay time and see
what happens with the output and the elapsed time
and then as you implement
and observe each of these Timers
keep in mind which Timer might be the most
appropriate way to implement our application
where we like the Gate Output to stay ON
for an additional delay time.
So as before I encourage you to try
to do this here on your own
pause it, and then I will go through my solution.
Okay, so here's what you do
you go to Logical POUs
and let's Insert > Timers
as a ladder, before I forget
I'll run that here in the Fast Task
probably right around, right below Main
so let's Insert the Program instance here
Timers and the Program Type again Timers
match those up
alright, runs right after Main
now opening up Timers here
I could add under the Function Block group
Timers are Function Blocks
I have these three here
a TOF, a TON and TP
so let's put in one of each
TOF
and I'll take the default name
remember you can also type these in TON
and a TP
and please recall also
anytime you use a new block you can
right-click on it for Help
and you see here the description
it's an OFF Delay Timer
it's looking for input changing
from True to False
rather than from False to True
and a Timing Diagram of how that works.
So let's give it an Input
called TOF_IN
and then I'll arrow down here
to give it a delay
of Datatype Time
and let's have an Initial value of T#5s
five seconds
and for this test I will not put anything on
the outputs
I'll just monitor it here
now for the TON Timer
let's call this Input TON_IN
and one a little trick here to copy a variable
you can hold down the control
I'm holding down control
and I'm clicking and dragging
and you can see I've generated a copy of that
line that up
sometimes that's useful
let me scroll down here
TP_IN
and you can also do a copy and paste.
Okay, now a Download Changes
Okay, so we can close the Resource Window
go to Debug Mode
and let's try to turn on this TOF Input
and what happens?
The Output is ON and
it's not counting the elapsed time
it's looking for, as we had mentioned,
the Falling Edge so let's turn this back OFF
and there it goes it's counting up
and the Output turns OFF after the elapsed time.
Now how about TON.
Let's turn our TON to True
and that once begins counting right away
and then the output turns ON
after the elapsed time
and how about TP?
Let's turn this one ON
So it first turns the output ON
and counts immediately
and then turns the output OFF
after the amount of Time
TP in the Help
says it creates a Pulse
so when we have the input go from False to True
a Pulse is created for the duration of
that Input so we're creating a a Pulse
for a certain amount of time.
Another test to do on this
is a Momentary Input
and so either you got to be real quick
on your Debug Mode
or else we could try toggle Boolean
I'll do toggle a boolean really quick
remember how to do this
you turn OFF Debug Mode
go to your Boolean Variables
and turn ON TB check box for each of these
and download the changes
okay close the Resource
and back here to Debug Mode
I now go to my Online Menu
and turn ON Toggle Boolean
and now with Toggle Boolean by the way it's not
showing up yellow because of the
Show Borders this blue
background is overwriting that
but it'll still work I'll click on it
that's ON
you can see if I click on it while it's running
it'll cancel it and do it again
then how about this one I'll
click this one real quick
I gotta hold it down
I'm holding it down
it's counting
I let go, it clears
so this one you got to hold down that input
and then here okay this one's already ON
you can turn it back OFF
otherwise if I want to make a positive Pulse
I'll need to real quick
turn OFF Toggle Boolean
start it OFF at a False
and then go back in to
Toggle Boolean values
now I can click real quick here, Pulse
and you can see I don't need
to leave that one ON
and it counts the time.
So I would like to implement this
with the TP timer
I'm sure the other Timers
could also be used with a
different approach
and I'll use the Timer Output
in the rung that opens G_GateOpen
and additionally the Sensor Input G Sensor
will be used
in parallel with that
and then in order to invert
the input so that I'm looking at the
sensor turning OFF
I'll change the properties
and negate the input.
So let's update our code now
with a Debug Mode OFF
and then in the Main POU
there's a way to insert space
you right-click Insert
either Columns or in this case Rows
Insert Rows a couple times
and then I'll put in my TP
and as the Input we have G_Sensor
and as the Output
we're calling it Timer and for PT
I'll use G_DelayTime
which we created in a previous video
and now to edit the ladder
you can click on the rung
and do Contact right
and then a parallel contact
this first contact will be G_Sensor
so I want the gate to open
as the cars come in
and then Timer
in parallel with that
so the idea here is
that when the sensor turns OFF
it could create a Pulse
for an additional amount
of time that would keep the Gate Open
for an additional amount of time passed
when the Sensor keeps it open
but to do that I need to look at
the Sensor turning OFF
and those several ways to do this
and I just would like to show that
if you double-click
on a block
you can go down to its properties
and it's possible to negate or hide
different inputs and outputs
so I would like to negate the in Input
and that puts this little circle on here
and what that means then is that it's
it's the same as if you would
have put a normally closed
contact if I would have put something like this
in front with G_Sensor
that would be the equivalent
another way to do this would be
to use the NOT
the NOT Function Block in front of it
but I wanted to do it using
the Negate Property.
So let's observe how this works
with Download Changes.
Okay, so now we'll go to Debug Mode
so we can check this out
and we'll start here in the Simulator
I'll open us up for business
and now I'll hit the Sensor
so we hit the Sensor, the car comes up,
the gate opens
and if I let go of the Sensor
I click it again
if the Run OFF the sensor
the gate stays open
for the elapsed time
I'm doing 2 seconds on this one
of course you could always change that
if I wanted T#5s like before
you can tab here to Overwrite
turn the Sensor ON
and the Sensor OFF
gate stays open
for five seconds
and then I'd mentioned that in the Help
an IEC 61131
that the area on Literals tells
how to format Time
here's some examples you can use milliseconds
minutes,
hours
so how about I'll try one of those
we could do delay time of T#1 second
400 milliseconds
basically 1.4 seconds you overwrite that
yep, puts it in there as 1.4
and now turn it ON
and turn it OFF
works fine.
Now in this section on Timers
let's finish OFF
with what I'm calling a Timer Sequencing
anytime you have a Function Block
that takes some time to execute
they can be sequenced together
in the way shown here
where one output just triggers the next
but there's a commonly used ladder logic
assembly called "seal-in" circuit
which I think it's also a good time to look at
using this R_TRIG rising edge trigger
so if we have an input called Start
and it has a rising edge it will create this
R_TRIG will create a Pulse
a one scan Pulse
and then as long as the active Input is ON
this Pulse created from the previous rung
will come down and energize
the sealed coil
which then in parallel here seals itself in
so it stays ON
so we start with
a rising edge just an input
that may be momentary
and we end up with a sealed ON
Boolean Variable
and then this sealed ON
can be used to have a maintained ON
Input and allow the sequence to complete
regardless of the state of the Start Input.
So as you give it that Start Input
it will complete the sequence.
So let's create that here together
in the Timer's POU
leaving Debug Mode, we'll go up to timers
and let's scroll down here and
put in
a ladder network
wanted to call this Variable Start
and then there's the R_TRIG
it's a Function Block again
because it takes place over several scans
R_TRIG rising edge trigger
and you can put that one
right on the ladder rung
we wanted to call this one Pulse
okay, moving down we can create another
network and we'll take now Pulse
and Contact right
for Active
these are the two Inputs here Start and Active
if you don't have Active
there's no way to deactivate
the whole sequence and start it over.
We got Sealed
and then here in parallel
we'll put again sealed
this is another way to enter, okay
alright next network
we'll take Sealed
and Timer1_done
I need to put on a TON Timer
there I see it
TON
I can stick it here on the rung
says TON_2
goes on just like that
we can use the same Delay here
if you want
Delay
and we'll make 3 of these in sequence
and it makes sense here to do a Copy
you can Copy this whole rung
with ctrl C
and then place your cursor down
ctrl V to paste
got a little extra there get rid of that
then you just update your Inputs
this was Timer1_done
and we wanted to have this be called
Timer2_done
however there's going to be an issue
and I wanted to show this on purpose
when you Make after a paste like this
let's see what happens.
We have an error
it says here's 6 errors and 2 warnings
Function Block corresponding to TON3
not found
Function Block not found, not found
says it can't find the inputs to this block
and that's at first seems like
kind of a strange error
but if you look here at the Timers
V the Variables for Timers
and for ease let's just to sort by name
by double-clicking the column
you can see that I have a TON1
and a TON2
but it's complaining that there
is no TON3
you see what happens is when you paste a block
it doesn't paste the what they call the Instance
so all you need to do
is click on it and click OK
after you paste
it's kind of like the confirmation
that you truly did want to paste it
and then here in Timers V
and now we do have TON3.
So that very simple step is important
and a Make now will be successful
with zero errors.
Okay, so I'll paste one more time here
and update this here
this was Timer1
I'll scroll down here with my mouse
click wheel down to number two
Timer2
and this one was called last Timer_done
and then don't forget to double-click
on TON4
click OK
if you want to, you can check the variables
okay the instance there of it
and we'll Download changes
and now let's test it out
we'll close the Resource
Open the Debug
and I'll adjust my window here
first I'll activate
and then I can turn on the
Start Input
and I can even turn it back OFF
because it's momentary
see already here, the Sealed Circuits sealed in
and it's going down through here
and doing all of these Timers in Sequence
so this method applies to
any type of Sequence
looking ahead here to Motion programming
these could be for example
steps to a Homing Sequence
or steps to any type of Move Sequence
when you're starting off with a Input
to trigger that whole Sequence
and all you really want from that Input is
a rising edge
just some type of trigger to get the
whole Sequence going without
requiring that Input to stay ON.
So thank you
that's it for Timers and Sequencing.