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.
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.
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.
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.
Previous article:A novel design of solar energy tracking and collection system
Next article:C language source code for simulating serial port
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【Qinheng RISC-V core CH582】BLE lighting
- EEWORLD University ---- Altium Designer 4-layer smart car complete PCB design video tutorial
- How to solve the problem of insufficient ports of 51 MCU? (without adding expansion chips)
- 【TI recommended course】#What is I2C design tool? #
- How to determine the chip output current of the op amp
- Found a bug in threadx with stmcube
- [Simulation-Physical-Test] 790 to 960 MHz Broadband 600W LDMOS Asymmetric Doherty Amplifier
- TRUWB digital receiver performance based on ADC and its FPGA implementation.pdf
- Can the number of pulses of an ultrasonic generator driven by a transformer be accurately controlled?
- The helper2416 development board driver failed to create a device node