Support Forums
Logical Expressions

Hello there,

I've a problem with a Logical Expression in order to set a value taking in account a measured value.

1*R(“R_DIRV~ohm”,=141CV,FF3)

140cv=(141cv>=29700)OR(141cv<=36300)?0: (141cv>=5913)OR(141cv<=7384)?22.5: (141cv>=7385)OR(141cv<=10000)?45: (141cv>=790)OR(141cv<=936)?67.5: (141cv>=950)OR(141cv<=1050)?90: (141cv>=654)OR(141cv<=789)?112.5: (141cv>=1806)OR(141cv<=2670)?135: (141cv>=1051)OR(141cv<=1805)?157.5: (141cv>=3521)OR(141cv<=5912)?180: (141cv>=2671)OR(141cv<=3520)?202.5: (141cv>=15060)OR(141cv<=17600)?225: (141cv>=11421)OR(141cv<=15061)?247.5: (141cv>=92452)?270: (141cv>=37908 )OR(141cv<=50000)?292.5:140CV
140CV=(141cv>=58410)OR(141cv<=92450)?315: (141cv>=19692)OR(141cv<=24068 )?337.5:-999

Well, at first I had all of this in one line, but then I've noticed that the code line in DT80 has a lenght limit and I divided it (probably not the best way).
This resistance measurement is a cheap wind direction sensor (22.5º resolution) and therefore I would like to set the direction taking in account the measured resistance values. However, 140CV allways assumes the first condition and ignores the following ones. Besides the resistance value corresponding to 112.5 (654<=direction<=789) it is allways set as 0º.

what I'm missing here? can this be simplified?

Thanks for the help.

Hello there, I&#039;ve a problem with a Logical Expression in order to set a value taking in account a measured value. 1*R(&ldquo;R_DIRV~ohm&rdquo;,=141CV,FF3) 140cv=(141cv&gt;=29700)OR(141cv&lt;=36300)?0: (141cv&gt;=5913)OR(141cv&lt;=7384)?22.5: (141cv&gt;=7385)OR(141cv&lt;=10000)?45: (141cv&gt;=790)OR(141cv&lt;=936)?67.5: (141cv&gt;=950)OR(141cv&lt;=1050)?90: (141cv&gt;=654)OR(141cv&lt;=789)?112.5: (141cv&gt;=1806)OR(141cv&lt;=2670)?135: (141cv&gt;=1051)OR(141cv&lt;=1805)?157.5: (141cv&gt;=3521)OR(141cv&lt;=5912)?180: (141cv&gt;=2671)OR(141cv&lt;=3520)?202.5: (141cv&gt;=15060)OR(141cv&lt;=17600)?225: (141cv&gt;=11421)OR(141cv&lt;=15061)?247.5: (141cv&gt;=92452)?270: (141cv&gt;=37908 )OR(141cv&lt;=50000)?292.5:140CV 140CV=(141cv&gt;=58410)OR(141cv&lt;=92450)?315: (141cv&gt;=19692)OR(141cv&lt;=24068 )?337.5:-999 Well, at first I had all of this in one line, but then I&#039;ve noticed that the code line in DT80 has a lenght limit and I divided it (probably not the best way). This resistance measurement is a cheap wind direction sensor (22.5&ordm; resolution) and therefore I would like to set the direction taking in account the measured resistance values. However, 140CV allways assumes the first condition and ignores the following ones. Besides the resistance value corresponding to 112.5 (654&lt;=direction&lt;=789) it is allways set as 0&ordm;. what I&#039;m missing here? can this be simplified? Thanks for the help.

Hi Osnofa,

Declaration IF THEN ELSE if nested requires a bracket, you get the first condition because you did not use any extra brackets.
140cv=(141cv>=29700)OR(141cv<=36300)?0smile(141cv>=5913)OR(141cv<=7384)?22.5smile(141cv>=7385)OR(141cv<=10000)?45:.....

Furthermore if you need to create multiple IF THEN ELSE can be written into several lines (I did not check your limit condition)
140cv(W)=((141cv>=29700)OR(141cv<=36300)?0: ((141cv>=5913)OR(141cv<=7384)?22.5: ((141cv>=7385)OR(141cv<=10000)?45: ((141cv>=790)OR(141cv<=936)?67.5:-99))))
IF(140cv==-99){140cv=((141cv>=950)OR(141cv<=1050)?90: ((141cv>=654)OR(141cv<=789)?112.5: ((141cv>=1806)OR(141cv<=2670)?135: ((141cv>=1051)OR(141cv<=1805)?157.5:-99))))}
IF(140cv==-99){140cv=((141cv>=3521)OR(141cv<=5912)?180: ((141cv>=2671)OR(141cv<=3520)?202.5: ((141cv>=15060)OR(141cv<=17600)?225: ((141cv>=11421)OR(141cv<=15061)?247.5:-99))))}
IF(140cv==-99){140cv=((141cv>=92452)?270: ((141cv>=37908 )OR(141cv<=50000)?292.5: ((141cv>=58410)OR(141cv<=92450)?315: ((141cv>=19692)OR(141cv<=24068 )?337.5:-999))))}
140cv

Or you may assign several conditional statements rather than IF THEN ELSE for a better handle (a bit long though):
IF(141CV><29700,36300){140CV=0}
IF(141CV><5913,7384){140CV=22.5}
...
IF(141CV><19692,24068 ){140CV=337.5}
140CV

Best regards,
Rudy Gunawan

Hi Osnofa, Declaration IF THEN ELSE if nested requires a bracket, you get the first condition because you did not use any extra brackets. 140cv=(141cv&gt;=29700)OR(141cv&lt;=36300)?0:((141cv&gt;=5913)OR(141cv&lt;=7384)?22.5:((141cv&gt;=7385)OR(141cv&lt;=10000)?45:..... Furthermore if you need to create multiple IF THEN ELSE can be written* into several lines (*I did not check your limit condition) 140cv(W)=((141cv&gt;=29700)OR(141cv&lt;=36300)?0: ((141cv&gt;=5913)OR(141cv&lt;=7384)?22.5: ((141cv&gt;=7385)OR(141cv&lt;=10000)?45: ((141cv&gt;=790)OR(141cv&lt;=936)?67.5:-99)))) IF(140cv==-99){140cv=((141cv&gt;=950)OR(141cv&lt;=1050)?90: ((141cv&gt;=654)OR(141cv&lt;=789)?112.5: ((141cv&gt;=1806)OR(141cv&lt;=2670)?135: ((141cv&gt;=1051)OR(141cv&lt;=1805)?157.5:-99))))} IF(140cv==-99){140cv=((141cv&gt;=3521)OR(141cv&lt;=5912)?180: ((141cv&gt;=2671)OR(141cv&lt;=3520)?202.5: ((141cv&gt;=15060)OR(141cv&lt;=17600)?225: ((141cv&gt;=11421)OR(141cv&lt;=15061)?247.5:-99))))} IF(140cv==-99){140cv=((141cv&gt;=92452)?270: ((141cv&gt;=37908 )OR(141cv&lt;=50000)?292.5: ((141cv&gt;=58410)OR(141cv&lt;=92450)?315: ((141cv&gt;=19692)OR(141cv&lt;=24068 )?337.5:-999))))} 140cv Or you may assign several conditional statements rather than IF THEN ELSE for a better handle (a bit long though): IF(141CV&gt;&lt;29700,36300){140CV=0} IF(141CV&gt;&lt;5913,7384){140CV=22.5} ... IF(141CV&gt;&lt;19692,24068 ){140CV=337.5} 140CV Best regards, Rudy Gunawan
20
1
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft