一、温度传感器选择由于采用NTC热敏电阻与温度的关系是非线性的,用电桥实现温度升高引起的电阻变化对应于电压变化,因此输出的结果测试精度较低,并且不能达到我们对温度控制的要求。温度传感器AD590是一种电压输入、电流输出型集成温度传感器,测温范围为-55℃~150℃,精度高,非线性误差仅为±0.3℃,调节系数为1微安每K,输出电流I=(273+T)微安。温度传感器LM1335,V0=10毫伏每摄氏度,具有很高的工作精度与线性工作范围。器件输出电压与温度成线性关系,调节系数为10毫伏每摄氏度,因而优越之处在于无需外部校准微调,可以供±1\4℃常用室温精度。二、转换电路将采集到的电信号转换为0~5V之间,使之可以直接加到ADC0809端口。三、采样值量化算法:比例系数KT=0.0278V|℃=27.8MV0摄氏度时,电压为0+55*0.0278=1.529V,每个数字量对应电压值19.53MV,用KS表示得到数字量与温度的关系。KT|KS=1.426数字量每摄氏度0摄氏度对用AD输出量D0=55*1.426=78.43≈79=01001111B四、ADC0809五、基本功能是用三个按键来控制风速、类型以及停止这三个状态的变换。当风速键按下时实现风速强、中、弱三种状态依次循环切换,并用三个LED指示灯来显示;当类型键按下时实现类型正常、睡眠、自然三种状态的依次循环切换,并用三个LED指示灯来显示。题目中类型键要求自然状态转2秒,停4秒;睡眠状态转2秒,停转6秒,这个涉及到时间问题,可以通过硬件或者软件来实现,选择通过软件来实现。控制系统分四个功能模块,主要包含风速设置、类型设置、默认状态显示和退出系统。1、风速设置这个模块中风速的三个状态强、中、弱之间的循环切换是通过将端口A的键值逐次加1(初始值为0,每按下一次风速键寄存器值加1),然后对3求余,取其余数分别代表这三个状态来实现的。由于对3求余的余数只有0、1、2三个值,分别代表强、中、弱,将其余数保存到寄存器中,根据寄存器中是0、1、2来判断强、中、弱风三个状态。2、类型设置风的类型有:正常、自然、睡眠三种。a)正常电扇连续运转。b)自然电扇模拟自然风,即转2s,停4s。c)睡眠电扇慢转,产生轻柔的微风,运转2s,停转6s。自然状态和睡眠状态时间的控制是通过调用延时子程序来实现的,由于一个机器周期是10-6秒,延时程序是通过循环来实现的,让指令执行106次来实现1秒。不是很精确。MY8255_AEQU0FF00H;8255AMY8255_BEQU0FF01H;8255BMY8255_CEQU0FF02H;8255CMY8255_MODEEQU0FF03H;8255STACK1SEGMENTSTACKDW256DUP(?)STACK1ENDSDATASEGMENTDATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVDX,MY8255_MODEMOVAL,90HOUTDX,ALMOVDX,MY8255_CMOVAL,00HOUTDX,ALMOVDX,MY8255_BMOVAL,0FFHOUTDX,ALSTART1:MOVDX,MY8255_A//对8255A口进行扫描INAL,DXANDAL,00001000BCMPAL,08H//对按键进行判断JNZT1CALLZIRAN//调用自然模式T1:MOVDX,MY8255_AINAL,DXANDAL,00000111B//屏蔽按键CMPAL,00HJNZT10CALLSTOPT10:CMPAL,01HJNZT6CALLQIANGT6:CMPAL,02HJNZT8//AL非02H跳入T8CALLZHONGT8:CMPAL,04HJNZT9CALLRUOT9:JMPSTART1//自然模式ZIRANPROCNEARMOVDX,MY8255_B//对8255B口进行初始化MOVAL,0F7HOUTDX,ALMOVCX,40//循环次数进行控制T:MOV[DI],1770HCALLZHENGZHUANLOOPTCALLDL4SRETENDP//强风模式QIANGPROCNEARMOVDX,MY8255_B//对8255B口进行初始化MOVAL,0FEHOUTDX,ALMOV[DI],0A00HMOVDX,MY8255_A//扫描8255A口INAL,DXANDAL,00010000BCMPAL,10H//对按键进行判断JNZT2CALLFANZHUANCMPAL,01HJZT3T2:CALLZHENGZHUANT3:RETENDP//中风模式ZHONGPROCNEARMOVDX,MY8255_B//对8255B口进行初始化MOVAL,0FDHOUTDX,ALMOV[DI],1000HMOVDX,MY8255_A//扫描8255A口INAL,DXANDAL,00010000BCMPAL,10H//对按键进行判断JNZT4T4:CALLFANZHUANCMPAL,10HJNZT5CALLZHENGZHUANT5:RETENDP//停止模式STOPPROCNEARMOVDX,MY8255_B//对8255B口进行初始MOVAL,0FFHOUTDX,ALMOVDX,MY8255_C//对8255C口进行初始化MOVAL,00HOUTDX,ALCALLDL500ms//调用延时RETENDP//弱风模式RUOPROCNEARMOVDX,MY8255_B//对8255B口进行初始MOVAL,0FBHOUTDX,ALMOV[DI],1B00HMOVDX,MY8255_A//扫描8255AINAL,DXANDAL,00010000BCMPAL,10H//对按键进行判断JNZA1CALLFANZHUANA1:CMPAL,10HJNZA2CALLZHENGZHUANA2:RETENDP//反转模式FANZHUANPROCNEARMOVDX,MY8255_A//扫描8255AINAL,DXNOTALMOVDX,MY8255_BOUTDX,ALMOVDX,MY8255_CMOVAL,09H//设置风扇的旋转方式OUTDX,ALCALLDELAYMOVAL,0CHOUTDX,ALCALLDELAYMOVAL,06HOUTDX,ALCALLDELAYMOVAL,03HOUTDX,ALCALLDELAYRETENDP//正转模式ZHENGZHUANPROCNEARPUSHDXMOVDX,MY8255_C//对8255C口进行初始化MOVAL,03HOUTDX,ALCALLDELAYMOVAL,06H//设置风扇的旋转方式OUTDX,ALCALLDELAYMOVAL,0CHOUTDX,ALCALLDELAYMOVAL,09HOUTDX,ALCALLDELAYPOPDXRETENDP//延时程序设置DELAYPROCNEARPUSHCXMOVCX,[DI]DATE:LOOPDATEPOPCXRETENDPDL500msPROCNEARPUSHCXMOVCX,60000DL500ms1:LOOPDL500ms1POPCXRETDL500msENDPDL4SPROCNEARPUSHCXMOVCX,8DL4S1:CALLDL500msLOOPDL4S1POPCXRETENDPCODEENDSENDSTARTPa08255Pb0……Pb7cs8279Clk1out1Gate18253clk0Out0csgate0Int08259cs200~207228~22fDL8……DL1csPc0Pc3脉冲源210~217220~227datasegmentisenddb0n0db0n1db0n2db0isrightdb1keykinddb0oldkeydb0kinddb0isstopdb0flagsdb0numbersdb3fh,6,5bh,0,0,0,0,0,0,0dataendscodesegmentassumecs:code,ds:datamain:;主程序climovax,csmovds,axmovkind,0movisright,1movkeykind,0ahmovoldkey,0ahmovkind,0movisstop,0movflags,0movisend,0movn0,0movn1,0movn2,0callinitnumberscallinit8255callinit8259callinit8253callmodifyintmovdx,212hmoval,0outdx,alcallcleardevicecalldisplaymoval,0movdx,22ahoutdx,almoval,30houtdx,almoval,7fhstidowhat:pushaxdowait:moval,0ffh;单色灯清零movdx,211houtdx,almovdx,210hinal,dxtestal,1;判断开关jzdowaitpopaxcallreadakeycmpkeykind,0ahjnza1movkind,2callgotonextjmpaaa1:;判断风速改变cmpkeykind,0bhjnza2movkind,1callgotonextjmpaaa2:cmpkeykind,0chjnza3movkind,0callgotonextjmpaaa3:cmpkeykind,0dhjnza4pushaxmovdx,212hmoval,0outdx,alpopaxmovisstop,0pushaxmoval,oldkeymovkeykind,alcallreadingmovdx,212hmoval,0ffhoutdx,alpopaxstijmpaaa4:cmpkeykind,0ehjnzaanotflagspushaxmoval,oldkeymovkeykind,alpopaxaa:jmpdowhatgotonext:;单色灯循环亮灭movdx,211houtdx,alcmpflags,0jnznororroral,1noror:cmpal,0fehjnzcontinuejmpcontinuecontinue:cmpkind,2jnzmm1callspeed2jmpmm3mm1:;改变风速cmpkind,1jnzmm2callspeed1jmpmm3mm2:cmpkind,0jnzmm3callspeed0mm3:pushaxmm33:cmpisstop,0jzmm4movdx,211hmoval,0ffhoutdx,almovdx,210hinal,dxtestal,1jnzmm33movisstop,0climm4:popaxretreadakey:;读取键盘输入pushaxmoval,keykindmovoldkey,almovdx,22ahinal,dxandal,0fhcmpal,0jzgotoexitmoval,40hmovdx,22ahoutdx,almovdx,228hinal,dxmovkeykind,algotoexit:popaxretspeed1:;速度设置pushcxmovcx,18000sp1:loopsp1popcxretspeed2:pushcxmovcx,50000sp2:loopsp2popcxretspeed0:pushcxmovcx,8000sp0:loopsp0popcxretreadisd:key:movdx,22ahinal,dxandal,0fhcmpal,0jzkeymoval,40houtdx,almovdx,228hinal,dxcmpal,0dhjnzkeyretreading:;输入时间pushaxmovn0,0movn1,0movn2,0callreadanumbermovn0,alcalldisplaycallreadanumbercmpal,0dhjzreadexitmovah,n0movn0,almovn1,ahcalldisplaycallreadanumbercmp