全国大学生电子设计竞赛风帆控制装置摘要本系统采用STC90C516RD+系列单片机作为控制核心,包括角度传感器、L298N电机驱动模块、液晶显示、独立键盘控制、声光报警等电路模块。单片机以PWM方式控制电机工作。安装在帆板上的SCA100T-D02角度传感器将检测信号传送至单片机,由ADC0809将模拟信号转换为数字信号,计算出偏转角度并显示,同时单片机将采集的角度信号经处理后输出相应的PWM信号,PWM信号经L298N驱动,控制直流轴流风扇转速,达到控制风板角度的目的。测试结果证明,系统运行稳定可靠,可以准确快速地调整运转角度,液晶显示角度准确,声光提示信息齐全,完全达到题目所有规定的基本及发挥部分的要求。关键词:角度传感器;PWM;STC单片机;L298N电机驱动模块AbstractThissystemadoptsSTC90C516RD+seriessinglechipmicrocomputerascontrolcore,includingtheAnglesensor,L298Nmotordrivermodule,liquidcrystaldisplay,keyboardcontrol,soundandlightalarmcircuitmoduleindependently.SinglechipmicrocomputercontrolmotorworkinginPWMmanner.InstalledinthepanelsontheAngleofthesensorwilldetectsignalstosinglechipmicrocomputer,fromtheSCA100T-D02singleAnglesensorwithADconverterconvertsanalogsignalstodigitalsignals,calculatetherotationAngleandshowtheresult,thencomputercalcutethesingalofcollectingandoutputsthePWM.PWMsignalbyL298Ndrive,controldcaxialflowfanspeed,achievethegoalofcontrollingwindplateAngle.Testresultsprovedthatthesystemrunsstableandreliable,andcanbequicklyandaccuratelyadjustrunningAngle,AngleofLCDdisplayaccurate,acousto-optichintinformationiscomplete,fullymeetthebasicoftherequirementsinthesubject,andexertingrequirements.Keyword:Anglesensor;PWM.OnSTCmicrocontroller;L298NmotordrivermoduleI目录1系统方案...................................................................................................................................................11.1总体设计......................................................................................................................................11.2单片机控制模块..........................................................................................................................11.3角度传感器..................................................................................................................................11.4风板材料的选择..........................................................................................................................21.5风量控制方式的论证与选择......................................................................................................21.6风扇驱动模块..............................................................................................................................21.7键盘输入模块..............................................................................................................................21.8显示模块......................................................................................................................................21.9声光报警模块..............................................................................................................................32理论分析与计算.......................................................................................................................................32.1角度控制分析..............................................................................................................................32.2风板控制分析..............................................................................................................................42.3电源模块设计分析......................................................................................................................43系统软件设计...........................................................................................................................................43.1程序流程分析..............................................................................................................................43.2主程序结构与部分控制代码......................................................................................................74系统测试...................................................................................................................................................74.1测试仪器清单和元器件清单......................................................................................................74.2度传感器模块测试与校正..........................................................................................................7参考文献.......................................................................................................................................................9附录一电路原理图.....................................................................................................................................10附录二源程序(仅核心部分)...............................................................................................................1211系统方案1.1总体设计本系统以单片机STC90C516RD+为核心,电路包括液晶模块、键盘控制模块、角度传感器模块、L298N电机驱动模块、声光报警模块、电源模块。系统功能原理如图1所示。角度传感器直流电源电机驱动模块单片机最小系统声光报警按键控制1602显示图1系统功能原理框图1.2单片机控制模块方案一:采用AT89S52单片机。AT89S52是一款低功耗、高性能的8位微控制器,具有8K在线编程(ISP)的FLASH存储器,256*8位内部RAM,32个I/O端口。缺点是处理速度较慢,而且片上资源较少。方案二:采用STC90C516RD+单片机。STC90C516RD+系列单片机是宏晶科技推出的新一代超**/高速/低功耗的单片机,指令代码完全兼容传统8051单片机,12时钟/机器周期和6时钟/机器周期可任意选择,内部集成MAX810专用复位电路,时钟频率在12MHz以下时,复位脚可直接接地。综合考虑采用方案二。1.3角度传感器方案一:采用旋转编码器。常用的旋转编码器有ANGTRON系列,通常采用正5V供电,大量应用于精密机械、智能机器人、航空等高精尖领域,精度远超过大赛题目要求,但价格也相对较高。方案二:采用角度传感器。具体型号为SCA100T-D02。这款角度传感器有模拟量和数字量的输出,数字量的输出需采用SPI通讯,编程比较复杂。采用模拟量的输出,编程简单,通过采集X或