Valid data checking help please… Hysteresis Question ?


+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Angry Valid data checking help please… Hysteresis Question ?

    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:-

    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

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825

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

    Temp must be the differential from setpoint - reading. So this could be a solution:


    Allarm_Validation:
    For a0 = 1 to 500
    Pause 1
    Next a0
    If temp <= 2 then
    time_count = time_count + 1
    If time_count >= 10 then gosub allarm_label
    Count = 0
    Flag_alrm = 1
    Else
    time_count = 0
    Flag_alrm = 0
    ENDIF

    Cheers

    Al.
    All progress began with an idea

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

    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

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,255

    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

  5. #5
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

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

    HI..

    Thank you for all suggestions of code examples....

    Am away from the issues till next week.... Hot Sticky Queen Anne Blast furnace in Scunthorpe UK

    Will try them and update when I get back..... Or any suggestions for a simulator.

    As yet have seen them but easier to build and prove. But simulation looks interesting

    Thank you
    Andy

  6. #6
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

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

    Thank you Robert and Steve

    A mixture of both your suggestions got me more or less on the right track…. I "Think" it is working now.

    Thank you others as well …. Software is not my strong point
    If I can't measure what it doing with a Fluke I find it difficult

    So Thank you

  7. #7
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305

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

    I know how you feel about using a Fluke. Trying to explain it to some of my bosses the difference between analog and digital troubleshooting is even tougher.

    More importantly though, you get to work on a blast furnace? Do you use any of your programming abilities? Are PICs involved in any way?

    Best wishes.

  8. #8
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

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

    I get to work on a Blast furnace yes....

    There are 4 furnaces at Scunthorpe UK.... We are presently getting one back up and running (Queen Anne).

    Unfortunately pics are not used ....not where I am anyway. Probably due to my lack of programming abilities. :-) I

    I look after the weighing.... mostly Analogue.. SG's

    So Mv and V little bit of mA.... Serial / Profi and Modbus...

    BR



    Andy

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

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

    Any chance of playing with that big "1200 tonne" crane?

    Anyone that looks after the four Queens is a friend to all in Sunny Scunny.

    Keep asking the questions and programing help will hopefully be provided.

  10. #10
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

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

    Quote Originally Posted by EarlyBird2 View Post
    Any chance of playing with that big "1200 tonne" crane?
    I wouldn't mind having a go with that myself....

    I have been close during lift ops..... :-)

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

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