【正文】
1A,0x02, 0x1A,0x02, 0x19,0x01, 0x18,0x02, 0x18,0x02, 0x17,0x02, 0x17,0x02, 0x16,0x02, 0x16,0x02, 0x15,0x01, 0x00,0x00 }。 do { }while(key==1)。 |調(diào)號 (011) : 是指樂曲升多少個(gè)半音演奏 。 unsigned char Sound_Temp_TH0,Sound_Temp_TL0。 ET0 = 1。 } //************************************************************************** void Play(unsigned char *Sound,unsigned char Signature,unsigned Octachord,unsigned int Speed) { unsigned int NewFreTab[12]。 NewFreTab[i] = FreTab[j]*2。 Length = Sound[Point+1]。 //計(jì)算出高低音 SH=Tone/100。 TL0 = Sound_Temp_TL0 + 12。 else LDiv1=LDiv/2。 TH1 = Sound_Temp_TH1。 TH1 = Sound_Temp_TH1。 6a*CZ7H$dq8Kqqf HVZFedswSyXTyamp。ksv*3t nGK8!z89Am YWpazadNuKNamp。 } BeepIO = 0。i0。i0。 if(XG!=1) if(XG==0) //算出普通音符的演奏長度 if (SLen=4) 34 LDiv1=LDivLDiv4。 Sound_Temp_TL0 = Temp_T%256。 while(Point SoundLength) { SL=Tone%10。 } Point = 0。i++) // 根據(jù)調(diào)號及升降八度來生成新的頻率表 { j = i + Signature。 TH0 = Sound_Temp_TH0。 TL1 = Sound_Temp_TL1。 //原始頻率表 unsigned char code SignTab[7] = { 0,2,4,5,7,9,11 }。 音長最多由三位數(shù)字組成: 個(gè)位表示音符的時(shí)值,其對應(yīng)關(guān)系是: |數(shù)值 (n): |0 |1 |2 |3 | 4 | 5 | 6 30 |幾分音符 : |1 |2 |4 |8 |16 |32 |64 音符 =2^n 十位表示音符的演奏效果 (02): 0普通, 1連音, 2頓音 百位是符點(diǎn)位 : 0無符點(diǎn), 1有符點(diǎn) 調(diào)用演奏子程序的格式 Play(樂曲名 ,調(diào)號 ,升降八度 ,演奏速度 )。 if(key==0) { Delay1ms(10)。j++)。其次是程序方面的設(shè)計(jì),主要解決的問題是如何在一個(gè)按鈕的基礎(chǔ)上,實(shí)現(xiàn)歌曲的輪換以及播放,這是此次設(shè)計(jì)的難點(diǎn)之一,另外,焊接是此次設(shè)計(jì)所用時(shí)間最多的一部分,因?yàn)楸救说暮附蛹夹g(shù)不到位 ,焊接能力不高,所以造成焊接的屢次失敗,不過我在失敗中吸取經(jīng)驗(yàn),在完成焊接后,焊接技術(shù)得到很大的提高。 程序在開始之初是用簡單的中斷延遲來實(shí)現(xiàn),對于編歌曲來講需要很大的工作量,在網(wǎng)上查找大量的資料之后,找到了一個(gè)做音樂播放器的程序,他也是基于中斷延遲來實(shí)現(xiàn)播放功能,但是他對于歌曲編輯的靈活性,有很大的發(fā)展空間,所以我就采用了他的部分程序 。這樣的焊接不僅有利于系統(tǒng)的調(diào)試,還有利于日后對于其他系統(tǒng)的開發(fā),直接利用最小系統(tǒng)以及杜邦線引出端口即可。 //高音 Temp_T = 65536(50000/CurrentFre)*10/(12021000/SYSTEM_OSC)。 21 TH0 = Sound_Temp_TH0。 TL1 = Sound_Temp_TL1。i++) for(j=0。 if(key==0) Play(Music_Same,0,3,360)。 1/4 拍的延時(shí)時(shí)間在此我們設(shè)為 125毫秒。運(yùn)行 Keil 軟件需要 Pentium或以上的 CPU, 16MB 或更多 RAM、 20M 以上空閑的硬盤空間、 WIN9 NT、WIN202 WINXP 等 操作系統(tǒng) ??稍谄涞?⑦ 腳與地之間接一只 0. 1 F 瓷片電容,在第 ④ 、 ⑥ 腳間 (注: 15 不同于第 ⑥ 腳接地 )接一保 0. 1 F 瓷片電 容 [11]。對于由于輸入信號過強(qiáng)引起的嘯叫,可在 LM386第 ① 、 ⑨ 腳之間加阻容網(wǎng)絡(luò),批量應(yīng)用時(shí), R的阻值可由實(shí)驗(yàn)決定,或?qū)?R代換為微調(diào)電位器 w,若信號仍然過強(qiáng),可將 LM386第 ① 、 ⑤ 腳懸空。 LM386 電源電壓 412V,音 頻功率 。 AT89C51 是一種低功耗/低電壓、高性能的 8 位單片機(jī),其輸出引腳和指令系統(tǒng)都與 MCS 一 51 兼容,雙列直插封裝圖如 [14]所示。 此 電子音樂門鈴的電路設(shè)計(jì)方案如圖 所示 圖 PCB 繪制電路圖 主電路設(shè)計(jì) AT89C5l 單片機(jī)簡介 :單片機(jī)發(fā)展至今已有 20 余年的歷史,形成了約 50 個(gè)系列 400 余種機(jī)型,設(shè)計(jì)者不可能對每一種芯片都熟悉,因此在選擇芯片時(shí)切勿追趕時(shí)髦,使用從未接觸過的芯片。 通過音頻功放電路,把信號輸出到揚(yáng)聲器,播出美妙的音樂。 對于計(jì)算機(jī)編程 節(jié)拍碼及節(jié)拍數(shù)如 圖 [5]所示 : 圖 節(jié)拍碼及節(jié)拍數(shù) 7 3 系統(tǒng)硬件設(shè)計(jì) 系統(tǒng)以 AT89C51單片機(jī)為核心,加上外圍電源時(shí)鐘電路、 LM386功放電路及揚(yáng)聲器電路組成。 以標(biāo)準(zhǔn)高音 A 的頻率 F=440HZ,其對應(yīng)的周期為: T=1/F=1/440=2272us 因此需要在單片機(jī) I/O 端口輸出周期為 T=2272us 的方波脈沖,也就是t=T/2=2272/2=1136us 也就是說,單片機(jī)上定時(shí)器的中斷出發(fā)時(shí)間為 1136us。 音調(diào)的高低還與發(fā)聲體的結(jié)構(gòu)有關(guān),因?yàn)榘l(fā)聲體的結(jié)構(gòu)影響了聲音的頻率。因此單片機(jī)演奏音樂比較簡單,只需能清楚 “音調(diào) ”和 “節(jié)拍 ”兩個(gè)概念即可。 4 系統(tǒng)原理與控制方法 利用單片機(jī) 89C52產(chǎn)生樂曲音符,再把樂譜翻譯成計(jì)算機(jī)音樂語言,由單片機(jī)進(jìn)行信息處理,在經(jīng)過信號放大,由喇叭放出樂曲聲。由于將多功能 8 位 CPU 和閃爍存儲器組合在單個(gè)芯片中, ATMEL 的 AT89C51 是一種高效微控制器, AT89C2051 是它的一種精簡版本。 本文利用單片機(jī)體積小、速度快、 功能強(qiáng)、性能可靠、價(jià)格低廉等優(yōu)點(diǎn),介紹了用 AT89C52 單片機(jī)設(shè)計(jì)電子音樂門鈴的方法,系統(tǒng)實(shí)現(xiàn)簡單、功能穩(wěn)定。其中絕大多數(shù)沒有按鈕提示以及其他功能,要不就是造價(jià)昂貴,諸多缺點(diǎn)。 題目背景及目的 隨著時(shí)代的 發(fā)展和進(jìn)步 ,控制智能化、儀器小型化、功耗微小化得到廣 泛關(guān)注。除芯片基本電路部分外,還需要聲音擴(kuò)大部分,用到 386DE 芯片。本設(shè)計(jì)中音樂門鈴的基本功能都能由 51 芯片提供,且價(jià)格低廉。 關(guān)鍵 詞 : 單片機(jī),低成本,程序,音樂 Abstract Doorbell application, can be seen everywhere in modern society, but because of various considerations, such as low cost, voice pattern, we need to dig further. The design of this thesis is to focus on research and development cost music doorbell. Mainly applied to the 51chip, 51 chip is a microprocessor, microcontroller 51 has excellent performance and low cost, high integration, small size, high reliability, high control, low voltage, low power consumption. The design of the basic functions of music doorbell can be from 51 chips, and low prices. In addition to the basic part of the circuit chip, but also need to expand the sound section, use 386DE chip. Expand the system around the low cost and expand the function by the program partially achieved. First with the c language code to achieve musical doorbell, and then use keil software c language generated hex file to stc89c51 integrated chip, the use of different frequencies make different tone, the use of delay have different beats, transmitted through the power amplifier To the speaker to broadcast the wonderful music. To further reduce costs, so the design process the main part is pleted, the program is divided into subject and extension. Extension of the provisions of the songs used in rhythm, tone control. Extension from the main program, music tracks and songs posed of an array of functions. In the use of drawing tools to plete the basic circuit design, and then soldering the circuit, and finally reentering into a part. Key words: Single chip, Lowcost, Program,Music 目錄 1 緒論 ........................................................................................................................................ 1 題目背景及目的 .............................................................................................................. 1 國內(nèi)外研究狀況 .............................................................................................................. 1 題目研究方法 .................................................................................................................. 2 論文構(gòu)成及研究內(nèi)容 ....................................................................................................... 2 2 電子音樂門鈴系統(tǒng)簡介 ........................................................................................................