Yaskawa
eLearning
You're watching the IEC 61131 Basic Series
This is Programming QuickStart Part 1
Hi I'm Matt Pelletier and I hope
that you've got a good feel for our software
after following along in the last video.
Now in this video, we're going to create
a really simple program and go
through the fundamental process of
Make, Download, Debug,
creating Ladder rungs, Variables and
looking at some Variable Properties.
And what better way to learn these topics
then by means of a simple application
here from the beginning, very simple
we have a PLC and a sensor going
into one of the inputs and a parking gate
controlled by one of the outputs
and let's say that we want to program
this PLC to control a parking gate
and this will be our ongoing example as we
go through the training here.
The first step will be to create a brand new
project and work in the POU "Main"
to create a simple counter an UP Counter
as shown here in this presentation
and so I'll do that, we'll say goodbye
to this test program from before, and make a
new project - don't need to save the old one
stick with the PLC Simulator Template
don't need to save the old one
and we're in here, I think I'll save this
right away, save the project and I'll call it
Programming QuickStart number one
and Save.
So remember, the idea is to follow
along with me and do this on your own
and pause the video if you need to
in order to catch up or rewind it to see it again.
The first thing I'll do is go to Main
this is the POU that's part of the template,
might as well use it
and I wanted to put in a Counter Up
so here I see it right away in the Edit Wizard
dragging a Counter Up
accept the name and OK
talked about the error about that
in the previous video.
And now our task is to add variables to the input
and so I'm going to refer to the document here
the training document, by the way, a couple
notes throughout this whole document
I have put this little logo, the IEC logo
on all the pages that are specifically
related to the IEC 61131-3 specification
in order to teach this software we have to show
some things that are specific to Yaskawa
and our software and other things that are
more of a global application too.
So this is one of those times,
this counter is common to all software packages
and the proper variable properties a lot of
the things we're doing here are common to
any platform running IEC 61131
so we'll put a variable called Sensor
here at the Counter Up
some Boolean with Usage VAR
we'll get into more of that later.
The Reset Input we can also call the variable Reset
and this will be a counter counting
the cars coming in through this Sensor.
PV is the Preset Value
and we'll call that MaxCapacity
and recognize data type INT leave it
also as Usage VAR
Q is the output when it's counted
up to the max capacity
it will be full, let's call that Full
and CV is the Current Value
Current Value
Okay so we've entered that into
the Main POU
so this simple function block
is valid code and can run on a PLC
in this case, the PLC Simulator will be used
but the first step is to compile or Make
and I'll use this icon here called Make
You can see the status of Make in
the the build window here
wait for that to say that it's complete
you may find errors if you've typed,
made a mistake in your typing.
Okay it says zero errors, zero warnings
if you had any errors or warnings
you would look on the errors and warnings tab
and double click on those
errors and warnings to find the
offending area.
I don't have any.
The next step is to go to the Project Control
button, the Project Control button brings up
the Resource window,
the Resource means the PLC that you
are downloading to
and well click Download
and then Download again.
There's a lot of other options here
and we'll cover that at another time.
So click Download and Download
and this is the way that you
download the code to the controller for
the first time specifically or anytime
that the controller has nothing on it
you'll need to Make and Download
and then, run the code.
And so this page outlines that process
Make, Project Control,
Download and Download.
So you need to start the controller and there
are two ways to start
you can choose Cold or Warm.
For Yaskawa controllers,
Warm Start is the way that the PLC starts
when you power it up
and we'll give you again more details on this later
for now we're doing a quick way
to get going here
we'll click Warm Start
and when you hit Warm Start
it will run and you'll see this simulator run
light turn on, we haven't seen the simulator yet
the simulator you may see
is an application here running
it's called Demo Driver
and this is what's representing
the PLC and an Input and Output card
on that PLC
we need to Warm Start it
and Warm Start
that simulator went away
there it is
Warm Start runs the PLC
and so now this code is running
in this PLC.
So how can we see what's happening
as this code runs in the PLC?
The answer is...to use what's called Debug Mode
and this is a monitoring mode only
where you cannot make any more changes
to the code
but you can see displayed
the status of the function blocks.
All right, so Debug mode is this button here
Debug on/off
and now we see that Sensor is at zero, Resets at zero
MaxCapacity is zero
zero capacity Full is on
you can also close the resource box
as a good practice
we don't need to have that open.
So let's set the MaxCapacity to something
you just double-click on it and type in
in this case 20 perhaps overwrite with 20
and now we can also
simulate that the sensor has been
turned on by double-clicking on Sensor
and then here it shows that we
could overwrite that variable to true
and that counts up
and double-click it again
choose as false, you can Overwrite back to false
true, there it it counted number 2
false and so on,
you could reset it by turning Reset on
that resets it back to zero
a simple counter and this is the counter
of IEC 61131.
So let's move on with some more editing
by adding a Simple Ladder
using this ladder instruction
and we'll add a contact and a coil
and I'll show you how to do
what's called Download Changes.
So what's the first step if we want to edit now
we're in Online and Debug Mode
you're not able to edit a lot of
things would be grayed out
it's one of the first issues with new users
is they want to edit but they're in Debug Mode
so you remove Debug Mode
and let's put the crosshair down here
the cursor to where we would like
to have a Ladder Network
and here's the button called Ladder Network
again we get this warning and
there is the Ladder Network.
And to build on this example,
let's create a variable called OpenForBusiness
so if some variable that represents if the
parking lot is open
and this coil will be the coil that drives
the gate to be open or closed
and so we'll call this GateOpen
and additionally as shown on this page here
of the training guide, I would like
to know if the parking lot is not full
so I normally closed contact for the
Full variable and we're open for business
then the gate will be open
so it's like a simple ladder circuit here
let's build that, go to the OpenForBusiness coil
and there is a contact called
Contact right button here
and we can change it
using this Contact Type button
to be normally closed
and I'll open it and write Full
So now I've made some changes
and well I could once again go through
the process of Make and Download
and Warm Starting the controller again
I really don't have to do that there is a
time-saving button called
Download Changes right here.
Download Changes does a Make
and by the way every Make includes
a Save so you don't have to worry
about saving your project if you Make
it's also saved and you can see
that as I am doing this Download Changes
without clicking anything else it opened
up the Resource window and it downloaded
the the changed code and it just keeps
running, you don't have to Stop and Warm Start
so there's no Warm Start involved
with the download changes
and close that again
and I'll go back to Debug Mode to
check this out, it will save some time here
say my capacity is 5
and then I can go to the sensor
and overwrite this a few times to get that counter
let's just do this 5 times
alright I'm up to four this is it
alright the gate is not open anymore I'm
and should had OpenforBusiness ON also
here we go OpenforBusiness.
Let's say all the cars leave
I'll reset this counter
and the gates open we're OpenforBusiness
cars can come in
so a very simple application, but hope that you
guys are learning how to use the interface
and how to program in IEC 61131
with this example.
A question that comes up often
when you're programming is
How do I leave a comment?
So I'll just cover that right away
let's leave Debug Mode
you right-click where you want the comment
and you'll see it Text(comment)
and you type.
you click OK
This is a change to the code
even though logically there's no
change, it is a change to the to the code
and so if you wanted to run it you
should do another Download Changes
and there we have it.
As we've been programming
we've been adding many variables
and those variables are found
that can be seen in the MainV,
the Variable list
go ahead and open that and
and you'll see a list of the variables
and I'd like to point out a few useful
properties of these variables
every variable does have a data Type and its Usage
expect all those usages to be VAR at this point
well skipping ahead here, there is a
column called (I'll skip to the end here)
TB which means Toggle Boolean
and why don't you find the input called Sensor
and let's change that one to a Toggle Boolean
you'll see what that does.
It's pretty handy when you're using our software
and let's go to OpenforBusiness and we'll
mark that one as Retain.
So we can see what Retain does
and then MaxCapacity
type in a 20 for the initial value for that
and so we can see how the initial value works.
So I'll do that here, Debug OFF
go to the Main Variable list
you can adjust the width the columns here
so Sensor, I had said let's mark that one
as TB (Toggle Boolean)
OpenForBusiness
let's check that one as Retain
If you lose power to the PC
maybe doesn't mean you're closed
power to the PLC, I should say
and then for the initial value of MaxCapacity
there's a 20
different order, you can double click on the
the Name column here to alphabetize
that must be what I did for the screenshot there
and so to apply these changes to
the code we should do once again
a Download Changes
OK Download Changes is complete
I'll go to Debug Mode now
and the first one I'll demonstrate is this
Toggle Boolean
if you have a variable marked Toggle Boolean
and then go to the
online menu and turn on this feature
called Toggle Boolean Values
it will make the Boolean Variable
that's a True/False type a variable
in this case the Sensor was chosen
this variable will have the ability to be clicked on
and then by clicking on it, it will toggle
it from, in this case, as one to zero
whatever it was makes it the opposite
because I was expecting it to be a zero
of first and I think that's because
I had a Toggle Boolean ON when it was a
one so if I started here first
as a False and then turned Toggle Boolean
back on again and it's a zero
now as I click on it it will turn to one
when I click on it.
So this can be a very useful feature
turns your programming code
into a simple interface very useful for testing
so that's the Toggle Boolean property
turns a variable into a push button
right there in the code.
Now the other two was the Initial Value
and the Retained Value
and those have to do with
a Warm Start and a Cold Start
you can force a Cold Start or Warm Start
to simulate what will happen in the PLC
when you cycle power or when you load
the code at the first commissioning of the PLC
and so here in my code you can
see that I can test this out
you should go ahead and do this as well
until you're satisfied with
understanding what's happening
and we had marked what
we had marked OpenForBusiness
as a
as Retain and we had marked MaxCapacity
with initial value of 20
so keep our eye here on MaxCapacity and
OpenForBusiness and I can stop the PLC
and Warm Start it
and you'll see that the MaxCapacity variable
reverted to its initial value
from the five that I had typed in there before.
So then again Overwrite with a
five or any other number
and if you Stop and Warm Start
it reverts back to the initial value.
You could also Stop and Cold Start
and notice what Cold Start did
it applied the initial value to MaxCapacity but it
also applied the initial value to OpenForBusiness
it hadn't done that with the Warm Start
What's the difference? Well, remember
OpenForBusiness was marked Retain
and Retain means that it will survive a
Warm Start and retain whatever
value it it had previously.
So this is one of the main differences here
between Warm Start and Cold Start
is there's the ability to
retain some variables to survive power cycle
and that's the Retain check box
and then each variable also has its
initial value if you don't have an
initial value here the initial value is
assumed it to be 0 and 0 will be applied
or false when you do a Cold Start.
So go ahead and play around with this
and be sure you understand what's going on
with Warm Start, Cold Start and how
that relates to Retain and Initial Value
feel free to deviate a little bit beyond
what you see here
and so with this will conclude
Programming Quick Start Part 1
and we'll see you in
Programming Quick Start Part 2