找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 3636|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

SIM900 GPRS+GPS單片機(jī)源程序_帶NOKIA5110顯示

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
發(fā)一個(gè)SIM900A+GPS單片機(jī)源程序

單片機(jī)源程序如下:
  1. /**************************************************************************
  2. *                                                                        *
  3. * GPS+GPRS方式實(shí)現(xiàn)GPS地理位置信息通過GPRS無線上網(wǎng)方式傳給上位機(jī)實(shí)例程序  *
  4. *                                                                        *
  5. * 功能:GPS地理坐標(biāo)、衛(wèi)星時(shí)間等信息通過GPRS方式傳到上位機(jī)                *
  6. *       板上提供Nokia5110液晶屏接口,GPS信息可以通過液晶實(shí)時(shí)顯示         *
  7. * 版本: V1.0 (08/24)                                               *
  8. *【聲明】此程序僅用于學(xué)習(xí)與參考,引用請(qǐng)注明版權(quán)和作者信息!              *
  9. *                                                                        *
  10. *************************************************************************/


  11. #include <SIM300.h>
  12. #include <reg51.h>
  13. #include <string.h>
  14. #include <gps.h>

  15. void dis_time()
  16. {
  17.         unsigned char hh;
  18.         unsigned char i,temp_buff[10];
  19.          hh=(gps_time[0]-'0')*10+(gps_time[1]-'0');
  20.          hh+=8;                          //將格林威治時(shí)間校正成北京時(shí)間
  21.          if(hh>=24)
  22.                 hh-=24;                   //校正小時(shí)
  23.          temp_buff[0]=hh/10+'0';
  24.          temp_buff[1]=hh%10+'0';
  25.          temp_buff[2]=':';
  26.          temp_buff[3]=gps_time[2];
  27.          temp_buff[4]=gps_time[3];
  28.          temp_buff[5]=':';
  29.          temp_buff[6]=gps_time[4];
  30.          temp_buff[7]=gps_time[5];   
  31.          for(i=0;i<8;i++)
  32.             gps_time[i]=temp_buff[i];
  33.         LCD_write_english_string(0,0,"TIME");
  34.         LCD_set_XY(36,0);
  35.         for(i=0;i<8;i++)
  36.         {
  37.                 LCD_write_char(gps_time[i]);        
  38.         }
  39. }
  40. void  dis_jwdu()
  41. {
  42.         unsigned i;
  43.         LCD_set_XY(0,1);LCD_write_char(gps_latitude_dir);
  44.         LCD_set_XY(24,1);
  45.         for(i=0;i<10;i++)
  46.         {        
  47.                 LCD_write_char(gps_latitude[i]);
  48.         }
  49.         LCD_set_XY(0,2);LCD_write_char(gps_longitude_dir);               
  50.         LCD_set_XY(30,2);
  51.         for(i=0;i<9;i++)
  52.         {
  53.                 LCD_write_char(gps_longitude[i]);
  54.         }               
  55. }
  56. void dis_high()
  57. {
  58.         unsigned i;
  59.         LCD_write_english_string(0,5,"HIGH");        
  60.         LCD_set_XY(42,5);
  61.         for(i=0;i<7;i++)
  62.         {
  63.                 LCD_write_char(gps_height[i]);
  64.         }
  65. }
  66. /*gprs_data()
  67. {
  68.         unsigned char buff[40];
  69.         unsigned i;
  70.         
  71. }*/
  72. //聲明GPS驅(qū)動(dòng)部分的全局變量
  73. void delay_time(unsigned char t)
  74. {
  75.         unsigned int i,n;
  76.         for(n=0;n<t;n++)
  77.                    for(i=0;i<10000;i++);
  78. }

  79. void main(void)
  80. {
  81.         LCD_init();                        //LCD初始化
  82.         LCD_write_english_string(0,0,"System Starting and Initializing......");
  83.         Delay_ms(5000);
  84.         sys_init();                        //UART1初始化
  85.         Init_GPS_module();         //GPS初始化
  86.         Start_GSM();                //開啟模塊
  87.     GSM_init();                        //GSM初始化
  88.         BELL_UP();                        //BEEP
  89.         clear_SystemBuf();        //清除串口1緩沖區(qū)數(shù)據(jù)
  90.         while(strsearch("Call Ready",SystemBuf)==0);//等待模塊準(zhǔn)備好
  91.         BELL_UP();
  92.         do
  93.         {
  94.                 LCD_clear();
  95.                 clear_SystemBuf();
  96.                 sendstring(AT_COPS);
  97.                 LCD_write_english_string( 4,2,"searching>");
  98.                 Delay_ms(3000);
  99.                 LCD_write_english_string( 4,2,"searching->");
  100.                 Delay_ms(3000);
  101.                 LCD_write_english_string( 4,2,"searching-->");
  102.                 Delay_ms(3000);
  103.                 LCD_write_english_string( 4,2,"searching--->");
  104.                 Delay_ms(3000);
  105.         }while((strsearch("CHINA UN",SystemBuf)==0)&&(strsearch("CHINA MOBILE",SystemBuf)==0));//檢測服務(wù)商信息
  106.         BELL_UP();
  107.         LCD_clear();
  108.         LCD_write_english_string(0,0,"KinCony");
  109.         //GPRS初始化 */
  110.         ES=0;
  111.         Delay_ms(10000);
  112.         Delay_ms(10000);
  113.         sendstring(AT_CIPMUX);
  114.         Delay_ms(10000);        
  115.         sendstring(AT_CIPSTART);
  116.         //while(strsearch("CONNECT OK",SystemBuf)!=0);
  117.     BELL_UP();                           
  118.         LCD_clear();                             //清屏幕
  119.         ET0=1;                                                                //開中斷  
  120.         while(1)                       
  121.         {         
  122.                 if(gps_data_ok_flag)                                //查詢GPS數(shù)據(jù)是否OK
  123.                 {
  124.                         IE2=0x00;                                //如果OK就關(guān)中斷處理數(shù)據(jù)并顯示數(shù)據(jù)
  125.                         dis_time();
  126.                         dis_jwdu();
  127.                         dis_high();
  128.                         gps_data_ok_flag=0;
  129.                         IE2=0x01;                                 
  130.                 }
  131.         }
  132. }
  133. /********************************************************************************************************
  134. ** 函數(shù)名稱         Int_Timer0()
  135. ** 函數(shù)功能                定時(shí)器中斷位,是整個(gè)程序的心跳,如果停止,程序會(huì)死機(jī)
  136. *********************************************************************************************************/
  137. void  Int_Timer0(void) interrupt 1 using 3
  138. {
  139.         unsigned char i;
  140.         TH0 = 0xB8;
  141.         TL0 = 0x00;                                         //20ms的時(shí)鐘基準(zhǔn)
  142.         timer_1S_cnt++;   
  143.         timercount++;
  144.         EA=0;
  145.         if(timer_1S_cnt==50)                    //20×50=1000M
  146.         {
  147.                 timer_10S_cnt++;
  148.                 timer_1S_cnt=0;
  149.                 timer_S_cnt++;
  150.         }                                      //1秒=1000毫秒
  151.         if(timer_10S_cnt==10)                   //10S
  152.         {
  153.                 timer_10S_cnt=0;
  154.                 BELL_UP();
  155.                 sendstring(AT_CIPSEND);
  156.                 Delay_ms(5000);
  157.                 Delay_ms(5000);
  158.                 for(i=0;i<8;i++)
  159.                 {
  160.                         sendchar(gps_time[i]);        
  161. ……………………

  162. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
SIM900 GPRS GPS單片機(jī)源程序_帶NOKIA5110顯示.zip (77.26 KB, 下載次數(shù): 69)


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:505380 發(fā)表于 2020-2-18 16:03 | 只看該作者
沒有仿真嘛?
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表