Simulation and production of music player based on single chip microcomputer

Publisher:MagicalSerenadeLatest update time:2011-04-11 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract: In order to solve the shortcomings of dedicated music player chips that can only be burned once and the content of the playback cannot be changed, this paper gives a method of using a single-chip microcomputer to design a music player, and at the same time, using Proteus software to simulate the music player based on the AT89S52 single-chip microcomputer. The playback content and number of songs of the player designed by this method can be modified at any time.
Keywords: single-chip microcomputer; music player; Proteus

0 Introduction
The simplest way to play music is to use a dedicated music chip. The disadvantage of this method is that the music chip can only be burned once and the content of the playback cannot be changed. Using a single-chip microcomputer to play music can overcome this disadvantage, and the content of the playback and the number of songs can be modified at any time. At the same time, using software Proteus to simulate the design in the early stage of product development is undoubtedly a good way to improve efficiency and reduce costs, but simulation has certain limitations after all, and there may be some problems in practice. To this end, this paper simulates the use of AT89S52 single-chip microcomputer to play music through Proteus software, and points out the points that need to be paid attention to in the actual production process.

1 Hardware Circuit Design
1.1 Introduction to Proteus Simulation Software
Proteus's ISIS is a circuit analysis physical simulation system produced by Labcenter. It can simulate various circuits and ICs. It supports single-chip microcomputers and has a complete component library. It is easy to use and is a rare professional single-chip microcomputer software simulation system. Currently, the types of single-chip microcomputers that can be supported are 68000 series, 8051 series, AVR series, PIC12 series, PIC16 series, PIC18 series, Z80 series, HC11 series and various peripheral chips.
1.2 Circuit Design
Figure 1 shows the simulation schematic diagram of the single-chip microcomputer music player. In the Proteus simulation software, press a button and the hummingbird can play music.

a.JPG
In fact, welding the circuit according to the schematic diagram shown in Figure 1 may not have any effect. Figure 2 shows the actual production circuit of the single-chip music player. Compared with Figure 1, the actual
circuit has two more parts: one is the circuit part required for the minimum system on the left side of the single-chip, which is omitted in the simulation software; the other is that there is an additional triode on the right side of the single-chip. The reason for adding this triode is mainly to amplify the driving current of the buzzer, and all the components in the simulation software are ideal components, so the effect that can be achieved by simulation is often not effective in actual production. Therefore, in order to achieve satisfactory results in practice, it is necessary to rely on hardware experience to repeatedly explore and try.

b.JPG



2 Software Design
2.1 Playback Principle
The frequency spectrum of sound is usually about tens to thousands of hertz. By controlling the I/O port of the microcontroller through the program, rectangular waves of different frequencies can be output. When the frequency of the rectangular wave is within the frequency spectrum of the sound, the sound can be made by connecting a speaker to the I/O port of the microcontroller. Then, by using the delay program to control the duration of the high and low levels of the rectangular wave, that is, changing the frequency of the rectangular wave, different tones can be generated, thereby making different sounds. Then, by making the length of the rectangular wave output correspond to the beat, the microcontroller can play the music.
2.2 Tone and Beat Coding
To play music with a microcontroller, you only need to understand two concepts, namely "tone" and "beat". The tone indicates how high the frequency of a note is, and the beat indicates how long a note is sung.
Since the frequency corresponding to each tone is known, when playing music, the tones that appear in the music should be encoded, and the initial timing values ​​corresponding to the microcontroller playing these tones should be found. Table 1 lists the initial value table of tone coding and timer, in which the frequency is known and the coding can be set by oneself, but how is the initial value of the timing obtained? The following is an example of "low 6". The frequency f of "low 6" is 440 Hz, and its corresponding period is: T = 1 / f = 1 / 440 = 272μs. The time for the I / O port corresponding to the buzzer on the microcontroller to go back and forth should be: t = T / 2 = 2272 / 2 = 1136μs. When the microcontroller plays music, its timer is in working mode 1. If the twelve-frequency signal of the oscillator is used as the counting pulse, if the microcontroller crystal oscillator is 12MHz, it counts once every 1μs. Therefore, for "low 6", the initial value of its timer should be: 216-1136 = 64400.
The control of the beat can be achieved through the delay program. Table 2 lists the beat coding table. If the duration of 1 beat is 400ms, the duration of 1/2 beat is 200ms, and the duration of 1/4 beat is 100ms. First, determine a delay program with a basic duration. For example, if the basic delay time is 100ms, then 1/4 beat can call the delay program once, 1/2 beat needs to call the delay program twice, 1 beat needs to call the delay program four times, and so on.
2.3 Programming
After the pitch and beat are encoded, a piece of music can be represented by several 8-bit simple codes. For example, the first simple code of "Happy Birthday" is "82H". From Table 1, we can see that the upper four bits "8" represent the pitch "medium 5", the corresponding frequency is 784Hz, and the corresponding timer initial value is 64898; from Table 2, we can see that the lower four bits "2" represent the beat as "2/4 beat". In this way, the simple code of any piece of music can be obtained through the music score extraction software, and after obtaining the simple code, it can be programmed. Figure 3 shows the program flow chart of the single-chip microcomputer playing music. This article uses timer 0. The pitch is controlled by the timer to control P3.7 and inverted at a certain frequency. The length of the beat is controlled by the delay program. The "TABLE" in the flowchart is composed of the timing initial values ​​in Table 1.

c.JPG

d.JPG

e.JPG



3 Conclusion
This article simulates the single-chip music player through Proteus ISIS, and makes a physical music player based on the simulation, which plays music very well. The author compares and summarizes the two through simulation and production, and gives two circuit diagrams and program flow charts, hoping to be a reference for readers.

Reference address:Simulation and production of music player based on single chip microcomputer

Previous article:A novel design of solar energy tracking and collection system
Next article:C language source code for simulating serial port

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号