基于单片机的电子音乐盒的设计与实现
- 格式:docx
- 大小:93.32 KB
- 文档页数:8
基于单片机的数字式音乐盒设计数字式音乐盒是一种音乐播放器,它通过数字技术存储和播放音乐。
基于单片机的数字式音乐盒可以使用单片机控制音乐的播放,实现音符和旋律的发声和控制。
本文将介绍如何设计一款基于单片机的数字式音乐盒。
一、音乐盒基本原理音乐盒是通过一个带有齿轮的转子,以弹簧的力量驱动,使得钢片受到磁力响应并发声,从而发出旋律。
数字式音乐盒是通过数字技术将音乐编码为数字信号,并存储在芯片中,通过解码器将数字信号还原为音符和旋律发声。
二、单片机控制电路设计1.芯片选择要设计一个数字式音乐盒,需要先选择一款合适的单片机,常用的有AT89C51、STC89C52等。
这里选择一款性能好且价格适中的STC89C52单片机。
2.存储器选型数字式音乐盒的数字信号需要存储在内存中,为了方便起见,使用一个4Mbit的Flash记忆芯片作为存储器。
3.音频输出电路数字信号需要通过解码器进行还原后才能通过音频输出电路输出。
可以使用一对耳机或者喇叭,同时需要用到音量电位器控制音量。
三、软件程序设计1.数字信号编解码算法的设计,可以使用目前较为流行的MIDI编码格式。
2.音乐信号输入模块设计,可以使用USB接口或SD卡接口。
3.数据接收模块设计,可以使用串行通信或者并行通信。
4.数字信号存储模块设计,使用Flash记忆芯片。
5.控制模块设计,实现单片机控制音乐盒的所有操作。
四、实现效果基于单片机的数字式音乐盒实现较为简单,但是需要注意以下几点:1.考虑使用定时器计算控制音乐的播放时间,保证旋律按照要求执行。
2.使用ADC(模拟-数字转换器)读取音量电位器值,对音量进行控制。
3.在使用USB接口时,需要有电路板,使得USB通信接口稳定,可靠。
基于单片机的数字式音乐盒是一种方便实用的音乐盒,通过数字技术的运用,实现了音乐的存储和播放,可广泛应用于各个领域中。
单片机的音乐盒设计报告一、引言音乐盒作为一种能够带来美妙旋律的装置,一直以来都深受人们的喜爱。
随着科技的不断发展,单片机技术的应用使得音乐盒的设计更加多样化和智能化。
本报告将详细介绍基于单片机的音乐盒的设计过程,包括硬件设计、软件编程以及最终的实现效果。
二、设计目标与需求本次设计的目标是制作一个基于单片机的音乐盒,能够播放多首预存的音乐曲目,并且可以通过按键进行曲目选择和控制播放暂停等功能。
具体需求如下:1、能够存储至少三首不同的音乐曲目。
2、具备简单直观的操作界面,通过按键实现曲目切换、播放暂停等功能。
3、具有良好的音质输出,能够清晰地播放音乐。
4、设计成本低,易于实现和维护。
三、硬件设计1、单片机选择选用 STC89C52 单片机作为核心控制器,其具有丰富的 I/O 端口和较高的性价比,能够满足本设计的需求。
2、存储模块使用 EEPROM 芯片(如 AT24C02)来存储音乐曲目数据,以便在掉电情况下仍能保存曲目信息。
3、音频输出模块采用无源蜂鸣器作为音频输出设备,通过单片机的 I/O 端口输出不同频率的方波信号来驱动蜂鸣器发声。
4、按键模块设置四个独立按键,分别用于曲目选择、播放、暂停和停止功能。
5、电源模块采用 5V 直流电源为整个系统供电。
四、软件设计1、编程语言选择使用 C 语言进行编程,具有较高的可读性和可移植性。
2、主程序流程系统初始化,包括单片机端口设置、EEPROM 读取等。
进入按键扫描循环,检测按键操作并执行相应的功能。
根据当前曲目播放状态,输出相应的音频信号。
3、音乐数据存储与读取将音乐曲目数据以特定的格式存储在 EEPROM 中,通过读取相应地址的数据来获取曲目信息。
4、音频信号产生根据不同的音符频率,计算出对应的方波周期,并通过定时器中断来产生相应频率的方波信号,驱动蜂鸣器发声。
五、系统实现与调试1、硬件焊接与组装按照设计原理图,将各个硬件模块焊接在电路板上,并进行组装和连接。
HEFEI UNIVERSITYFPGA综述报告系别电子信息与电气工程系任课教师汪济洲班级姓名成绩日期数字音乐盒设计摘要:本设计是一个基于STC89C51系列单片机的音乐盒,依据单片机技术原理,通过硬件电路制作以及软件编译,设计制作出一个多功能音乐盒。
该音乐盒主要由按键电路、复位电路、时钟电路以及蜂鸣器组成。
使用两个按键控制音乐盒,一个用来切换歌曲,另一个用来切换8路LED的变化花样,本音乐盒共有两首歌曲,花样灯花样共计4种。
播放歌曲时,蜂鸣器发出某个音调,与之对应的LED亮起。
本设计利用KEIL编程软件对音乐盒源程序进行编程并调试,配合PROTEUS仿真软件对硬件进行仿真调试,节约了设计时间。
关键字:音乐盒STC89C51单片机KEIL PROTEUS 音调目录1概述 (3)1.1设计方案 (3)1.2研究内容 (3)1.3音乐盒的功能结构图 (3)2硬件设计 (4)2.1总体设计框图 (4)2.2各部分硬件设计及其原理 (4)2.2.1 STC89C51简介 (4)2.2.2 LED显示电路设计与原理 (5)2.2.3 时钟振荡电路 (5)2.3硬件电路图及功能 (6)3软件设计 (7)3.1音调、节拍以及编码的确定方法 (7)4.1.1 音调的确定 (7)4.1.2 节拍的确定 (8)4.1.3 编码 (9)4.2软件程序设计 (10)4.2.1 程序流程图及相应代码块 (10)4.2.2 程序源代码(见附录A) (14)5调试 (14)5.1检查硬件连接 (14)5.2检查软件系统 (14)5.3测试结果 (14)5.3.1.总体运行图 (14)5.3.2.花样灯4种花样图 (15)参考文献 (16)附录A 程序源代码及注释 (16)。
目录摘要 (I)ABSTRACT.............................................................................................................................................................. I I 目录 (1)第1章绪论 (1)第2章音乐盒总体设计 (2)2.1设计功能要求 (2)2.2总体设计原理 (2)2.3总体设计框图 (2)第3章芯片的选择和介绍 (4)3.1MCS-51系列单片机简介 (4)3.2单片机的选择 (4)3.2.1 AT89S51芯片介绍 (5)第4章系统硬件设计 (8)4.1电源电路 (8)4.2单片机最小系统 (8)4.3数码管显示部分 (9)4.4键盘部分 (11)4.4.1 按键开关 (11)4.4.2 轻触开关 (11)4.5蜂鸣器部分 (11)第5章系统软件设计 (13)5.1软件系统介绍 (13)5.2编程语言的选择 (13)5.3应用软件的选择——KEILC51 (13)5.4系统程序设计 (14)5.4.1 主程序流程图 (14)5.4.2 主程序 (15)5.4.3 定时器定时 (18)第6章系统仿真及硬件制作 (21)6.1仿真的必要性 (21)6.2系统仿真过程 (21)6.2.1 原理图的绘制 (21)6.2.2 程序的调入 (22)6.3硬件模型的制作和调试 (22)6.3.1 硬件制作的意义 (23)6.3.2 硬件制作所需器件 (23)6.3.3 硬件制作 (23)参考文献 (25)总结 (26)附录 (27)附录二音乐盒原理图 (33)附录三外文原文 (34)附录四外文原文翻译 (41)摘要为了实现单片机控制音乐播放,此次毕业设计做出了尝试,即电子音乐盒的设计。
本设计采用了蜂鸣器发声来实现歌曲的播放,能保持基本音调不变,流畅播放出歌曲。
图2 蜂鸣器电路控制电路图4 仿真调试6.2性能分析用AT89C51单片机的I/O口产生一定频率的方波,驱动蜂鸣器,出不同的音调,从而演奏乐曲。
共有4支乐曲,每首乐曲都由相应的按键控制,并且有开关键、暂停键、上一曲以及下一曲控制键。
将源程序导入单片机后,在proteus软件中进行仿真。
我通过仿真发现,按下按8 总结通过对单片机的学习,发现对单片机的硬件设计,软件设计掌握的a您好,为你提供优秀的毕业论文参考资料,请您删除以下内容,O(∩_∩)O谢谢!!!A national survey was recently launched to evaluate the eye health of Chinese children andteenagers.On June 6, China 's annual National Day for Eye Care, the China Youth Development ServiceCenter and Zhejiang Medicine, a leading li sted Chinese pharmaceutical company, jointlyannounced the kickoff of the survey.In about one month, a questionnair e compiled by top eye care medical experts in China willbe distributed through multiple online partners, including He , as well asthrough offline survey events held in universities, middle schools and primary schools acrosst he country.A report will be released based on the survey statistics and analysis, and most importantly,guidelines for pa rents and youth on how to care for the eyes and prevent myopia — agrowing problem in China's digitized society, will also be attached on the report."Myopia is not only a disease that makes people see things blurrily, but also leads to sev erecomplications, such as glaucoma (increased pressure within the eyeball), and can causeblindness," said Zhou Yueh ua, an established eye care specialist with Beijing TongrenHospital."It is very important for parents and children to k now about the risk and care for their eyes."There are about 450 million myopia patients in China. Among Chinese my opia patients,30million are severe patients, according to ZhouThe prevalence of myopia among high school and colleg e students is more than 70 percent,and the situation is continuously worsening, he added.Sun Zhu, director with the C hina Youth Development Service Center, said long hours ofstudy, lack of exercise, especially outdoor activities, and att achment to electronic screen aresome of the top reasons behind the widespread myopia problems, and the increase ofy ounger patients, although China has made great progress in improving the hardwarefacilities and lighting conditions i n schools.He said he hopes the survey will alert people on the threatening situation, and also helpmedical experts to be tter guideline parents and children's behaviors to care for eyes, basedon the timely and factual statistics the survey col lected.A series of follow-up events will also be held in six cities, including Jinan in Shandongprovince, and Changsha i n Hunan province, to educate people on how to care for eyes afterthe survey started. More and more Chinese are jogging to get and stay fit. Most joggers will run alone, but some will jog with friends or even coaches. The Beijing Olympic Forest Park is one of the most popular spots. It is packed with runners in the afternoon, usually after work, and at weekends. Jogging after a whole day's work can be a way to unwind. It is true for He Wenjun, whose workplace is right near the forest park. She discovered her athletic aptitude at the age of seven, when she began playing tennis. Then she turned to jogging, and she has persevered with it for 10 years. "I come to jog almost every day after work, whenever I have time. I think jogging is good for my health. And for me, a girl, it helps me to achieve to eternal goal, to keep slim," He said. He says she prefers jogging alone, so she can focus better. She loves jogging, even during Beijing's smoggy days. "If the smog is severe, I'll hold off jogging for a while. But if I really want to get away from work, I'll wear a mask, or just ignore the smog and go on jogging," she said. For those who are not so athletic, jogging also has its attractions. Wu Houbin started roughly two years ago, when he was severely obese. Within two months, his weight dropped from 82 kilograms to 64 kilograms. The success helped him recover health, and he has made friends. "Jogging does not require speed, but stamina. If you want to stick to the game, you need to take it as a mission, a habit, and then eventually a hobby," Wu said. But persevering with jogging is not always easy. Jogging is beneficial for heart-lung function, and the skeletal system, but doctors say improper technique damages the joints, especially the knees and ankles. "Excessive jogging wears down the body, and harms one's health. Poor technique harms the muscles and skeleton, and can cause secondary injures. And, jogging in a bad environment can cause circulation problems," said Lu Zhiyong, attending doctor, Sports Hospital, General Admin. of Sports.Dr. Lu has some tips for joggers, and thosewho are thinking of taking it up.He says peoplesh ould first evaluate their physical condition, to decide the amount and type of exercise, and jogging in the open air is better running on a treadmill. Conrad Macaowill run special programs for the entire month of October this year to support the Hong Kong Cancer Fund's Pink Revolution, an annual campaign that seeks to raise awareness and funds for breast cancer research, the hotel recently announced. A major sponsor of the campaign for three years in a row, Conrad Macao has pledged to donate a portion of its proceeds to the fund,includ ing those collected from selling its popular bear and rubber duck merchandise, in limited pink editions. Pink is the theme for floral arrangements and decorations in the hotel in October. In addition, on Fridays that month, members of the management and staff will add something pink to their uniforms, regular e-mails and handwritten guest cards. "Breast cancer is the most prevalent type of cancer among women in Hong Kong and is also of significant concern in Macao and around the world, regardless of age," general manager Bede Barry said in a statement. The hotel has enlisted the support of a number of international and local celebrities to help drive the cause, including South Korean actor Jung Suk Won. This year, a lucky guest who stays at the hotel during the campaign and also donates money for the cause will win a necklace specially designed by Arte Madrid, a Spanish jewelry brand. Women should strive to balance quality of work and life, and have children at a young age. As a doctor I see much suffering because of this imbalance. Xiao Ying, 36, works for a large law firm. Her job means lots of travel, a heavy caseload and a large number of meetings, so her schedule is hectic. She has been pregnant twice, but had abortions on both occasions because she felt her busy,high-pressure career wasn't conducive to raising a child. She planned to have children once she had achieved career success so she could provide a stable environment for her baby. After 10 years, Xiao felt the time was right, and she tried to conceive for about six months, but was unable to become pregnant. I conducted comprehensive physicalcheckups. The results suggested that Xiao's ovarian function has declined and a bilateral oviduct blockage has occurred, meaning that in vitro fertilization is her only option. So, after reducing her workload, Xiao underwent IVF treatment. Luckily, she got pregnant after just one treatment cycle, but later experienced vaginal bleeding, and rushed to the hospital. I told her to rest and carry on with the treatment (to prevent a miscarriage). As Zubin Zarthoshtimanesh, a yoga guru, demonstrated postures at a high school stadium in Dujiangyan city, Sichuan province, some 200 students sat on colorful mats watching him closely. It was part of the first India-China international yoga festival in the provincial capital, Chengdu, in Southwest China, where more than 1,000 fans from home and abroad gathered for lessons from 20 leading practitioners of the ancient Indian regimen, from June 17-21. Yoga is to India what perhaps tai chi is to China. Many countries other than India and China, also held the first World Yoga Day on June 21, after the United Nations last year agreed to Indian Prime Minister Narendra Modi's suggestion that a special day be marked in the year for the global practice of the stress-busting regimen, which is already a multibillion dollar industry in the United States. Modi said in the speech: "Yoga is an invaluable gift of India's ancient tradition. ... It is not about exercise but to discover the sense of oneness with yourself, the world and nature."Zarthoshtimanesh, who runs his own yoga center, Iyengar Yogabhyasa, in the Indian financial capital of Mumbai, says: "Chinese students are very respectful. For me, all students are the same no matter what their race is and where they come from. The most important thing is to remove mental walls." Zarthoshtimanesh learned yoga from the late Yogacharya Iyengar and traveled with the master to different countries. Consulate General of India in southern China's Guangzhou city organized the Chengdu festival. A terrifying wooden bridge in China has just been replaced by a glass one. This, the world’s longest glass-bottomed walkway, is located in Shiniuzhai Geopark in Hunan, and spans 300m (984f) and is 180m (590f) above ground. The floor is made of double-layered glass that is24mm (0.94in), and is reportedly 25 times stronger than regular window glass. The bridge had previously been made of wood, linking the two peaks of Stone Buddha Mountain, but 11 engineers working 12 hours a day converted it to glass. Previously, you were considered brave if you steeled yourself to cross the wooden walkway; now, with its glass bo ttom, the bridge is already being referred to as “hero bridge.”The popular chain's longtime executive chef embraces mapo tofu and other exotic elements for the burger-driven menu, Liu Zhihua reports.At the age of 37, Shanghai native Lin Zhengu has become a star as a Western cuisine chef in the Chinese metropolis, a city that has a wealth of Western restaurants. The executive chef of Blue Frog Bar and Grill, a popular burger-based restaurant and bar chain on the Chinese mainland, Lin is the soul of the restaurant franchise's team of more than 550 chefs. Many of the franchise's most popular dishes are his brainchild. Lin says his secret of success is innovation rooted in experience: He spends months every year traveling and eating worldwide, seeking new ingredients and inspirations that could improve the offerings of Blue Frog restaurants. The restaurant chain regularly launches a new seasonal menu, usually featuring eight new dishes with fresh ingredients. The best-selling seasonal dishes later replace the least popular items on the regular menu, which is usually updated in late fall and boasts a selection of about 40 dishes. "Food should have no boundaries," Lin says. "As long as the food tastes good and is healthy, it doesn't really matter where it originates or how it is cooked." Lin likes to give the American-style restaurants' menu some culinary touches from other countries, such as China and Mexico, and customers love such innovation, he says. He started his career as an apprentice in a Chinese kitchen in 1993. By chance he learned from a French chef in 1994, and soon became enamored with the world of Western food. During the next couple of years, he received strict training in Western culinary art from French, Chinese and German chefs. That was rare for a Chinese chef in the 1990s, he says-and so was being a Chinese chef who spoke fluent English. When an American entrepreneur invited him to join in his startup Blue Frog in 2000, Lin didn't hesitate to resign from a five-star hotel to work in the new restaurant with just five chefs, eager to explore the excitement of a life that had yet to unfold. Since that Shanghai launch, Blue Frog has opened 24 branches in seven cities across China, including Beijing, Tianjin, Chongqing and Nanjing in Jiangsu province. The new menu for this fall, which was launched in early September, showcases how flavors of East and West meet to create a variety of delicious burgers and other entrees in the cozy, soft-lit restaurants. I liked the mapo burger best. Just imagine the flavorful combination of the hot, mildly numb-spicy mapo tofu sauce and grilled 100-percent Australian beef patty, along with a slice of cheddar cheese and a side of french fries. The savory sauce helped highlight the patty's juicy, tender texture and its delicious beef flavor. Matching that Sichuan flavor with cheese created a new taste experience.。
毕业设计题目基于AT89C52单片机的音乐盒设计学生所在学院电气信息学院专业电子信息工程学号*********学生姓名XXXXXX指导教师XXXXXXXXXX助理指导教师XXXXXXXXXX起止日期2013.3.10-2013.5.15目录目录 (2)摘要 (1)1概述 (3)1.1 课题意义 (3)1.2设计任务和要求 (3)1.3应用软件介绍 (4)1.3.1 Proteus软件简介 (4)1.3.2 KEIL简介 (4)2设计方案 (5)3时钟电路 (6)4 复位电路 (7)4.1上电复位 (7)4.2按键复位 (7)5 硬件设计 (8)5.1 按键模块设计 (8)5.2 发音电路及数码显示电路设计 (9)5.3 Proteus 仿真电路图 (10)6 软件设计 (10)6.1音调、节拍以及编码的确定方法 (10)6.1.1 音调的确定 (10)6.1.2 节拍的确定 (12)6.1.3 编码 (13)6.2 暂停与播放 (13)6.3上一曲程序设计 (14)6.4下一曲程序设计 (16)6.4.1 程序源代码(见附录A) (20)7调试 (20)7.1 检查硬件连接 (20)7.2 检查软件系统 (20)7.3 测试结果 (20)7.3.1总体运行图 (21)8总结 (22)致谢 (23)参考文献 (24)附录A 程序源代码 (25)摘要本设计是一个基于AT89C52系列单片机的音乐盒,依据单片机技术原理,通过硬件电路制作以及软件编译,设计制作出一个多功能音乐盒。
该音乐盒主要由按键电路、复位电路、内部振荡器、数码管显示、中断控制电路以及蜂鸣器电路组成。
使用三个按键控制音乐盒,两个用来切换歌曲,且数码管显示当前曲目。
另一个用来控制开始\暂停。
播放歌曲时,蜂鸣器发出某个音调,数码管显示与之对应的曲目。
本设计利用Keil编程软件对音乐盒源程序进行编程并调试,配合Proteus仿真软件对硬件进行仿真调试,节约了设计时间。
本科毕业设计基于单片机音乐盒的设计Document number:PBGCG-0857-BTDO-0089-PTT1998本科毕业设计(论文)基于单片机的音乐盒的设计学院名称:专业:班级:学号:姓名:指导教师姓名:指导教师职称:二〇一四年六月基于单片机的音乐盒的设计摘要:本次设计根据单片机技术原理,通过硬件电路制作以及软件编程,制作出一个基于AT89C52单片机的简易音乐播放器,该系统以单片机作为电路的主控核心,硬件电路主要由按键电路、复位电路、显示电路等模块组成。
系统软件采用C语言进行编写,采用了模块化编程,其移植性较好。
系统程序主要包括主程序、播放子程序、按键子程序、延时子程序等。
该系统有歌曲播放、电子琴两种模式,可通过按键进行模式选择。
本论文包括系统方案的建立、硬件电路的具体设计及软件的程序实现等过程。
并通过软硬件的联合调试,验证了设计方案的可行性。
该系统最终实现了模式的选择、歌曲的选择及播放等功能,实验证明,该系统具有一定的实用性。
关键词:AT89C52单片机;软件编程;音乐盒The Design of Music Box of the Single Chip MicrocomputerAbstract:This design according to principle of single chip microcomputer technology,through the hardware circuits and software programming,make a simple music player based on AT89C52 single chip microcomputer,the system with single chip microcomputer as control core of the circuit,the hardware circuit is mainly composed of keypad circuit,reset circuit,display circuit module .System software using C language to write,using the modular portablility is program mainly includes the main program subroutine,played subroutines,buttons,delay system has a song play,keyboard two modes,can through the button to choose.This paper includes the establishment of the system,detailed design of hardware circuit and software program implementation through the software and hardware joint debugging,verify the feasibility of design system finally realize the pattern selection,selection of songs and play function,such as experiments show that the system has a certain practicality.Keywords: AT89C52 microcontroller,;Software programming;the music box目录第1章绪论 (1)课题背景及研究意义 (1)课题设计目的及主要工作 (2)第2章课题任务分析与方案选择 (3)课题任务分析 (3)硬件电路的组成 (3)设计功能要求 (3)总体设计原理 (4)总体设计框图 (4)选用的方案 (5)第3章系统硬件设计 (6)单片机最小系统 (6)AT89C52单片机介绍 (6)复位电路介绍 (8) (9)显示电路 (10)4*4矩阵键盘识别电路 (11)声音电路 (12)第4章软件设计 (14)Proteus仿真软件与Keil编译介绍 (14)音调与节拍 (15)发声原理 (15)音调的确定 (16)节拍的确定 (17)音乐编码 (18)系统软件总体设计流程图 (18)主程序流程图 (18)歌曲播放流程图 (20)按键扫描流程图 (20)延时子程序流程图 (21)第5章总结 (23)致谢 (24)参考文献 (25)附录1:电路原理图 (27)附录2:元器件清单 (28)附录3:源程序 (29)第1章绪论课题背景及研究意义单片机应用到当前社会的各个领域中,既提高了社会的信息化水平又大力的发展了社会的生产力,同时也使目前电子产品的性能有了更高的提升,从而使产品更新换代的周期也逐渐变短。
基于单片机的点阵音乐盒设计
基于单片机的点阵音乐盒是一种通过单片机控制点阵LED灯
来显示音符,将音符转化为电信号的音乐盒。
它的主要原理是通过单片机控制点阵LED灯的亮灭,产生不同的音符,从而
实现音乐的播放。
设计基于单片机的点阵音乐盒,需要考虑以下几个方面:
1. 单片机的选择
根据功能和成本等考虑,可以选择常见的单片机,例如
MSP430或STM32等。
同时,需要保证单片机的性能能够满
足音乐盒的要求,例如需要具有足够的存储空间和运算能力等。
2. 点阵LED的选型
点阵LED的选型需要结合电路设计和后续的程序控制。
可以
考虑使用8x8、16x16等不同规格的点阵LED。
3. 程序设计
程序设计是整个点阵音乐盒设计的核心。
需要将音符转换成电信号发送到点阵LED灯。
可以使用计时器来控制音符的持续
时间和频率等参数,从而实现音乐播放的效果。
除了以上几个方面,还需要设计电路、音符存储和外壳等方面。
设计电路时需要考虑到单片机和点阵LED的驱动,以及电源
电路等方面。
另外,为了方便程序设计,可以将不同音符的电信号进行编码,存储在EEPROM中,方便单片机读取和控制。
外壳设计可以根据使用者的需求和喜好进行,可以是简单的塑料外壳,也可以是制作精美的木质外壳。
基于单片机的点阵音乐盒具有设计成本低、可制作的优点,也方便用户自行学习制作。
此外,可以根据需要进行功能扩展,例如增加MP3播放等功能。
它适合于音乐入门者或DIY爱好者制作。
基于单片机的电子书阅读器设计与实现 页脚内容1 课 程 设 计 报 告 设计名称 基于单片机的电子音乐盒的设计与实现 学 校 陕西电子科技职业学院 学 院 电子工程学院 学生姓名 滕一帆 班 级 1507 学 号 2013062040311 指导教师 聂弘颖 时 间2017年09月22日 基于单片机的电子书阅读器设计与实现
页脚内容2 基于单片机的电子音乐盒的设计与实现
一、设计目的 为证明单片机可以通过软件程序控制硬件电路实现简单音乐播放器的功能,以此证明单片机的功能强大。
二、设计概述 本课题是一个基于51单片机的电子音乐盒,依据单片机控制技术原理,设计出一个可以播放多首音乐的数字音乐盒,通过数码管显示当前是第几首音乐,系统设计了三个按键,具体功能:S1:暂停/播放;S2:加一首(下一首);S3:减一首(上一首)。通过硬件电路制作以及以及软件编程,设计制作出一个多功能的电子音乐盒。
三、设计方案 在这个系统的设计中,单片机采用51兼容系列的STC89C52RC。有以下几部分构成:电源电路、单片机最小系统、发声系统、键盘控制电路、显示电路。经过论证后我确定的系统框图,如下图所示:
四、设计原理 1、原理 本系统由单片机系统,独立按键、数码管组成。利用I/O口产生一定频率的方波,驱动扬声器,发生不同的音调,从而实现乐曲的演奏。系统能通过功能键完成选择乐曲、播放、暂停、和复位的基本功能。在播放乐曲的同时LCD上显示所播放的歌曲序号,可以通过复位键使音乐盒从第一首歌曲重新播放,本系统成本低廉,功能强大实用。
51 单 片 机
数字显示电路 键盘控制电路 发声控制电路
电源电路
单片机最小系统 基于单片机的电子书阅读器设计与实现
页脚内容3 2、音乐基础简介 <1>音乐频率表 低音 频率 中音 频率 高音 频率 11 262 1 523 11 1046 22 294 2 587 22 1175 33 330 3 659 33 1318 44 349 4 698 44 1397 55 392 5 784 55 1568 66 440 6 880 66 1760 77 494 7 988 77 1967
<2>音调表建立
由于单片机输出为方波输入信号,波形图如下:
高低电平各占1/2,根据单片机定时器工作原理。 定时时间=(满值-初值)X机器周期 初值=满值-定时时间/机器周期 =216-(1/f)X(1/2)X106 以低音11为例,初值为=216-(1/262)X(1/2)X106 =63627.6 =63628 同理得其他音调值,具体如下: Unsigned int code table[]={0,63628,63835,64021,64103,64260,64399,64523, 64579,64684,64777,64819,64898,64968,65030,65058,65110,65157,65178,65217,65252,65282}; <3>音乐表的建立 我们以两只老虎音乐为例子,然后我们就会得到该音乐表 Uchar code music1[]={8,4,9,4,10,4,8,4,9,4,10,4,8,4,10,4,11,4,12,8,10,4,11,4,12,8,12,3, 13,1,12,3,11,1,10,4,8,4,12,3,13,1,12,3,11,1,10,4,8,4,9,4,5,4,8,8,9,4,5,4,8,8,0,0xff}; 3、硬件电路设计 基于单片机的电子书阅读器设计与实现 页脚内容4 1) 单片机最小系统 在基于单片机的应用系统中,其核心是单片机的最小系统,而单片机又是最小系统的核心,为了方便起见,采用的型号是:STC89C52RC,内部资源有:8kbflash,512b sram,4个8位I/O口,2个TC,1个UART,带ISP和IAP功能。是近年来流行的低端51单片机。时钟电路采用12MHz晶体,复位电路采用简单的RC复位电路。R4=1KΩ,R3=10KΩ,C5=10Uf。 2) 发声控制电路 音乐的发生器采用小喇叭,使用PNP型三极管。 3) 键盘控制电路 通过安按键来控制乐曲的暂停/播放、加+、减-。S1、S2、S3的功能设定如下。S1暂停/播放;S2乐曲/+;S3乐曲/-。 4) 音乐数目显示电路 显示当前的乐曲序列。为了直观的观察室哪一首曲子的效果,设置一位数码管显示,数码管需要接一个200-100Ω的电阻起分压作用。 4、程序流程图
处理按键 开始 初始化 检查按键
有键按下? 显示乐曲号播放乐曲
该曲是否播放完? 显示乐曲号+1 所有曲子是否放完? 基于单片机的电子书阅读器设计与实现 页脚内容5 五、仿真结果
所仿真出来的结果,去掉N2905,声音变小了,加上之后声音变大了,额,第一首是两只老虎,第二首,我换成通天大道,不过没找到乐谱规律,错了,第三首是小兔子快开门,第四首新年好,第五首歌曲接连被放出来。效果不错。
六、总结 通过本次仿真作图,以及程序编写,仿真原图,和自己再画图,和程序再组合效果,依然不错,原图只是作为参考,其次,通过本次作业,明白,每一门课代表以后的每项工作,而这门课开设的原因估计是要我们认为,在一台机器,里面通过芯片,芯片的程序带动硬件,一件成品就出来了。所以,软件和硬件属于相辅相成,在未来的世界中,是属于硬件和软件共存的时代,没有软件,硬件别想动;同理硬件也是一样的。认可了工程师的伟大,以及程序员的厉害之处。
七、附录 1、元件清单 元件清单:2N2905、2W10G、7SEG-MPX2-CA A700127M004ATE018、AT89C52、
P0.0P0.7P0.1P0.2P0.3P0.4P0.5P0.6P3.1P3.2P3.3
P3.1P3.2P3.3
P0.6P0.0P0.1P0.2P0.3P0.4P0.5P0.7
X1CRYSTAL
XTAL218XTAL119ALE30EA31PSEN29RST9P0.0/AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435
P0.5/AD534
P0.6/AD633
P0.7/AD732
P1.0/T21P1.1/T2EX2P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD11
P3.2/INT012
P3.3/INT113
P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115P2.7/A1528P2.0/A821P2.1/A922P2.2/A1023P2.3/A1124P2.4/A1225P2.5/A1326P2.6/A1427U1AT89C52C630pF
C730pF
R110k
R61k
R410kR3
10k
C510u
BUZZERQ12N2905
R810k基于单片机的电子书阅读器设计与实现
页脚内容6 BUTTON、BUZZER、CAP CRYSTAL、 DIODE-LED、 RES、 SW-SPDT 2、电路图
3、程序代码 #include"reg52.h" #define uchar unsigned char #define uint unsigned int sbit buzzer=P2^7; void delay(uint z); void scan(); sbit S1=P3^1; sbit S2=P3^2; sbit S3=P3^3; bit flag=1; uchar buf,high,low,n; char i; uint sound; uchar code num[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; uint code table[]={0,63628,63835,64021,64103,64260,64399,64523,64579,64684,64777,64819,64898, 64968,65030,65058,65110,65157,65178,65217,65252,65282}; uchar code music1[]={8,4,9,4,10,4,8,4,9,4,10,4,8,4,10,4,11,4,12,8,10,4,11,4,12,8,12,3,13,1,12,3,11,1,10, 4,8,4,12,3,13,1,12,3,11,1,10,4,8,4,9,4,5,4,8,8,9,4,5,4,8,8,0xff}; uchar code music2[]={10,10,10,9,8,9,10,12,10,10,9,8,9,10,20,19,20,17,19,19,19,15,20,19,17,19,19,19, 15,16,17,16,19,17,16,15,16,19,8,20,19,19,8,20,19,17,19,20,8,8,20,19,10,10,12,9,8,8,0xff}; uchar code music3[]={12,4,15,2,13,2,12,4,12,4,10,2,12,2,13,2,15,4,12,4,12,4,13,4,12,2,10,2,9,4,9,4,10, 4,12,2,10,2,9,2,10,2,8,4,13,4,12,4,13,4,12,4,13,4,12,4,10,4,13,4,12,4,12,2,12,2,10,2,9,2,8,2,8,8,2,8,2,9,2,10,2,8,8,0xff}; uchar code music4[]={8,3,8,3,8,3,5,3,10,3,10,3,10,3,8,4,8,3,10,3,12,3,12,4,10,3,11,3,10,3,9,6,9,3,10,3,
P0.0P0.7P0.1P0.2P0.3P0.4P0.5P0.6P3.1P3.2P3.3
P3.1P3.2P3.3
P0.6P0.0P0.1P0.2P0.3P0.4P0.5P0.7
X1CRYSTAL
XTAL218XTAL119ALE30EA31PSEN29RST9P0.0/AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435
P0.5/AD534
P0.6/AD633
P0.7/AD732
P1.0/T21P1.1/T2EX2P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD11
P3.2/INT012
P3.3/INT113
P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115P2.7/A1528P2.0/A821P2.1/A922P2.2/A1023P2.3/A1124P2.4/A1225P2.5/A1326P2.6/A1427U1AT89C52C630pF