Quote Originally Posted by andybarrett1 View Post
Hi.. Looking for a bit of help … Again :-)

I have a temperature monitoring design all working fine but I am attempting to filter a low temp alarm (A little like a hysteresis window). In my case "temp" has to be <=2 degrees for 5 seconds before I jump to the alarm label.

At moment as soon as it sees 2degrees alarm condition.

My Code:-
Code:
START:

IF temp <2 THEN
FOR COUNTBYTE = 0 TO 9
PAUSE 500
IF temp >2 THEN START
NEXT COUNTBYTE
GOTO ALARM
END IF
I am assuming that if I sample and act 10 x 500ms this will do as I think….

As usual comments / help advice welcome

Thank you for reading

Andy
"IF temp >2 THEN START" will never happen as temp will not change within the loop. You need to take a new temp reading before the IF temp>2 test. Another way is to set an alarm flag and increment it so when alarm flag >8 goto alarm.

Code:
InAlarm var Byte

START:
.
.
read temp routine
.
.
IF temp <2 THEN
InAlarm=InAlarm+1
PAUSE 500
If InAlarm>8 then ALARM
ELSE
InAlarm=0
Goto START
END IF