Cai Webcontrol as true thermostat

Great!
In your first subroutine:
THERM005:
TSTLT CT 0:0:1
GOTO THE05SKIP
TSTLT T1 680
CALLSUB HEAT_ON
TSTGT T1 690
CALLSUB HEAT_OFF
THE05SKIP:
RET

You don't have to test for 0:0:1, since that will include all time from 0:0:0
without TSTLR CR 0:0:1 and next line GOTO THE05SKIP and the THE05SKIP: label.

In your
THERM0817:
TSTLT CT 0:0:0
GOTO TH817SKIP
TSTLT T1 690
CALLSUB HEAT_ON
TSTGT T1 700
CALLSUB HEAT_OFF
TH817SKIP:
RET

I think you mean "TSTLT CT 8:0:0"

And in your
THERM1723:
TSTLT CT 17:0:0
GOTO THE58SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
THE58SKIP:
RET

The goto label and label itself should probably THE2359SKIP, instead of reuse THE58SKIP.
Please note labels are global, even in subroutines.
 
Great!
In your first subroutine:
THERM005:
TSTLT CT 0:0:1
GOTO THE05SKIP
TSTLT T1 680
CALLSUB HEAT_ON
TSTGT T1 690
CALLSUB HEAT_OFF
THE05SKIP:
RET

You don't have to test for 0:0:1, since that will include all time from 0:0:0
without TSTLR CR 0:0:1 and next line GOTO THE05SKIP and the THE05SKIP: label.

In your
THERM0817:
TSTLT CT 0:0:0
GOTO TH817SKIP
TSTLT T1 690
CALLSUB HEAT_ON
TSTGT T1 700
CALLSUB HEAT_OFF
TH817SKIP:
RET

I think you mean "TSTLT CT 8:0:0"

And in your
THERM1723:
TSTLT CT 17:0:0
GOTO THE58SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
THE58SKIP:
RET

The goto label and label itself should probably THE2359SKIP, instead of reuse THE58SKIP.
Please note labels are global, even in subroutines.

Sorry not sure why it did not post correctly, but that's what I meant,

Please see below.

I had to make some small adjustments to the GOTO lines as I get an error as I can only use a max of 10 characters, but even that's not true, it's actually 9 max from what I can tell.


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

THERM005:
TSTLT CT 0:0:0
GOTO THE05SKIP
TSTLT T1 680
CALLSUB HEAT_ON
TSTGT T1 690
CALLSUB HEAT_OFF
THE05SKIP:
RET

THERM58:
TSTLT CT 5:0:0
GOTO THE58SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
THE58SKIP:
RET

THERM0817:
TSTLT CT 8:0:0
GOTO TH817SKIP
TSTLT T1 690
CALLSUB HEAT_ON
TSTGT T1 700
CALLSUB HEAT_OFF
TH817SKIP:
RET

THERM1723:
TSTLT CT 17:0:0
GOTO T1723SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
T1723SKIP:
RET

HEAT_ON:
SET OP2 1
RET

HEAT_OFF:
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
 
It will work. Just in this subroutine, you don't have to put the check in:
THERM005:
TSTLT CT 0:0:0
GOTO THE05SKIP
TSTLT T1 680
CALLSUB HEAT_ON
TSTGT T1 690
CALLSUB HEAT_OFF
THE05SKIP:
RET


Since it starts from 0:0:0, you can just say:

THERM005:
TSTLT T1 680
CALLSUB HEAT_ON
TSTGT T1 690
CALLSUB HEAT_OFF
RET
 
It will work. Just in this subroutine, you don't have to put the check in:
THERM005:
TSTLT CT 0:0:0
GOTO THE05SKIP
TSTLT T1 680
CALLSUB HEAT_ON
TSTGT T1 690
CALLSUB HEAT_OFF
THE05SKIP:
RET


Since it starts from 0:0:0, you can just say:

THERM005:
TSTLT T1 680
CALLSUB HEAT_ON
TSTGT T1 690
CALLSUB HEAT_OFF
RET


Perfect, thank you for your help Cai.


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

THERM005:
TSTLT T1 680
CALLSUB HEAT_ON
TSTGT T1 690
CALLSUB HEAT_OFF
RET

THERM58:
TSTLT CT 5:0:0
GOTO THE58SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
THE58SKIP:
RET

THERM0817:
TSTLT CT 8:0:0
GOTO TH817SKIP
TSTLT T1 690
CALLSUB HEAT_ON
TSTGT T1 700
CALLSUB HEAT_OFF
TH817SKIP:
RET

THERM1723:
TSTLT CT 17:0:0
GOTO T1723SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
T1723SKIP:
RET

HEAT_ON:
SET OP2 1
RET

HEAT_OFF:
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
 
If you want to be fancy, you can also add sensor to measure airflow behind filter. Once the airflow reduced to certain level, you can program WebControl to send you an email for replacing filter.

Also, don't know what kind of heater do yoy use. If burner type, you could add carbon monoxide sensor to alert you the carbon monoxide level. Since carbon monoxide is leathal, your email alert need to be programmed sending once every few minutes, until the carbon monoxide level is low enough.

This kind of carbon monoxide sensor can be used with analog input:
http://www.ebay.com/itm/330576589322

You can program what analog input level WebControl will alert you.
 
Perfect, thank you for your help Cai.


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

THERM005:
TSTLT T1 680
CALLSUB HEAT_ON
TSTGT T1 690
CALLSUB HEAT_OFF
RET

THERM58:
TSTLT CT 5:0:0
GOTO THE58SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
THE58SKIP:
RET

THERM0817:
TSTLT CT 8:0:0
GOTO TH817SKIP
TSTLT T1 690
CALLSUB HEAT_ON
TSTGT T1 700
CALLSUB HEAT_OFF
TH817SKIP:
RET

