Help to setup GPS connection.


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Hi, I got a follow up question, I need to get latitude and longitude from this string
    $GPRMC,053740.000,A,250.6319,N,12136.0099,E,2.69,7 9.65,100106,,,A*53. How can I achieve it using SERIN?

    thanks,
    mbox

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


    Did you find this post helpful? Yes | No

    Default

    You would be better off using SERIN2.
    Here is a snippet from something .
    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.

  3. #3
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    You would be better off using SERIN2.
    Here is a snippet from something .
    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]
    Hi, I'm trying to understand SERIN2 command. why this code do not work when I entered "hello"?
    Code:
    Include "modedefs.bas"
    main:
    Serin2 PORTC.7, T9600, error, [WAIT("hello")]
    serout2 PortC.6, T9600, ["Valid"]
    goto main
    
    error:
    serout2 PortC.6, T9600, ["Invalid"]
    goto main
    end
    regards,
    mbox

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


    Did you find this post helpful? Yes | No

    Default

    I imagine many are thinking, "have you read the manual?".

    Include "modedefs.bas"
    Does nothing with SERIN2/SEROUT2.

    T9600
    Is for SERIN/SEROUT. "T" is for true mode anyways so if you are connecting directly to a PC you want INVERTED mode.

    Appendix A from the manual has the modes for SERIN2. At 9600 baud the mode will be 16468. To see how that is calculated look here. http://www.picbasic.co.uk/forum/cont...SERIN2-SEROUT2

    You will also want to specify a time for the GOTO LABEL "error".

    Try this
    Code:
    SERIN2 PORTC.7, 16468,100, error, [WAIT("hello")]
    The above will wait for 100 milliseconds, then GOTO "error" if "hello" is not received.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Red face

    Hi mackrackit, thanks for the help, appreciated very much. I manage to run this code MCU to PC and use this guide http://melabs.com/resources/ser2modes.htm
    Code:
    main:
    SERIN2 PORTC.7, 84,200, error, [WAIT("Hello")]
    serout2 PortC.6,84, ["Valid",10,13]
    goto main
    
    error:
    serout2 PortC.6, 84, ["Invalid",10,13]
    goto main
    end
    I know u have given me an example, but dont really get it ,
    Is there a way I could receive this value "$GPRMC,053740.000" and place it on a variable?

    thanks and regards,
    mbox
    Last edited by mbox; - 2nd November 2010 at 01:00.

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


    Did you find this post helpful? Yes | No

    Default

    Code:
        H       VAR BYTE 'HOURS
        M       VAR BYTE 'MINUTES
        S       VAR BYTE 'SECONDS
    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Waits for GPRMC

    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Waits for ","

    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Places the first two digits into VAR H

    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Places the middle two digits into VAR M

    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Places the last two digits into VAR S

    "$GPRMC,053740.000"
    053740 =
    H = 05 Hours
    M = 37 Minutes
    S = 40 Seconds
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    If you have not seen this it might be handy
    http://aprs.gids.nl/nmea/
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Thumbs up

    Quote Originally Posted by mackrackit View Post
    Code:
        H       VAR BYTE 'HOURS
        M       VAR BYTE 'MINUTES
        S       VAR BYTE 'SECONDS
    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Waits for GPRMC

    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Waits for ","

    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Places the first two digits into VAR H

    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Places the middle two digits into VAR M

    [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
    Places the last two digits into VAR S

    "$GPRMC,053740.000"
    053740 =
    H = 05 Hours
    M = 37 Minutes
    S = 40 Seconds
    Thanks so much mackrackit.

    regards,
    mbox

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