×

Subscribe to newsletter

subscribe to our weekly newsletter to get notified with latest story and article Subscribe now!




PLC BLOG | OMRON CX-Programmer Structured Text CASE OF Statements

Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


OMRON CX-Programmer Structured Text CASE OF Statements

in a case of statement a numerical expression select label and statement of selected label is executed. CASE OF Is a Control Flow Statement That Used for Execute Different Statement list Of Code Based on the Value of the Selector or Expression. CASE OF Is An Alternative Of Multiple If-Else-If Statements. CASE OF Easy To Understand. Basic Syntax Of CASE OF Statement Is A Selector Or Expression To Be Evaluated Based On Result Label Select. In Structured Text Language, CASE OF Is A Variable Selector Or Selection Statement That Allows A Program To Choose Among Multiple Alternatives Based On The Value Of A Variable. Use CASE_OF To Select What To Do Based On A Numerical Value.


OMRON CX-Programmer Structured Text CASE OF Statement Syntax

CASE OF Is Control Flow Statement Which Match case numerical value With selector expression If selector expression And case label Value Matched Than Statement Of label is selected by Selector Value Is Executed Otherwise Else Statement Executed. Following Is Representation Of Working Case Of Statement.
  • CASE Selector OF
  • label1:
  • statement-list1;
  • label2:
  • statement-list2;
  • label3:
  • statement-list3;
  • ELSE
  • statement-list for else
  • END_CASE;
selector of case statement is numerical value. these selector value match with label. label is also a any expression, range of values, more than one different values etc. Statement like start stop motor, coil,


OMRON CX-Programmer Structured Text case of statement example

below is the simple example of case of statement in this example we select a motor to run so motor_selector is numerical expression which select motor for example if motor_selector is equal to 1 than only motor_1_run set to true and only first motor start similarly if motor_selector is equal to 2 than second motor start and first motor stop. so according to numerical expression label is selected and statement of label is executed. if value is more than three than else statement executed and all motor set to false;

OMRON CX-Programmer Structured Text case of statement example

OMRON CX-Programmer Structured Text case of statement example for range of values

The .. operator denotes a range case label. If the CASE expression is within that range then the associated statement-list is executed . in above example numerical expression only for single value in this example we select range of values. According to water level motor start or stop and valve open or close in our automation project. so we have water level analog reading first we convert into process data. in this example when water level is between 0 meter to 5 meter than all motor start to run. if the water level is more than 5 to 7 meter than only two motor start and 2 motor stop. if water level is more than 9 meter so valve open for maintain water level to 7 meter. if water level more than 7 to 8 meter than only one motor start. in this logic not used else.

OMRON CX-Programmer Structured Text case of statement example for range of values

OMRON CX-Programmer Structured Text case of statement example for different values

in this example we see different values in level for separating different values use coma (,) in this example we assign different values for label . these different values selected by numerical expression so in this example we set a set point of a VFD for speed up or down according to our air pressure. Different air pressure in different values.

 OMRON CX-Programmer Structured Text case of statement example for different values

OMRON CX-Programmer Structured Text case of statement example with if else

you can use if else inside the statement operation is same if label is selected than statement is executed with if and else statement. for example if operator select conveyor 1 for transporting material bur at this time conveyor is stop due to fault conveyor motor or this conveyor busy for other transportation so we use if else statement for starting another conveyor for transporting material.

OMRON CX-Programmer Structured Text case of statement example with if else
 
Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


Suggested Post


 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

comment