SERIN2 - "Timeout" hangs if > 255


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    916

    Default SERIN2 - "Timeout" hangs if > 255

    Hello There,

    I have been working on a tiny GPS project and while I was tuning the code, I noticed that the timeout set to more than a value of 255 would always make the program hang (!).

    After googeling a few hours around, I couldn't find a specific answer to my "problem".

    Is this value limit mentionned somewhere in the docs or is there something wrong with my code?
    Attached Files Attached Files
    Roger

  2. #2
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Byte default?

    Quote Originally Posted by flotulopex View Post
    Is this value limit mentionned somewhere in the docs or is there something wrong with my code?
    I wonder if "Timeout" is defaulted to byte size and may need to be declared Word size before assigning a value to it?
    Louie

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Try
    Code:
    SERIN2 GPSfrom,Gpsbps,2500,NoGGA,[WAIT("$GPGGA")]
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    916


    Did you find this post helpful? Yes | No

    Default >255 will still hang

    Either declared as WORD or value stated in the command, if > 255 the program will hang....

    But I did some additional tests with value from 256 up to 999; from time to time, the program will resume. Nevertheless, the value expressed in milliseconds is never corresponding (time is far far longer, can last over minutes!).

    Values over 999, will make the program never resume.

    My circuit is simple:
    PIC16F690 - 4MHz Xtal
    GPS module GLOBALSAT em-406a + 10k pull-up on TX
    LCDisplay in 4bits mode

    I use MCS standard 3.0.0.5 + PBP2.50C.
    Roger

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    DOH!!
    I was not really thinking about your application when I answered before.
    The TIMEOUT option will not work for you because the GPS is always sending something. All the TIMEOUT does is looks for the absence of a signal. If the GPS was turned off then TIMEOUT could be used to indicate that.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    916


    Did you find this post helpful? Yes | No

    Default any signal or character string?

    Thanks mackrackit,

    For info, my GPS module sends data @ 1Hz interval. As long as I set my timeout value < 255, the expected result will occur.

    Are your saying that timeout will not work if the expected character string OR any signal is received whithin the timeout value? I'm confused.

    I use this modified (in red) routine to check if a particular NMEA sentence is sent by the GPS module. In that way, SERIN2 will receive signals and still have the timeout (<255) working - or is this test not valid?
    Code:
    CHECK_GGA:
    SERIN2 GPSfrom,Gpsbps,Timeout,NoGGA,[WAIT("$GPxxxGGA")]
    GOTO GPGGA:
    NoGGA:
    LCDOUT $FE,2, "no xxx"
    PAUSE 500
    SEROUT2 GPSto,Gpsbps,["$PSRF103,00,00,01,01*25",13,10]  'set ON GGA
    GOTO CHECK_GGA:
    GPGGA:   'start the next step....
    Roger

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Are your saying that timeout will not work if the expected character string OR any signal is received whithin the timeout value? I'm confused.
    Yes, that is why TIMEOUT does not work with RF serial comms either. There is always noise that will appear to be a signal.
    Here is a snippet from a GPS app of mine if it helps.
    Code:
    SERIN2 PORTB.2,16572,[WAIT("$GPGGA"),WAIT(","),DEC2 H,DEC2 M,DEC2 S,_
            WAIT(","),DEC2 ND,DEC2 NM,WAIT("."),DEC3 NMD,WAIT(",N,"),_
            DEC3 WD,DEC2 WM,WAIT("."),DEC3 WMD]
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    916


    Did you find this post helpful? Yes | No

    Default

    Thanks for this clarification - may help me a lot

    I will leave timeout by side then.

    How would one make sure then, that, in my example, the GGA sentence has been generated in the GPS module?

    Should I make a loop, timed, let's say at least 2 seconds, watch for the "$GPGGA" string anf flag it (yes/no)? But this will not work since the "WAIT" will make the program stop here!!!

    In fact, my problem is, my module after being left peacefully in the drawer for more than a week returns to its default settings. Unfortunately, the RMC sentence is not generated in the module by default so I need to activate it. I've noticed, I sometimes need to generate the activation commande several times before the module will accept it. This is why I need to check if the particular sentence is activated.
    Last edited by flotulopex; - 11th July 2010 at 11:24. Reason: noticed my wrong reasoning
    Roger

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I am not sure of the best way to go then.
    Maybe have a routine at startup using TIMEOUT just to check for $GPGGA and if it is not found send the activation command. When $GPGGA is found the code goes to the MAIN operation.
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 0

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