Automation studio B&R PLC ST programming PART 13 - WHILE .....DO LOOP for finding highest value.

Image
 While do loop is used continuously monitor a condition, if the condition is fulfilled the statement insdie the loop is executed. Otherwise it will jump out of loop. In  tutorial the while is continuously monitoring the Array J[i] which is having integer value, and displaying the largest value. Download Prog file from below drive link:- https://drive.google.com/file/d/1bzc0gqOsBHh_NUvumjbhzAdq090prK-4/view?usp=sharing Explanation:- Below is the flow of While do loo[ for Program execution:- Below are the variables used in While loop example:-

Automation Studio B&R PLC Part 10 - Using 'CASE Statement' for programming Complete Tank Level Logic in ST

This tutorial is About Learning how to use CASE Statement for Programming Tank Level Logic. CASE Statement are widely used as it helps for easy programming.

Click Below for Video Tutorial:-

Case statement Video Tutorial


CASE Statements are also Called Switch Statement in C++. 

Case Statement acts as a switch. We can switch between Staements.

Benefits of Using Case Statements :-

1. Better than Cascaded IF else statements.

2. easier to understand

3. Faster execution than IF Statements as CASE acts like a switch.


 Syntax:-



Explanation:-
'Casename ' is similar to variable name ( user can define any name )
'Statements' is also similar variable name (user can define any name )

Statements consist of  Logic. we can switch between Different statements i.e switch between different logic.

Statement 1 is Executed first when CASE is executed. In statement 1 user have to specify other statements to jump in form of Logic
Please watch Youtube video below which would make understand better in practical manner.





We are going to Develop Logic for below Tank using CASE Statement in Structured Text.




I/O List as below:-

Inputs :-
gDI_Low = Low Level sensor
gDI_High = High Level Sensor
gDI_Start = Start Push Button
gDI_Stop = Stop Push Button

Outputs :-
gDO_Drain _Vlv = Drain Valve
gDO_FIll_Vlv = Fill  Valve
gDO_Motor = Motor
 Logic  :-

When gDi_Start is pressed and level is below gDi_low Sensor the gDo_Fill_Vlv will Start.
Once the Water level reaches gDi_High, gDO_motor & gDo_Drain_Vlv Starts Together.
Once level is below gDi_Low again gDo_Fill_Vlv starts.
  
Lets us divide above logic into 4 Stages:-

1. Initial State = All outputs will be OFF i.e  gDo_Motor := 0 , dDo_Drain_vlv :=0, gDo_FIll_vlv := 0.

2. Check Level State = In this State Logic Input ( gDi_Low & gDi_High ) is Analyzed and decision is taken too switch in  Filling or draining State.

3. Filling State = In this Logic only gDo_Fill_Vlv := 1 , gDo_Motor := 0 & gDo_Drain_Vlv.
Means only filling vlve is On rest Outputs are OFF.

4. Draining State = In this logic gDo_Motor := 1 ,gDo_Dran := 1 & gDo_Fill_Vlv := 0.
Only Motor & Drain valve is ON.


Lets us Start with programming:-

STEP 1 :-

Define 4 States in Enumeration inside Global.Typ as below:-











STEP 2 :-

Define all variable
'Case Tank' is CASE Name. We have to call machine state 'Machine_states' in Case Name.
'Current_state' Display current executing State.






STEP 3 :-

Logic Implementation as below:-


                            







Thank you,
KOTT TUTORIAL
Rohit K







 



Comments

Popular posts from this blog

Automation studio B&R PLC ST programming PART 13 - WHILE .....DO LOOP for finding highest value.