Hi guys,
I need check a condition with bg logic.
It consists that R1=R2 OR R2<R1<R3,
DO1=on.
How can do it?
Example is correct?
IF R[1]=R[2] OR R[1]<>R[2] and R[3],
DO1=ON;
Thanks
Inviato dal mio PRA-LX1 utilizzando Tapatalk
Hi guys,
I need check a condition with bg logic.
It consists that R1=R2 OR R2<R1<R3,
DO1=on.
How can do it?
Example is correct?
IF R[1]=R[2] OR R[1]<>R[2] and R[3],
DO1=ON;
Thanks
Inviato dal mio PRA-LX1 utilizzando Tapatalk
Hi guys,
I need check a condition with bg logic.It consists that R1=R2 OR R2<R1<R3,
DO1=on.
Since this is a question I think it should be posted in the main forum. The sticky BG thread should be reserved for posting examples of useful code, to help the community.
HawkME
As you wished
When using an 'If' statement in BG logic, you need to use mixed logic. There are 2 ways to do this.
1. If you want the DO to be on when the condition is true and off when the condition is false, then directly assign it:
: DO[1] = (logical condition);
2. If you want the DO to just turn on when true, but do nothing when false, then use 'If':
: IF (condition), DO = (ON);
(Side note: If you are familiar with ladder logic, example 1 is like an Output Coil and example 2 is like a Latched coil)
It is easy to know when you are using mixed logic, because the conditionals and assignments are parenthesis. Also, you cannot check one value against two others with only one comparison operator. See this example.
The wrong way:
: If (R[1]<>R[2] AND R[3]), DO[1]=(ON); -> This will not work, it is a syntax error
The right way:
: If (R[1]<>R[2] AND R[1]<>R[3]), DO[1]=(ON);