0
1
00:00:21,570 --> 00:00:22,170
Hello.
1

2
00:00:22,230 --> 00:00:27,240
In this video we are going to learn case loop in the ST  programming language.
2

3
00:00:27,300 --> 00:00:28,650
I will create a new project
3

4
00:00:31,330 --> 00:00:39,580
and I will add new program as is the language structure text and I will say OK
4

5
00:00:43,270 --> 00:00:46,600
new program is created already we tried.
5

6
00:00:46,780 --> 00:01:00,120
If loops and we already learn if and expression and THEN and etc. elsif and also else and END_IF;
6

7
00:01:00,140 --> 00:01:00,690
--
7

8
00:01:00,870 --> 00:01:06,450
But now we will work with the case loop or case programming.
8

9
00:01:06,450 --> 00:01:08,580
How can we use case.
9

10
00:01:08,700 --> 00:01:16,800
We will just need to put case and then we will put here word or data.
10

11
00:01:17,220 --> 00:01:20,820
So for example we can put here d0
11

12
00:01:20,850 --> 00:01:26,870
Like this case D0 of this is what we need to use.
12

13
00:01:26,940 --> 00:01:34,050
But before this ,maybe I should just click this and you can see them all in here.
13

14
00:01:34,050 --> 00:01:41,530
This is the example of the case what case is doing case F of F means you.
14

15
00:01:41,610 --> 00:01:43,200
This is the data of us.
15

16
00:01:43,440 --> 00:01:49,610
So 1 or 2 or another values in here.
16

17
00:01:49,620 --> 00:01:53,370
In the case loop for example 3 or 4 or 5.
17

18
00:01:53,370 --> 00:02:03,980
These are all coming from F and ELSE the like just a if loop in here if it is not equals to
18

19
00:02:04,020 --> 00:02:15,480
For example if f is not equal to 1 2 3 or 4 or 5 then g will be 0 then let's write our code for example
19

20
00:02:15,690 --> 00:02:34,740
if M5 then motor1 forward should be true and else motor1 forward should be false but also we need
20

21
00:02:34,740 --> 00:02:46,340
to assign our variables in here motor1 forward should be bool and this is just a variable.
21

22
00:02:46,340 --> 00:02:47,260
This okay.
22

23
00:02:47,390 --> 00:02:49,910
And what we need to put here and
23

24
00:02:53,360 --> 00:03:01,670
this moment we need to give a speed to the motor for example and then I will say motor speed
24

25
00:03:05,510 --> 00:03:14,120
equals to for example D0 thats all and in here I will say
25

26
00:03:17,630 --> 00:03:34,030
motor speed should be zero I will add here motorspeed and then it should be word than we can
26

27
00:03:34,030 --> 00:03:46,900
start case loop, case D0  of and than we can say in here we need to put for example in here to 
27

28
00:03:46,920 --> 00:03:56,990
understand this example easily and professionally case D0 of I will  just the selections to
28

29
00:03:56,990 --> 00:04:05,810
here one and this moment according to d0 the motor speed I will change to here a little bit
29

30
00:04:05,960 --> 00:04:06,760
later.
30

31
00:04:06,980 --> 00:04:21,270
Motor speed should be 200 and the selection is two and motor speed should be 300 and then three
31

32
00:04:22,330 --> 00:04:36,920
and the motor speed should be 400 and ELSE motor speed is going to be 0 and case that's all.
32

33
00:04:37,040 --> 00:04:45,890
So what we need if d0 is 1 the motor speed will be two hundred motor speed is going to be not adjusted
33

34
00:04:45,890 --> 00:05:00,450
in here like this and then we can say now if and 10 that's adopted a little bit more if M5 than what
34

35
00:05:00,450 --> 00:05:01,470
will happen.
35

36
00:05:01,470 --> 00:05:18,390
D 0 is going to be 1 ELSIF  m4  then that moment D 0 is going to be 2 and we can say just m6
36

37
00:05:18,670 --> 00:05:29,780
Let's increase it ELSIF M7 then that moment D0 is going to be three ELSE what we gonna say
37

38
00:05:30,230 --> 00:05:33,840
D0  is going to be zero.
38

