1
00:00:21,470 --> 00:00:22,130
Hello.

2
00:00:22,190 --> 00:00:28,180
In this video we are going to learn Math, increment and decrement commands.

3
00:00:28,250 --> 00:00:32,120
The left side you can see at command usage.

4
00:00:32,240 --> 00:00:41,180
So in here S1 edited by S2 and the result is written to hear the output.

5
00:00:41,180 --> 00:00:51,770
So in here in example you can see when the condition is 0 is high the zero plus the time the output

6
00:00:51,800 --> 00:00:58,100
is say 2 or the result is saved or written into D 20.

7
00:00:58,130 --> 00:01:07,130
If you want to use sub command so as one minus as to the result is written two in here in here also

8
00:01:07,130 --> 00:01:12,840
you can see in on example when it's zero is activated or high.

9
00:01:13,280 --> 00:01:24,560
So from the zero B 10 is subtracted down the result is written to the twenty fourth division command

10
00:01:25,250 --> 00:01:27,610
from S1 and is 2.

11
00:01:27,800 --> 00:01:37,310
You can write here just sixteen bit values so as one divided by S2 and the result is written to hear

12
00:01:37,610 --> 00:01:38,450
the output.

13
00:01:38,540 --> 00:01:44,870
So outputs and the input should be worth data type in here.

14
00:01:44,870 --> 00:01:55,370
You can see an example x1 divided by S 2 and the result is written to the twenty four sixteen bit.

15
00:01:55,490 --> 00:02:05,930
You can see here just one words are used and if the result is higher or if you want to work with their

16
00:02:05,960 --> 00:02:07,220
high numbers.

17
00:02:07,220 --> 00:02:15,610
So imagine you are working with the 32 bits number or over thirty two thousand seven hundred sixty seven.

18
00:02:15,710 --> 00:02:24,350
So values for example you are working with the 1 million numbers a variable numbers.

19
00:02:24,650 --> 00:02:28,960
So you need to use 32 bit division.

20
00:02:29,000 --> 00:02:39,230
So in here what you write for example imagine S1 is D0 for division D0 and D1 is going to be used

21
00:02:39,520 --> 00:02:50,960
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

22
00:02:50,960 --> 00:02:55,280
be used for the division and also for the output.

23
00:02:55,550 --> 00:03:07,280
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

24
00:03:07,460 --> 00:03:18,960
plus 1 for multiplication or multiply for the sixteen B unit use just one word and sixteen bit equals

25
00:03:18,960 --> 00:03:19,600
word.

26
00:03:19,800 --> 00:03:23,030
You remember previous lessons in here.

27
00:03:23,070 --> 00:03:34,890
The 0 multiply by the 10 and the output or result is written into the twenty for the 32 bit multiply

28
00:03:35,130 --> 00:03:44,040
or multiplication as 1 and as who is going to multiply or after multiplication the output or result

29
00:03:44,040 --> 00:03:53,280
is written to here but like here we are not going to use just one word they will use S1 and as one plus

30
00:03:53,280 --> 00:04:03,870
one as two as two plus 1 and D Day plus 1 because this is just sixteen bit but this is also sixteen

31
00:04:03,870 --> 00:04:09,570
bit but totally thought it to be means uh to work.

32
00:04:09,720 --> 00:04:19,160
So they will use 32 bit multiplication just two words and the next page we will see increment common.

33
00:04:19,230 --> 00:04:29,280
So when the condition goes high each time this value is going to be upside plus 1 each time one will

34
00:04:29,280 --> 00:04:41,070
be added to this value all the zeros value the increase by 1 1 0 goes from off to on each time.

35
00:04:41,070 --> 00:04:52,140
And if these euro is 16 b we will use these values if these euro is 32 bit these values will be range

36
00:04:52,140 --> 00:05:02,400
of our data register for decrement command we will go lower this time so each time these 0 minus 1 will

37
00:05:02,400 --> 00:05:07,960
be the value will be mu minus or subtract by 1.

38
00:05:08,070 --> 00:05:21,180
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

39
00:05:21,420 --> 00:05:25,380
0 is activated again the 0 will be a.

40
00:05:25,560 --> 00:05:29,510
And these applications and practices that we need to see.

41
00:05:29,760 --> 00:05:39,300
So let's go ISPsof and create a new project and new project is created and programs come here and

42
00:05:39,480 --> 00:05:49,140
right click a new a new program is opened and I will create a device monitor table also and lets say

43
00:05:49,170 --> 00:05:54,830
Okay and let's go programs and let's do some examples.

44
00:05:54,840 --> 00:06:06,460
Ld m0 and at  D0 to D4 and in here one more network and LD M1.

