problem with connection between gps evalution board and sk40

Digital Fiber, Photoelectric, Laser Range, Optical, Temperature, Rotary Encoder, Ultrasonic, Gas, Gyro, Accelerometer, FlexiBend, Flexiforce, Compass......

Re: problem with connection between gps evalution board and sk40

Postby chuaweekok » Sun Mar 28, 2010 1:59 pm

waiweng83 WROTE:Is the UART of the PIC having overrun error?
Is the UART of the PIC having overrun error?


i dont understand what is the overrun error?
how to check it?
chuaweekok
Newbie
 
Posts: 14
Joined: Wed Mar 17, 2010 12:49 pm

Re: problem with connection between gps evalution board and sk40

Postby waiweng83 » Mon Mar 29, 2010 10:27 am

Overrun error occurs when the data in the receiver buffer has not been read out and there is another new data coming in. It can be said as the receiver buffer has overflown.

You can check one of the flag bit in the PIC to know whether the overrun error has occurred.
With the power of dream, nothing is impossible...
User avatar
waiweng83
Moderator
 
Posts: 205
Joined: Wed Apr 15, 2009 2:17 pm

Re: problem with connection between gps evalution board and sk40

Postby waiweng83 » Mon Mar 29, 2010 10:55 am

Ok...I think I know what is the problem already. I guess you are really having the problem of overrun error.

Let's say your baud rate is 9600bps, and 1 byte of data consists of 10 bits (including start and stop bit). So the data rate is actually 960 bytes per second. This means that 1 byte of data only takes 1/960 = 1.042mS to transfer.

In your program, you read the 1st character from UART, display the character on LCD, then loop and read the second character again. The problem lies in the function that display the character on the LCD. This function is taking a few mS. The data is coming in every 1.042mS, but your program will loop slower than that. As a result, you will see a few character is missing on the LCD.

To solve this problem, maybe you can save the received data in a buffer, let say you save the first 32 bytes of data in an array first. After that, you only display the character on the LCD.
With the power of dream, nothing is impossible...
User avatar
waiweng83
Moderator
 
Posts: 205
Joined: Wed Apr 15, 2009 2:17 pm

Re: problem with connection between gps evalution board and sk40

Postby chuaweekok » Mon Mar 29, 2010 11:46 am

waiweng83 WROTE:To solve this problem, maybe you can save the received data in a buffer, let say you save the first 32 bytes of data in an array first. After that, you only display the character on the LCD


thanks alot for your guidance and help
i finally can obtain theNMEA code from gps
and the character display on the LCD seen ok
chuaweekok
Newbie
 
Posts: 14
Joined: Wed Mar 17, 2010 12:49 pm

Re: problem with connection between gps evalution board and sk40

Postby waiweng83 » Mon Mar 29, 2010 3:35 pm

You are welcome. Is good to hear that your code is working. Do share with us how you solve it ya. Maybe you can post your source code here for the benefit of those who having the same problem as well. :)
With the power of dream, nothing is impossible...
User avatar
waiweng83
Moderator
 
Posts: 205
Joined: Wed Apr 15, 2009 2:17 pm

Re: problem with connection between gps evalution board and sk40

Postby chuaweekok » Mon Mar 29, 2010 4:28 pm

CODE: SELECT_ALL_CODE
int cnt = 0;
int cnt1 = 0;

int mystat = 0;

char rec[32];


void LCDdisplay(char data, char data);

void main()
{

USART_init(4800);
TRISB = 0; PORTB = 0X00;
TRISC = 0x80; PORTC = 0x00;
TRISD = 0; PORTD = 0X00;
Lcd_Custom_Config(&PORTD,7,6,5,4,&PORTB,4,6,5);
lCD_Custom_Cmd(Lcd_CURSOR_OFF);

while(1)
{

 if(Usart_Data_Ready()==1)
 { rec[cnt]=Usart_Read();
   cnt++;  }
   
 if(cnt > 33){
 for(cnt1=0; cnt1 < 33; cnt1++)
{ Lcd_Custom_Chr(1,cnt1+1,rec[cnt1]);
  if(cnt1>16){Lcd_Custom_Chr(2,cnt1-16,rec[cnt1]);}
  if(cnt1>32){ cnt=33;}  }
}
   }  }


this is the code i use to display the first 32 character of NMEA code from GPS
chuaweekok
Newbie
 
Posts: 14
Joined: Wed Mar 17, 2010 12:49 pm

Re: problem with connection between gps evalution board and sk40

Postby ober » Tue Mar 30, 2010 2:30 pm

Good work! Keep on update us about your progress!
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: problem with connection between gps evalution board and sk40

Postby chuaweekok » Thu Apr 15, 2010 5:08 pm

here is the code to output latitude and longitude to LCD 4 bit
before that, the GPS has to set using miniGPS
baudrate to 4800, NMEA output only RMC is 1, other 0
CODE: SELECT_ALL_CODE
int cnt = 0;
int cnt1 = 0;
int rec = 0;
int rec1 = 0;
int rec2 = 0;

int cnt2 = 0;

