Cai Webcontrol as true thermostat

Just be aware that if you do the modification to the program as listed above it will "lock-up" the plc program in an endless loop (until you fix the temp sensor). This isn't a problem if the only thing the plc code is doing is controlling your heater. But, if you add other tasks, they may stop working as well, depending on how you write them in. If the temp sensor fails, the only lines of code that will get run are the ones between SKIP_HEATR: branch and the GOTO SKIP_HEATR line.


Hello Lou and thank you for the information.

As I am running additional programs besides the heater, the code suggested by Cai is appears correct as far as I can tell from your explanation and if the temp sensor was to fail the only code was to run (hopefully correctly) would be the one I've marked below in red, anything else is related to the heater and would be skipped, right?

START
TSTLT CT 5:0:0
CALLSUB THERMO05
TSTLT CT 8:0:0
CALLSUB THERM58
TSTLT CT 17:0:0
CALLSUB THERM0817
TSTLT CT 23:59:59
CALLSUB THERM1723
SKIP_HEATR:
TSTEQ TS1 0
SET OP2 0
TSTEQ OP2 1
CALLSUB MAILON
TSTEQ OP2 0
CALLSUB MAILOFF
TSTEQ OP1[1000] 1
SET OP1 0
TSTGT IP1 0 EM1
NOP
TSTEQ TS1 0
goto SKIP_HEATR

END
 
Yes, the red lines would run over and over again as long as ts1 = 0. Any subroutines that you inserted in there would also be run, so if you wanted a subroutine to run despite the temp sensor being broken, you would need to insert the call for the subroutine from within the red area.
 
Yes, the red lines would run over and over again as long as ts1 = 0. Any subroutines that you inserted in there would also be run, so if you wanted a subroutine to run despite the temp sensor being broken, you would need to insert the call for the subroutine from within the red area.


Hi Lou,

Please see below.

I think I set it up correctly to send an email (email 4) when temp sensor 1 has failed (0) I used VAR 3 and 4 for this, so it does not constantly send email to tell me that TS1 has failed, is this look right?

Also, how do I set the VAR's (3 and 4) to reset back to where they were before the TS1 error? So they are ready to send one email again on the next TS1 error, not sure how to do this.

START
TSTLT CT 5:0:0
CALLSUB THERMO05
TSTLT CT 8:0:0
CALLSUB THERM58
TSTLT CT 17:0:0
CALLSUB THERM0817
TSTLT CT 23:59:59
CALLSUB THERM1723
SKIP_HEATR:
TSTEQ TS1 0
SKIP_HEATR:
TSTEQ TS1 0
SET OP2 0
TSTEQ OP2 1
CALLSUB MAILON
TSTEQ OP2 0
CALLSUB MAILOFF
TSTEQ OP1[1000] 1
SET OP1 0
TSTGT IP1 0
CALLSUB DOORMAIL
NOP
TSTEQ TS1 0
CALLSUB MAILER
goto SKIP_HEATR
END


THERMO05:
TSTLT T1 680
SET OP2 1
TSTGT T1 690
SET OP2 0
RET

THERM58:
TSTLT CT 5:0:0
RET

TSTLT T1 710
SET OP2 1
TSTGT T1 720
SET OP2 0
RET

THERM0817:
TSTLT CT 8:0:0
RET

TSTLT T1 690
SET OP2 1
TSTGT T1 700
SET OP2 0
RET

THERM1723:
TSTLT CT 17:0:0
RET

TSTLT T1 710
SET OP2 1
TSTGT T1 720
SET OP2 0
RET

MAILON:
SET VAR2 0
TSTEQ VAR1 0
GOTO MAILON1
RET

MAILON1:
EMAIL EM2
SET VAR1 1
RET

MAILOFF:
SET VAR1 0
TSTEQ VAR2 0
GOTO MAILOFF1
RET

MAILOFF1:
EMAIL EM3
SET VAR2 1
RET

DOORMAIL:
EMAIL EM1
RET

MAILER:
SET VAR4 0
TSTEQ VAR3 0
GOTO MAILER1
RET

MAILER1:
EMAIL EM4
SET VAR3 1
RET
 
Hi Siafu,

I did not see Lou reply, so I will put my answer here for you. You have three ways to clear that:
1) do it in program, automatically clear it when it sees the sensor okay again;
2) do it in program, using one TTL input hook up a reset button. When pushed, it will cause PLC to reset the VAR value for you;
3) do it in browser to issue a setvar.cgi command, which you can specify zero value in the browser.

