×

Subscribe to newsletter

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




PLC BLOG | B&R Automation | Logical Operators | < B&R Automation Studio Logical Operators In C ANSI C Programming
Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


B&R Automation Studio Logical Operators In C ANSI C Programming

Logical Operators Are Used to Combine Two or More Condition and Evaluate Them as a Single Expression. AND, OR, NOT Are Main Logical Operator. Below Is The Example Of Logical Operator In If Else Statement In ANSI C. In This Example We Evaluate A Two Momentary Push Button And Motor On Output To Single Expression. It Is A Example Of Motor Start Stop Using A Start Stop Push Button In ANSI C. || Is Logical Or Operator, && Logical And Operator And ! Logical Not Operator.


B&R Automation Studio AND Logical Operators In ANSI C Programming

AND Logical Operators In ANSI C Programming return true if the both operands are true. below is the example of AND Logical Operator. in this example we have two limit switch limit_switch_1 and limit_switch_2,both are operands. so we use AND operator (limit_switch_1 && limit_switch_2) if both of limit switch operated than condition is TRUE && TRUE than operation result is also true. if limit_switch_1 is true and limit_switch_2 is false than combined result of both operands is false.

B&R Automation Studio AND Logical Operators In ANSI C Programming

in above example belt_1 stop both if limit switch is operated otherwise else condition executed and belt_1 run continuously.


B&R Automation Studio OR Logical Operators In ANSI C Programming

OR Logical Operators In ANSI C Programming return true if an expression at least one of the operands is true. for example if we have three push button and our logical condition is if any of the push button is pressed than lamp on otherwise lamp of. logical operator does same thing. Below is the example of OR Logical Operator. in this example we have three limit switch limit_switch_1, limit_switch_2 and limit_switch_3 so expression for this condition is limit_switch_1 || limit_switch_2 || limit_switch_3. if any of the limit switch is operated than result of expression is also true.

B&R Automation Studio OR Logical Operators In ANSI C Programming

in above example belt_1 run if at least one limit switch is operated. if more than one limit switch is operated than belt_1 run. belt stop if all limit switch is false state.


B&R Automation Studio NOT Logical Operators In ANSI C Programming

NOT Logical Operators In ANSI C Programming invert the logical state of its variable or operation. it same as NOT gate.

B&R Automation Studio NOT Logical Operators In ANSI C Programming

above is the example of NOT logical operator in ANSI C in this example push button variable is pb_stop when so when we use NOT logical operator than push button state is change.

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