×

Subscribe to newsletter

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




PLC BLOG | PLC programming - What Is Logical Operators In Structured Text
Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


PLC programming - What Is Logical Operators In Structured Text

Logical Operator Used for Perform Multiple Conditions expressions. it also combine multiple Relational Operators, The Result Of A Logical Operation Is A BOOL Value (true and false).In PLC programming Structured Text , there are Four logical operators: And(&) logical operators, OR logical operators, XOR logical operators and NOT logical operators. Logical compare element-by-element with logical 1 or 0 accordingly as the result is true or false respectively.


Structured Text And Logical Operators

The logical AND operator (&) result is true if all relation expressions is true, otherwise result is false. For AND logical operator keyword is "AND" and symbol is "&". Basically And logical operator work same as AND gate and we know that in AND gate if all the inputs is 1 than output is 1 otherwise output is 0 same apply in AND logical operator. A simple example of the logical AND operator we have three limit switch and we know that limit switch has only two condition either ON or OFF. Condition for process is if all three limit switch operated (ON) then gate open otherwise gate remains closed. So the code in structured text look like first example

AND Logical Operators In Structured Text

in first example if all limit switch is operated then statement is executed i.e. gate open command set to true and gate will open. in second example comparison of three thermocouple temperature with constant value , as per our program if first thermocouple temperature(temp1) value is less than 20 degrees Celsius, second thermocouple(temp2) is greater 50 degrees Celsius and third thermocouple is equal to 40 degrees Celsius than condition is true and alarm is set. So in logical operator no matter what value we compare as in our case all three thermocouple is different condition. But when they reach these condition than result is true otherwise result is false. So it combines multiple condition. If conclude so all condition in series to each other.


Structured Text OR Logical Operators

The logical OR operator result is true when one or more than one of the relation expressions is true otherwise result is false. execution of logical OR operator is same as OR Gate as we know that output of logical OR gate is 1 if any of the input bit is 1 otherwise output is 0. Keyword for OR Logical Operators is "OR". Consider simple two example of Structured Text OR Logical Operators.

OR Logical Operators In Structured Text

in first example when we have four push button if any one push button is pressed then motor is start and if all push button is pressed than result is also true so our will motor will start. Two push button is pressed then the result is false and motor not start. In second example we have three pressure gauge if any one or all of the pressure gauges value is less than to the set point than compressor start for maintain a pressure. if all of the pressure gauges value is less than to the set point than compressor start for maintaining pressure.


Structured Text XOR Logical Operators

XOR Logical Operators that result is True when one of the condition is true or all condition is true. In OR logical operator output is true if one or more than one condition is true but in XOR logical operator output is true if any one or all condition is true. Working is same as XOR logical gate. Keyword for logical XOR is "XOR". Below is a simple example of XOR Logical Operators

XOR Logical Operators In Structured Text

in above example of XOR Logical Operators conveyor start if any one of the limit switch operated or all limit switch operated. If more than one limit switch operated then conveyor will not start.


Structured Text NOT Logical Operators

NOT Logical Operators inverts the result of conditional stamen. As we know that a logical NOT GATE output is 0 when input is 1 and if the input is 1 than output is zero. You can use NOT logical Operators in a multiple condition. NOT inverts output of other logical operator.

NOT Logical Operators In Structured Text

in first example of NOT logical operator if push button is pressed then motor not because NOT logical operator invert the output of condition result. In second example have multiple NOT logical operator.


Structured Text Multiple Logical Operator In Same Conditional Statement

Structured Text Multiple Logical Operator In Same Conditional Statement

in above example of logical operator I am using multiple logical operator you made your own condition and logic if you have any difficulty to write comment below.

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

comment