Practice English Speaking&Listening with: 4.6 User Libraries (IEC 61131-3 Basics with MotionWorks IEC)

Normal
(0)
Difficulty: 0

Yaskawa

eLearning

You are watching the IEC 61131 Basics

Video Tutorial Series

This video shows how to work with User Libraries

Hi, I'm Matt Pelletier

and you know probably the

greatest advantage of the IEC 161131-3 Specification

is that it is designed with reusable code in mind

POUs and Data Types that have been designed in

one project can easily be imported into another

these projects are referred to

as User Libraries

and in this video we'll show how to

both create and incorporate them.

I'd like to begin with an overview of the process

of inserting a Library into your project

basically what it comes down to is you have

your project with a Libraries Folder

and you right-click Insert > User Library

this User Library is nothing more than another project

after you Insert that Library,

the data that you get from that project

basically are all of the Functions and Function Blocks

and even Program POUs from that project

you also get the Data Types

what you don't get is the Global Variables

or any hardware-based Variables

then for organization, any imported library

will appear in your Edit Wizard under a New Group

with the name of that library

and it's a good idea to keep version numbers

in those libraries just for a good housekeeping.

So that was real quick I'd like to now is show this

and you could go through and follow along with me

and do this as well it's a best way to learn

and let's say that we're done with this project

and we'll do a final Make

we can then go into Make a New Project

and let's start with the PLC to simulate a template

like we did before

and the basic concept here is that I could

Insert a User Library which my project was called PQS1

now it will automatically look in the Libraries folder

there is a default that can be changed

but I'll have to navigate to

the location of my project

if I want to use it as a Library

and by default that will be up

one level in the Projects folder

and I have created a subfolder for myself

and there it is, PQS1 I can include this and

now this new untitled Project includes this Library

and I can open up the POU from this new project

and here in the Edit wizard

I'll have this area called PQS1 and there

you can see I can pull in the same

Blinker, Force and Temperature

my Functions and Function Blocks

are all here and they can be used again

and the good thing is too that they

can't really be changed

I can double-click to Open them I can see the code

but I wouldn't be able to

to change them because it's in a different project

it's in my other project

so you have some level there of safety

against editing

this project, this Library Project

when you didn't really intend to.

Now this is also a good time

to look at these tabs

that are part of the Project Tree

and if you were to widen this

you'll see that one of these tabs is for Libraries

you can see the detail of any of the libraries

that you've entered

and here I can see

that I've have as I said that

Data Types and Logical POUs

so any of my Data Types from the other

project are included here and also any

of the Logical POUs

the POUs include more than just the Functions

and Function Block they include all

of the Program POUs as well

and so here you can see why it's important

in your project not to use

common words because

for example Main here from the Logical POU

I would not be able to reuse

because I have a Logical POU called Main already

in my Main project I could rename this one

but the names are important

and so that's why we've been pretty strict

about prefixing everything with YTTS.

So while this is the basic way of

inserting and using a library

so this what I just showed you is the main idea

of User Libraries, it's Inserting a Project

and then in the Libraries tab you see

what you have you can use the Function Blocks

and you can even Insert Instances

Program Instances from that library

we could reuse IPCSim and

a QPSim like we had in our other project.

And so the rest of this video is going

to be about the best practice of how to

do this in a controlled and logical way

so that you don't just have a big jumble

of projects being used by each other

we've found from experience

that doing a few steps will really help

clean it up and keep everything organized

and so to outline some of these practices

we do have in our Quick Reference Guide

which is available at Yaskawa.com

we have a few steps here on

how to best Create a Library

and I'll outline those steps here

the first step would be to Save it

in the Libraries folder

and give it a library sounding type of name

the second step would be to clean up

and re-Make the project with that new name

and then finally Save your project

as a ZIP, it creates a .zwt file

and this is a single file Portable Project

that can be easily stored on a network drive

or shared with others

and then you have a reference place to go back

in case you unintentionally make any changes

to the unzipped version.

So here's an outline of some of the things

that you should do.

Number one is call it with something

with the name Library, we'd recommend

Yaskawa uses the term Toolbox

to market our libraries

and we'd recommend you put the version number

somewhere in that name of that project

we recommend you prefix all the

