Valid data checking help please… Hysteresis Question ?


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Valid data checking help please… Hysteresis Question ?

    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

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Valid data checking help please… Hysteresis Question ?

    Close, can't monitor during PAUSE 500.

    Code:
    InAlarm var WORD
    LOOP VAR WORD
    
    START:
    .
    .
    ' Tweak 5000 value to take into account
    ' time to take temp reading.
    .
    .
    InAlarm=0
    FOR LOOP= 1 TO 5000      ' Loop 5 seconds
    ...READ TEMP
      IF temp <2 THEN
        InAlarm=InAlarm+1
        PAUSE 1           ' Pause 1 millisecond
      ELSE
        InAlarm=0
        LOOP=5555      'Reset loop
      ENDIF
    NEXT LOOP
    IF InAlarm=5000 THEN ALARM     ' Check if InAlarm incremented during entire 5 seconds
    GOTO START
    Personally, I'd use a timer in Darrel's instant interrupts to control 5 second lapse.

    Robert
    Last edited by Demon; - 24th July 2014 at 01:26. Reason: GOTO out of Code section, missing pause 1, comments

Similar Threads

  1. Is this a valid statement?
    By dbachman in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th February 2017, 19:34
  2. hysteresis control
    By hyeniyurt in forum Off Topic
    Replies: 0
    Last Post: - 25th February 2009, 23:37
  3. Hysteresis.. How to do it??
    By hoopstar in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2007, 01:35
  4. help with error checking GPS data over audio link
    By MUC in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st February 2005, 21:23
  5. Long Delays - Is there a valid way?
    By rad in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 29th December 2003, 11:52

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts