發一個SIM900A+GPS單片機源程序
QQ截圖20180202014738.jpg (43.84 KB, 下載次數: 31)
下載附件
2018-2-2 01:46 上傳
單片機源程序如下:
- /**************************************************************************
- * *
- * GPS+GPRS方式實現GPS地理位置信息通過GPRS無線上網方式傳給上位機實例程序 *
- * *
- * 功能:GPS地理坐標、衛星時間等信息通過GPRS方式傳到上位機 *
- * 板上提供Nokia5110液晶屏接口,GPS信息可以通過液晶實時顯示 *
- * 版本: V1.0 (08/24) *
- *【聲明】此程序僅用于學習與參考,引用請注明版權和作者信息! *
- * *
- *************************************************************************/
- #include <SIM300.h>
- #include <reg51.h>
- #include <string.h>
- #include <gps.h>
- void dis_time()
- {
- unsigned char hh;
- unsigned char i,temp_buff[10];
- hh=(gps_time[0]-'0')*10+(gps_time[1]-'0');
- hh+=8; //將格林威治時間校正成北京時間
- if(hh>=24)
- hh-=24; //校正小時
- temp_buff[0]=hh/10+'0';
- temp_buff[1]=hh%10+'0';
- temp_buff[2]=':';
- temp_buff[3]=gps_time[2];
- temp_buff[4]=gps_time[3];
- temp_buff[5]=':';
- temp_buff[6]=gps_time[4];
- temp_buff[7]=gps_time[5];
- for(i=0;i<8;i++)
- gps_time[i]=temp_buff[i];
- LCD_write_english_string(0,0,"TIME");
- LCD_set_XY(36,0);
- for(i=0;i<8;i++)
- {
- LCD_write_char(gps_time[i]);
- }
- }
- void dis_jwdu()
- {
- unsigned i;
- LCD_set_XY(0,1);LCD_write_char(gps_latitude_dir);
- LCD_set_XY(24,1);
- for(i=0;i<10;i++)
- {
- LCD_write_char(gps_latitude[i]);
- }
- LCD_set_XY(0,2);LCD_write_char(gps_longitude_dir);
- LCD_set_XY(30,2);
- for(i=0;i<9;i++)
- {
- LCD_write_char(gps_longitude[i]);
- }
- }
- void dis_high()
- {
- unsigned i;
- LCD_write_english_string(0,5,"HIGH");
- LCD_set_XY(42,5);
- for(i=0;i<7;i++)
- {
- LCD_write_char(gps_height[i]);
- }
- }
- /*gprs_data()
- {
- unsigned char buff[40];
- unsigned i;
-
- }*/
- //聲明GPS驅動部分的全局變量
- void delay_time(unsigned char t)
- {
- unsigned int i,n;
- for(n=0;n<t;n++)
- for(i=0;i<10000;i++);
- }
- void main(void)
- {
- LCD_init(); //LCD初始化
- LCD_write_english_string(0,0,"System Starting and Initializing......");
- Delay_ms(5000);
- sys_init(); //UART1初始化
- Init_GPS_module(); //GPS初始化
- Start_GSM(); //開啟模塊
- GSM_init(); //GSM初始化
- BELL_UP(); //BEEP
- clear_SystemBuf(); //清除串口1緩沖區數據
- while(strsearch("Call Ready",SystemBuf)==0);//等待模塊準備好
- BELL_UP();
- do
- {
- LCD_clear();
- clear_SystemBuf();
- sendstring(AT_COPS);
- LCD_write_english_string( 4,2,"searching>");
- Delay_ms(3000);
- LCD_write_english_string( 4,2,"searching->");
- Delay_ms(3000);
- LCD_write_english_string( 4,2,"searching-->");
- Delay_ms(3000);
- LCD_write_english_string( 4,2,"searching--->");
- Delay_ms(3000);
- }while((strsearch("CHINA UN",SystemBuf)==0)&&(strsearch("CHINA MOBILE",SystemBuf)==0));//檢測服務商信息
- BELL_UP();
- LCD_clear();
- LCD_write_english_string(0,0,"KinCony");
- //GPRS初始化 */
- ES=0;
- Delay_ms(10000);
- Delay_ms(10000);
- sendstring(AT_CIPMUX);
- Delay_ms(10000);
- sendstring(AT_CIPSTART);
- //while(strsearch("CONNECT OK",SystemBuf)!=0);
- BELL_UP();
- LCD_clear(); //清屏幕
- ET0=1; //開中斷
- while(1)
- {
- if(gps_data_ok_flag) //查詢GPS數據是否OK
- {
- IE2=0x00; //如果OK就關中斷處理數據并顯示數據
- dis_time();
- dis_jwdu();
- dis_high();
- gps_data_ok_flag=0;
- IE2=0x01;
- }
- }
- }
- /********************************************************************************************************
- ** 函數名稱 Int_Timer0()
- ** 函數功能 定時器中斷位,是整個程序的心跳,如果停止,程序會死機
- *********************************************************************************************************/
- void Int_Timer0(void) interrupt 1 using 3
- {
- unsigned char i;
- TH0 = 0xB8;
- TL0 = 0x00; //20ms的時鐘基準
- timer_1S_cnt++;
- timercount++;
- EA=0;
- if(timer_1S_cnt==50) //20×50=1000M
- {
- timer_10S_cnt++;
- timer_1S_cnt=0;
- timer_S_cnt++;
- } //1秒=1000毫秒
- if(timer_10S_cnt==10) //10S
- {
- timer_10S_cnt=0;
- BELL_UP();
- sendstring(AT_CIPSEND);
- Delay_ms(5000);
- Delay_ms(5000);
- for(i=0;i<8;i++)
- {
- sendchar(gps_time[i]);
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
SIM900 GPRS GPS單片機源程序_帶NOKIA5110顯示.zip
(77.26 KB, 下載次數: 69)
2018-2-2 01:44 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|