Data Types we've been good about that

we also recommend you prefix all of the

POUs that you plan to keep

and finally we found that it's usually not

the Program POUs that are of interest

to the Library but rather the

Functions and Function Blocks

so you'd like to have a minimum

of POUs required in order for the project to compile

probably INIT POU and some

type of we call it Palette POU

where you can put each Block in

so that it compiles

and then have a very minimum

number of Tasks and Instances within that Task.

So again, follow along with me

as we attempt to build our first Library Project

so that we can have access to these

three Function Blocks that exist in our Project.

So first we'll go to File

and go back here to our project

I'd called the PQS1

I'm not going to save the UNTITLED project

I don't need that that was just a temporary

and step number one was to Save

under a new name in the Libraries folder.

So we will do Save Project As

and then we'll go up

to the Libraries folder

and I will call it IECbasicsLibrary_V001

version control is very important

and that new project name

and the path of that project

is also shown here in the Project Tree window.

So now the idea is that I'm not thinking of this project

as an application solution for a

a parking gate anymore

I'm thinking of it as a library of Functions

and Function Blocks

that I can use for future applications

perhaps parking gates or perhaps other

and so I'll keep the Blinker

I'll keep this Force and Temperature

but I don't really need to have Timers

I can delete that one

I don't need this Task here

called Lowest Priority I don't need INIT

I really don't need any of these here

I think I can select several of them

and I'll just delete them

however now you can see that I've tasks in my list

for which there are no Logical POUs

so I'll need to start

deleting some of these

remember be sure that that Resource is Closed

not minimized but Closed

and I think I'll delete everything but Fast

and all of the Instances

and now if the code would compile

like this I could leave it

but it says I'm missing a Program Instance

so you have to have one Program POU

so I will insert one

call it YTTS_Palette

as a Ladder Diagram

and then in this Palette

we typically put in

each of the Function Blocks

just to be sure they compile

so Blinker

put in some test Variables

Force, so I think I'll leave EN/ENO alone

we can accept these default names

and there's Temperature

and none of the Global Variables will be used

so we don't really care about these

there's not any reason to remove them

they will not be imported

and let's see if this is enough to Make

Oops, we didn't do the Instance yet so

so the Fast should Insert a Program Instance

of YTTS_Palette

and now we can Make it

so I have an error let's go to see the error

it says Invalid data type 'BOOL'

let's see I guess this V004 turned out to be BOOL

we needed LREAL

okay missed that I guess

still have zero errors and two warnings

it is a good idea to get rid of any of the warnings

because you'll see those warnings

in any of the projects.

So anything about

Instance is never used

let's get rid of that

zero errors, zero warnings you know I

even like to do a Rebuild Project

that sometimes shakes out a few other

errors and warnings that may have

been accepted.

Alright, Rebuild even gave me zero errors,

zero warnings

so I believe that I've prepared this project

now properly

I have only one Program POU

I have my Function in Function Blocks

each of them are tested here in this

Palette, I have Compiled

I have one task only

and I've gotten rid of everything else that is

not part of what I'm expecting in this Library.

Now it's time to Zip the Libraries

I'll just have to do Save As Zip

my next step is to Zip the library

and when I do that

there will be some options

and one of them is to Zip User Libraries

and another one is to Zip Frontend Code

this is important so that you don't have to

Recompile the Library

it takes the result of my last build there

that Make and includes that and it's also

a good idea to Zip the Firmware Libraries

and the User Libraries

anything that you may have added to the project

and it will see that in ours

we don't have anything there

so that won't apply for our case

there's also an Option called Page Layouts

but that is not used

so let's do a Zip here

File > Save Project As >Zip Project As

we're in our Libraries folder

I will change it to Zipped Project File

and I don't have any any User or Firmware Libraries

but if I did it doesn't hurt

to check these boxes anyway.

So we'll Zip it now and we now have officially

we're going to be officially making Version 001

Alright, let me just show you where

they put that in Windows Explorer

it's not a Windows library, it'll be under C

this is Windows 7 here

C > Users > Public > Public Documents

and you'll see MotionWorks IEC Pro Libraries

so I have some other libraries that I've

downloaded from Yaskawa are also in here

