自动干手器设计
参考文献
[1] 《单片机微型计算机与接口技术》[M]. 李群芳,张士军,黄建,北京:电子工业出版社,
2005
[2]单片机原理及接口技术(第3版)[M]. 李朝青编 北京航天航空大学出版社,2005 [3] 单片机原理与接口技术,李华.北京:清华大学出版社,33-80.
[4] 单片机C51程序设计教程与实验[M]. 祁伟, 杨亭.北京:北京航空航天大学出版社,2006.
[5] 电路设计与制版Protel 98[M]. 谈世哲,胡少宏.北京:人民邮电出版社,1998 [6] 张茂青,吴坚,胡继康等.AVR单片机在新型干手机中的应用[J].江苏电器,2003(03):27~
29,38
[7] 现代电子技术, 张杨.2011(01):143~145
[8] Tomas C.Bartee. Computer Architecture and Logic Design. McGraw-Hill Inc.1991 [9] 模拟电子电路基础. 王卫东,西安电子科技大学出版社, 2003.2 [10]数字电子技术基础(第五版). 阎石, 高等教育出版社,2006.5.
21
自动干手器设计
附 录
附录一:单片机控制原理图
附录二:红外感应原理图
22
自动干手器设计
附录三:单片机控制程序
#include
//定时器2的初值,20kHz的红外发射频率
//定时器1的初值,10ms的定时计算接收频率
#define FREQUENT_MIN 190 //频率比较范围 #define FREQUENT_MAX 220
1
#define START #define STOP 2 #define RUNNING 3 #define INVERIFY 4 #define HAVE_INVERIFY 5 #define SETINGTIME 6
#define LEDPORT P0 #define KEYPORT P1 sbit LED_0=P2^1; sbit LED_1=P2^0; sbit Relay_0=P1^3; sbit KEY_0=P1^6; sbit KEY_1=P1^5; sbit KEY_3=P1^4;
void Time2_xkHz_inital(); 化
void Start_timing(unsigned char settime); //开始倒计时 void LED_bit_print(unsigned char num, unsigned char printdata); void LED_all_print(unsigned char printdata); void delayms(unsigned int ms); unsigned char GetKeyboardVal();
23
//方波发生初始化 //红外频率检测初始
void frequent_test_inital();
自动干手器设计
volatile unsigned int timecount,settimecounter;
volatile unsigned char timesecond,ctrlcount,Flag,settime; unsigned char code
LED_tab[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; main() {
unsigned char key; Relay_0=1; Flag=START; settime=15;
Time2_xkHz_inital(); delayms(2000);
frequent_test_inital(); timesecond=0; while(1) {
if(Flag==RUNNING) {//显示 }
else if(Flag==SETINGTIME) { }
key=GetKeyboardVal(); switch(key) {
case 1: {
if(Flag!=RUNNING) {
if(settime>0)settime--; settimecounter=0; Flag=SETINGTIME;
24
LED_all_print(timesecond);
LED_all_print(settime);
自动干手器设计
} break;
}
case 2: { if(Flag!=RUNNING) { if(settime<30)settime++; settimecounter=0; Flag=SETINGTIME;
} break;
}
}
}
}
void T1_interrupt() interrupt 3 using 2 {
unsigned int fre_count; TF1=0; TR1=0; TR0=0;
if(Flag==RUNNING) { timecount++; if(timecount==100) { timecount=0; timesecond--; if(timesecond==0) { //停止吹风
Relay_0=1;
25
//定时器1中断程序