Humidity sensor help

siafu

Active Member
Hello all,
 
I have the following in my old Version: v03.01.03 of webcontrol.
 
However, it is not working. I'm trying to have the board send me one email when the humidity goes past 50%  and then another email when humidity reading goes below 45%
 
In red is the humidity setup, and below that is the rest of program for other things.
 
Can someone please help me set up this? Greatly appreciate your help.
 
 
START    
TSTGE H1 45 VAR5 
TSTLT H1 40 VAR5 
NOP    
SET OP5 VAR5  
TSTEQ VAR6 VAR5  
GOTO GLIGHT   
TSTLT H1 50  
EMAIL 5   
TSTGE H1 45  
EMAIL 6   
SET VAR6 VAR5  
 

GLIGHT:
TSTLT CYEAR 2016  
GOTO BLIGHT   
TSTGE CT 5:0:0 VAR3 
TSTLT CT 21:0:0 VAR3 
NOP    
SET OP3 VAR3  
TSTEQ VAR4 VAR3  
GOTO BLIGHT   
TSTEQ VAR3 1  
EMAIL 7   
TSTEQ VAR3 0  
EMAIL 8   
SET VAR4 VAR3  
BLIGHT:
TSTLT AIP1 25  
SET OP1 1  
TSTGT AIP1 35  
SET OP1 0  
TSTLT T3 1000  
SET OP2 1  
TSTGT T3 1160  
SET OP2 0  
XOR OP1 VAR1  
BZ  TEMPTEST  
TSTEQ OP1 1  
EMAIL 1   
TSTEQ OP1 0  
EMAIL 2   
TEMPTEST:
XOR OP2 VAR2  
BZ  DONE  
TSTEQ OP2 1  
EMAIL 3   
TSTEQ OP2 0  
EMAIL 4   
DONE:
SET VAR1 OP1  
SET VAR2 OP2  
END    
 
 
 

 
 
siafu said:
TSTGE H1 45 VAR5 
TSTLT H1 40 VAR5 
NOP    
 
The first line will set VAR5 to 1 if H1 is 45 or more.
The second line will OVERWRITE VAR5 and set it true if H1 is less than 40 or false if H1 is 40 or more.
Ie, H1 will ONLY be set true if H1 < 40.
Edit: Nonsense, Ross!  If H1>=45, the first test will skip over the second!
 
siafu said:
SET OP5 VAR5  
 
You COULD do this in the above line, eg:
  TSTGE H1 45 OP5
will set OP5 on if H1>=45
 
siafu said:
 
TSTEQ VAR6 VAR5  
GOTO GLIGHT   
 
Trying to make an edge-detector?
 
siafu said:
TSTLT H1 50  
EMAIL 5   
TSTGE H1 45  
EMAIL 6
 
If you get here, you've assumed (incorrectly) that either H1>45 or H1<=40, but will in fact only get here if H1<40, so it should be sending an email5
Correction: if you get here, either H1>45 or <=40. If it's <=50 (which would satisfy all conditions of <=40, but only SOME conditions of >45), then email 5 is sent. If it is >=45, which will be satisfied for all conditions of H1>45, it should send email6.
 
 
siafu said:
  
SET VAR6 VAR5
 
 
Setting var6=var5 means this code shouldn't run again until something changes state, which could be when H1 falls back within your chosen limits. You seem to have some inconsistent values. What does the state of OP5 do?

 
 
@siafu,
 
Do you have pseudo code for what you want to do, in addition to send email?  If you have the pseudo code in English, we can work together on getting that logic into PLC code.
 
Hello Cai and Ross.
 
Sorry, I posted this back in the summer, and never received email that someone responded to my post. I logged in today and noticed the posts from you both.
 
In plain English, I would like to be emailed when the humidity goes past a certain %. The Humidity sensor is located in the boiler room, and if a pipe breaks or something leaks in that room the humidity in the room goes up, and I just want an email to be sent to me to alert me, so I can go check it out.
 
Someone gave me that come some time ago, but it doesn't send me an email when the humidity goes past a certain % that I set. I tested this by misting water in the air from a spray bottle to force the humidity to past my set %.
 