THERM1723:
TSTLT CT 17:0:0
GOTO T1723SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
T1723SKIP:
RET

HEAT_ON:
SET OP2 1
RET

HEAT_OFF:
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


This program works but you it could be a lot more streamlined and shorter and do the exact same thing.

For example:
1) You have two subroutines with one action each. HEAT_ON and HEAT_OFF both have one line each, either set op2 to 1 or 0. You should skip the subroutine all together and just set the input directly.

2) You have a GOTO statement sending you to a branch which has a single RET command. Same concept as number 1, just skip the "goto" and the entire branch program and just put the ret in the place of the goto.

THERM1723:
TSTLT CT 17:0:0
GOTO T1723SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
T1723SKIP:
RET

HEAT_ON:
SET OP2 1
RET

HEAT_OFF:
SET OP2 0
RET



Would be the same as

THERM1723:
TSTLT CT 17:0:0
RET
TSTLT T1 710
SET OP2 1
TSTGT T1 720
SET OP2 0
RET

Also, since you are not using variables as your temp set points, you are needing to write a longer subroutines to set your temperature and you also have no way of manually over-riding the temps short of actually re-writing the program.
 
one more thing to consider if you have a gas furnace is to make sure you put in code to prevent the furnace from quick cycling as it can cause damage to the heat exchangers!
 
This program works but you it could be a lot more streamlined and shorter and do the exact same thing.

For example:
1) You have two subroutines with one action each. HEAT_ON and HEAT_OFF both have one line each, either set op2 to 1 or 0. You should skip the subroutine all together and just set the input directly.

2) You have a GOTO statement sending you to a branch which has a single RET command. Same concept as number 1, just skip the "goto" and the entire branch program and just put the ret in the place of the goto.

THERM1723:
TSTLT CT 17:0:0
GOTO T1723SKIP
TSTLT T1 710
CALLSUB HEAT_ON
TSTGT T1 720
CALLSUB HEAT_OFF
T1723SKIP:
RET

HEAT_ON:
SET OP2 1
RET

HEAT_OFF:
SET OP2 0
RET



Would be the same as

THERM1723:
TSTLT CT 17:0:0
RET
TSTLT T1 710
SET OP2 1
TSTGT T1 720
SET OP2 0
RET

Also, since you are not using variables as your temp set points, you are needing to write a longer subroutines to set your temperature and you also have no way of manually over-riding the temps short of actually re-writing the program.


Thank you Lou, I've implemented your suggestions, please see below.


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
TSTEQ OP2 1
CALLSUB MAILON
TSTEQ OP2 0
CALLSUB MAILOFF
TSTEQ OP1[1000] 1
SET OP1 0
TSTGT IP1 0 EM1
NOP
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
 
one more thing to consider if you have a gas furnace is to make sure you put in code to prevent the furnace from quick cycling as it can cause damage to the heat exchangers!


Thanks for warning, but this is for something else, something that has to heat an entire building, and as it may appear that one degree between on and off is too little time, it actually takes probably 30 minutes to an hour to make a one degree difference.
 
Siafu,

From firmware 3-1-4, WebControl adds a PLC I/O identifier, TSx, x ranges from 1 to 8. TS stands for Temp sensor Status. If the temp sensor failed, it will report 0. You could add logic to check temp sensor status, to see if that sensor is still responding. That way, if the temp sensor wire being cut by accident, you don't heat building forever, instead, sending an email to alert you. You can also hook up an external switch to one of the TTL input, as emergency stop, when that button pushed, PLC will turn off the heat.

Does the code you posted work now?
 
Siafu,

From firmware 3-1-4, WebControl adds a PLC I/O identifier, TSx, x ranges from 1 to 8. TS stands for Temp sensor Status. If the temp sensor failed, it will report 0. You could add logic to check temp sensor status, to see if that sensor is still responding. That way, if the temp sensor wire being cut by accident, you don't heat building forever, instead, sending an email to alert you. You can also hook up an external switch to one of the TTL input, as emergency stop, when that button pushed, PLC will turn off the heat.

Does the code you posted work now?


Hello Cai,

The latest code, with modification from Lou appears to be working, also the code you helped me with also appeared to be working, the code from Lou is just shorter, but looks like it's doing the same thing.

I would like to know how to implement this safety feature into my code, to be alerted if and or when the temp sensor goes dead.

How would I go about adding this feature?

Thanks in advance for your help.
 
Hi Siafu,

Your PLC program has these lines in the main function:
TSTEQ OP2 1
CALLSUB MAILON

You can add couple lines like that:
TSTEQ TS1 0
CALLSUB MAILON

That will send you the same email, in which TS1 status should be listed as failed.
If you want to have a seperate email subject and body message, you can create another email message in email screen, then add another MAILON1 subroutine to send that separate message.

If you want to automatically turn off heater, then you can modify your PLC main body:
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

These few lines added will 1) turn off heater relay on OP2, 2) skip all heater control functions; until the TS1 becomes 1 again.
 
Hi Siafu,

Your PLC program has these lines in the main function:
TSTEQ OP2 1
CALLSUB MAILON

You can add couple lines like that:
TSTEQ TS1 0
CALLSUB MAILON

That will send you the same email, in which TS1 status should be listed as failed.
If you want to have a seperate email subject and body message, you can create another email message in email screen, then add another MAILON1 subroutine to send that separate message.

If you want to automatically turn off heater, then you can modify your PLC main body:
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

These few lines added will 1) turn off heater relay on OP2, 2) skip all heater control functions; until the TS1 becomes 1 again.

Great, thank you Cai, will add the suggested to the program for safety measures.

Thanks again.
 
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.
 
Back
Top