but here's ours IECbasicsLibrary_V001

and this is the MotionWorks IEC2 project

the .zwt

you can see that icon Zwt version

a little compression icon there

this is the zipped portable all-in-one project

the unzipped version

is also called IECbasicsLibrary

but that's just a 4k file which has all of

its data here within this folder

and the many subfolders and pieces of

information that are there

this is the working project

and then the Zip project

one level up

wraps that into one

and by the way

you always want to use MotionWorks IEC

to make Zips and to Unzip them

never try to use WinZip

or WinRAR they that will not

reconstruct directory structure appropriately.

So now this Zip library

can be ported over to another computer

maybe it's like a computer that does not have

this IECbasicsLibrary and so to

simulate that I will delete this confidently.

So now I no longer have this

maybe I shouldn't have done that with

the project open but I'll just do a

close this project

and let's check that again

so I don't have a IEC Basics

I'll delete it again

and so now if this was a new computer

and a different computer

you could send that Zip file to somebody

they could put it into their Libraries folder

and then you could go here

to Open Unzip Project

get that Library

and Unzip it

and it asks you do you want to

Unzip the project to the folder

containing the .zwt file

well in my case, that is the the Libraries folder

so I would click Yes

if you had the. zwt file on your desktop

I would answer No

in any case, you can always answer No

and then find the folder that you want to Unzip to

and that would be the Libraries folder.

You Save it, that Unzips it

and now here I'm looking at the restored unzipped

IECbasicLibrary.V001

now what I always tell people to do is when

you look at this Unzipped version

take a little note of what the Data Types are

of this library

because that'll be important in the next step here

YTTS_CustomTypes and PLCTaskingInfoType

and so this is a library you really

don't need to change it or remake it

what we want to do is to use this

library in another project.

so let's make a New Project again

the PLC Simulator in this case

so now I have a new Untitled Project

and we'd like to start with

those three Function Blocks so we'll insert a

User Library

now it looks right in the Libraries folder

and I see it here

IECbasicsLibrary let's include it

and your first step might be to say okay

I've got a New Project here I've got a Library

let's be sure that I can Make this

and it seems that almost instantly

it says there are 10 errors and zero warnings

this is a little gotcha here because

there are these Data Types

defined more than once

you see what happens when you do

File > New Project and

you choose one of the Templates

the Template gives you some default Data Types

and some POUs and some hardware

it's usually to your advantage but in

the case of a library that already

includes those Data Types

it's a double definition

and so you can look in the library

and look at the Data Types

that are in it

and if the Data Type worksheet already exists

in the library you don't

need to have it again in your project

and so you can delete it

and this is all you need to do now in order to Make

successfully your project

and so my empty project now has compiled

with the library in it

and finally I'd like to demonstrate what happens

when you use a library to make another library.

So let's say that I'm using this project

Untitled, and I want to

use it to create yet another library

first of all I would ask you why not instead include

these new Blocks in the IECbasicsLibrary

if you can that would be better

not to have so many levels but

perhaps you have a library that is based on the

IEC Basics but goes beyond it

and just to show an example here I'll create a

Function Block

and this will be something very simple

YTTS_CustomBlock

and in the interest of time this one will have a

very easy Function is this going to take an Input

and I'm going to move it to a CustomOutput

you can do this, this means move one into the other

I'll Compile this sheet

I'll Rename this to YTTS_CustomPalette

and maybe I added other Functions and

Function Blocks the concept that I'm demonstrating

will be the same

so that I can Insert a YTTS_CustomBlock

into here, just to show that it works

Okay, so I have a library within a library

and to make it interesting and I could even put in

another Data Type

and also being careful not to use the same name

as the the Library Data Type name

and I'll even quickly make a simple Array

maybe I'll make an Array of 9 LREALS

and now let's Save this Project As a Library project

IECbasics and I'll use this word Custom

IECustomLibraryVersion001

okay it wants to Save everything

it is important to Make or Build after

you change a name

so I'll do Rebuild Project got an error

what's this...got a leftover

and so now I have one Library Project

that uses another Library and I have Data Types

in this Custom Library Project

my next step then would be to create a Zip

go down here to Zip the project

and here's where it makes sense to check the box

for a User Libraries

