Help to setup GPS connection.


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    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.

  2. #2
    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

  3. #3
    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.

  4. #4
    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 00:00.

  5. #5
    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.

  6. #6
    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.

  7. #7
    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

  8. #8
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Hi, I want to try to use 38400 baud rate with 20Mz crystal. I want to test it first in the hyperterminal by entering this line "$GPGGA,115209.600,1114.5166,N,12500.3439,E,1,10,0 .83,16.9,M,55.4,M,,*5E" and I use this code
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 32 ' 38400 Baud @ -1.36%
    define HSER_BAUD 38400
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    define OSC 20
    
    gpsin var portc.7 'rx
    gpsout var portc.6 'tx
    
    
    HH VAR byte 
    MM VAR BYTE
    SS VAR BYTE
    ND VAR BYTE
    NM VAR BYTE
    NMD VAR WORD
    WD VAR BYTE
    WM VAR BYTE
    WMD VAR WORD
    AR VAR BYTE[20]
    
    START: 
    SERIN2 gpsin,16572,[WAIT("$GPGGA"),WAIT(","),DEC2 hH,DEC2 mM,DEC2 sS,_
    WAIT(","),DEC2 ND,DEC2 NM,WAIT("."),DEC3 NMD,WAIT(",N,"),_
    DEC3 WD,DEC2 WM,WAIT("."),DEC3 WMD]
    
    PAUSE 1000
    
    SEROUT2 gpsin,16572,[DEC2 HH,DEC2 MM,DEC2 SS,_
    DEC2 ND,DEC2 NM,DEC3 NMD,DEC3 WD,DEC2 WM,DEC3 WMD,13,10]
    
    
    goto START
    end
    but I dont have any display on the recieve window. Please help..

    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