Help to setup GPS connection.


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Posts
    65

    Default Help to setup GPS connection.

    Hi everyone, I have a GPS with 57600 baud rate and runs on 3.3v, I'm using Pic16F877A with 4Mz crystal. I'm planning to use Serin to read GPS data on PortB.0 and use PortC.6 for Serout to transmit it an LCD or to PC. Do I need to have voltage divider...please give advice.


    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

    Read this
    http://www.picbasic.co.uk/forum/showthread.php?t=5667

    To give you a good answer we would need the data sheet of the GPS.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Quote Originally Posted by mackrackit View Post
    Read this
    http://www.picbasic.co.uk/forum/showthread.php?t=5667

    To give you a good answer we would need the data sheet of the GPS.
    So far based on what I read I think, voltage divider is not needed because I just want data reading from GPS(LS20031) to MCU or PC.
    For GPS to Pic16F877A
    GPS Tx--> Mcu Rx
    For GPS to PC
    GPS Tx--> PC Rx

    thanks and regards,
    mbox
    Attached Images Attached Images
    Last edited by mbox; - 23rd October 2010 at 00:47.

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mbox View Post
    So far based on what I read I think, voltage divider is not needed because I just want data reading from GPS(LS20031) to MCU or PC.
    For GPS to Pic16F877A
    GPS Tx--> Mcu Rx
    For GPS to PC
    GPS Tx--> PC Rx
    The LS20031 is TTL, and not RS-232. So you will not be able to send it out directly to the PC. You will need something like a max232, or an equivalent to invert the signal levels.

    Your PIC should be able to receive the TTL at 3.3v, even though I am guessing the PIC is at 5v. Just don't TX from the PIC to the GPS without a level shifter.
    http://www.scalerobotics.com

  5. #5
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Sorry its been a while, been busy working with other things.
    The LS20031 is TTL, and not RS-232. So you will not be able to send it out directly to the PC. You will need something like a max232, or an equivalent to invert the signal levels.

    Your PIC should be able to receive the TTL at 3.3v, even though I am guessing the PIC is at 5v. Just don't TX from the PIC to the GPS without a level shifter.
    Thanks for the info...one more question, I don't have 20Mz crystal, but I do have 20.945 Cyrstal, can I use it?

    thanks in advance,
    mbox

  6. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mbox View Post
    I have a GPS with 57600 baud rate and runs on 3.3v, I'm using Pic16F877A with 4Mz crystal.
    That's a little too high a baud rate for 4 mhz to handle. I think you will have better luck trying 57600 with a 20 mhz crystal.
    http://www.scalerobotics.com

  7. #7
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    That's a little too high a baud rate for 4 mhz to handle. I think you will have better luck trying 57600 with a 20 mhz crystal.
    okay I will try to change the crystal and update you the results.

    thanks and regards,
    mbox

  8. #8
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    For the baud rate to be timed right, PicBasic needs to told exactly what frequency the crystal is. PicBasic only allows certain crystals to be defined. Here are the settings allowed: MHz: 3(3.58) 4 8 10 12 16 20 24 25 32 33 40 48 64. Of course your chip has restrictions as well. (It max's out at 20 mhz).

    If you have a 16mhz crystal, you might give it a try while you wait for a 20mhz to come in. 38400 baud works with debug out at 8 mhz, so at 16mhz I figure your 57600 might work. In the meantime, you could connect the gps to a max232 device, and change the baud lower with your computer. Then you could connect it to your pic at a lower baud rate, using a lower speed crystal. But 20mhz is highly recommended.
    Last edited by ScaleRobotics; - 28th October 2010 at 12:37.
    http://www.scalerobotics.com

  9. #9
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Finally I manage to make the baudrate to 9600 with this guide http://docs.trenz-electronic.de/GlobalT ... ket_01.pdf but I have not connected it yet to PIC16F877A.
    I'm going to use SERIN on PortB.0 to fetch data from GPS using 4Mz crytsal....feed back you later the result when I get back home.

    regards,
    mbox
    Last edited by mbox; - 29th October 2010 at 23:04.

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

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

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

  13. #13
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default TIMEOUT issue

    Be careful while using TIMEOUT - you may get fuzzy results.

    Have a look here http://www.picbasic.co.uk/forum/show...1443#post91443.
    Roger

  14. #14
    Join Date
    Oct 2008
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Be careful while using TIMEOUT - you may get fuzzy results.

    Have a look here http://www.picbasic.co.uk/forum/show...1443#post91443.
    Hi, thanks for the tip, it sure did saved me from trouble

    regards,
    mbox

Members who have read this thread : 2

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