Practice English Speaking&Listening with: 2.4 Using I/O Part 1 (IEC 61131-3 Basics with MotionWorks IEC)

Difficulty: 0



You're watching the IEC 61131 Basic Series

this video tutorial shows how to implement

hardware inputs and outputs in IEC 61131

Hi I'm Matt Pelletier

and we're going to continue with that

parking gate control example

by simulating an input and an output to the PLC.

We will look at I/O Modules, Addressing

implementing Best Practice

and going so far as to examine the

Execution Sequence of the I/O

and a configuration of Task Assignment.

So let's look at our project here and see what we have

we have this simple counter

with the GateOpen coil

and we're able to use this in Debug Mode

we can use the sensor here built-in

and it counts up the number of cars

as if there were cars coming in

but the way this works right now

it's not using any real inputs or outputs

we do have the ability to

simulate real inputs and outputs

to this input Module Hardware Input Module

in the simulator

and this Hardware Output Module

in the simulator we're able to click on these

and turn them on

so the idea here is wouldn't it be more realistic

to assume that there is a sensor wired to Input 0

to sense the cars and that there is a relay

wired to Output 0 to lift and lower the gate

and that's exactly what is being illustrated here

we have a sensor of some kind which

in reality is just the same as a switch

a physical circuit is

wired into an input module

and then the output module is wired to

some type of relay

which raises and lowers the gate

and so the question then

how can the PLC interface with these devices

and more importantly, what do you

as a programmer have to do and have to understand

in order for these devices to work properly.

and so that brings us to the I/O Module Concept

which we be illustrating here let's look first at

the input side so you see how the

Digital Input Module represented in the simulator

by this piece is really just a

way for a simple circuit - a simple switch

to turn on and off in optically isolated

input inside this module

and this is the interface into the PLC

and the PLC the

processor will see an Input Variable

and we'll see that that is indicated by the

syntax % I, followed by a specific address

and recall that the hardware

address and then likewise the processor

is able to control these Output

Variables which are given by % Q

and those Output Variables control the

real-world Output Module

which in turn causes a flow of electric current

in this case to energize a relay

that could be used to raise or lower the gate.

And so without getting into any

more of the specifics, I will just tell you

that this Input 0 is already configured

in the system as address % I for input

an X0.0

and all you have to do to turn a variable into

an Input Variable, basically to make that tie between

a physical input and a variable is to give

it an address in the Address column

and so we can do that with our input called

sensor give it an address in the address column

and then we'll be able to turn

that sensor on and off with the physical input

and we'll explain later why IX0.0

where does that number

and this letter X come from?

well that explanation will be coming up next

but let's implement this first

so back in our program let's

be sure to leave Debug Mode

and we're editing our MainV, Variable List

so open the Variable List

and just you guys can see this a little better here

I'm going to zoom in

and we're locating the variable

called Sensor

and we're going to give it that address as %IX0.0

X means bit, by the way.

So with this simple change

you can Download Changes

remember that Download Changes does the Save

it's doing a Make

and it will download as long as the

Make is successful

there we go, there's the download

okay now we're running

and close the Resource

go to Debug Mode

just to test this out

activate your PLC simulator

and then if you click on 0

Input 0 you see that sensor goes to True

or to False

and then even back here in Main

you can see the effect of that

Sensor goes to True

car came in, car rolls off

ready for the next car it's counting up

and since we'll be using this sensor now

you may even want to adjust this window

and while that does chew up

some of the real estate here

it does give you easy access to see this

Simulator which otherwise will

continue to be lost

behind the application itself

and so as promised, I said that I would

tell you where that address comes from

and it comes from the I/O configuration

just double-click to open that

and you'll see that there are Inputs and

Outputs and a range

IO configuration is in the project tree

at the bottom

and you can see this here

there's a tab for Inputs User-defined Input

it says %IB0

not an X but you get the idea

% IB0 means a byte 0 and then the

output also %QB0

they use Q for Outputs

so as not to confuse with the letter O

or the number 0

so this I/O configuration is what

determines where a particular input

or output module is used

in the memory

location of that particular PLC

and with Yaskawa products you don't typically

need to change this

but it can be useful to look at it

in order to confirm I/O addresses.

So we can cancel out of this

and now that we've seen a little bit of

I/O addresses in action in our code

I'd like to formally present the IEC 61131

byte level addressing

the first two characters are the

percent and a letter

and that's called the Location Prefix

you'll typically see %I for an input

%Q for output as I mentioned

and you may also see %M meaning

just a memory location

not particularly related to

physical inputs or outputs.

The next part of the address is the

data size where X means a Bit

B means a Byte

W means a Word (16 bits)

D for Double (32 bits)

and L for Long (64 bits)

so while the numbering scheme

coming up next here

is numbering the number of

bytes you can have a data size

that uses several bytes.

So the number here is the

memory address in bytes

specifically for the location

that's been given

so just as we saw that we had %I0

we can also have %Q byte number 0

and those are not the same memory location

those are these locations are

completely separate

the memory is separate and

the addressing starts over

at 0 in each of these locations

and the maximum is just whatever

the maximum is supported

by that particular PLC.

Now this last piece which is

the dot and any number up to

from 0 to 7

is only valid you'll only see this

if you've used data size Bit

because what you're saying here

is which particular Bit

of this Byte is being used