39
00:05:34,700 --> 00:05:35,350
That's okay.
39

40
00:05:35,600 --> 00:05:40,900
So what will happen if we press M5 then D0 is going to be one.
40

41
00:05:41,030 --> 00:05:49,370
And the motor speed will be two hundred if we press to M6 that moment D0  is going to be 2 and
41

42
00:05:49,370 --> 00:05:56,300
the motor speed is going to be three hundred and let's go online to plc 
42

43
00:05:56,660 --> 00:05:57,640
Let's check.
43

44
00:05:57,650 --> 00:05:58,830
Will it work or not.
44

45
00:05:58,910 --> 00:06:04,550
According to our codes ,I want to do a download this codes to cpu.
45

46
00:06:04,550 --> 00:06:08,980
And now it's transferring and I want to go back to running state.
46

47
00:06:08,980 --> 00:06:10,400
Let's start it.
47

48
00:06:10,400 --> 00:06:15,770
Firstly I will just make it bigger for you.
48

49
00:06:15,770 --> 00:06:24,250
I guess this is okay and then M5 is on now M5 is on and D 0 equals to 1.
49

50
00:06:24,500 --> 00:06:26,930
And the motor speed is 200.
50

51
00:06:26,960 --> 00:06:38,030
You can see it and then let's say M7 is going to be on and then motor speed is 400 because now we are
51

52
00:06:38,030 --> 00:06:48,710
writing 3 to D0 set off and M6 and now you can see it is 2 and because of 2 equals to 300 and m6
52

53
00:06:48,730 --> 00:06:52,800
set off that moment motor speed is 0.
53

54
00:06:53,060 --> 00:07:03,680
So also in the st operators lesson than you can remember or already we just check.
54

55
00:07:03,750 --> 00:07:17,770
We can use if M5 and not m6 and not  m7 we can use it like this.
55

56
00:07:17,770 --> 00:07:22,820
So it is normally open contact normally close and normally close.
56

57
00:07:22,900 --> 00:07:33,510
Also we can say or not M7 for example we can adopt this if loop in here and according to if loop we
57

58
00:07:33,510 --> 00:07:36,220
can adapt our case loop in here.
58

59
00:07:36,270 --> 00:07:43,140
So what we need we need just one data in the case of between the case and OF we need to put here data
59

60
00:07:43,170 --> 00:07:44,440
according to this data.
60

61
00:07:44,550 --> 00:07:52,920
We can just adopt 1 2 and 3 to dot in here and then we have our variable and we are assigning value
61

62
00:07:52,920 --> 00:07:57,700
to our variable and after ELSE we are just writing okay.
62

63
00:07:57,740 --> 00:08:00,360
This is in the case loop everything is wrong.
63

64
00:08:00,360 --> 00:08:02,660
So just you need to use this.
64

65
00:08:02,760 --> 00:08:08,800
And after else we are just putting it to here we have our variable  and according to else 
65

66
00:08:08,820 --> 00:08:15,550
Loop in the case loop we are just writing 0 or true or etc. This is up to you.
66

67
00:08:15,570 --> 00:08:17,970
So this is how can we use case.
67

68
00:08:17,970 --> 00:08:26,400
So when we came here just click case and you will see the structure of the case and after case
68

69
00:08:26,400 --> 00:08:29,310
loop is when you make it like this.
69

70
00:08:29,320 --> 00:08:37,510
A basic examples you can add and not, or , or not , or and just M6 like this and M7
70

71
00:08:37,680 --> 00:08:45,420
This is just 3 serial contact normally open contact in the if loop that you can do a little bit more
71

72
00:08:46,260 --> 00:08:54,150
advanced examples with yourself and if you stuck any point or any time  you should just inform
72

73
00:08:54,150 --> 00:09:01,100
me I am going to help you whatever I can and we can fix your problems or solve problems everytime.
73

74
00:09:02,250 --> 00:09:05,070
You should know you need to keep follow and keep learning.
74

75
00:09:05,090 --> 00:09:07,030
I'm finished sorry for this video.
75

76
00:09:07,110 --> 00:09:08,640
See you in the next video.
