Host Engineering Forum
General Category => General Discussion => Topic started by: PLCGuy on August 29, 2016, 06:36:46 AM
-
Can someone help me write an IF Statement, or something that would work for what I am trying to do in the DO-More?
If V0, V1, and V2 are equal to "0" then output a bit to show this. I do not to run a device if there are no values in those locations.
I was looking at the example but I do not understand the example, IF(C7,D0,D1) means.
Or if there is a better way, that would be great too.
-
I think I got it.
If(V0,0 + V1,0 + V2,0) result c300
I had to click on the IF column and there it was. Nice examples. I was only looking at the last column where it says examples
Is there a better way to write it?
-
whoops, that is incorrrect.
I need if v0 or v1 or v2 equals zero, result bit C?
Not in example
-
You could do it in ladder logic or in MATH. Here's the MATH expression
MATH C300 "IF(((V0 == 0) || (V1 == 0) || (V2 == 0)), 1, 0)"
or simpler (no IF needed)
MATH C300 "(V0 == 0) || (V1 == 0) || (V2 == 0)"
or in LADDER
V0 0 C300
-] = [-+-------------------( OUT )
|
V1 0 |
-] = [-+
|
V2 0 |
-] = [-+
-
If you need all 3 to be zero to have C300 be ON, change the logical-OR operators || to logical-AND operators &&
In ladder logic, place the equal-to contacts in series instead of parallel.
-
Thank you franji 1. I just like to do it in the math box. Just to be cool.
Maybe you could add that example to the help!