http: //192.168.1.15 /api/setvar.cgi?varid=3&value=0

will set var3 value to zero, when WebControl PLC is on IP address 192.168.1.15. Sorry I have to add space to break the line, otherwise the IP board software will be collapsed into a shorter line, then you will not see it all. It should have no space in the line.
 
Hi Siafu,

I did not see Lou reply, so I will put my answer here for you. You have three ways to clear that:
1) do it in program, automatically clear it when it sees the sensor okay again;
2) do it in program, using one TTL input hook up a reset button. When pushed, it will cause PLC to reset the VAR value for you;
3) do it in browser to issue a setvar.cgi command, which you can specify zero value in the browser.

http: //192.168.1.15 /api/setvar.cgi?varid=3&value=0

will set var3 value to zero, when WebControl PLC is on IP address 192.168.1.15. Sorry I have to add space to break the line, otherwise the IP board software will be collapsed into a shorter line, then you will not see it all. It should have no space in the line.

Hello Cai.

so the program for option one, would be like this?

TSTEQ T1 OK
SET VAR3 0

if the above is correct, where would i put that? In the main body or in a sub?
 
Hi Siafu,

TSTEQ and other test operator checking the value. You code will work if you change the OK to 1.

TSTEQ T1 1
SET VAR3 0

However, in your main program last few lines may have problem:
START
...
TSTEQ TS1 0
CALLSUB MAILER
goto SKIP_HEATR
END

It will check if TS1 failed. If failed, it will
CALLSUB MAILER
However, does not matter TS1 is 0 (failed) or 1(good), your program will always execute this line:
goto SKIP_HEATR
which is not what you wanted. You should move the "goto SKIP_HEATR" into your mailer subroutine.

Hope this helps.
 
Hello Cai,

Thank you,

Please see below entire program, please let me know if this looks right. I haven't tested this in the wevbcontrol yet.

START
TSTLT CT 5:0:0
CALLSUB THERMO05
TSTLT CT 8:0:0
CALLSUB THERM58
TSTLT CT 17:0:0
CALLSUB THERM0817
TSTLT CT 23:59:59
CALLSUB THERM1723
SKIP_HEATR:
TSTEQ TS1 0
SKIP_HEATR:
TSTEQ TS1 0
SET OP2 0
TSTEQ OP2 1
CALLSUB MAILON
TSTEQ OP2 0
CALLSUB MAILOFF
TSTEQ OP1[1000] 1
SET OP1 0
TSTGT IP1 0
CALLSUB DOORMAIL
NOP
TSTEQ TS1 0
CALLSUB MAILER
TSTEQ TS1 1
CALLSUB SETVAR3
END


THERMO05:
TSTLT T1 680
SET OP2 1
TSTGT T1 690
SET OP2 0
RET

THERM58:
TSTLT CT 5:0:0
RET

TSTLT T1 710
SET OP2 1
TSTGT T1 720
SET OP2 0
RET

THERM0817:
TSTLT CT 8:0:0
RET

TSTLT T1 690
SET OP2 1
TSTGT T1 700
SET OP2 0
RET

THERM1723:
TSTLT CT 17:0:0
RET

TSTLT T1 710
SET OP2 1
TSTGT T1 720
SET OP2 0
RET

MAILON:
SET VAR2 0
TSTEQ VAR1 0
GOTO MAILON1
RET

MAILON1:
EMAIL EM2
SET VAR1 1
RET

MAILOFF:
SET VAR1 0
TSTEQ VAR2 0
GOTO MAILOFF1
RET

MAILOFF1:
EMAIL EM3
SET VAR2 1
RET

DOORMAIL:
EMAIL EM1
RET

MAILER:
SET VAR4 0
TSTEQ VAR3 0
GOTO MAILER1
RET

MAILER1:
EMAIL EM4
SET VAR3 1
goto SKIP_HEATR
RET

SETVAR3:
TSTEQ TS1 1
SET VAR3 0
RET
 
Hi Saifu,

Sorry for the late reply. The change you made probably not going to work, because you moved

goto SKIP_HEATR
into MAILER1: subroutine.

Your following subroutines:
MAILER:
SET VAR4 0
TSTEQ VAR3 0
GOTO MAILER1
RET

MAILER1:
EMAIL EM4
SET VAR3 1
goto SKIP_HEATR
RET
should be changed to:
MAILER:
SET VAR4 0
TSTEQ VAR3 0
callsub MAILER1
goto SKIP_HEATR
RET
MAILER1:
EMAIL EM4
SET VAR3 1
RET
Hope this helps.
 
