基于51單片機(jī)設(shè)計(jì)的的GSM的遠(yuǎn)程家庭智能報(bào)警系統(tǒng)PPT內(nèi)容預(yù)覽:
本設(shè)計(jì)采用的是飛思卡爾公司的加速度傳感器MMA7455I。
差容式加速度傳感器
輸出信號(hào)為數(shù)字信號(hào),CS端口的高低電平?jīng)Q定其通信方式
在本設(shè)計(jì)中采用IIC通信
內(nèi)部還有信號(hào)調(diào)理和電壓轉(zhuǎn)換電路電路
二 溫濕度傳感器
在本設(shè)計(jì)中采用的是溫濕度傳感器DHT11,DHT11 數(shù)字溫濕度傳感器是一款含有已校準(zhǔn)數(shù)字信號(hào)輸出的溫濕度復(fù)合傳感器。它應(yīng)用專用的數(shù)字模塊采集技術(shù)和溫濕度傳感技術(shù),采用的是NTC測(cè)溫元件。
運(yùn)用IIC協(xié)議讀出加速度信號(hào),并通過液晶屏分別顯示X、Y和Z軸的加速度。
對(duì)加速度信號(hào)的處理過程:
本設(shè)計(jì)只對(duì)X軸信號(hào)進(jìn)行處理,為了有效避免誤報(bào)現(xiàn)象,我采用的是用加速度的平均值進(jìn)行位移的計(jì)算:
其中的時(shí)間t我們?cè)O(shè)定為加速度值大于
到位移大于0.1m之間的時(shí)間長(zhǎng)度。此時(shí)停止對(duì)加速度信號(hào)進(jìn)行采集同時(shí)報(bào)警!
DHT11為溫濕度傳感器,我只取其采集的溫度信息并對(duì)其判斷處理。
在DHT11子函數(shù)中,由于其通信的特點(diǎn),運(yùn)用最多的是對(duì)不同延時(shí)程序的調(diào)用。
本設(shè)計(jì)針對(duì)現(xiàn)有的GSM無線網(wǎng)絡(luò),介紹了基于GSM的遠(yuǎn)程家庭智能報(bào)警系統(tǒng)的設(shè)計(jì)及實(shí)現(xiàn)方法。利用各種傳感器,如溫濕度傳感器、加速度傳感器等對(duì)家中可能出現(xiàn)的各種意外情況進(jìn)行采集,并通過組建的家中內(nèi)部無線網(wǎng)絡(luò)及時(shí)向單片機(jī)進(jìn)行中斷報(bào)警。GSM模塊在單片機(jī)控制下,利用GSM網(wǎng)絡(luò),將各種報(bào)警信息通過短信的方式發(fā)送到預(yù)先設(shè)定的手機(jī)中,達(dá)到了遠(yuǎn)程無線智能報(bào)警的功能。同時(shí),本文在對(duì)加速度信號(hào)的處理上,采用新的方法,即使用加速度平均值,并設(shè)定參考點(diǎn)的思路和方法,有效避免了漏報(bào)、誤報(bào)現(xiàn)象的產(chǎn)生,是系統(tǒng)更加穩(wěn)定。經(jīng)過測(cè)試,該系統(tǒng)經(jīng)濟(jì)、可靠、穩(wěn)定性高。家庭無需為傳感器布線,具有廣泛的市場(chǎng)推廣價(jià)值。
單片機(jī)源程序如下:
- #include <reg52.h>
- #include <intrins.h>
- #include <lcd_1602.h>
- #include <IIC.h>
- #include <DHT11.h>
- #include <DGSM.h>
- #include <math.h>
- #define uchar unsigned char
- #define uint unsigned int
- uint ttt,tt;
- int jiasu;
- uint chen,juli,flag;
- uchar str[8]="H: T: ";
- uchar code table4[10]="0123456789";
- //uchar U8T_data_H,U8T_data_L,U8RH_data_H,U8RH_data_L;
- /***************rs=P1^2;rw=P1^1;e =P1^0;液晶顯示還有P0*****************/
- /***************sda=P1^3;scl=P1^4;傳感器************/
- /***************P2_0 = P2^0 ;溫濕度**********************/
- /**************************************************************************/
- /************ 延時(shí)程序 **************/
- /**************************************************************************/
- void DelayUs(unsigned char us)//delay us
- {
- unsigned char uscnt;
- uscnt=us>>1;/* Crystal frequency in 12MHz*/
- while(--uscnt);
- }
- void DelayMs(unsigned char ms)//delay Ms
- {
- while(--ms)
- {
- DelayUs(250);
- DelayUs(250);
- DelayUs(250);
- DelayUs(250);
- }
- }
- void delay_50ms(uchar t)
- {
- uint j;
- for(;t>0;t--)
- for(j=6245;j>0;j--);
- }
- void sendx() //函數(shù)功能:向1602發(fā)送x軸測(cè)量數(shù)據(jù)
- {
- uchar x1,x2,x3,xsign;
- char x;
-
- x=iic_read(0x06);
- if(abs(x)>5)
- {
- TR0=1;
- while(abs(x)>5)
- {
-
- flag++;
- x=iic_read(0x06);
- //if((x&0x80)==0x00)
- //{
- // xsign=0x2b; //+
- // }
- // else
- // {
- // xsign=0x2d; //-
- // x=x-0x01;
- // x=~x;
- // }
- // x1=(x/63);
- // x2=((x*100/63)%100)/10;
- // x3=(x*100/63)%10;
- jiasu=jiasu+x;
- }
- }
- TR0=0;
- chen=tt;
- tt=0;
- juli=(jiasu/flag)*15*chen*chen/200;
- if(juli>100)
- A1=0;
- if((x&0x80)==0x00)
- {
- xsign=0x2b; //+
- }
- else
- {
- xsign=0x2d; //-
- x=x-0x01;
- x=~x;
- }
- // x1=(x/63);
- // x2=((x*100/63)%100)/10;
- // x3=(x*100/63)%10;
-
- // else
- // A1=1;
- x1=x/100;
- x2=x%100/10;
- x3=x%10;
- write_com(0x8B);
- write_data(xsign);
- delay_50us(10);
- write_com(0x8C);
- write_data(table9[x1]);
- delay_50us(10);
- write_com(0x8E);
- write_data(table9[x2]);
- delay_50us(10);
- write_com(0x8F);
- write_data(table9[x3]);
- delay_50us(20);
- }
-
- /***********************************************************/
- /**************** 主函數(shù) ****************/
- /***********************************************************/
- void main()
- {
- uchar j;
- uchar shi,ge,shi0,ge0;
- init1602();
- Ini_UART(); //串口初始化
- Delaym();
- DelayMs(15);
- self_test7455();
- iic_write(0x10,0x15);//校正X值
- iic_write(0x12,0x25);//校正Y值
- iic_write(0x14,0x10);//校正Z值
- delay_50ms(20);
-
- while(1)
- {
-
- RH();
- shi=U8RH_data_H%100/10;
- ge=U8RH_data_H%10;
- str[2]=table4[shi];
- str[3]=table4[ge];
-
- shi0=U8T_data_H%100/10;
- ge0=U8T_data_H%10;
- str[6]=table4[shi0];
- str[7]=table4[ge0];
- if((shi0>3)||(shi>4))
- {
- if(shi0>3)
- A2=0;
- else
- A2=1;
- if(shi>4)
- A1=0;
- else
- A1=1;
- }
- write_com(0x80);
- for(j=0;j<8;j++)
- {
- write_data(str[j]);
- delay_50us(10);
- }
-
- sendx();
- //delay_50ms(1);
- if(A1==0)
- {
- ATD(); //打電話
- Delaym();
- Delay1(10000);
- ATH();
- Delaym();
- A1=1;
- }
- if(A2==0)
- {
- CMGF();
- Delay1(3000);
- CMGS();
- Delay1(3000);
- ……………………
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼完整的文檔預(yù)覽: http://www.torrancerestoration.com/bbs/dpj-85501-1.html
所有資料51hei提供下載(含完整文檔+程序+ppt文件):
基于GSM的遠(yuǎn)程家庭智能防盜系統(tǒng).rar
(2.53 MB, 下載次數(shù): 234)
2017-5-21 13:23 上傳
點(diǎn)擊文件名下載附件
|