45
00:06:06,920 --> 00:06:19,510
and for the subtract sub d10 D12 and D14 I will do it like this.

46
00:06:19,510 --> 00:06:29,930
And in here I will say LD M22 and let s do multiplication add D22 D24

47
00:06:30,340 --> 00:06:41,550
and one more LD M3 and multiplication 32 bit that we are going to use now D32 and D34

48
00:06:41,550 --> 00:06:54,870
ups this is not okay and let's take a look once two division LD 5 and division

49
00:06:55,200 --> 00:07:07,140
D40 D42 D44 will be resolved and ld M6 division 32bit will be

50
00:07:07,140 --> 00:07:18,300
D50 D52 and d54 and for the increment and decrement commands LD M7 and

51
00:07:18,590 --> 00:07:33,930
increment D60 and for decrement command LD M8 and decrement D70 so let s go

52
00:07:33,930 --> 00:07:44,250
online and let's do some practice is about our commands and learn them all effectively and how

53
00:07:44,250 --> 00:07:47,480
can we can use them how we can monitor them.

54
00:07:47,780 --> 00:07:49,470
Let's let's take a look them all.

55
00:07:49,620 --> 00:07:59,970
First of all ADD command and I will just check our CPU is now run situation and I will open my

56
00:08:00,040 --> 00:08:05,130
online edit button or activate my online Edit Also and I will change.

57
00:08:05,130 --> 00:08:09,170
This will do is say 5.

58
00:08:09,690 --> 00:08:13,130
Let's say this change present value to a.

59
00:08:13,600 --> 00:08:14,400
I'm waiting.

60
00:08:14,400 --> 00:08:25,790
The output should be 13 so set on the condition on and our output is 13 four subtract command from 20.

61
00:08:25,980 --> 00:08:28,320
Let's subtract for example.

62
00:08:28,500 --> 00:08:32,040
And 7 and I'm still waiting.

63
00:08:32,040 --> 00:08:42,450
The output of this condition should be 13 set or so it is subtracted subtracted from the 10.

64
00:08:42,480 --> 00:08:43,240
---

65
00:08:43,250 --> 00:08:47,310
D 12 so 20 -  7 = 13 .

66
00:08:47,640 --> 00:08:56,240
So multiplication let's say 5 multiply by for example 9

67
00:08:56,280 --> 00:08:58,020
So output should be.

68
00:08:58,320 --> 00:09:04,530
I'm waiting that 45 and is activated and 45 is our result.

69
00:09:04,530 --> 00:09:09,370
So what about the 32 bit multiplication.

70
00:09:09,510 --> 00:09:15,210
So let's change this value to for example 1000.

71
00:09:15,450 --> 00:09:19,590
So let's change this value to 5000

72
00:09:19,800 --> 00:09:26,040
So I'm waiting the output should be five million and set on.

73
00:09:26,580 --> 00:09:28,700
So now let's take a look.

74
00:09:28,830 --> 00:09:34,280
The output is 19264

75
00:09:34,530 --> 00:09:38,850
But they are expecting the result should be 5 million.

76
00:09:38,850 --> 00:09:39,510
Why.

77
00:09:39,510 --> 00:09:40,590
Let's take a look.

78
00:09:40,650 --> 00:09:45,960
Monitor table and let's come here and the identifiers.

79
00:09:45,960 --> 00:09:47,990
I will take a look two registers.

80
00:09:48,080 --> 00:09:48,710
Okay.

81
00:09:48,870 --> 00:09:51,930
The 30 at 10 million.

82
00:09:52,230 --> 00:09:53,610
So let's take a look.

83
00:09:53,610 --> 00:09:54,960
One thousand.

84
00:09:55,170 --> 00:09:57,500
Multiply by five thousand.

85
00:09:57,660 --> 00:10:00,330
And the result is a 32 bit.

86
00:10:00,390 --> 00:10:01,020
Imagine.

87
00:10:01,080 --> 00:10:02,750
Let's look let's focus here.

88
00:10:02,760 --> 00:10:03,630
5 million.

89
00:10:03,690 --> 00:10:07,740
But we are saying it in the eyes piece of 19.

90
00:10:08,130 --> 00:10:09,810
264.

91
00:10:09,810 --> 00:10:11,580
So let's open.

92
00:10:11,580 --> 00:10:15,450
Calculator and let's take a look once.

93
00:10:15,480 --> 00:10:21,050
How can we get there reach five million value after thirty.

94
00:10:21,050 --> 00:10:24,450
The 32 bit multiplication.

95
00:10:24,550 --> 00:10:30,230
So now 2^16 bit

96
00:10:30,330 --> 00:10:38,170
So we can we can get complete numbers and full numbers or maximum numbers for one word.

97
00:10:38,190 --> 00:10:43,150
So this is the value of one word can get maximum value.

