Maths

#1
Evening all I'm having a play again, always find the best way to learn is a bit of trial and error but I can't work out the below if any of you can help.

I currently have the below in a piece of code and it works fine

Code:
Temp_Check_1A:
readtemp C.7, b1                'Read the DS18B20 temperature
pause 500                   
sertxd(#b1,"c  Water Temp",13,10)
if b1 >= 80 then Up_Temp
if b1 >= 55 then Temp_Check_1B
if b1 <= 54 then Burner_Up_Ramp
This works fine but as I say I've been having a play and I cannot get the -1 to work.

Code:
b2 = 80
b3 = 55

Temp_Check_1A:
readtemp C.7, b1                'Read the DS18B20 temperature
pause 500                   
sertxd(#b1,"c  Water Temp",13,10)
if b1 >= b2 then Up_Temp
if b1 >= b3 then Temp_Check_1B
if b1 <= b3 - 1 then Burner_Up_Ramp
it's the last line that returns an error and I can't fathom it
 

Pongo

Senior Member
#2
It can't handle the calculation within the "if"
Code:
b3 = b3 - 1
if b1 <= b3 - 1 then Burner_Up_Ramp
Or you could just do:

Code:
if b1 < b3 then Burner_Up_Ramp
Which would have the same effect.
 

AllyCat

Senior Member
#3
Hi,

Yes, as Pongo says: if b1 <= b3 - 1 then is not a valid syntax in PICaxe Basic (although it is in many other languages). The command reference defines only the conditions variable comparison value and variable comparison variable , but NOT variable comparison expression.

Cheers, Alan..
 

hippy

Technical Support
Staff member
#6
Code:
if b1 >= b3 then Temp_Check_1B
if b1 <= b3 - 1 then Burner_Up_Ramp
The first checks for "b1 >= b3" so, after that, you know that "b1 <= b3-1" must be true if it gets that far. So -
Code:
if b1 >= b3 then 
  goto Temp_Check_1B
else
  goto Burner_Up_Ramp
end if
 
Top