欢迎来到天天文库
浏览记录
ID:2188069
大小:135.50 KB
页数:7页
时间:2017-11-15
《简易温度计的设计与制作》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、项目五、简易温度计的设计与制作一、项目内容:(1)、使用温度传感器AD590进行温度谢信息获取(2)、使用ATmega16将获取的温度信息进行处理并用1602字符点阵液晶显示模块进行显示二、项目目标:(1)、熟练使用ATmega16内部的ADC模块(2)、熟悉温度传感器AD590与变送器的设计与使用(3)、进一步熟悉C语言的编程技巧(4)、进一步掌握熟悉系统的概率三、程序设计:#include"iom16v.h"#include"macros.h"#defineATmega16_AD_EnableADCSRA
2、=(1<3、#defineATmega16_AD_DisableADCSRA&=(~(1<4、=(1<5、=(1<6、=(1<7、ATmega16_ADIE_DisableADCSRA&=(~(1<8、=(1<<0)#defineLCM_RS_0PORTB&=(~(1<<0))#defineLCM_RW_1PORTB9、=(1<<1)#defineLCM_RW_0PORTB&=(~(1<<1))#defineLCM_E_1PORTB10、=(1<<2)#defineLCM_E_0PORTB&=(~(1<<2))unsignedcharLCM_Num_Table[]={'0','1','2','3','4','5'11、,'6','7','8','9'};voidDelay_1_us(void){NOP();NOP();NOP();NOP();}voidDelay_n_us(unsignedintn_us){unsignedintcnt_i;for(cnt_i=0;cnt_i12、voidDelay_n_ms(unsignedintn_ms){unsignedintcnt_i;for(cnt_i=0;cnt_i13、M_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_0;LCM_RW_0;LCM_E_1;PORTD=cmd_dat;Delay_n_us(1);LCM_E_0;}voidLCM_Wr_DAT(unsignedchardis_dat){while(LCM_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_1;LCM_RW_0;LCM_E_1;PORTD=dis_dat;Delay_n_us(1);LCM_E_0;Delay_n_us(40);}voidLCM_1602_Init(void){LCM14、_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x0e);Delay_n_ms(5);LCM_Wr_CMD(0x06);Delay_n_ms(5);LCM_Wr_CMD(0x01);Delay_n_ms(5);}voidATmega16_ADC_Init(void){ADCSRA=0x00;ADMUX=0X41;ACSR=0X80;ADCSRA=0X87;}unsignedin15、tATmega16_ADC_Convert(void){unsignedintadc_value;ATmega16_AD_Start;while(!(ADCSR&(1<
3、#defineATmega16_AD_DisableADCSRA&=(~(1<4、=(1<5、=(1<6、=(1<7、ATmega16_ADIE_DisableADCSRA&=(~(1<8、=(1<<0)#defineLCM_RS_0PORTB&=(~(1<<0))#defineLCM_RW_1PORTB9、=(1<<1)#defineLCM_RW_0PORTB&=(~(1<<1))#defineLCM_E_1PORTB10、=(1<<2)#defineLCM_E_0PORTB&=(~(1<<2))unsignedcharLCM_Num_Table[]={'0','1','2','3','4','5'11、,'6','7','8','9'};voidDelay_1_us(void){NOP();NOP();NOP();NOP();}voidDelay_n_us(unsignedintn_us){unsignedintcnt_i;for(cnt_i=0;cnt_i12、voidDelay_n_ms(unsignedintn_ms){unsignedintcnt_i;for(cnt_i=0;cnt_i13、M_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_0;LCM_RW_0;LCM_E_1;PORTD=cmd_dat;Delay_n_us(1);LCM_E_0;}voidLCM_Wr_DAT(unsignedchardis_dat){while(LCM_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_1;LCM_RW_0;LCM_E_1;PORTD=dis_dat;Delay_n_us(1);LCM_E_0;Delay_n_us(40);}voidLCM_1602_Init(void){LCM14、_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x0e);Delay_n_ms(5);LCM_Wr_CMD(0x06);Delay_n_ms(5);LCM_Wr_CMD(0x01);Delay_n_ms(5);}voidATmega16_ADC_Init(void){ADCSRA=0x00;ADMUX=0X41;ACSR=0X80;ADCSRA=0X87;}unsignedin15、tATmega16_ADC_Convert(void){unsignedintadc_value;ATmega16_AD_Start;while(!(ADCSR&(1<
4、=(1<5、=(1<6、=(1<7、ATmega16_ADIE_DisableADCSRA&=(~(1<8、=(1<<0)#defineLCM_RS_0PORTB&=(~(1<<0))#defineLCM_RW_1PORTB9、=(1<<1)#defineLCM_RW_0PORTB&=(~(1<<1))#defineLCM_E_1PORTB10、=(1<<2)#defineLCM_E_0PORTB&=(~(1<<2))unsignedcharLCM_Num_Table[]={'0','1','2','3','4','5'11、,'6','7','8','9'};voidDelay_1_us(void){NOP();NOP();NOP();NOP();}voidDelay_n_us(unsignedintn_us){unsignedintcnt_i;for(cnt_i=0;cnt_i12、voidDelay_n_ms(unsignedintn_ms){unsignedintcnt_i;for(cnt_i=0;cnt_i13、M_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_0;LCM_RW_0;LCM_E_1;PORTD=cmd_dat;Delay_n_us(1);LCM_E_0;}voidLCM_Wr_DAT(unsignedchardis_dat){while(LCM_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_1;LCM_RW_0;LCM_E_1;PORTD=dis_dat;Delay_n_us(1);LCM_E_0;Delay_n_us(40);}voidLCM_1602_Init(void){LCM14、_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x0e);Delay_n_ms(5);LCM_Wr_CMD(0x06);Delay_n_ms(5);LCM_Wr_CMD(0x01);Delay_n_ms(5);}voidATmega16_ADC_Init(void){ADCSRA=0x00;ADMUX=0X41;ACSR=0X80;ADCSRA=0X87;}unsignedin15、tATmega16_ADC_Convert(void){unsignedintadc_value;ATmega16_AD_Start;while(!(ADCSR&(1<
5、=(1<6、=(1<7、ATmega16_ADIE_DisableADCSRA&=(~(1<8、=(1<<0)#defineLCM_RS_0PORTB&=(~(1<<0))#defineLCM_RW_1PORTB9、=(1<<1)#defineLCM_RW_0PORTB&=(~(1<<1))#defineLCM_E_1PORTB10、=(1<<2)#defineLCM_E_0PORTB&=(~(1<<2))unsignedcharLCM_Num_Table[]={'0','1','2','3','4','5'11、,'6','7','8','9'};voidDelay_1_us(void){NOP();NOP();NOP();NOP();}voidDelay_n_us(unsignedintn_us){unsignedintcnt_i;for(cnt_i=0;cnt_i12、voidDelay_n_ms(unsignedintn_ms){unsignedintcnt_i;for(cnt_i=0;cnt_i13、M_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_0;LCM_RW_0;LCM_E_1;PORTD=cmd_dat;Delay_n_us(1);LCM_E_0;}voidLCM_Wr_DAT(unsignedchardis_dat){while(LCM_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_1;LCM_RW_0;LCM_E_1;PORTD=dis_dat;Delay_n_us(1);LCM_E_0;Delay_n_us(40);}voidLCM_1602_Init(void){LCM14、_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x0e);Delay_n_ms(5);LCM_Wr_CMD(0x06);Delay_n_ms(5);LCM_Wr_CMD(0x01);Delay_n_ms(5);}voidATmega16_ADC_Init(void){ADCSRA=0x00;ADMUX=0X41;ACSR=0X80;ADCSRA=0X87;}unsignedin15、tATmega16_ADC_Convert(void){unsignedintadc_value;ATmega16_AD_Start;while(!(ADCSR&(1<
6、=(1<7、ATmega16_ADIE_DisableADCSRA&=(~(1<8、=(1<<0)#defineLCM_RS_0PORTB&=(~(1<<0))#defineLCM_RW_1PORTB9、=(1<<1)#defineLCM_RW_0PORTB&=(~(1<<1))#defineLCM_E_1PORTB10、=(1<<2)#defineLCM_E_0PORTB&=(~(1<<2))unsignedcharLCM_Num_Table[]={'0','1','2','3','4','5'11、,'6','7','8','9'};voidDelay_1_us(void){NOP();NOP();NOP();NOP();}voidDelay_n_us(unsignedintn_us){unsignedintcnt_i;for(cnt_i=0;cnt_i12、voidDelay_n_ms(unsignedintn_ms){unsignedintcnt_i;for(cnt_i=0;cnt_i13、M_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_0;LCM_RW_0;LCM_E_1;PORTD=cmd_dat;Delay_n_us(1);LCM_E_0;}voidLCM_Wr_DAT(unsignedchardis_dat){while(LCM_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_1;LCM_RW_0;LCM_E_1;PORTD=dis_dat;Delay_n_us(1);LCM_E_0;Delay_n_us(40);}voidLCM_1602_Init(void){LCM14、_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x0e);Delay_n_ms(5);LCM_Wr_CMD(0x06);Delay_n_ms(5);LCM_Wr_CMD(0x01);Delay_n_ms(5);}voidATmega16_ADC_Init(void){ADCSRA=0x00;ADMUX=0X41;ACSR=0X80;ADCSRA=0X87;}unsignedin15、tATmega16_ADC_Convert(void){unsignedintadc_value;ATmega16_AD_Start;while(!(ADCSR&(1<
7、ATmega16_ADIE_DisableADCSRA&=(~(1<8、=(1<<0)#defineLCM_RS_0PORTB&=(~(1<<0))#defineLCM_RW_1PORTB9、=(1<<1)#defineLCM_RW_0PORTB&=(~(1<<1))#defineLCM_E_1PORTB10、=(1<<2)#defineLCM_E_0PORTB&=(~(1<<2))unsignedcharLCM_Num_Table[]={'0','1','2','3','4','5'11、,'6','7','8','9'};voidDelay_1_us(void){NOP();NOP();NOP();NOP();}voidDelay_n_us(unsignedintn_us){unsignedintcnt_i;for(cnt_i=0;cnt_i12、voidDelay_n_ms(unsignedintn_ms){unsignedintcnt_i;for(cnt_i=0;cnt_i13、M_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_0;LCM_RW_0;LCM_E_1;PORTD=cmd_dat;Delay_n_us(1);LCM_E_0;}voidLCM_Wr_DAT(unsignedchardis_dat){while(LCM_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_1;LCM_RW_0;LCM_E_1;PORTD=dis_dat;Delay_n_us(1);LCM_E_0;Delay_n_us(40);}voidLCM_1602_Init(void){LCM14、_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x0e);Delay_n_ms(5);LCM_Wr_CMD(0x06);Delay_n_ms(5);LCM_Wr_CMD(0x01);Delay_n_ms(5);}voidATmega16_ADC_Init(void){ADCSRA=0x00;ADMUX=0X41;ACSR=0X80;ADCSRA=0X87;}unsignedin15、tATmega16_ADC_Convert(void){unsignedintadc_value;ATmega16_AD_Start;while(!(ADCSR&(1<
8、=(1<<0)#defineLCM_RS_0PORTB&=(~(1<<0))#defineLCM_RW_1PORTB
9、=(1<<1)#defineLCM_RW_0PORTB&=(~(1<<1))#defineLCM_E_1PORTB
10、=(1<<2)#defineLCM_E_0PORTB&=(~(1<<2))unsignedcharLCM_Num_Table[]={'0','1','2','3','4','5'
11、,'6','7','8','9'};voidDelay_1_us(void){NOP();NOP();NOP();NOP();}voidDelay_n_us(unsignedintn_us){unsignedintcnt_i;for(cnt_i=0;cnt_i12、voidDelay_n_ms(unsignedintn_ms){unsignedintcnt_i;for(cnt_i=0;cnt_i13、M_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_0;LCM_RW_0;LCM_E_1;PORTD=cmd_dat;Delay_n_us(1);LCM_E_0;}voidLCM_Wr_DAT(unsignedchardis_dat){while(LCM_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_1;LCM_RW_0;LCM_E_1;PORTD=dis_dat;Delay_n_us(1);LCM_E_0;Delay_n_us(40);}voidLCM_1602_Init(void){LCM14、_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x0e);Delay_n_ms(5);LCM_Wr_CMD(0x06);Delay_n_ms(5);LCM_Wr_CMD(0x01);Delay_n_ms(5);}voidATmega16_ADC_Init(void){ADCSRA=0x00;ADMUX=0X41;ACSR=0X80;ADCSRA=0X87;}unsignedin15、tATmega16_ADC_Convert(void){unsignedintadc_value;ATmega16_AD_Start;while(!(ADCSR&(1<
12、voidDelay_n_ms(unsignedintn_ms){unsignedintcnt_i;for(cnt_i=0;cnt_i13、M_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_0;LCM_RW_0;LCM_E_1;PORTD=cmd_dat;Delay_n_us(1);LCM_E_0;}voidLCM_Wr_DAT(unsignedchardis_dat){while(LCM_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_1;LCM_RW_0;LCM_E_1;PORTD=dis_dat;Delay_n_us(1);LCM_E_0;Delay_n_us(40);}voidLCM_1602_Init(void){LCM14、_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x0e);Delay_n_ms(5);LCM_Wr_CMD(0x06);Delay_n_ms(5);LCM_Wr_CMD(0x01);Delay_n_ms(5);}voidATmega16_ADC_Init(void){ADCSRA=0x00;ADMUX=0X41;ACSR=0X80;ADCSRA=0X87;}unsignedin15、tATmega16_ADC_Convert(void){unsignedintadc_value;ATmega16_AD_Start;while(!(ADCSR&(1<
13、M_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_0;LCM_RW_0;LCM_E_1;PORTD=cmd_dat;Delay_n_us(1);LCM_E_0;}voidLCM_Wr_DAT(unsignedchardis_dat){while(LCM_Re_BAC()>=0x80);DDRD=0xFF;LCM_RS_1;LCM_RW_0;LCM_E_1;PORTD=dis_dat;Delay_n_us(1);LCM_E_0;Delay_n_us(40);}voidLCM_1602_Init(void){LCM
14、_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x38);Delay_n_ms(5);LCM_Wr_CMD(0x0e);Delay_n_ms(5);LCM_Wr_CMD(0x06);Delay_n_ms(5);LCM_Wr_CMD(0x01);Delay_n_ms(5);}voidATmega16_ADC_Init(void){ADCSRA=0x00;ADMUX=0X41;ACSR=0X80;ADCSRA=0X87;}unsignedin
15、tATmega16_ADC_Convert(void){unsignedintadc_value;ATmega16_AD_Start;while(!(ADCSR&(1<
此文档下载收益归作者所有