Hello Cai,

I tested the above program, and all appears to be working, if I unbound the temperature (to emulate temp sensor failed) the heat is turned off and I get email stating heat off because temp sensor failed.

Thank you very much for the help.

I have additional temp sensors, and would like to hook them up to the board, but when I hood more than one, nothing works properly, all temps are not accurate, and they jump to fail and back on and forth.

How can I have more than one temp sensor hooked up to the board at one time?

Thanks for your help.
 
I read that I would need a 4.7k resistor and an external power supply to be able to ad additional temp sensors.

I tried, but still does not work. At best it gets to see the serial number of the sensor, but then it locks up, like the temperature is stuck.

The way I tried this is via 2 wires, because in the location where I need to put this additional temp sensor I only have to wires left. So I jumped pin 1 and 3, and ran them on one wire, and pin 2 on it's own on one wire. at the other end (board end) I hooked up the 4.7 resistor to the data line (pin2) and gave it 4.5 volts of power then plugged into pin 2 of the board, the other line I plugged into the gnd pin of the board. But like I said I can only get to see the serial number of the sensor, like it's detecting it, but nothing much else happens.

If the above scenario is incorrect (as it might be, because it's not working) can someone let me know the correct one on how to get it working via two wires and external power?

I have the humidity sensor working on separate wires in the same location, with 3 wire hookup.
 
Hi Siafu,

If you board is HW 2.0.2, you may use humidity sensor wire to power the temperature sensors, that will provide higher voltage to the temp sensors. When our engineers designed the 2.0.2 board, they thought the Maxim spec saying the temp sensor can work as low as 2.7V. But in reality, even 3V supply does not work well. One simply way to work on that situation is to use humidity sensor 5V to power the temp sensors.

WebControl does not allow using parasite sensor, due to its 1-wire bus busy pulling devices. During temperature conversion, each sensor will have 980mS to finish conversion. To have all sensors pulled, that will take 8 seconds. Besides, we plan to support other 1-wire devices they do not work on bus running in parasite mode. Parasite mode use the data line to power the sensors during conversion, so that you can not do anything on the bus during 980mS conversion time.

You could use the humidity sensor's power line also power the temp sensors. That should work okay. If you have a few temp sensors, it may be better to remove the protection diode on the back of the board-- if your board is HW 2.0.2. In hw V2.2.2, both temp sensor and humidity sensors are using same 5V power without the diodes.

Please let us know if this helps.
 
Hello Cai.

I'm not sure what HW version I have, the only thing I can see if the "Version: v03.01.04"

I hooked up the one temp sensor to the humidity power, and it appears to be working, I also hooked up the humidity sensor to same power and both appear to be working fine. I tested the temp power supply and it's 2.7 volts, this is how I had it hooked up before, but I didn't see any problem hooked up to the 2.7 power before, but you say it's not working correctly on 2.7 volt power?

The problem I'm facing is with the other temp sensor that runs into another room, that I have only a cable with 5 wires. So the temp sensor works hooked up to 3 wires, but that only gives me 2 wires and was looking into a way to get reading from that room (to a second temp input) via the two wires, but you say that this is not possible with this temp sensor.

What about the humidity sensor, can it run on two wires only? Then I can use the 3 wires for the second temp sensor..

Thank you for your help.
 
Hardware version is printed on the silver screen on the PCB. The firmware version is what you see in the browser.

Hardware version 2.0.2 has protection diode on both temperature sensor and humidity sensor, to protect sensors in case they wired wrong. But the protection diode adding certain voltage drop to the power line. We removed those protection diodes in the hardware rev 2.2.2. You can safely remove the protection diode and simply short the two pins under D9.

You can have those humidity and temperature sensors sharing power line between them, that way, five wires will be enough.
 
Hello Cai,

Both my boards are Version 2.0.2.

I hooked up one temperature sensor and the humidity sensor to the power supply of the humidity senso, and all appears to be working fine. However, when I hook up a second temperature sensor then the temp sensors do not work any longer.

My goal is to have one temp sensor in my room, another in another room, and one outside, and one humidity sensor all work together, but so far, I can only can get it to work with two sensors hooked up at one time.

You mention that the diode could be a a potential power drainer? If I was to remove the diode at D9 do you believe that there would be enough power to drive the 4 sensors? (3 temp sensors and one humidity sensor?

Another option would be to power some of the sensors from a dedicated power supply, but I'm not sure how this would be wired and what power supply I would need.

Thank you for any suggestions and continued help.
 
Back
Top