char NMEA[50];
char receive = ' ';
char latitude[] = "xxxx.xxxx";
char longitude[] = "xxxxx.xxxx";

void LCDdisplay(void);

void main()
{

USART_init(4800);
TRISB = 0x00; PORTB = 0X00;                                                        // Port b is output and initialize port b
TRISC = 0x80; PORTC = 0x00;
TRISD = 0x00; PORTD = 0X00;                                                        // Port d is output and initialize port d
Lcd_Custom_Config(&PORTD,7,6,5,4,&PORTB,4,6,5);                                 // Initialize Lcd port
lCD_Custom_Cmd(Lcd_CURSOR_OFF);

while(1)
{
receive = ' ';
while(receive != '*')
{if (Usart_Data_Ready() == 1)
      {receive = Usart_Read();
      cnt++;
               if (receive == ',' )
               {rec2++; cnt = 0;
               }
               else if (receive == '$' )
               {rec2 = 0;
               }
               if (rec2 == 3 && cnt != 0)
               {latitude[cnt-1]=Usart_read();
               }
               else if (rec2 ==5 && cnt!= 0)
               {longitude[cnt-1]=Usart_read();
               }
      }
}


LCDdisplay();
}
}



void LCDdisplay(void)
{
Lcd_Custom_Out(1,1,"lat : ");                                                       // Output to Lcd.
Lcd_Custom_Out(2,1,"long: ");
Lcd_Custom_Out(1,16,"N");                                                       // Output to Lcd.
Lcd_Custom_Out(2,16,"E");

for(cnt1=0; cnt1 < 11; cnt1++)
{ Lcd_Custom_Chr(1,cnt1+7,latitude[cnt1]);
  Lcd_Custom_Chr(2,cnt1+6,longitude[cnt1]);
}
}
chuaweekok
Newbie
 
Posts: 14
Joined: Wed Mar 17, 2010 12:49 pm

Re: problem with connection between gps evalution board and

Postby cheeboon » Wed Apr 18, 2012 5:33 pm

chuaweekok WROTE:here is the code to output latitude and longitude to LCD 4 bit
before that, the GPS has to set using miniGPS
baudrate to 4800, NMEA output only RMC is 1, other 0



hallo..may i ask...
after i change the NMEA output only RMC is 1 and other is 0,
and click set...but, after i switch off the GPS evaluation board,
and open again..the NMEA will remain the same before i change....
any solution? thanks..~
cheeboon
Greenhorn
 
Posts: 2
Joined: Wed Apr 18, 2012 5:27 pm

Re: problem with connection between gps evalution board and

Postby cheeboon » Mon Apr 30, 2012 9:31 am

chuaweekok WROTE:here is the code to output latitude and longitude to LCD 4 bit
before that, the GPS has to set using miniGPS
baudrate to 4800, NMEA output only RMC is 1, other 0
CODE: SELECT_ALL_CODE
int cnt = 0;
int cnt1 = 0;
int rec = 0;
int rec1 = 0;
int rec2 = 0;

int cnt2 = 0;

char NMEA[50];
char receive = ' ';
char latitude[] = "xxxx.xxxx";
char longitude[] = "xxxxx.xxxx";

void LCDdisplay(void);

void main()
{

USART_init(4800);
TRISB = 0x00; PORTB = 0X00;                                                        // Port b is output and initialize port b
TRISC = 0x80; PORTC = 0x00;
TRISD = 0x00; PORTD = 0X00;                                                        // Port d is output and initialize port d
Lcd_Custom_Config(&PORTD,7,6,5,4,&PORTB,4,6,5);                                 // Initialize Lcd port
lCD_Custom_Cmd(Lcd_CURSOR_OFF);

while(1)
{
receive = ' ';
while(receive != '*')
{if (Usart_Data_Ready() == 1)
      {receive = Usart_Read();
      cnt++;
               if (receive == ',' )
               {rec2++; cnt = 0;
               }
               else if (receive == '$' )
               {rec2 = 0;
               }
               if (rec2 == 3 && cnt != 0)
               {latitude[cnt-1]=Usart_read();
               }
               else if (rec2 ==5 && cnt!= 0)
               {longitude[cnt-1]=Usart_read();
               }
      }
}


LCDdisplay();
}
}



void LCDdisplay(void)
{
Lcd_Custom_Out(1,1,"lat : ");                                                       // Output to Lcd.
Lcd_Custom_Out(2,1,"long: ");
Lcd_Custom_Out(1,16,"N");                                                       // Output to Lcd.
Lcd_Custom_Out(2,16,"E");

for(cnt1=0; cnt1 < 11; cnt1++)
{ Lcd_Custom_Chr(1,cnt1+7,latitude[cnt1]);
  Lcd_Custom_Chr(2,cnt1+6,longitude[cnt1]);
}
}



hey...can send me the electrical schematic diagram? thanks ya
cheeboon
Greenhorn
 
Posts: 2
Joined: Wed Apr 18, 2012 5:27 pm

Previous

Return to Sensor

Who is online

Users browsing this forum: No registered users and 10 guests