I haver two cai boards and have two humidity hooked up to each and would like this email alert is possible.
 
Thank you all in advance for all your help with this and other programming in the past, greatly appreciate it.
 
It depends on how your boiler room configuration, water on the ground may not cause humidity in the air increase immediately.  Rather some kind of leak detection on the floor might work better.
 
If you hook up Honeywell HIH4000 humidity sensor to the WC humidity sensor posts, then simple PLC code would send email when humidity raising. Then you can let email send to you.  For example,
TSTGT H1  900
EMAIL EM1
 
will keep sending you email once humidity reached above 90.0%.  However, if weather is about rain, humidity sensor could also detect above 90.0%.
 
Hello Ross and Cai,
 
Still can't set this up to send me one email when the humidity is at a certain percentage and then send another email when it's at another percentage. Any help would be greatly appreciated.
 
siafu said:
Hello Ross and Cai,
 
Still can't set this up to send me one email when the humidity is at a certain percentage and then send another email when it's at another percentage. Any help would be greatly appreciated.
 
Your terminology is somewhat vague.
Do you want to achieve basically hysteresis? Or incremental setpoints?
 
Eg:
Humidity quiescently below say, 40%. IF the humidity reaches 50% you want a warning, and if it then reaches 70% you want a panic warning?
(In this case, what do you do if it goes to 55%, then back to 49%, then back to 52%? Does it generate a second low-level warning? What if it hovers around the 70% do you want it to constantly generate warnings each time it goes past the 70%? You will need some sort of hysteresis to prevent it doing so. Do you need another email when the humidity returns to "normal" levels?
 
Second scenario: Same quiescent condition, around 40%. If humidity gets to 70% you get an alarm. When humidity drops below 50% you get a second email "All clear" and the system is reset (and won't send another email until humidity goes to 70% again)
 
 
Hi Ross,
 
I just want it to send me a warning via email that the humidity has gone above certain %, just one email.
 
Then when it goes below a certain % sent another warning, just one email in both cases.
 
So basically the Second Scenario you mentioned.
 
"Second scenario: Same quiescent condition, around 40%. If humidity gets to 70% you get an alarm. When humidity drops below 50% you get a second email "All clear" and the system is reset (and won't send another email until humidity goes to 70% again)"
 
siafu said:
Hi Ross,
 
I just want it to send me a warning via email that the humidity has gone above certain %, just one email.
 
Then when it goes below a certain % sent another warning, just one email in both cases.
 
So basically the Second Scenario you mentioned.
 
"Second scenario: Same quiescent condition, around 40%. If humidity gets to 70% you get an alarm. When humidity drops below 50% you get a second email "All clear" and the system is reset (and won't send another email until humidity goes to 70% again)"
 
 
Well, untested, but have a play with something like this.  (comments only for description, remove them before loading!)
 
START:
loop:
    tstlt H1 70           ; humidity under 70%?
    goto nothi           ; no, so check for low.
    bnz ram1 nothi   ; if ram1 set we have already sent an alarm
    set ram1 1          ; set high humidity alarm
    email em1           ; send "humidity too high" alarm
 
nothi:
    tstgt H1 40         ; humidity over 40%?
    goto loop           ; yes? It is not safe yet then, do nothing
    bz ram1 loop      ; if ram1 clear we have already reset
    set ram1 0           ; else clear the flag
    email em2           ; send "humidity ok" alarm
    goto loop
END
 
Hello Ross,
 
Thank you very much, the code you provided works, in one of my web control devices.
 
I entered the same code in my other web control device added it to the existing code that controls other things. 
 
But in this one it does not work. I did have to change the RAM from 1 to 5 as the other RAMs are used for other things. I also changed loop to loop1 as loop was already in use.
 
I'm providing below the entire code to my devices and highlighting in red where I've added the code you provided. Perhaps it's not inserted in the right spot?
 
 
 
START    
SET RAM1 0  
SET RAM2 0  
SET RAM3 0  
SET RAM4 0  
 
LOOP:
CALLSUB CHKIP2   
CALLSUB CHKIP3   
CALLSUB CHKHEAT   
CALLSUB HTMAIL   
GOTO LOOP   
 
LOOP1:
            TSTLT H1 35  
            GOTO NOTHI   
            TSTEQ RAM5 1  
            GOTO NOTHI   
            SET RAM1 1  
            EMAIL EM7
  
NOTHI:
            TSTGT H1 40  
            GOTO LOOP1   
            TSTEQ RAM5 0  
            GOTO LOOP1   
           SET RAM5 0  
          EMAIL EM8   
          GOTO LOOP1   
END    
 
CHKHEAT:
TSTEQ TS1 0  
GOTO FAILTS1   
CALLSUB OKTS1   
TSTLT CT 5:15:0  
GOTO THERMO05   
TSTLT CT 8:0:0  
GOTO THERM58   
TSTLT CT 12:0:0  
GOTO THERM0812   
TSTLT CT 17:0:0  
GOTO THERM1217   
THERM1723:
TSTLT T1 710  
SET OP2 1  
TSTGT T1 720  
SET OP2 0  
RET    
 
THERMO05:
TSTLT T1 700  
SET OP2 1  
TSTGT T1 710  
SET OP2 0  
RET    
 
THERM58:
TSTLT T1 710  
SET OP2 1  
TSTGT T1 720  
SET OP2 0  
RET    
 
THERM0812:
TSTLT T1 710  
SET OP2 1  
TSTGT T1 720  
SET OP2 0  
RET    
 
THERM1217:
TSTLT T1 710  
SET OP2 1  
TSTGT T1 720  
SET OP2 0  
RET    
 
FAILTS1:
SET OP2 0  
TSTEQ RAM4 0  
RET    
 
EMAIL EM4   
SET RAM4 0  
RET    
 
OKTS1:
TSTEQ RAM4 1  
RET    
 
EMAIL EM6   
SET RAM4 1  
RET    
 
HTMAIL:
TSTEQ OP2 1  
GOTO HTON   
HTOFF:
TSTEQ RAM3 0  
RET    
 
EMAIL EM3   
SET RAM3 0  
RET    
 
HTON:
TSTEQ RAM3 1  
RET    
 
EMAIL EM2   
SET RAM3 1  
RET    
 
CHKIP2:
TSTEQ IP2[500] 1  
GOTO ONIP2   
GOTO CHKIP2END   
ONIP2:
TSTEQ RAM2 1  
GOTO CHKIP2END   
SET OP1 1  
EMAIL EM5   
SET RAM2 1  
CHKIP2END:
TSTEQ OP1[1000] 1  
SET OP1 0  
TSTEQ IP2[500] 0  
SET RAM2 0  
RET    
 
CHKIP3:
TSTEQ IP3[500] 1  
GOTO ONIP3   
GOTO CHKIP3END   
ONIP3:
TSTEQ RAM1 1  
GOTO CHKIP3END   
EMAIL EM1   
SET RAM1 1  
CHKIP3END:
TSTEQ IP3[500] 0  
SET RAM1 0  
RET    
 
siafu said:
Hello Ross,
 
Thank you very much, the code you provided works, in one of my web control devices.
 
I entered the same code in my other web control device added it to the existing code that controls other things. 
 
But in this one it does not work. I did have to change the RAM from 1 to 5 as the other RAMs are used for other things. I also changed loop to loop1 as loop was already in use.
 
I'm providing below the entire code to my devices and highlighting in red where I've added the code you provided. Perhaps it's not inserted in the right spot?
 
 
 
START    
SET RAM1 0  
SET RAM2 0  
SET RAM3 0  
SET RAM4 0  
 
LOOP:
CALLSUB CHKIP2   
CALLSUB CHKIP3   
CALLSUB CHKHEAT   
CALLSUB HTMAIL   
GOTO LOOP      <<<-------
 
LOOP1:
            TSTLT H1 35  
            GOTO NOTHI   
            TSTEQ RAM5 1  
            GOTO NOTHI   
            SET RAM1 1  
            EMAIL EM7
  
NOTHI:
            TSTGT H1 40  
            GOTO LOOP1   
            TSTEQ RAM5 0  
            GOTO LOOP1   
           SET RAM5 0  
          EMAIL EM8   
          GOTO LOOP1   
END    
 
The "goto loop" highlighted above, will be stopping your code ever reaching mine.
Remove that "goto loop" entirely, and the   loop1: label in mine, and change the goto loop1 jumps to goto loop per below should work.
 
 
CALLSUB HTMAIL   

 
            TSTLT H1 35  
            GOTO NOTHI   
            TSTEQ RAM5 1  
            GOTO NOTHI   
            SET RAM1 1  
            EMAIL EM7
  
NOTHI:
            TSTGT H1 40  
            GOTO LOOP
            TSTEQ RAM5 0  
            GOTO LOOP  
           SET RAM5 0  
          EMAIL EM8   
          GOTO LOOP  
END   
 
this sort of works,
 
I get one email when the H1 goes high, but then I get many emails when H1 goes low. About 15 emails of H1 is low.
 
START    
SET RAM1 0  
SET RAM2 0  
SET RAM3 0  
SET RAM4 0  
LOOP:
CALLSUB CHKIP2   
CALLSUB CHKIP3   
CALLSUB CHKHEAT   
CALLSUB HTMAIL   
TSTLT H1 35  
GOTO NOTHI   
TSTEQ RAM5 1  
GOTO NOTHI   
SET RAM5 1  
EMAIL EM7   
NOTHI:
TSTGT H1 40  
GOTO LOOP   
TSTEQ RAM5 0  
GOTO LOOP   
SET RAM5 0  
EMAIL EM8   
GOTO LOOP   
END    
 
CHKHEAT:
TSTEQ TS1 0  
GOTO FAILTS1   
CALLSUB OKTS1   
TSTLT CT 5:15:0  
GOTO THERMO05   
TSTLT CT 8:0:0  
GOTO THERM58   
TSTLT CT 12:0:0  
GOTO THERM0812   
TSTLT CT 17:0:0  
GOTO THERM1217   
THERM1723:
TSTLT T1 710  
SET OP2 1  
TSTGT T1 720  
SET OP2 0  
RET    
 
THERMO05:
TSTLT T1 700  
SET OP2 1  
TSTGT T1 710  
SET OP2 0  
RET    
 
THERM58:
TSTLT T1 710  
SET OP2 1  
TSTGT T1 720  
SET OP2 0  
RET    
 
THERM0812:
TSTLT T1 710  
SET OP2 1  
TSTGT T1 720  
SET OP2 0  
RET    
 
THERM1217:
TSTLT T1 710  
SET OP2 1  
TSTGT T1 720  
SET OP2 0  
RET    
 
FAILTS1:
SET OP2 0  
TSTEQ RAM4 0  
RET    
 
EMAIL EM4   
SET RAM4 0  
RET    
 
OKTS1:
TSTEQ RAM4 1  
RET    
 
EMAIL EM6   
SET RAM4 1  
RET    
 
HTMAIL:
TSTEQ OP2 1  
GOTO HTON   
HTOFF:
TSTEQ RAM3 0  
RET    
 
EMAIL EM3   
SET RAM3 0  
RET    
 
HTON:
TSTEQ RAM3 1  
RET    
 
EMAIL EM2   
SET RAM3 1  
RET    
 
CHKIP2:
TSTEQ IP2[500] 1  
GOTO ONIP2   
GOTO CHKIP2END   
ONIP2:
TSTEQ RAM2 1  
GOTO CHKIP2END   
SET OP1 1  
EMAIL EM5   
SET RAM2 1  
CHKIP2END:
TSTEQ OP1[1000] 1  
SET OP1 0  
TSTEQ IP2[500] 0  
SET RAM2 0  
RET    
 
CHKIP3:
TSTEQ IP3[500] 1  
GOTO ONIP3   
GOTO CHKIP3END   
ONIP3:
TSTEQ RAM1 1  
GOTO CHKIP3END   
EMAIL EM1   
SET RAM1 1  
CHKIP3END:
TSTEQ IP3[500] 0  
SET RAM1 0  
RET    
 
siafu said:
this sort of works,
 
I get one email when the H1 goes high, but then I get many emails when H1 goes low. About 15 emails of H1 is low.
 
START    
SET RAM1 0  
SET RAM2 0  
SET RAM3 0  
SET RAM4 0  
LOOP:
CALLSUB CHKIP2   
CALLSUB CHKIP3   
CALLSUB CHKHEAT   
CALLSUB HTMAIL   
TSTLT H1 35       <<-----
GOTO NOTHI   
TSTEQ RAM5 1  
GOTO NOTHI   
SET RAM5 1  
EMAIL EM7   
NOTHI:
TSTGT H1 40    <<--------
GOTO LOOP   
TSTEQ RAM5 0  
GOTO LOOP   
SET RAM5 0  
EMAIL EM8   
GOTO LOOP   
END    
 
 
You have the HIGH threshold lower than the LOW threshold. Reduce the 40 to something significantly less than 35, or increase the 35 to something significantly more than 40!
 
Thank you Ross, that appears to have fixed the issue with multiple emails one of the Webcontrol and the humidity code incorporated in with my other codes.
 
But I found a problem with my other webcontrol and the humidity code, the one that I initially said it was working.
 
Below is the entire code in the webcontrol. Everything appeared to be working, but then it did not execute the code below, like turn on Glight and Blight. So I modified the goto loop to make it go to Glight. But then again when humidity goes below 25, I get continuous email non stop. 
 
Can you please have a look at the code below and advise what needs changing?
 
 
START    
LOOP:
TSTLT H1 30  
GOTO NOTHI   
TSTEQ RAM1 1  
GOTO NOTHI   
SET RAM1 1  
EMAIL EM5   
NOTHI:
TSTGT H1 25  
GOTO GLIGHT   
TSTEQ RAM1 0  
SET RAM1 0  
EMAIL EM6   
GOTO GLIGHT   
GLIGHT:
TSTLT CYEAR 2017  
GOTO BLIGHT   
TSTGE CT 5:0:0 VAR3 
TSTLT CT 23:59:0 VAR3 
NOP    
SET OP3 VAR3  
TSTEQ VAR4 VAR3  
GOTO BLIGHT   
TSTEQ VAR3 1  
EMAIL EM7   
TSTEQ VAR3 0  
EMAIL EM8   
SET VAR4 VAR3  
BLIGHT:
TSTLT AIP1 100  
SET OP1 1  
TSTGT AIP1 110  
SET OP1 0  
TSTLT T3 1050  
SET OP2 1  
TSTGT T3 1140  
SET OP2 0  
XOR OP1 VAR1  
BZ  TEMPTEST  
TSTEQ OP1 1  
EMAIL EM1   
TSTEQ OP1 0  
EMAIL EM2   
TEMPTEST:
XOR OP2 VAR2  
BZ  DONE  
TSTEQ OP2 1  
EMAIL EM3   
TSTEQ OP2 0  
EMAIL EM4   
DONE:
SET VAR1 OP1  
SET VAR2 OP2  
END    
 
siafu said:
Thank you Ross, that appears to have fixed the issue with multiple emails one of the Webcontrol and the humidity code incorporated in with my other codes.
 
But I found a problem with my other webcontrol and the humidity code, the one that I initially said it was working.
 
Below is the entire code in the webcontrol. Everything appeared to be working, but then it did not execute the code below, like turn on Glight and Blight. So I modified the goto loop to make it go to Glight. But then again when humidity goes below 25, I get continuous email non stop. 
 
Can you please have a look at the code below and advise what needs changing?
 
 
START    
LOOP:
TSTLT H1 30  
GOTO NOTHI   
TSTEQ RAM1 1  
GOTO NOTHI   
SET RAM1 1  
EMAIL EM5   
NOTHI:
TSTGT H1 25  
GOTO GLIGHT   
TSTEQ RAM1 0  
goto glight    <<-------- this one is missing
SET RAM1 0  
EMAIL EM6   
GOTO GLIGHT   <<------- and this one doesn't need to be here.
GLIGHT:
 
Back
Top