Hello.
In this video we are going to learn Math, increment and decrement commands.
The left side you can see at command usage.
So in here S1 edited by S2 and the result is written to hear the output.
So in here in example you can see when the condition is 0 is high the zero plus the time the output
is say 2 or the result is saved or written into D 20.
If you want to use sub command so as one minus as to the result is written two in here in here also
you can see in on example when it's zero is activated or high.
So from the zero B 10 is subtracted down the result is written to the twenty fourth division command
from S1 and is 2.
You can write here just sixteen bit values so as one divided by S2 and the result is written to hear
the output.
So outputs and the input should be worth data type in here.
You can see an example x1 divided by S 2 and the result is written to the twenty four sixteen bit.
You can see here just one words are used and if the result is higher or if you want to work with their
high numbers.
So imagine you are working with the 32 bits number or over thirty two thousand seven hundred sixty seven.
So values for example you are working with the 1 million numbers a variable numbers.
So you need to use 32 bit division.
So in here what you write for example imagine S1 is D0 for division D0 and D1 is going to be used
and for the as 2 if you are dividing as 1 2 for example or by the 10 so the eleven is also going to
be used for the division and also for the output.
So in here you can see it as one and as one plus one as two as two plus 1 and the result is D and D
plus 1 for multiplication or multiply for the sixteen B unit use just one word and sixteen bit equals
word.
You remember previous lessons in here.
The 0 multiply by the 10 and the output or result is written into the twenty for the 32 bit multiply
or multiplication as 1 and as who is going to multiply or after multiplication the output or result
is written to here but like here we are not going to use just one word they will use S1 and as one plus
one as two as two plus 1 and D Day plus 1 because this is just sixteen bit but this is also sixteen
bit but totally thought it to be means uh to work.
So they will use 32 bit multiplication just two words and the next page we will see increment common.
So when the condition goes high each time this value is going to be upside plus 1 each time one will
be added to this value all the zeros value the increase by 1 1 0 goes from off to on each time.
And if these euro is 16 b we will use these values if these euro is 32 bit these values will be range
of our data register for decrement command we will go lower this time so each time these 0 minus 1 will
be the value will be mu minus or subtract by 1.
And when it 0 goes from off to on for example the 0 is 10 so x 0 is activated the 0 will be 9 and after
0 is activated again the 0 will be a.
And these applications and practices that we need to see.
So let's go ISPsof and create a new project and new project is created and programs come here and
right click a new a new program is opened and I will create a device monitor table also and lets say
Okay and let's go programs and let's do some examples.
Ld m0 and at D0 to D4 and in here one more network and LD M1.
and for the subtract sub d10 D12 and D14 I will do it like this.
And in here I will say LD M22 and let s do multiplication add D22 D24
and one more LD M3 and multiplication 32 bit that we are going to use now D32 and D34
ups this is not okay and let's take a look once two division LD 5 and division
D40 D42 D44 will be resolved and ld M6 division 32bit will be
D50 D52 and d54 and for the increment and decrement commands LD M7 and
increment D60 and for decrement command LD M8 and decrement D70 so let s go
online and let's do some practice is about our commands and learn them all effectively and how
can we can use them how we can monitor them.
Let's let's take a look them all.
First of all ADD command and I will just check our CPU is now run situation and I will open my
online edit button or activate my online Edit Also and I will change.
This will do is say 5.
Let's say this change present value to a.
I'm waiting.
The output should be 13 so set on the condition on and our output is 13 four subtract command from 20.
Let's subtract for example.
And 7 and I'm still waiting.
The output of this condition should be 13 set or so it is subtracted subtracted from the 10.
---
D 12 so 20 - 7 = 13 .
So multiplication let's say 5 multiply by for example 9
So output should be.
I'm waiting that 45 and is activated and 45 is our result.
So what about the 32 bit multiplication.
So let's change this value to for example 1000.
So let's change this value to 5000
So I'm waiting the output should be five million and set on.
So now let's take a look.
The output is 19264
But they are expecting the result should be 5 million.
Why.
Let's take a look.
Monitor table and let's come here and the identifiers.
I will take a look two registers.
Okay.
The 30 at 10 million.
So let's take a look.
One thousand.
Multiply by five thousand.
And the result is a 32 bit.
Imagine.
Let's look let's focus here.
5 million.
But we are saying it in the eyes piece of 19.
264.
So let's open.
Calculator and let's take a look once.
How can we get there reach five million value after thirty.
The 32 bit multiplication.
So now 2^16 bit
So we can we can get complete numbers and full numbers or maximum numbers for one word.
So this is the value of one word can get maximum value.
So how many or what is the value of these 35 or carry value of our multiplication.
So this is 76, multiplied by 76
And what we have in these 34 the rest of all value 19264 +
sorry ---
This is my mistake again and multiply by 76 2^16
multiply by 76 equals and + 19264
equals five million.
So after division you can see the D0 the D will use of us was D 34 D34 and
D34+1 means D35 is includes our complete multiplication so multiplication
result is +5000000
So already we have five million in here and let's take a look once to division for example let's divide
40 by 4 so the result should be ten.
Let's take a look once said on M5 contact and our result is done.
So this is the easy.
So what about 32 bit division so D50 let's change this present value for example 1 0 2 3 5 6 7 this
is just an example I will to write this one.
So 32bit but it seems negative volume so how can we give and number two it just I'm not
used to in here as word I will just use like this.
Okay.
This is ten million two hundred fifty four thousand three hundred and sixty five and to show you the
fifty two will be five but first I will update my project and project updated so let's change this to
for example
an M6 is going to be activated so the result is fifteen 374 so I will do it I will do my calculation
in here so this is our result let's fifteen thousand three hundred and seventy four multiplied by two.
But look this is not our as one module so what happened in here.
Let's take a look.
The
deep 40 and 10 number is in here.
Um it started in here but what was out the the 58 and the 54 that I need to take a look.
Sorry for the deep deep 40 was not okay.
The 50 and 10 molar.
Let's show us.
Okay.
This is our
This is D fifty four A's.
Let's take a look wants to in here in our result and we need to focus to carry
What is the value of the D55
--
So come here and check once this is out.
D55 value 78
This is our carry value so we need to reach a complete D value as one value so we divided ten million
two hundred and fifty four thousand two hundred and sixty five followed by two.
But how can we go to this value again.
So let's calculate it again in here.
I will use my calculator and two exponential sixteen equals this value.
This is complete value of one word multiply by seventy eight.
These were you and what we need to plus fifteen.
Three hundred and seventy four.
Look this is our value.
let's check in here.
You can see you can see five million one hundred twenty seven and one hundred thousand one hundred
and eighty two.
This is 32bit result.
So this is our result.
So the carry inside of D55 is shows us how can we use 32Bit value inside of
the plc projects.
So when you do a division or multiplication with the higher values , higher value numbers or data registers
you need to check ones to the upper data registers inside of your plc projects.
So let's go back to our program and let's take a look once to increment and decrement commands M7 is
on.
Look this is always on and this is incrementing by one always and always and always.
So we need to we need to stop this and we need to increment our d60 value one by one how can we do
this.
We can do it like this for example if we say this is our rising edge and this is also a rising edge and
let's take a look once and also add one more contact let's say OR contact OR M0 like this and
I will use this one to here to show you and in here I need to M8 or M10 then this should be M9 because
M8 is used and again in here I will use it , I will update my project and okay update the program
line okay and it's completed.
So now imagine this is activated then like and always on this is incrementing all.
But now look and so on is activated and it is incremented just once because this is just the rising
h what happens M9 is goes always on just once you see we are just giving a one pulse and it's increasing
just one for the decrement let's say our value is for example 10 so look set on just once it is decrement
it as one or 10 is always on but it is just decrement it just once just one pulse so we can use these
commands with the rising edge or falling edge contact and also with the just normal contact but with the
up the same like rising edge or falling edge contacts then we can increment or decrement our data registers
one by one each pulse just one and one and one is sequentially and what happens if I put here for
example or M1011 this is can millisecond clock pulse so let's take a look once what
will happen inside of the 60.
Look it's incrementing so let's give a pulse 13 1s clock pulse and each one second we
need to look what will happen.
You see it is not incrementing also just sequentially one and one plus one plus one.
No just this is going on high.
Deep down you are going to remember previous lessons.
Just how 1sec goes high just half sec.
It's incrementing a lot.
Also so the solution is possible solutions like these.
Again I need to select it.
I think to change.
Okay just should come here.
Okay
I will use it to here it is possible the same thing.
And sent this project to the plc
An update is completed.
You see it is incrementing one by one each.
Second each and 1013 goes high.
It is incrementing 1.
So thank you for this video.
I'm finished.
So see you in the next video.