Help with IR controlled Thermostat
jsaddiction
Posts: 84
new thermostat.bs2
Hello I am new to the forum and new to programming but I have learned alot along the way. This is my first project meant for a permanent solution so I am really trying to work out all the little bugs. I have a BS2 a 1620 temp sensor a photo cell an IR reciever and a universal remote programmed for the sony protocal. I have wrote some of this code and coppied some from examples i found on the internet. It works pretty well with the exception of one kind of major problem. The main routine will run well untill it sees some IR and then it goes into the temp entry sub routine. It will then check to see what the command from the remote is and apply it to the desired temperature. Problem is if it sees a remote code and it is not a command from the sony protocol it will stay in the temp entry or the get remote code subroutine (not sure which) I guess what i need is to set up a way to verify a sony protocol and if it isn't return to the main routine.
Thanks in advance for any insite on this issue. Sorry the code is kind of scrambled I tried to keep it somewhat clean.
Hello I am new to the forum and new to programming but I have learned alot along the way. This is my first project meant for a permanent solution so I am really trying to work out all the little bugs. I have a BS2 a 1620 temp sensor a photo cell an IR reciever and a universal remote programmed for the sony protocal. I have wrote some of this code and coppied some from examples i found on the internet. It works pretty well with the exception of one kind of major problem. The main routine will run well untill it sees some IR and then it goes into the temp entry sub routine. It will then check to see what the command from the remote is and apply it to the desired temperature. Problem is if it sees a remote code and it is not a command from the sony protocol it will stay in the temp entry or the get remote code subroutine (not sure which) I guess what i need is to set up a way to verify a sony protocol and if it isn't return to the main routine.
Thanks in advance for any insite on this issue. Sorry the code is kind of scrambled I tried to keep it somewhat clean.
Comments
Please post your code and let see what up and maybe we can help you with it
Also revise your usage of RCTIME in DO / LOOP
See RCTIME command - state parameter
"State is a variable/constant/expression (0 - 1) that specifies the desired state to measure. Once Pin is not in State, the command ends and stores the result in Variable. "
Here is a simple test - reads state od pin 0 once:
DEBUG ? IrDet
DEBUG BIN16 ? INS
DEBUG ? irPulse
'DO
RCTIME IrDet, 0, irPulse
DEBUG ? IrDet
DEBUG ? irPulse
'STOP
'LOOP UNTIL irPulse > 1100
DEBUG BIN16 ? INS
DEBUG "stop",CR
STOP
Vaclav
Second - the temperature conversion algorithm is incorrect - remember that BS uses integer math only.
It works... I put everything into sub routines and then interlaced the functions so that it would respond to the remote commands better.
Also with the temperature calculation. I thought that because the BS2 only works with interger math that it would just trunicate the decimal if the calculation resulted in one. is there a better way to do it? more precision with bs2 and the interger limitation?
Edit your original post - use "edit" " go advanced" and select from pull down box. ( upper left corner I believe)
By the way your temparatire conversion constant is also wrong.
Here is one way to get fractions into the conversion .