98
00:10:43,170 --> 00:10:51,840
So how many or what is the value of these 35 or carry value of our multiplication.

99
00:10:51,870 --> 00:10:56,750
So this is 76,  multiplied by 76

100
00:10:56,880 --> 00:11:07,770
And what we have in these 34 the rest of all value 19264 + 

101
00:11:08,390 --> 00:11:12,790
sorry ---

102
00:11:13,050 --> 00:11:23,760
This is my mistake again and multiply by 76 2^16 

103
00:11:23,880 --> 00:11:35,030
multiply by 76 equals and  + 19264

104
00:11:35,240 --> 00:11:40,300
equals five million.

105
00:11:40,340 --> 00:11:53,450
So after division you can see the D0 the D will use of us was D 34 D34 and

106
00:11:53,650 --> 00:12:04,340
D34+1  means D35 is includes our complete multiplication so multiplication

107
00:12:04,340 --> 00:12:06,770
result is +5000000

108
00:12:06,860 --> 00:12:15,500
So already we have five million in here and let's take a look once to division for example let's divide

109
00:12:15,920 --> 00:12:23,130
40 by 4 so the result should be ten.

110
00:12:23,210 --> 00:12:30,190
Let's take a look once said on M5 contact and our result is done.

111
00:12:30,410 --> 00:12:32,000
So this is the easy.

112
00:12:32,000 --> 00:12:46,520
So what about 32 bit division so D50 let's change this present value for example 1 0 2 3 5 6 7 this

113
00:12:46,520 --> 00:12:51,970
is just an example I will to write this one.

114
00:12:52,040 --> 00:13:03,080
So 32bit but it seems negative volume so how can we give and number two it just I'm not

115
00:13:03,080 --> 00:13:08,970
used to in here as word I will just use like this.

116
00:13:09,250 --> 00:13:09,850
Okay.

117
00:13:10,070 --> 00:13:20,270
This is ten million two hundred fifty four thousand three hundred and sixty five and to show you the

118
00:13:20,780 --> 00:13:30,200
fifty two will be five but first I will update my project and project updated so let's change this to

119
00:13:30,620 --> 00:13:31,490
for example

120
00:13:35,390 --> 00:13:48,570
an M6 is going to be activated so the result is fifteen 374 so I will do it I will do my calculation

121
00:13:48,570 --> 00:13:58,710
in here so this is our result let's fifteen thousand three hundred and seventy four multiplied by two.

122
00:13:59,000 --> 00:14:03,960
But look this is not our as one module so what happened in here.

123
00:14:04,010 --> 00:14:05,320
Let's take a look.

124
00:14:05,440 --> 00:14:05,870
The

125
00:14:08,990 --> 00:14:13,220
deep 40 and 10 number is in here.

126
00:14:13,880 --> 00:14:28,540
Um it started in here but what was out the the 58 and the 54 that I need to take a look.

127
00:14:29,260 --> 00:14:33,020
Sorry for the deep deep 40 was not okay.

128
00:14:33,080 --> 00:14:36,060
The 50 and 10 molar.

129
00:14:36,250 --> 00:14:37,470
Let's show us.

130
00:14:37,570 --> 00:14:38,610
Okay.

131
00:14:38,740 --> 00:14:40,850
This is our 

132
00:14:40,960 --> 00:14:44,160
This is D fifty four A's.

133
00:14:44,200 --> 00:14:53,150
Let's take a look wants to in here in our result and we need to focus to carry

134
00:14:53,410 --> 00:14:55,780
What is the value of the D55

135
00:14:55,880 --> 00:14:57,060
--

136
00:14:57,100 --> 00:15:00,770
So come here and check once this is out.

137
00:15:00,890 --> 00:15:04,120
D55 value 78

138
00:15:04,180 --> 00:15:15,190
This is our carry value so we need to reach a complete D value as one value so we divided ten million

139
00:15:15,190 --> 00:15:20,890
two hundred and fifty four thousand two hundred and sixty five followed by two.

140
00:15:20,980 --> 00:15:24,670
But how can we go to this value again.

141
00:15:24,670 --> 00:15:28,460
So let's calculate it again in here.

142
00:15:28,540 --> 00:15:35,740
I will use my calculator and two exponential sixteen equals this value.

143
00:15:35,740 --> 00:15:41,990
This is complete value of one word multiply by seventy eight.

144
00:15:42,050 --> 00:15:51,280
These were you and what we need to plus fifteen.

145
00:15:51,280 --> 00:15:53,400
Three hundred and seventy four.

146
00:15:53,400 --> 00:15:57,740
Look this is  our value.

147
00:15:57,930 --> 00:16:00,720
 let's check in here.

