GPS module + PIC


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    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

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,146


    Did you find this post helpful? Yes | No

    Default

    Is it Hyperterminal?

    Ioannis

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


    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

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


    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

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


    Did you find this post helpful? Yes | No

    Default

    At what level is the Serial input of the PIC when you disconnect the GPS module? I guess the timeout is blocked by the incorrect level.

    You should have a pull up resistor there.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default It's working... yes and no

    I have tried both a 10k pull-down and pull-up resistor.

    I was thinking a pull-down would be correct since the PIC gets a "true" signal, but as it didn't work, I tried the pull-up way; no success

    Meanwhile, I have seen that the GPS module will always send the string my SERIN2 command is waiting for ("$GPVTG").

    If the module has no signal (no satellite coverage), it will still send the NMEA sentence with empty data, just like this "$GPVTG,,T,0,M,,N,,K*xx".

    So, if I disconnect the GPS from the PIC, it works but... it is not the way I would like to have it working.
    Roger

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