it means I would like to include this library

so Zip it

now back to the Libraries folder here in Windows

I've got IECbasics unzipped

IECustom Library unzipped

I've got that Zip here

so let's say that I want to close this project

I'll do it right this time

and I'm gonna delete everything of my

libraries let's say that we have sent only

the IECustomLibrary

from one computer to another

so the unzipped folder

the MWT Project

and even that original IECbasicsLibrary

I can confidently delete

and all I have now is IECustomLibrary

and it has the other of the first library in it

so let's see how this works here

I'll do a New Project

so let's see how this works now

the first step would be to Open that Library Project

assuming that somebody had sent this to me

IECustomLibrary Unzip it

this time also say yes Unzip to that Library folder

good idea to keep those .zwts

also a copy of them in the in the Library folder

and now here we see we

have that CustomLibraryV001

and we see the dependent library.

Very good, let me show you also what

happens here in Windows.

Do you notice that it gave me back IECbasicsLibrary

as well as IECustomLibrary

so those two that I deleted now reappeared

when I unzipped the library that included

that CustomLibrary

but now here's the here's the catch

if we go to a New Project

and I'll have to do two library inserts

the first one

can be the one that I that I wanted

the CustomLibrary

that's the second one that I created

that includes IECbasicsLibrary

but notice it doesn't automatically pull

in that other library

you might think that it's hidden in there somewhere

but it's not

so it's up to you to do a Manual Insert

you can right-click on that library

itself to include its User Library

called IECbasicLibrary

and now we have IECbasics and IECustomLibrary

CustomLibrary uses BasicsLibrary

when you have one project that uses

another project as the library

when you create a new project

you'll need to use all of the libraries

and they're dependent libraries

and that was that my point of showing this

is there's two inserts required in order to Make

of course, if I Make now I'll have these

same ten errors from the Data Types

of the Template

which I can delete

Make now gives me zero errors

and you'll see that in one of the POUs

the Edit wizard now has a group

for each of the libraries

the CustomLibrary and the

BasicLibrary and I can use these again

as I would use any other Function Block.

So I hope I seen these little demonstrations

here that you can be

convinced of the the power

and the flexibility and the way that you could

really start to create your own

Functions and Function Blocks for your

type of application

and then reuse them

and in this way have a very rapid

deployment of any machines that you create

in the special area that you're in

if you can use different libraries

at different levels of application even

things like your Help here

will make their way through the libraries.

I think a good conclusion would be to

show Yaskawa's libraries

these can be found by going to yaskawa.com/iectb

we use the term TB Toolbox

is our marketing term for the User Libraries

that Yaskawa has created

and you can see we have a whole host of

User Libraries for both the

Pro and the Express versions

for example one of the most common ones

might be a PLCopen

you can download them

and there's that .zwt file

along with the version number

but we've even made it easier

we've wrapped a lot of these into an Installer

and if you Download and Run this Installer

as you would any software installation

it will give you all of those libraries

like the ones that you see here

Cam_Toolbox all these that say Toolbox

are from the Toolbox Installer

and of course they have to do with Motion

since Yaskawa products are Motion Controllers

but in any case, we have these Libraries

available for free

to all who use MotionWorks IEC

they are also well documented

with the Toolbox manual and

the Installer here

which I showed the Download page

that has the advantage of installing the Help

in such a way that we can right-click on it

I'll show this here as User Library

and so here I did not show the steps

in the interest of time

but I have now PLCopen_Toolbox_v203

and you could use any of these

and you can use any of these Blocks here

and right-click on them for Help

and brings up a beautiful Help

that shows exactly how to use

the Inputs and Outputs.

So I leave you with this idea

and to let you know that there are

also videos on PLCopen_Toolbox

and Cam_Toolbox

where we highlight some of the Blocks

and explained a few examples really

quickly how to use them

and finally where to go from here and your training

you might try Yaskawa Toolbox videos

and you'll see that we have quite a few

webinars and videos

on the PLCopenToolbox

many videos on YouTube and in our website.

So with this we conclude User Libraries.

We hope that this has been useful to you

and worth your time and effort

thank you for your attention.

The Description of 4.6 User Libraries (IEC 61131-3 Basics with MotionWorks IEC)