#picaxe 20m2
symbol DAY = b0
symbol HOUR = b1
symbol HEAT = b2
for b0 = 1 to 7
sertxd(13,10,"D",#b0)
for b1 = 1 to 24
b2 = 0
IF DAY=$1 OR DAY=$7 AND HOUR>=$09 AND HOUR <=$17 THEN
LET HEAT=19
END IF
sertxd(" ",#b2)
next b1
next b0
D1 0 0 0 0 0 0 0 0 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 0
D2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
D3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
D4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
D5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
D6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
D7 0 0 0 0 0 0 0 0 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 0
I have re-written all of my lines as you suggest. It works fine in the simulator. I will download the code to my thermostat and give it a tryI might write that as:
If Day=$1 Or Day=$7 Then
If Hour>=$09 And Hour <=$17 Then
Let Heat =19
Return
EndIf
EndIf
It is possible your version is not being interpreted in that way.
It is something I have always done using the following code. I can enter actual time (0-23) and date values (0 to 31)I'm intrigued as to why your HOUR would ever be >= $18 (=24 decimal) and anything other than <= $23 (=35 decimal).
As tmfkam and InglewoodPete imply, it is better not to write complicated mixed conditionals. It is clearer (and safer) to break them up into smaller bits which have no ambiguity.
i2cslave %11010000, i2cslow, i2cbyte
hi2cin 0,(SECONDS,MINS,HOUR,DAY,DATE,MONTH,YEAR)
BCDTOASCII DATE,DATE_T,DATE_U
BCDTOASCII HOUR,HR_T,HR_U
BCDTOASCII MINS,MIN_T,MIN_U
BCDTOASCII SECONDS,SEC_T,SEC_U
Are you sure? If so, this is a bug in the simulator and ought to be reported. You will need to put in SERTXDs to show that the same "inputs" produce different "outputs" for the chip and the simulator.It jumps to the next line of code which turns the HEAT up to 20 after 17:00 hours.
It too works in my simulator but not in 'real life'
Most RTCs which picaxers play with return values as BCD (Binary Coded Decimal), so the hex value $18 means 18 hours, not the 24 you would expect if looking at the decimal value.I'm intrigued as to why your HOUR would ever be >= $18 (=24 decimal) and anything other than <= $23 (=35 decimal).