Hello. 1
In this video we are going to learn case loop in the ST programming language. 2
I will create a new project 3
and I will add new program as is the language structure text and I will say OK 4
new program is created already we tried. 5
If loops and we already learn if and expression and THEN and etc. elsif and also else and END_IF; 6
-- 7
But now we will work with the case loop or case programming. 8
How can we use case. 9
We will just need to put case and then we will put here word or data. 10
So for example we can put here d0 11
Like this case D0 of this is what we need to use. 12
But before this ,maybe I should just click this and you can see them all in here. 13
This is the example of the case what case is doing case F of F means you. 14
This is the data of us. 15
So 1 or 2 or another values in here. 16
In the case loop for example 3 or 4 or 5. 17
These are all coming from F and ELSE the like just a if loop in here if it is not equals to 18
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
if M5 then motor1 forward should be true and else motor1 forward should be false but also we need 20
to assign our variables in here motor1 forward should be bool and this is just a variable. 21
This okay. 22
And what we need to put here and 23
this moment we need to give a speed to the motor for example and then I will say motor speed 24
equals to for example D0 thats all and in here I will say 25
motor speed should be zero I will add here motorspeed and then it should be word than we can 26
start case loop, case D0 of and than we can say in here we need to put for example in here to 27
understand this example easily and professionally case D0 of I will just the selections to 28
here one and this moment according to d0 the motor speed I will change to here a little bit 29
later. 30
Motor speed should be 200 and the selection is two and motor speed should be 300 and then three 31
and the motor speed should be 400 and ELSE motor speed is going to be 0 and case that's all. 32
So what we need if d0 is 1 the motor speed will be two hundred motor speed is going to be not adjusted 33
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
will happen. 35
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
Let's increase it ELSIF M7 then that moment D0 is going to be three ELSE what we gonna say 37
D0 is going to be zero. 38
That's okay. 39
So what will happen if we press M5 then D0 is going to be one. 40
And the motor speed will be two hundred if we press to M6 that moment D0 is going to be 2 and 41
the motor speed is going to be three hundred and let's go online to plc 42
Let's check. 43
Will it work or not. 44
According to our codes ,I want to do a download this codes to cpu. 45
And now it's transferring and I want to go back to running state. 46
Let's start it. 47
Firstly I will just make it bigger for you. 48
I guess this is okay and then M5 is on now M5 is on and D 0 equals to 1. 49
And the motor speed is 200. 50
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
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
set off that moment motor speed is 0. 53
So also in the st operators lesson than you can remember or already we just check. 54
We can use if M5 and not m6 and not m7 we can use it like this. 55
So it is normally open contact normally close and normally close. 56
Also we can say or not M7 for example we can adopt this if loop in here and according to if loop we 57
can adapt our case loop in here. 58
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
according to this data. 60
We can just adopt 1 2 and 3 to dot in here and then we have our variable and we are assigning value 61
to our variable and after ELSE we are just writing okay. 62
This is in the case loop everything is wrong. 63
So just you need to use this. 64
And after else we are just putting it to here we have our variable and according to else 65
Loop in the case loop we are just writing 0 or true or etc. This is up to you. 66
So this is how can we use case. 67
So when we came here just click case and you will see the structure of the case and after case 68
loop is when you make it like this. 69
A basic examples you can add and not, or , or not , or and just M6 like this and M7 70
This is just 3 serial contact normally open contact in the if loop that you can do a little bit more 71
advanced examples with yourself and if you stuck any point or any time you should just inform 72
me I am going to help you whatever I can and we can fix your problems or solve problems everytime. 73
You should know you need to keep follow and keep learning. 74
I'm finished sorry for this video. 75
See you in the next video.