CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Fastrax iTrax300 GPS output help
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
princejude



Joined: 07 Aug 2010
Posts: 72

View user's profile Send private message

PostPosted: Thu Dec 16, 2010 2:42 am     Reply with quote

Quote:
Sorry, but it's not clear to me what your problem is?

How can I attach files(.pdf) here, so that I can post my schematics and codes for you to understand ?
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Dec 16, 2010 7:38 pm     Reply with quote

Hi,

You can post your code here using the Code button, but I think you already know that. There are lots of free file hosting sites that will allow you to upload a file for us to get. Once you do that, you just post the link.

John
princejude



Joined: 07 Aug 2010
Posts: 72

View user's profile Send private message

PostPosted: Fri Dec 17, 2010 6:19 am     Reply with quote

Here is the schematic for the iTRAX300 GPS RECEIVER MODULE
http://filefactory.com/file/b4b95h5/n/iTRAX02_io.rar[/img]
princejude



Joined: 07 Aug 2010
Posts: 72

View user's profile Send private message

PostPosted: Fri Dec 17, 2010 7:13 am     Reply with quote

My header file (gps.h) is :

Code:

#include <16F887.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT                           //XTAL Osc
#FUSES NOPUT                     //No Power Up Timer
#FUSES NOPROTECT             //Code not protected from reading
#FUSES NODEBUG                //No Debug mode for ICD
#FUSES NOBROWNOUT         //No brownout reset
#FUSES NOLVP                     //No low voltage prgming
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected

#use delay(clock=4000000)
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)



And my main code is (This code is to display TIME, LATITUDE AND LONGITUDE on 16x2LCD)

Code:


#include "gps.h"
#include <string.h>

#include "flex_lcd.c"

char cmd[10] = "$GPGGA";
char str[50]; //string to hold data from gps module
char* ptr;

/*char lat[10];
char lon[10];
char time[10];*/
//int i;
void main()
{
   char term[3];
   int i = 0;
   char lat[12];
   char lon[13];
   char time[10];
   
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   // TODO: USER CODE!!
   lcd_init();
   printf("Ready: ");
   lcd_putc("\fReady...\n");

   strcpy(term,",;");
   
   while (TRUE) {
      gets(str);                                    //get string from serial port
      if(strncmp(str+1, cmd, 5) == 0)   //check message type
      {
         ptr = strtok(str, term);
         i=0;

         while(ptr!=0) {
         
            //puts(ptr);
         
            strcpy(term,",;");
            ptr = strtok(0, term);
            i++;
            if(i==1)
            {
                time[0] = ptr[0]; time[1] = ptr[1];
                time[2] = ':';
                time[3] = ptr[2]; time[4] = ptr[3];
                time[5] = ':';//0; use this for LCD display version to show seconds separately
                time[6] = ptr[4]; time[7] = ptr[5];
                time[8] = 0;
                lcd_putc("time:%s\n", time);
            }
            if(i==2)
            {
                lat[0] = ptr[0];
                lat[1] = ptr[1];
                lat[2] = '\'';
                lat[3] = ptr[2];
                lat[4] = ptr[3];
               
               for(i = 0; i <= 4; i++)
                  lat[i+5] = ptr[i+4];
               
               ptr = strtok(0, term);
               i=3;
               
               lat[10] = ptr[0];
               lat[11] = 0;   
               lcd_putc("latitude:%s\n", lat);
            }
            if(i==4)
            {
                lon[0] = ptr[0];
                lon[1] = ptr[1];
                lon[2] = ptr[2];
                lon[3] = '\'';
                lon[4] = ptr[3];
                lon[5] = ptr[4];
                //coordinate2[6] = '.';
               
                for(i = 0; i <= 4; i++)
                  lon[i+6] = ptr[i + 5];
                ptr = strtok(0, term);
                i++;
                lon[11] = ptr[0];//E/W
                lon[12] = 0;   
                lcd_putc("longitude:%s\n",lon);
            }
         }
      }
      else
         puts("Ignored\n");
   }
}

The issue is that the lcd is not printing.

I tested my hardware(without the GPS) with this code and it worked with 9600 baud rate but it did not work with 4800 baud rate.

My test code is:
Code:

#include "gps.h"
#include "flex_lcd.c"

void main()
{
   while(TRUE)
  {
   lcd_init();
   lcd_putc("HELLO WORLD");
  }
}


Please how can I make the pic to communicate with 4800 baud rate because the gps operates with 4800 baud.

For the hardware connection I used the following pins:
Code:

GPS           TO        PIC16F887

SX1(PIN8)     TO        RC6/TX
RX1(PIN9)     TO        RC7/RX  (NULL MODEM CONNECTION) 1ST TEST

SX1           TO        RC6/RX
RX1           TO        RC7/TX   (NORMAL CONNECTION) 2ND TEST
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Fri Dec 17, 2010 9:34 am     Reply with quote

My feeling is this code will never ever work reliably. A GPS squawks so a circular buffer with a INT RA isr is needed in order to capture the data with 100% success.
Most start with a circular buffer that reads the squawked sentences and displays them. If that works they move on to gating specific sentences into the buffer and then on to parsing ( always done in main). This is a proven road to success.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Fri Dec 17, 2010 11:30 am     Reply with quote

Hi,

While Douglas is 100% correct, and that discussion will probably come later, at the moment the issue on the table is whether the GPS baud rate effects your ability to send data to the LCD.

In the code you just posted, do you see the "Ready:" text, which is generated outside your While loop, on your LCD??

A couple of things. I'm not sure if it's strictly required, but try a delay after you execute the lcd_int() function. Also, your display syntax may work fine, but I don't do it that way. Try this method instead:
Code:

//Here we initialize the LCD display...
   lcd_init();
   delay_ms(1000);

   printf(lcd_putc, "\f");
   printf(lcd_putc, "Waiting\nfor GPS!");

I want to know if you see the text show above on your LCD, AND do you see it regardless of the baud rate setting for your GPS.

John
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group