148
00:16:00,720 --> 00:16:11,470
You can see you can see five million one hundred  twenty seven and one hundred thousand one hundred

149
00:16:11,470 --> 00:16:12,600
and eighty two.

150
00:16:12,640 --> 00:16:16,390
This is 32bit result.

151
00:16:16,390 --> 00:16:17,660
So this is our result.

152
00:16:17,920 --> 00:16:30,580
So the carry inside of D55 is shows us how can we  use 32Bit value inside of

153
00:16:30,580 --> 00:16:32,020
the plc projects.

154
00:16:32,080 --> 00:16:42,940
So when you do a division or multiplication with the higher values , higher value numbers or data registers

155
00:16:43,300 --> 00:16:51,330
you need to check ones to the upper data registers inside of your plc projects.

156
00:16:51,370 --> 00:16:59,230
So let's go back to our program and let's take a look once to increment and decrement commands M7 is

157
00:16:59,230 --> 00:16:59,590
on.

158
00:17:00,220 --> 00:17:08,350
Look this is always on and this is incrementing by one always and always and always.

159
00:17:08,410 --> 00:17:17,860
So we need to we need to stop this and we need to increment our d60 value one by one how can we do

160
00:17:17,860 --> 00:17:18,390
this.

161
00:17:18,610 --> 00:17:26,590
We can do it like this for example if we say this is our rising edge and this is also a rising edge and

162
00:17:26,950 --> 00:17:38,770
let's take a look once and also add one more contact let's say OR contact  OR M0 like this and

163
00:17:38,920 --> 00:17:52,290
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

164
00:17:52,310 --> 00:18:05,410
M8 is used and again in here I will use it , I will update my project and okay update the program

165
00:18:05,410 --> 00:18:08,210
line okay and it's completed.

166
00:18:08,590 --> 00:18:17,340
So now imagine this is activated then like and always on this is incrementing all.

167
00:18:17,530 --> 00:18:29,520
But now look and so on is activated and it is incremented just once because this is just the rising

168
00:18:29,530 --> 00:18:39,490
h what happens M9 is goes always on just once you see we are just giving a one pulse and it's increasing

169
00:18:39,850 --> 00:18:52,560
just one for the decrement let's say our value is for example 10 so look set on just once it is decrement

170
00:18:52,560 --> 00:19:02,940
it as one or 10 is always on but it is just decrement it just once just one pulse so we can use these

171
00:19:02,940 --> 00:19:11,250
commands with the rising edge or falling edge contact and also with the just normal contact but with the

172
00:19:11,580 --> 00:19:21,900
up the same like rising edge or falling edge contacts then we can increment or decrement our data registers

173
00:19:21,920 --> 00:19:31,680
one by one each pulse just one and one and one is sequentially and what happens if I put here for

174
00:19:31,680 --> 00:19:43,920
example or M1011 this is can millisecond clock pulse so let's take a look once what

175
00:19:43,920 --> 00:19:47,160
will happen inside of the 60.

176
00:19:47,490 --> 00:19:57,180
Look it's incrementing so let's give a pulse 13 1s clock pulse and each one second we

177
00:19:57,180 --> 00:19:59,640
need to look what will happen.

178
00:19:59,790 --> 00:20:07,180
You see it is not incrementing also just sequentially one and one plus one plus one.

179
00:20:07,180 --> 00:20:11,440
No just this is going on high.

180
00:20:11,450 --> 00:20:14,640
Deep down you are going to remember previous lessons.

181
00:20:14,830 --> 00:20:18,870
Just how 1sec goes high just half sec.

182
00:20:18,950 --> 00:20:20,440
It's incrementing a lot.

183
00:20:20,440 --> 00:20:27,810
Also so the solution is possible solutions like these.

184
00:20:28,030 --> 00:20:31,080
Again I need to select it.

185
00:20:31,630 --> 00:20:33,840
I think to change.

186
00:20:33,860 --> 00:20:38,650
Okay just should come here.

187
00:20:38,770 --> 00:20:39,200
Okay

188
00:20:42,440 --> 00:20:47,650
I will use it to here it is possible the same thing.

189
00:20:47,820 --> 00:20:52,670
And sent this project to the plc

190
00:20:52,680 --> 00:20:54,170
An update is completed.

191
00:20:54,180 --> 00:20:59,520
You see it is incrementing one by one each.

192
00:20:59,640 --> 00:21:04,030
Second each and 1013 goes high.

193
00:21:04,050 --> 00:21:06,310
It is incrementing 1.

194
00:21:06,390 --> 00:21:09,370
So thank you for this video.

195
00:21:09,390 --> 00:21:10,980
I'm finished.

196
00:21:11,160 --> 00:21:13,250
So see you in the next video.
