Move, Fill Move and Block Move Instructions: Internal

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

34.

Move, Fill Move and Block Move


Instructions

In this video we will understand the MOV operations in S7 1200 PLC. So we have various MOV
operations, a typical of those are MOV that is a simple MOV operation and he has MOV_BLK if we want
to move a block of information, not just one information then you have SWAP to swap the information
between two inputs okay. So let's see how this move operation works in PLC. So we'll start with a basic
MOV instruction it says the MOV instruction copies the data, a single data okay single data element from
source specified by input to the destination specified by the output okay. So, if you see this MOV block
we have this input. This is my source and this is the output and this is my destination and we have EN
block. So, this move block will be enabled when you have a pulse at the input or when you have the
signal at the input. Now what we have in the input, we have mentioned MW10 which is a data register
word in which the value is 124 and this is the output MW12 which is zero as of now because this is not
enabled. So once you enable this by giving a signal to M0.0. This will copy the value from this input to
the output pretty easy okay. So this input is copied, it will not cut and paste it will be copy and move to
here okay. So the value will remain in the input. And now this star sign (*) indicates that you can move
the input to multiple outputs. So you can add more outputs here and you can move, you can move
single output to all these outputs. Okay, so you can move multiple, you can move single information to
multiple outputs, if you put more outputs here so that is the facility we have in this MOV block. Okay, so
this is a sample MOV instruction. emember it only copy single data. Okay, so if you want to copy
multiple data for that we have MOV_BLK instruction, okay. And to copy multiple data we have a
parameter COUNT, it says the count specify how many data elements are copied, okay, so if you are
wondering how you will specify the count in data.. in data register let say MW10. So in that case, we will
not take MW10 or MB0 or any other data type. In that case, we will take an array okay, we will define an
array and we will select which block of array you want to move. So let's take an example, this is a move
block instruction we have an input array here which is specified by "Block_1" array, underscore 1 and
three so this is the index of array three and that's the COUNT okay. So this is the COUNT how many data
you want to copy, it specify 5, so 4 data starting from 3 index, so it will be 3,4,5,6,7 that will be copied to
your output array, another array with starting index is 5. Okay, so let's see a figure which will explain
what is happening here. So if this is enabled, what will happen the value starting from array 3, this value
this value and how many values 5, so this is 1,2,3,4,5 this value will be copied to "Block_2.Array_2", this
is my array 2 starting from index 5, starting from here, up to 5. So you see this value 3,4,5,6,7 is copied
here. And these are the other values of my index, and this is another value. Okay, so if you want to copy
the value starting from here, up to here up to 7, you will specify 0 here and he will make count as 7.
Okay, if you just want to copy these two values 0 and 1, he will specify 0 here and write count as 2 and
this this specify where you want to copy the value. Okay, so this specify the starting address. So if you
want to copy the first 2 values from here to the first 2 values to here, you will just write 0 here, 2, and
here's zero that will just copy two values from source arrray to destination array. Okay, I will show in in
an example how the values is is being copied. We'll see that in the exercise later on. So this was the
move block instruction okay. So next is Fill block instruction. The Fill block instruction is very easy similar
to move block instruction, but in this case, we are only filling the value with a constant or with any input.
Okay.

So for example, if you see this Fill block, we have an input value which I took as a constant 45, I have a
count 5 and then I have a output array. So what will happen If I execute this instruction, this will copy 45

Internal
in 5 blocks, starting from the array index 2. So starting from here, you can see this is true. this is to move
the value 45, up to 5 indexes up to 6, from 2 to 6, this will move, this is 1,2,3,4,5 because the count is 5.
Okay, so this is Fill instruction, if you just want to fill a constant value to 5 array blocks, you can use fill
instruction, okay. Now next we have SWAP instruction. Now swap its meaning is if you want to
interchange the value, it says the the you can use a swap instruction to change the order of bytes in an
input and query the result in the output, the following figure shows how do how does this how this
operates. So let's take an example. We have a data register, assume we have this value in a data
register, starting with,.... this is 32 bits. Okay, if you execute swap instruction in this data block, what will
happen? It's its individual bytes will be interchanged. So if you notice this 4 comes here, 3 comes here,
this 2 comes here and 1 comes here. That's how it interchange the value using a swap instruction. Okay,
so let's see an example of swap. So it says swap the value of MW0 and store it into MW10. Okay, so this
is my swap block. This is my enable, we have enabled almost in every block. So that's my input MW0, in
which I have the address, I have the value 7FBA in hexadecimal. Okay, and my output is MW10, which is
initially 0. So what will happen if I execute swap my executing swap, you will notice this BA, so this last,
this, this 16 bit value comes here. And this 16 bit value comes here, this get interchange, okay, that's
how swap works. So, if you see this is the value here. Now I have breakdown this value into binary. So
the 7 is 0111, F is 1111, B is 1011, A is 1010. So this is MW0 before swapping. So once once we swap
that the output of MW this is this is 10, MW10. It goes B comes here. So this comes here, this A comes
here. So this F goes here and 7 goes here. So that's how swapping is done. Alright, so now it's time for
the exercise, it says make a ladder logic to continuously update the data from one block to another
block after every 10 seconds. So suppose you're doing a backup of data. And after every 10 seconds, you
want to move the data from source to some destination register, okay, and you're using that register to
evaluate something after every 10 seconds. So how to make a logic. In that case, we have to first define
a 10 second logic, we need a pulse here at Move block, we need a pulse, which will come after every 10
second, okay, we need a small pulse here, which will be on after every 10 seconds so that the Move
block will be enabled. We don't want continuously moving of data but we want for every 10 seconds.
This is just to make a little complex. So what we have done, we have used a timer logic to create pulse
after every 10 seconds. So what happens this is my timer block. This is an ON timer. And you might have
understand timer in my previous lectures. So here I have the PT at 10 seconds, my preset time, this is
the input and here I have an NC contact of the of its own timer. So what will happen, initially the timer is
off. Okay, when I start running this program, the timer is off. So this will pass the signal. So let me use
another pen. So this will pass the signal, timer is on. So it will start counting the time I will show you that
in the software. So once it goes to 10 seconds, this will be open. Because this is the timer output, this
get open so timer get reset. So once the timer get reset, this goes back to close and starts again. So after
every 10 seconds this open for a while, because the output is on for a while after every 10 second, and
we have used the same output here. So that's the same address here. So this will be on after every 10
seconds for a moment for a pulse. Okay, which will enable the move block, and which will copy the value
from "array_1" three index

