找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3636|回复: 1
打印 上一主题 下一主题
收起左侧

SIM900 GPRS+GPS单片机源程序_带NOKIA5110显示

[复制链接]
跳转到指定楼层
楼主
发一个SIM900A+GPS单片机源程序

单片机源程序如下:
  1. /**************************************************************************
  2. *                                                                        *
  3. * GPS+GPRS方式实现GPS地理位置信息通过GPRS无线上网方式传给上位机实例程序  *
  4. *                                                                        *
  5. * 功能:GPS地理坐标、卫星时间等信息通过GPRS方式传到上位机                *
  6. *       板上提供Nokia5110液晶屏接口,GPS信息可以通过液晶实时显示         *
  7. * 版本: V1.0 (08/24)                                               *
  8. *【声明】此程序仅用于学习与参考,引用请注明版权和作者信息!              *
  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;                          //将格林威治时间校正成北京时间
  21.          if(hh>=24)
  22.                 hh-=24;                   //校正小时
  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驱动部分的全局变量
  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缓冲区数据
  90.         while(strsearch("Call Ready",SystemBuf)==0);//等待模块准备好
  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));//检测服务商信息
  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数据是否OK
  123.                 {
  124.                         IE2=0x00;                                //如果OK就关中断处理数据并显示数据
  125.                         dis_time();
  126.                         dis_jwdu();
  127.                         dis_high();
  128.                         gps_data_ok_flag=0;
  129.                         IE2=0x01;                                 
  130.                 }
  131.         }
  132. }
  133. /********************************************************************************************************
  134. ** 函数名称         Int_Timer0()
  135. ** 函数功能                定时器中断位,是整个程序的心跳,如果停止,程序会死机
  136. *********************************************************************************************************/
  137. void  Int_Timer0(void) interrupt 1 using 3
  138. {
  139.         unsigned char i;
  140.         TH0 = 0xB8;
  141.         TL0 = 0x00;                                         //20ms的时钟基准
  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. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
SIM900 GPRS GPS单片机源程序_带NOKIA5110显示.zip (77.26 KB, 下载次数: 69)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:505380 发表于 2020-2-18 16:03 | 只看该作者
没有仿真嘛?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表