12 years ago.

Why is a front portion strange by a back portion? GPS sensor does not get a true numbers.

I connected Mbed(LPC1768), GPS(GT-720F),Xbee(Series2) and Analog switch. Pin17 to 21 control the Analog switch to share Pin9 and Pin10 by GPS and Xbee. Now I wrote source codes as described below. The program can get a true latitude and longitude. But the comments enable, latitude and longitude return 0.000; Why is a front portion strange by a back portion? I cannot understand...

  1. include "mbed.h"
  2. define ON 1
  3. define OFF 0

Serial xbee(p9,p10); Serial gps(p9,p10); Serial pc(USBTX,USBRX); DigitalOut gpstx(p17); DigitalOut gpsrx(p18); DigitalOut xbeetx(p19); DigitalOut xbeerx(p20);

int main() { int gps_i,rlock,stn; char gps_data[256]; char ns,ew; float time,hokui,tokei;

gps.baud(9600);

double gps_No,gps_Eo,gps_x,gps_y; double d_tokei,d_hokui;

while(1) { gpstx = 1;gpsrx = 1;xbeetx = 0;xbeerx = 0; wait_ms(5); gps_i=0; rlock=0; while(gps.getc()!='$'){} while( (gps_data[gps_i]=gps.getc()) != '\r') {gps_i++;if(gps_i==256){gps_i=255;break;}} gps_data[gps_i]='\0'; if( sscanf(gps_data,"GPGGA,%f,%f,%c,%f,%c,%d,%d",&time,&hokui,&ns,&tokei,&ew,&rlock,&stn) >= 1) rlock=1; {if(rlock>=1) { gpstx = 0;gpsrx = 0;xbeetx = 1;xbeerx = 1; wait_ms(5); pc.printf("Status:Lock(%d)\n\r",stn); pc.printf("Tokiei:%4.5f\n\r",tokei); pc.printf("Hokui:%4.5f\n\r",hokui);}}

/* gps_No = 14003.430; gps_Eo = 3543.414; d_tokei=double(tokei); d_hokui=double(hokui); gps_y = (d_hokui-gps_No); gps_x = (d_tokei-gps_Eo); pc.printf("x=%lf.y=%lf",gps_x,gps_y);

  • / }}
Be the first to answer this question.