Logical operators
In automation, it is very common for multiple conditions to be met before a system can perform a task. For example, in some cases, we may need to ensure that all the safety switches are open and the start button is engaged before the machine can start up. In other cases, we may need two motor drives to be on before the machine can try to move. To accomplish this, we need to look at more complex logical expressions.
So far, we have seen some code (nested IF
statements) that will behave in such a way that multiple conditions need to be met before a certain task can be carried out. Nested states are suitable when some code needs to be executed based on a single condition while other code requires an extra condition to be satisfied. However, for many cases where all the code needs to be executed when multiple conditions are met, the nested statements can be cumbersome and bloat the code. This is mainly because all of our IF
or ELSIF
statements have only been used as...