5 blocks to "array_2" 5. Okay, that's the equal in FBD logic. So let's see that result in our software. So
that's the same logic I have made for you. So let me download this okay. If you are, if you want to know
how to create, how to create a block array okay. So let me explain you that I have already created 2,
create it 2 blocks, but I will create one more for the explanation because that part was not covered, I will
go to program block and I will go to add new block. Okay, once you go to add new block, you will find
this option. So we'll go to a data block, okay, and the data block you will find these various options, so

Internal
you don't have to do anything with that, we just give a name. In that case our let's give "Array_Default",
I'll give a name. Okay. So this is my array default. Now if you see my these blocks, here, I have an array
and here this is the data type of array which is byte, and array limit is 0 to 10, I have specified in my
previous blocks. So I will go here and I will add a new static, i can write "Array". And here I will define an
array of low to high type, click this one. And if you click here, again, you will define the data type which I
want byte and the limit of an array, which will take it as Okay, let's take it 10. Click ok. So I have an array
of 10. Now from 0 to 10. Okay, so that's how I have defined area here from 0 to 10. And another array
here. Okay, so this is the array, this is how you create an array. So let's move back to main block. So then
you have to just write your array here. Okay, so this is block 1, array 3. So if I want, I can show you again
how to write. So to write an array, you have to first define the which block we are using. So I will write
"blo" so you will find your blocks, okay, if I use array, I will find my array block which I made just now. So
I want to use block. So "Block_1" click once, then array, it will show you automatically click once again,
then it will show you which index you want to copy. So I want to copy the second one and select here.
So this is how you give the input to your array block. Okay, that's how you give the output array block as
well. So let's download this now and see what's happening, load. So it's loaded, I go to monitor. Okay, so
let's find what's going on in the timer first, if you see here, this is closed, and this is on. And after every
10 seconds it get reset, because after every 10 seconds, this get open for a while, this get reset, and it
gets close for close again. So it's so fast, you cannot notice that here, so it's getting reset by itself. And
similarly, we are getting a pulse here after every 10 seconds. You cannot visually see that because it's so
fast, but we are getting as per the logic. Right. Now let's monitor how the data is being copied. So for
monitoring, i will go to watch table. So this is my watch table where I can put my array values. So let's
say I am putting my array values starting from 1 because my copy is starting from 2, five elements up to
6... 2,3,4,5 up to 6, copy 2 to 5. Okay, from 5 to 9. If you notice this value 1, 56, 45, 100, and 34, this is 5
values. These five values are copied here. Okay, these five values are copied here. So for understanding
easily, I'm removing the other blocks so that you can understand. So let's move that as well. And here let
me put space, okay, so these five values are copied here starting from 2 to 6, 5 to 10, 5 to 9 actually not
10 Okay, so let me just change the value. And here I want to display my timer. So hold on second yeah.

I will put a timer. I want to display how the timer is running ET perfect. And here you can see the time.
Okay. So after every 5 seconds, you will see the values are being copied. So I'm going to change the
value now. I will put here 100, maybe 10, 34, 45 is fine, 42, 78 okay. Now for a moment, I'm going to
modify the value of my array, which I can do by writing the values in the "Modify value" column. And
then pressing this once modify all selected value once. And now, this will copy this value here. And these
values will be copied here after every 5 seconds after every 10 seconds, this is a 10 second timer. So I'm
going to copy now, so this value is copied here. Now we will notice when this goes to 10 seconds, this
will be automatically copied here. Eight, nine, and 10. So this is updated. So if this value got changed
later how, you know, maybe by some process, that will be updated automatically after 10 seconds.
Suppose this value changed, it changed here, and after every 10 seconds, this will be updated here. 9, 10
this is updated. So that's a basic example how you can update the value in your new block array for
every 10 second interval, you can change the time and you can make it 2 seconds, 1 second, or if you
don't put any time here, this will be automatically copied here. If you use a simple a bit, a button so this
is a condition, in which condition you want to copy the value. So this was just a basic example. So this
was all about the move instructions or what did we learn today, move instruction is used to copy the
data from source to destination. Move block is used to copy the data in blocks from source to
destination using array. Fill instruction is used to fill the destination block with source and swap

Internal
instruction is used to swap the data in data memory register. All right. If you have any doubt you can put
in a comment. Thank you for watching. You can get a copy of this presentation in the course. I will see
you in the next video.

Internal

You might also like