Support Forums
IF THEN ELSE statements

Hi,

I am currently programming a DT85 to monitor several temperatures. I need to reference an alarm if any one of 8 temperature sensors are over X sensor + 45 deg. Basically I want:

IF (CV2 OR 3CV OR 4CV)>CV10 {1CV=1} ELSE {1CV=0} 
1CV IS ALARM STATUS 1 IS FOR ON 0 IS FOR OFF 2CV IS TEMP 2 3CV IS TEMP 3 4CV IS TEMP 4 10CV IS THE REFERENCED TEMP VALUE (5CV + 45)

Is there a guide to programming syntax?

Thanks,
jeremy

Hi, I am currently programming a DT85 to monitor several temperatures. I need to reference an alarm if any one of 8 temperature sensors are over X sensor + 45 deg. Basically I want: ```` IF (CV2 OR 3CV OR 4CV)>CV10 {1CV=1} ELSE {1CV=0} 1CV IS ALARM STATUS 1 IS FOR ON 0 IS FOR OFF 2CV IS TEMP 2 3CV IS TEMP 3 4CV IS TEMP 4 10CV IS THE REFERENCED TEMP VALUE (5CV + 45) ```` Is there a guide to programming syntax? Thanks, jeremy

Hi Jeremy

You can achieve this using a boolean logic expression, e.g:

1cv=(2cv>10cv)or(3cv>10cv)or(4cv>10cv)

1cv will be set to 1 if the overall logical expression is true, otherwise 0.

Conditional expressions such as (2cv>10cv) return 1 if true, 0 if false. These subexpressions can then be combined using logical operators (and/or/not) or arithmetic operators (+/*/etc).

Cheers,
Jeremy

Hi Jeremy You can achieve this using a boolean logic expression, e.g: ```` 1cv=(2cv>10cv)or(3cv>10cv)or(4cv>10cv) ```` 1cv will be set to 1 if the overall logical expression is true, otherwise 0. Conditional expressions such as (2cv>10cv) return 1 if true, 0 if false. These subexpressions can then be combined using logical operators (and/or/not) or arithmetic operators (+/*/etc). Cheers, Jeremy

Hi Jeremy,

You can also achieve the same by chaining the If statements together with "or" statements, e.g.:

If(2CV>10CV)Or
If(3CV>10CV)Or
If(4CV>10CV)1CV

If any of the conditions are true then 1CV is set to 1. If they all fail then 1CV is set to 0

Cheers,
Roger

Hi Jeremy, You can also achieve the same by chaining the If statements together with "or" statements, e.g.: ```` If(2CV>10CV)Or If(3CV>10CV)Or If(4CV>10CV)1CV ```` If any of the conditions are true then 1CV is set to 1. If they all fail then 1CV is set to 0 Cheers, Roger

Hey how are you?

I'm writing a code where I also need to use IF and ELSE. I need to display a time of a 24h cycle which can be between 8am and 8am. That means I have to calculate my values in different ways, according of the time of day. To simplify, I just use 1-4.

For example, value 6 appears 3 times, it could be 6am today, 6pm or 6am the next day. So I tried:

Alarm1(1CV>24)"1" DO{2CV=1} 'after midnight (day2)
Alarm2(1CV<24)"2" DO{2CV=2} 'after 12am
Alarm3(1CV<16)"3" DO{2CV=3} 'after 8 in the morning day1
Alarm4(1CV<12)"4" DO{2CV=4} 'before 8 in the morning day1

3CV=2CV

My problem is, that in 3CV is returned every time the value 4, even if the value is bigger than 12.

Any ideas?

Regards,
Thorsten

Hey how are you? I&#039;m writing a code where I also need to use IF and ELSE. I need to display a time of a 24h cycle which can be between 8am and 8am. That means I have to calculate my values in different ways, according of the time of day. To simplify, I just use 1-4. For example, value 6 appears 3 times, it could be 6am today, 6pm or 6am the next day. So I tried: ```` Alarm1(1CV&gt;24)&quot;1&quot; DO{2CV=1} &#039;after midnight (day2) Alarm2(1CV&lt;24)&quot;2&quot; DO{2CV=2} &#039;after 12am Alarm3(1CV&lt;16)&quot;3&quot; DO{2CV=3} &#039;after 8 in the morning day1 Alarm4(1CV&lt;12)&quot;4&quot; DO{2CV=4} &#039;before 8 in the morning day1 3CV=2CV ```` My problem is, that in 3CV is returned every time the value 4, even if the value is bigger than 12. Any ideas? Regards, Thorsten

Good morning Thorsten,

You have a programming error. You are over riding your alarms with the Do statement. A Do statement is an unconditional alarm so 2CV will always equal 4

You currently have:

Alarm1(1CV>24)"1" DO{2CV=1}

which is two commands

Alarm1(1CV>24)"1"
DO{2CV=1}

The correct syntax for the alarm:

Alarm1(1CV>24)"1"{2CV=1}

Cheers,
Roger

Good morning Thorsten, You have a programming error. You are over riding your alarms with the Do statement. A Do statement is an unconditional alarm so 2CV will always equal 4 You currently have: ```` Alarm1(1CV&gt;24)&quot;1&quot; DO{2CV=1} ```` which is two commands ```` Alarm1(1CV&gt;24)&quot;1&quot; DO{2CV=1} ```` The correct syntax for the alarm: ```` Alarm1(1CV&gt;24)&quot;1&quot;{2CV=1} ```` Cheers, Roger

Hi

Can someone tell me whats went wrong in following sentence?

IF(11CV!=10CV) AND IF(1DS==0){11CV=10CV 1CV=1}

I try to use it in DT80's manual channel

Thanks,
Markku

Hi Can someone tell me whats went wrong in following sentence? ```` IF(11CV!=10CV) AND IF(1DS==0){11CV=10CV 1CV=1} ```` I try to use it in DT80&#039;s manual channel Thanks, Markku

Good morning Markku,

You have a space between the close bracket and the AND. Try this:

IF(11CV!=10CV)AND IF(1DS==0){11CV=10CV 1CV=1}

Cheers,
Roger

Good morning Markku, You have a space between the close bracket and the AND. Try this: ```` IF(11CV!=10CV)AND IF(1DS==0){11CV=10CV 1CV=1} ```` Cheers, Roger

Thank you Roger,

I noticed it also myself after several hours... smile

Markku

Thank you Roger, I noticed it also myself after several hours... :smile: Markku
72
7
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