so for Byte, %IB0

but Byte has 8 Bits

you have Bit .0 through .7

and that is what we are seeing

in this PLC simulator

we're seeing that there are 8 Inputs

and 8 Outputs

the 8 inputs exist as a Byte

it's Byte 0 and the 8 Outputs

also exist as a Byte.

With this explanation now

I would like to challenge you

to complete this quick quiz

and the challenge is to

tell me what is the address required

if you want to have this sensor

here on Input 4

we want Input 4 of the module

to run the sensor

and you want output

number 6 to be the output wired

to the relay to make the gate open.

So question number 1 is a Sensor,

question number two is the Output

so if you need a minute to think about it

why don't you pause the video

and the answer is that you will use

the address %IX0.4

for the Input Sensor

use Input number 4

and you'll use %QX0.6

for the Output.

So let's see we can make that work.

Go ahead and make it work again

I recommend you pause the video and after

this then I will show how it's done

so to use Input 4 and Output 6 we'll go to

the Main Variables worksheet here

and the sensor variable I can just change

this here to I%IX0.4

and the Output was called

Gate Open

and so back here to

the Main Variable Gate Open

will be %QX0.6, if I wanted arbitrarily Output 6.

Let's download those changes

now closing the Resource

going to Debug Mode

you can see in the Main POU

that Output 6 is ON

the gate is open since the parking lot

is not full

and we can use Input number 4

to turn on the Sensor and turn it ON

and OFF and simulate cars passing

over the Sensor being counted into the counter.

And now for this next activity

called using I/O as a Byte

I would like us to create

an Input Variable that contains

all of the 8 Inputs

and another Input Variable

that contains all of the 8 outputs

and also for this activity

we're specifying that you should create

these variables in the Global Variables List

and we'll be able to play with that

look at that in Debug Mode

and learn a few other things

so if you think you know what to do

again just pause the video

and see if you can work through these

and I will also show how they're done.

OK, first I will create the Variable DI_PcSim

for the digital Input Bytes

I'll leave Debug Mode and I'm going to

make these as a Global Variable

so go to the Global Variables List

in Global Variables

the secret here is to right-click

anywhere and you can do

Append or Insert Variable

Append puts it at the bottom

and we're going to call it D_PcSim

first is the Data Type

we wanted it as a Byte

so we'll type in BY, Byte

let's skip ahead to the address

and the address is %I for Inputs

and now don't type in X like you may

have done before using B for Byte

we're doing the whole Byte

and 0

its Byte 0, no dot at the end

if it's a Byte, only for Bits with the X indicator

and then likewise for DO.

We'll do a Append Variable

and we'll create DO_PcSim

also as a Byte.

I'm just using tab here

to tab to the different fields

and now %Q for Output

B for Byte 0.

So let's download changes

to put those into our system

and once again close Resource go to Debug

and you can see it puts this

online value column

see it's given here it says DIPcSim

is 16#10 and this one 16#40

what do you think the 16# means?

Well why don't we go to the Help

on IEC 6113

Search for 16# and you can read

through these you'd get to

Literals in IEC61131

Base 16 Literals

are given with the prefix 16# so

it's hexadecimal numbering system


so it says we're seeing hexadecimal 1 0

and you may even want to see these in binary

that's also possible

the area you need to go to in the Variable List

is this grey row header area

if you double-click here you can get this

Debug Resource window up again

and over at the right

you have the Valuedisplay Standard

what just adjusts the display based on the data

itself, but you can force all of the data

to be binary

and then hit Close

and now we can see the

Bits of each of these

Bit 6 and Bit 4

looks a lot like that

And then also we had wanted to

overwrite the Outputs in Debug Mode

and that would be here DO

you can double-click on this row header again

you can put in a value it can be

in any format

if you want to put let's say five

you can override it

and then five converts to binary

you can see here

and you could also type in this

hexadecimal format


put in letters such as A, B

or letters or numbers,

the hexadecimal numbering system

we're assuming you're familiar with, I guess

and overwrite that

the hexadecimal numbering system

could test all the outputs

with 16# FF

there they all are

I'll turn them all off here with zero

and I will put it back to the Standard Valuedisplay

and so that's a little diversion of looking at

all of your Inputs and all of your Outputs

in one variable, you can see that we still have

our MainV where we look at a specific Bit

as a separate variable and so this

is not any type of conflict you can have

different variables using the

same memory areas

but you do have to be careful with that

so if we take this concept then

into the real world,

a PLC will have many modules

and just as a plug here for Yaskawa

and the MPiec Controllers

in case you're wondering how this works

is the MPiec has

different types of modules

and different types of Inputs

some of them are

EtherNet/IP Adapter, Modbus Slave

and those have a certain memory area

assigned to them

EtherNet/IP and Modbus devices

have another range of memory

anything operating over MECHATROLINK

has yet another range of memory

and then any of the local inputs

meaning slots right on the devices itself

would have this this a higher memory Input range

and likewise for the Outputs

there's a matching memory range

and to make managing all this memory a bit easier

you can rest assured that MotionWorks IEC

controls the addresses and creates

many of these variables automatically

for MPiec controllers.

At this point we're going to break

to end Part 1 of using I/O

so please continue with the next video

which covers the second half of this section.

The Description of 2.4 Using I/O Part 1 (IEC 61131-3 Basics with MotionWorks IEC)