GPS module + PIC


Closed Thread
Results 1 to 13 of 13

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

    10001000000
    is the number excel failed on but other than that I do not know. I will have to look into it.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default Check Sum

    Here is one check sum solution for gps:

    Code:
    gpsdata         var byte[82]       ' Max length of a GPS sentence is 82 bytes.
    
    DoCS:
        i = 0                             ' Initialize the position counter
                    
        WHILE gpsdata[i] != "*"           ' Count everthing until the *
            cs = cs ^gpsdata[i]           ' XOR for checksum
            i = i + 1                     ' Increment position counter
        WEND
    
        ' A quick and easy atoh function
        ' Make it a seperate label if we add more atoh conversions in the future
        LOOKDOWN gpsdata[i+1],["0123456789ABCDEF"],tempbyte
        gpscs = tempbyte * 16        
        LOOKDOWN gpsdata[i+2],["0123456789ABCDEF"],tempbyte                
        gpscs = gpscs + tempbyte
            
        ' Flag bad data "V" if checksum doesn't add up. 
        ' Or if the sentence is less then 20 chars long
        ' Which means there is no active waypoint to go to.
        ' Should be "A" otherwise.
        IF (cs != gpscs) OR (i < 20 )THEN 
              gpsvalid = 0
        ELSE 
              gpsvalid = 1
        ENDIF   
    RETURN
    Last edited by ScaleRobotics; - 10th April 2010 at 14:26.

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    952


    Did you find this post helpful? Yes | No

    Default Can't "talk" towards my GPS module...

    - Reading & parsing NMEA sentences is ok;
    - Calculating checksum is ok;
    - Sending data to GPS module is not ok.

    I have connected the GPS module via the MAX232 chip to my serial PC port both ways so I should be able to "talk" to my module.

    Unfortunately, only reading out (receiving) the GPS module is working.

    I checked the MAX chip with my oscillo and the signals are okay (TX & RX) on both levels (RS232 and TTL).

    I'm sending an example from the module's datasheet to enable a VTG sentence but it won't work.

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=4205&stc=1&d=127141338 1">

    I just never see this VTG data appear.

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=4207&stc=1&d=127141381 2">

    Any idea?
    Attached Images Attached Images   
    Roger

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


    Did you find this post helpful? Yes | No

    Default It works now!

    Strange....

    I just restarted the terminal and... it works now - I can sent messages to the module.

    Must be a kind of magic (?)
    Roger

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default

    Is it Hyperterminal?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    No, it's MicroCode Studio's terminal.

    But I checked with HT too and did the same (?).

    Nevermind, it works now
    Roger

  7. #7
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    952


    Did you find this post helpful? Yes | No

    Default Timeout routine not working

    Hello there,

    I just finished this piece of code and it works fine. It will simply display the GPS course & speed.

    I finally connected the GPS module's TX directly to a TTL port of my PIC (no level-shifter such as MAX232 used) with the correspondant mode settings.

    Everything is working fine appart from the NOGPS routine.

    When I disconnect the GPS's TX from the PIC's port, the NOGPS routine will never appear.

    Any idea what's wrong?
    Code:
    <html><head></head><body><!--StartFragment--><pre><code><font color="#000080"><i>' PIC 16F690 Fuses
    </i></font><font color="#008000">@ DEVICE FCMEN_OFF
    @ DEVICE IESO_OFF
    @ DEVICE BOD_OFF
    @ DEVICE CPD_OFF
    @ DEVICE PROTECT_OFF
    @ DEVICE MCLR_OFF
    @ DEVICE PWRT_OFF
    @ DEVICE WDT_OFF
    @ DEVICE XT_OSC
    
    </font><font color="#000080"><i>' Registers   76543210
    </i></font>OPTION_REG = %10000000 <font color="#000080"><i>'PORT A&amp;B Pull-Ups disabled (look WPUA &amp; WPUB)
    </i></font>ANSEL      = %00000000 <font color="#000080"><i>'Disable analog inputs Channels 0 to 7
    </i></font>ANSELH     = %00000000 <font color="#000080"><i>'Disable analog inputs Channels 8 to 11
    </i></font>ADCON0     = %00000000 <font color="#000080"><i>'A/D Module is OFF
    </i></font>CM1CON0    = %00000000 <font color="#000080"><i>'Comparator1 Module is OFF
    </i></font>CM2CON0    = %00000000 <font color="#000080"><i>'Comparator2 Module is OFF
    </i></font>INTCON     = %00000000 <font color="#000080"><i>'INTerrupts CONtrol
    </i></font>TRISA      = %00000001 <font color="#000080"><i>'Set Input/Output (0 to 5)
    </i></font>PORTA      = %00000000 <font color="#000080"><i>'Ports High/Low (0 to 5)
    </i></font>TRISB      = %00000000 <font color="#000080"><i>'Set Input/Output (4 to 7)
    </i></font>PORTB      = %00000000 <font color="#000080"><i>'Ports High/Low (4 to 7)
    </i></font>TRISC      = %00000000 <font color="#000080"><i>'Set Input/Output (0 to 7)
    </i></font>PORTC      = %00000000 <font color="#000080"><i>'Ports High/Low (0 to 7)
    
    '-------------------------------------------------------------------------------
    ' LCD cabling
    '-	    ( 1) Vss - GND
    '-	    ( 2) Vdd / Vcc +5V
    '-	    ( 3) Vee / Vo / Contrast adjust / Pot 4k7(1-2-W3) or R2k2(GND-3)
    'PORTC.1    ( 4) RS
    '-	    ( 5) R/W -&gt; to Vss
    'PORTC.2    ( 6) E
    'PORTB.4    (11) D4
    'PORTB.5    (12) D5
    'PORTB.6    (13) D6
    'PORTB.7    (14) D7
    
    </i></font><b>DEFINE </b>LCD_DREG PORTB  <font color="#000080"><i>'LCD data port 
    </i></font><b>DEFINE </b>LCD_DBIT 4      <font color="#000080"><i>'LCD data starting PORT.bit (0 or 4)
    </i></font><b>DEFINE </b>LCD_RSREG PORTC <font color="#000080"><i>'LCD register select port 
    </i></font><b>DEFINE </b>LCD_RSBIT 1     <font color="#000080"><i>'LCD register select bit 
    </i></font><b>DEFINE </b>LCD_EREG PORTC  <font color="#000080"><i>'LCD enable port 
    </i></font><b>DEFINE </b>LCD_EBIT 2      <font color="#000080"><i>'LCD enable bit 
    </i></font><b>DEFINE </b>LCD_BITS 4      <font color="#000080"><i>'LCD bus size 4 or 8 
    </i></font><b>DEFINE </b>LCD_LINES 2     <font color="#000080"><i>'Number lines on LCD 
    
    '-------------------------------------------------------------------------------
    </i></font>INIT:
    Ctr_A       <b>VAR BYTE    </b><font color="#000080"><i>'Counter
    </i></font>GPS_D       <b>VAR BYTE</b>(80)<font color="#000080"><i>'Incomming data bit array
    </i></font>Spd_U       <b>VAR WORD    </b><font color="#000080"><i>'Speed Units
    </i></font>GPSfrom     <b>VAR </b>PORTA.0 <font color="#000080"><i>'use a TTL I/O port on PIC!
    </i></font>GPSbps      <b>VAR WORD
    </b>GPSbps      = 32956     <font color="#000080"><i>'Open,True,N,4800bps (TTL level)
    </i></font>Timeout     <b>CON </b>3000
    CommaCnt    <b>VAR BYTE    </b><font color="#000080"><i>'comma count
    
    </i></font><b>PAUSE </b>1000
    <b>LCDOUT </b>$FE, 1
    
    <font color="#000080"><i>' Custom character definition
    </i></font><b>LCDOUT </b>$FE,$40,$0C,$12,$12,$0C,$00,$00,$00,$00 <font color="#000080"><i>'character 0 = &quot;&deg;&quot;
    </i></font><b>LCDOUT </b>$FE,$48,$14,$18,$14,$00,$1E,$15,$15,$00 <font color="#000080"><i>'character 1 = &quot;km&quot;
    
    </i></font><b>LCDOUT </b>$FE,2,<font color="#FF0000">&quot;GPS v1.1&quot;
    </font><b>PAUSE </b>3000
    
    <font color="#000080"><i>'-------------------------------------------------------------------------------
    </i></font>GPVTG:
    <font color="#000080"><i>' Get VTG sentence and store it into GPS_D var until &quot;*&quot; is found
    </i></font><b>SERIN2 </b>GPSfrom,GPSbps,Timeout,NOGPS,[WAIT(<font color="#FF0000">&quot;$GPVTG,&quot;</font>),<b>STR </b>GPS_D\<font color="#FF0000">&quot;*&quot;</font>]
    
    <font color="#000080"><i>' extract COURSE data
    </i></font>Ctr_A = 0
    cou_u = 0
    <b>WHILE </b>GPS_D(Ctr_A) != <font color="#FF0000">&quot;.&quot;
        </font>Cou_u = 10 * cou_u + (GPS_D(Ctr_A)-48)
        Ctr_A = Ctr_A + 1
    <b>WEND
    
    </b><font color="#000080"><i>' locate SPEED data after 6th comma
    </i></font>Ctr_A = 0
    CommaCnt = 0
    <b>WHILE </b>CommaCnt &lt; 6
        <b>IF </b>GPS_D(Ctr_A) = <font color="#FF0000">&quot;,&quot; </font><b>THEN </b>CommaCnt = CommaCnt + 1
        Ctr_A = Ctr_A + 1
    <b>WEND
    
    </b><font color="#000080"><i>' extract SPEED data - leave tenths
    </i></font>Spd_U = 0
    <b>WHILE </b>GPS_D(Ctr_A) != <font color="#FF0000">&quot;.&quot;
        </font>Spd_U = 10 * Spd_U + (GPS_D(Ctr_A)-48)
        Ctr_A = Ctr_A + 1
    <b>WEND
    
    LCDOUT </b>$FE,1
    <b>LCDOUT </b>$FE,2,<b>DEC </b>cou_u,0,<font color="#FF0000">&quot; &quot;</font>,<b>DEC </b>Spd_U,1
    <b>GOTO </b>GPVTG:
    
    <font color="#000080"><i>'-------------------------------------------------------------------------------
    </i></font>NOGPS: 
    <b>LCDOUT </b>$FE,2,<font color="#FF0000">&quot; No GPS &quot;
    </font><b>PAUSE  </b>1000 
    <b>GOTO </b>GPVTG:
    
    <b>END
    </b></code></pre><!--EndFragment--></body>
    </html>
    Roger

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