单片机课程设计论文(1)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

单片机课程设计项目名称基于单片机的电子琴设计专业班级通信103班学生姓名王欢指导教师靳展2012年12月10日通信103班付红娜基于单片机的电子琴设计I摘要本课程设计利用AT89C51单片机模拟了简单的电子琴系统。运用Proteus仿真、AltiumDesigner09软件绘制原理图,生成PCB,使用Keil软件编写C程序并通过单片机的I/O端口控制矩阵键盘及喇叭发声。实验原理简单清晰,使我们能够很容易的理解电子琴的工作原理。本系统运行稳定,其优点是硬件电路简单,软件功能完善,控制系统可靠,性价比较高等,具有一定的实用和参考价值。通过这次动手实验,既培养了对小设计的兴趣,又体会到了理论与实际的差距。关键词:AT89C51;矩阵键盘;喇叭;通信103班付红娜基于单片机的电子琴设计IIAbstractThecourseisdesignedbyusingAT89C51single-chipmicrocomputersimulatethesimplekeyboardsystem.UsingtheProteussimulation,drawingprinciplediagrambyAltiumDesigner09software,generatingPCB,usingKeilsoftwarewriteCprogram,throughtheS-M'sI/Oportcontrolmatrixkeyboardandatrumpetsound.Experimentprinciplesimpleandclean,sothatwecaneasilyunderstandtheworkingprincipleofthekeyboards.Thesystem’soperationstable,itsadvantageishardwarecircuitissimple,softwareperfectfunction,controlsystemreliable,ratioishigher,hasacertainpracticalandreferencevalue.Throughthishands-onexperiment,itisnotonlycultivateinterestinthesmalldesign,butalsoexperiencedthetheorywithpracticalgap.Keywords:AT89C51;Matrixkeyboard;Loundspeaker通信103班付红娜基于单片机的电子琴设计III目录摘要·······································································································IAbstract·····································································································II第1章绪论·····························································································11.1课题背景························································································11.2音乐产生原理··················································································11.3主要设计任务··················································································2第2章电子琴系统的基本理论·····································································32.1AT89C51································································错误!未定义书签。2.1.1AT89C51简介···········································································32.1.2AT89C51性能简介····································································32.1.3AT89C51引脚简介····································································42.2LM386···························································································52.2.1LM386简介·············································································52.2.2LM386内部电路·······································································52.2.2LM386引脚简介·······································································6第3章系统的硬件设计··············································································73.1系统工作原理··················································································73.2总体设计框图··················································································73.3中心控制模块··················································································83.4播放模块························································································93.5按键模块························································································93.6电路仿真图····················································································10第4章系统软件设计················································································114.1主程序流程图·················································································114.2定时器T0程序流程图······································································12结论········································································································13参考文献··································································································14附录1原理图···························································································15附录2PCB及3D视图················································································16附录3源程序···························································································17通信103班付红娜基于单片机的电子琴设计IV附录4实物图···························································································23通信103班付红娜基于单片机的电子琴设计1第1章绪论1.1课题背景电子琴是电声乐队的中坚力量,常用于奏主旋律并伴以丰富的和声。还常作为独奏乐器出现,具有鲜明时代特色,但电子琴的局限性也十分明显:旋律与和声缺乏音量变化,过于协和、单一;在模仿各类管、弦乐器时,音色还不够逼真,模仿提琴类乐器的音色时,失真度更大,还需要不断改进。电子琴的演奏较大一部分通过和弦伴奏来配合完成的,在音乐中和弦的连接推动了旋律地进行,不同的和声连接,形成了不同的音乐色彩。本次设计用AT89C51单片机为核心控制元件与按键和喇叭等模块,设计一个简易的电子琴。1.2音乐产生原理乐曲是由不同音符编制而成的,每个音符(音名)都有一个固定的振动频率,频率的高低决定了音调的高低。简谱中从低音1至高音1之间每个音名对应的频率参见表1-2[1]。表1-2简谱中音名与频率的关系音名频率/Hz音名频率/Hz音名频率/Hz低音1262中音1523高音11047低音2294中音2587高音21175低音3330中音3659高音31319低音4349中音4699高音41397低音5392中音5784高音51569低音6440中音6880高音61760低音7494中音7988高音71976现以低音6这个音名为例来进行分析。低音6的频率数位440Hz,则其周期为:T=1/f=1/440=0.00228s=2.28ms如果用定时器1方式1作定时,要P2.3输出周期为2.28ms的等宽方波,则定时值为1.14ms,设计数初值为X,根据:定时值=(2^16-X)*(12/晶振频率),求出计数初值为:X=64396(为计算方便,设晶振频率为12MHz)。计算出计数器初值后,只要将计数初值装入TH0、TL0,就能使P2.3的高电平或低电平的持续时间为1.14ms,从而发出440Hz的音调(音乐的音长由按键控制,按键按下时发声,按键释放时停止发声)[2]。表1-3所列是采用定时器1的方式1时,各音名与计数初值的对照表。通信103班付红娜基于单片机的电子琴设计2表1-3各音名与计数初值对照表音名计数初值音名计数初值音名计数初值低音163636中音164586高音165066低音263836中音264686高音265116低音364026中音364776高音365156低音464106中音464816高音465176低音564256中音56489

1 / 28
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功