freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于ds18b20測溫系統(tǒng)論文(編輯修改稿)

2024-12-22 20:40 本頁面
 

【文章內(nèi)容簡介】 covert1(TL,39。L39。)。 LCD_Print(0,1,TempBuffer0)。 } if(%5==0) { ISendStr(AT24C02,0,amp。TemperatureA,2)。 } 22 } } 各模塊子程序 [1]溫度測試程序: Ds18b20: include include include unsigned char tt[2]。 sbit DQ1 = P3^4。 /**********ds18b20 初始化函數(shù) **********************/ void Init_DS18B20(void) { unsigned char x=0。 DQ1= 1。 //DQ 復(fù)位 delay(8)。 //稍做延時(shí) DQ1= 0。 //單片機(jī)將 DQ拉低 delay(80)。 //精確延時(shí) 大于 480us DQ1= 1。 //拉高總線 delay(14)。 x=DQ1。 //稍做延時(shí)后 如果 x=0 則初始化成功 x=1 則初始化失敗 delay(20)。 } /***********ds18b20 讀一個(gè)字節(jié) **************/ unsigned char ReadOneChar(void) { unsigned char i=0。 unsigned char dat = 0。 23 for (i=8。i0。i) { DQ1 = 0。 // 給脈沖信號 dat=1。 DQ1 = 1。 // 給脈沖信號 if(DQ1) dat|=0x80。 delay(4)。 } return(dat)。 } /*************ds18b20 寫一個(gè)字節(jié) ****************/ void WriteOneChar(unsigned char dat) { unsigned char i=0。 for (i=8。 i0。 i) { DQ1 = 0。 DQ1 = datamp。0x01。 delay(5)。 DQ1 = 1。 dat=1。 } } /**************讀取 ds18b20 當(dāng)前溫度 ************/ unsigned char *ReadTemperature() { // Init_DS18B20()。 // WriteOneChar(0xCC)。 // 跳過讀序號列號的操作 // WriteOneChar(0x4E)。 // //寫入 寫暫存器 命令 ,修改 TH 和 TL 和分辯率配置寄存器 //先寫 TH,再寫 TL,最后寫配置寄存器 // WriteOneChar(TH)。 //寫入想設(shè)定的溫度報(bào)警上限 // WriteOneChar(TL)。 //寫入想設(shè)定的溫度報(bào)警下限 // WriteOneChar(RS)。 //寫配置寄存器 ,格式為 0 R1 R0 1,1 1 1 1 //R1R0=00 分辨率婁 9 位 ,R1R0=11 分辨率為 12 位 // delay(80)。 // this message is wery important Init_DS18B20()。 WriteOneChar(0xCC)。 // 跳過讀序號列號的操作 WriteOneChar(0x44)。 // 啟動(dòng)溫度轉(zhuǎn)換 24 delay(80)。 // this message is wery important Init_DS18B20()。 WriteOneChar(0xCC)。 //跳過讀序號列號的操作 WriteOneChar(0xBE)。 //讀取溫度寄存器等(共可讀 9 個(gè)寄存器 ) 前兩個(gè)就是溫度 delay(80)。 tt[0]=ReadOneChar()。 //讀取溫度值低位 tt[1]=ReadOneChar()。 //讀取溫度值高位 return(tt)。 } Ds18b201: include include include unsigned char tt1[2]。 sbit DQ2 = P2^5。 /**********ds18b20 初始化函數(shù) **********************/ void Init_DS18B201(void) { unsigned char x=0。 DQ2= 1。 //DQ 復(fù)位 delay(8)。 //稍做延時(shí) DQ2= 0。 //單片機(jī)將 DQ 拉低 delay(80)。 //精確延時(shí) 大于 480us DQ2= 1。 //拉高總線 delay(14)。 x=DQ2。 //稍做延時(shí)后 如果 x=0 則初始化成功 x=1 則初始化失敗 delay(20)。 } /***********ds18b20 讀一個(gè)字節(jié) **************/ unsigned char ReadOneChar1(void) { unsigned char i=0。 unsigned char dat = 0。 for (i=8。i0。i) { 25 DQ2 = 0。 // 給脈沖信號 dat=1。 DQ2 = 1。 // 給脈沖信號 if(DQ2) dat|=0x80。 delay(4)。 } return(dat)。 } /*************ds18b20 寫一個(gè)字節(jié) ****************/ void WriteOneChar1(unsigned char dat) { unsigned char i=0。 for (i=8。 i0。 i) { DQ2 = 0。 DQ2 = datamp。0x01。 delay(5)。 DQ2 = 1。 dat=1。 } } /**************讀取 ds18b201 當(dāng)前溫度 ************/ unsigned char *ReadTemperature1() { // Init_DS18B201()。 // WriteOneChar1(0xCC)。 // 跳過讀序號列號的操作 // WriteOneChar1(0x4E)。 // //寫入 寫暫存器 命令 ,修改 TH 和 TL 和分辯率配置寄存器 //先寫 TH,再寫 TL,最后寫配置寄存器 // WriteOneChar1(TH)。 //寫入想設(shè)定的溫度報(bào)警上限 // WriteOneChar1(TL)。 //寫入想設(shè)定的溫度報(bào)警下限 // WriteOneChar1(RS)。 //寫配置寄存器 ,格式為 0 R1 R0 1,1 1 1 1R1R0=00 分辨率婁9 位 ,R1R0=11 分辨率為 12 位 // delay(80)。 // this message is wery important Init_DS18B201()。 WriteOneChar1(0xCC)。 // 跳過讀序號列號的操作 WriteOneChar1(0x44)。 // 啟動(dòng)溫度 轉(zhuǎn)換 delay(80)。 // this message is wery important 26 Init_DS18B201()。 WriteOneChar1(0xCC)。 //跳過讀序號列號的操作 WriteOneChar1(0xBE)。 //讀取溫度寄存器等(共可讀 9 個(gè)寄存器) 前兩個(gè)就是溫度 delay(80)。 tt1[0]=ReadOneChar1()。 //讀取溫度值低位 tt1[1]=ReadOneChar1()。 //讀取溫度值高位 return(tt1)。 } [2]顯示程序 : include include include include //定義的時(shí)間類型 SYSTEMTIME MTIME。 sbit LcdRs = P2^0。 sbit LcdRw = P2^1。 sbit LcdEn = P2^2。 sfr DBPort = 0x80。 unsigned char ReadValue。 unsigned char t[2],*pt。 //用來存放溫度值 ,測溫程序就是通過這個(gè)數(shù)組與主函數(shù)通信的 //unsigned char display[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88}。 unsigned char TempBuffer1[9]={0x2b,0x31,0x32,0x32,0x2e,0x30,0x30,0x43,39。\039。}。 //顯示實(shí)時(shí)溫度 ,上電時(shí)顯示 + unsigned char TempBuffer0[17]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,39。\039。}。 //顯示溫度上下限 ,上電時(shí)顯示 TH:+125 TL:+124C unsigned char code dotcode[4]={0,25,50,75}。 // 內(nèi)部等待函數(shù)************************************************************************** unsigned char LCD_Wait(void) { LcdRs=0。 LcdRw=1。 _nop_()。 LcdEn=1。 _nop_()。 //while(DBPortamp。0x80)。//在用 Proteus 仿真時(shí),注意用屏蔽此語句,在調(diào)用 GotoXY() 27 時(shí),會進(jìn)入死循環(huán), //可能在寫該控制字時(shí),該模塊沒有返回寫入完備命令,即 DBPortamp。0x80==0x80 //實(shí)際硬件時(shí)打開此語句 LcdEn=0。 return DBPort。 } // 向 LCD 寫 入 命 令 或 數(shù) 據(jù)************************************************************ define LCD_COMMAND 0 // Command define LCD_DATA 1 // Data define LCD_CLEAR_SCREEN 0x01 // 清屏 define LCD_HOMING 0x02 // 光標(biāo)返回原點(diǎn) void LCD_Write(bit style, unsigned char input) { LcdEn=0。 LcdRs=style。 LcdRw=0。 _nop_()。 DBPort=input。_nop_()。//注意順序 LcdEn=1。 _nop_()。//注意順序 LcdEn=0。 _nop_()。 LCD_Wait()。 } //設(shè)置顯示模式 ************************************************************ define LCD_SHOW 0x04 //顯示開 define LCD_HIDE 0x00 //顯示關(guān) define LCD_CURSOR 0x02 //顯示光標(biāo) define LCD_NO_CURSOR 0x00 //無光標(biāo) define LCD_FLASH 0x01 //光標(biāo)閃動(dòng) define LCD_NO_FLASH 0x00 //光標(biāo)不閃動(dòng) void LCD_SetDisplay(unsigned char DisplayMode) { LCD_Write(LCD_COMMAND, 0x08|DisplayMode)。 } //設(shè)置輸入模式 ************************************************************
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1