In this video we are going to do if loop example. 1
I will create a new project in the program area. 2
I will create firstly ladder diagram and say new and OK 3
a new project is created. 4
This is the first example and then I will add LD M0 out m0 and also I will add set m1 and also reset 5
m2 this will be like this. 6
So what's happening in here. 7
If m0 is active that moment we are resetting M2. 8
We are setting M1 and we are giving a pulse while the m0 is active but this is something wrong 9
in here because m 0 is used in here m1 n2 and we can say to M3 then how can we write this 10
code as ST language. 11
So in the programs area right click and say new and structure text selected and say OK 12
and ST programming area is open so we can just write our variables in here. 13
If m 0 then so what was it. 14
Remember the output was m2 was resetted m1 set and M3 was just according to m3 condition 15
it will be on or off. 16
So how can we write it. 17
We can write it like this m2 18
was should be false M1 should be true. 19
This is what I remember in our example M1 is set m2 reset 20
So what we did in here 21
M2 is going to be false that means reset m1 is going to be true. 22
So that means it is going to be set after m0 becomes high. 23
And I will say and if so and loop is finished in here but one more thing that we need to put here we 24
forgot M3. 25
So M3 will be equals to M0 according to our example. 26
We should put it to here. 27
So firstly I will go online to my simulator. 28
This project is compiling and this project is compiled and say execution code going to be transferred 29
to simulator. 30
And now it is send simulator stopped. 31
so say Run Okay. 32
Now M0 is set on what's happened M2 is false. 33
And m1 set and M3 is active. 34
So m0 is gone or off so M1 is still set M3 is off M2 still of that I will say set off to it and 35
I will go offline and I will delete it . 36
Then let's focus to ST program that we write go on line say OK the project is compiling that we 37
are on line but it needs to do a transfer again say OK 38
then m 0 it set on you can see M0 is active M2 is still false and what is true at M3 is active m 0 is 39
set off then m2 is still false M3 is off but M1 still active. 40
So this is equals to our ladder diagram example. 41
In the end if you want to reset our M1 how can we do it. 42
I will go on line edit so we can say at this point for example in here or in here we can say else for 43
example M1 it goes to false then update it it is updating now update the programme line it is going 44
to send source code and Okay m0 we are going to say set on 45
but it is not allowing to it, I will go now set on m1 is true m2 is still false m3 46
is active m 0 is set off that moment all of them is off. 47
So this is our first if loop example in the next video I will continue to second example.