Stopping repeated messages


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2010
    Posts
    24

    Default Stopping repeated messages

    Currently the pic we are working with monitors pin status and sends a simple string out when one of them is pulled high. The problem I am having now is that the pic repeats the proper code over and over while the pin is still high. I need a suggestion on how to get the pic to send the message once and then go back to monitoring the rest of the pins even while the first one is high and NOT repeat the first one or any other that is triggered more then once. I need it to be able to repeat the same procedure for other pins if they also go high. Once the pins go low, it can go back to normal.

    If it would be easier, it is being sent to a VB application and I can deal with it on that side if the coding would be easier.

    Code:
    Basic idea of what I have now.
    
    :Watch
    if Portb.1 then Alarm1
    if Portb.2 then Alarm2
    if Portb.3 then Alarm3
    Goto Watch
    
    :Alarm1
    HSerout [Blah Blah]
    goto watch

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Stopping repeated messages

    set a flag to indicate the old status of the port pin. If the port goes high, and the flag is low, send the alarm and set the flag high. If the flag is high, ignore the port. When the port goes low, clear the flag
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Jan 2010
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: Stopping repeated messages

    What about setting a variable in the EEPROM that is checked when sent to Alarm1 and if it is already set return to Watch? Have it monitor for pin low as well as high and clear the value in memory if low?

  4. #4
    Join Date
    Jan 2010
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: Stopping repeated messages

    Quick reply CNC. Thank you.

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Stopping repeated messages

    EEPROM will get pretty tired of all the writes. If you don't need it to be persistent when powered off, just use ram
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Jan 2010
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: Stopping repeated messages

    I'm still learning Picbasic but could you give me an example of setting a simple flag? Something like Zone1Alarm = True when triggered then Zone1Alarm = false when cleared.

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Stopping repeated messages

    I usually have at least 1 byte dedicated to flagss, so
    Code:
    myflags var byte
    then to set up the flags its just this:
    Code:
    alarm1F var myflags.0
    alarm2F var myflags.1
    alarm3F var myflags.2
    ...
    then to use them it is this simple:
    Code:
    alarm1F = 1
    alarm2F = 0
    ...
    
    or 
    myflags = 0 'this clears all flags
    then for you case:
    Code:
    if portb.0 then 
     gosub alarm1
    else
     alarm1F = 0
    endif
    ...
    return
    
    
    alarm1:
     if alarm1F then return
     alarm1F = 1
     hser bla bla bla
    hope that helps
    Last edited by cncmachineguy; - 20th October 2011 at 19:38.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  8. #8
    Join Date
    Jan 2010
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: Stopping repeated messages

    Pure Gold! Thank you!

Members who have read this thread : 1

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

Posting Permissions

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