This series will bring systematic learning of FPGA, starting from the most basic digital circuit foundation, the most detailed operation steps, the most straightforward verbal description, and step-by-step "fool-proof" explanations, so that students majoring in electronics, information, and communications, newcomers to the workplace, and professional developers who plan to advance can all have the opportunity to learn systematically.
Systematically mastering technology development and related requirements has potential help for personal employment and career development. I hope it will be helpful to everyone. In the future, we will continue to update the relevant content of Xilinx's Vivado, ISE and related operating software development. While learning FPGA design methods and design ideas, practical operation combined with various operating software will make your technical learning path extremely smooth, say goodbye to technical learning small BUGs that break your brain, say goodbye to the current misleading training induction, and truly learn and apply it in practice. You will understand this kind of happiness if you try it. Without further ado, here are the goods.
Music Buzzer Design
A buzzer is an electronic sounder with an integrated structure, powered by DC voltage. It is widely used as a sound-generating device in electronic products such as computers, printers, copiers, alarms, electronic toys, automotive electronic equipment, telephones, timers, etc.
Figure 1: Buzzer picture
Buzzers are mainly divided into two types: piezoelectric buzzers and electromagnetic buzzers.
Piezoelectric Buzzer
The piezoelectric buzzer is mainly composed of a multivibrator, a piezoelectric buzzer, an impedance matcher, a resonance box, a shell, etc. Some piezoelectric buzzers are also equipped with a light-emitting diode on the shell. The multivibrator is composed of a transistor or an integrated circuit. When the power is turned on (1.5~15V DC working voltage), the multivibrator starts to vibrate and outputs an audio signal of 1.5~2.5kHZ. The impedance matcher drives the piezoelectric buzzer to sound.
Electromagnetic buzzer
The electromagnetic buzzer consists of an oscillator, an electromagnetic coil, a magnet, a vibrating diaphragm and a shell. After the power is turned on, the audio signal current generated by the oscillator passes through the electromagnetic coil, causing the electromagnetic coil to generate a magnetic field. Under the interaction of the electromagnetic coil and the magnet, the vibrating diaphragm vibrates periodically and makes a sound.
According to whether there is an oscillation source inside, it can be divided into active buzzers and passive buzzers. Active buzzers have an oscillation source inside, so they will make a sound as long as the power is turned on; while passive buzzers do not have an oscillation source inside, so if a DC signal is used, it cannot make it buzz. It must be driven by a square wave of a certain frequency.
First, design a frequency divider, design a 1KHz square wave, drive the buzzer, and observe whether the buzzer produces sound.
This section studies how to use a buzzer to sing a song "Only Mother is Good in the World".
The picture below is the simple score of "Only Mom is Good in the World".
Figure 2: The simple musical notation of "Only Mom is good in the world"
Simplified musical notation is a relatively simple and easy-to-learn musical notation. It is said that it was invented by the French thinker Rousseau in 1742. The first person to introduce simplified musical notation into my country was Shen Xingong, a modern Chinese music educator. Simplified musical notation should be said to be a relatively simple and easy-to-learn musical notation. Its biggest advantage is that it can record and express a myriad of musical pieces with only 7 Arabic numerals - 1234567.
In the simplified musical notation, the basic symbols used to indicate the pitch of notes and their relationships are seven Arabic numerals, namely 1, 2, 3, 4, 5, 6, and 7, which are sung as do, re, mi, fa, sol, la, and si, which is called solfeggio.
Notes: 1234567
Roll call: do re mi fa sol la si
Chinese characters: Duo Lai Mi Fa Suo La Xi
Obviously, the above seven notes alone cannot express many musical images. In actual works, there are some higher or lower notes. For example, adding a "·" above the basic note means that the note is raised by one octave, which is called a treble; adding two ":" means that the note is raised by two octaves, which is called a double treble. Adding a "·" below the basic note means that the note is lowered by one octave, which is called a bass; adding two ":" means that the note is lowered by two octaves, which is called a double bass.
In general songs, it is rare to add two or more "·" notes above or below the basic note.
In the simplified musical notation, the seven basic notes 1, 2, 3, 4, 5, 6, and 7 not only indicate the pitch of the sound, but also are the basic units for indicating the length of time, called quarter notes. Other notes are represented by adding a short dash "-" and a dot "·" on the basis of the quarter note.
Adding a short horizontal line to the right of the basic note indicates that the duration of the note is increased by one quarter note. This type of short horizontal line added to the right of the note to increase the duration of the note is called an augmented time line. The more augmented time lines there are, the longer the duration of the note.
Adding a short horizontal line under the basic note indicates that the original note value is shortened by half. This type of short horizontal line added under the note to shorten the note value is called a time reduction line. The more time reduction lines there are, the shorter the note value.
In simplified musical notation, the small dot "·" added to the right side of a simple note to increase the note value is called a dot. The note with a dot is called a dotted note. The dot itself has no fixed length, and its length is determined by the previous simple note. The meaning of the dot is to increase the original note value by half, and it is often used after a quarter note and various notes shorter than a quarter note.
In the simple score of "Only Mom Is Good in the World", the duration between each two vertical lines is 2 seconds. There are 4 notes between each two vertical lines, but most of them are half a note long. This design uses 1/4 second as the basic unit.
The buzzer can produce seven basic notes, 1, 2, 3, 4, 5, 6, and 7, at different frequencies.
Figure 3: The frequencies corresponding to the notes
This module is named music_beep, clk is the 50MHz clock, rst_n is the low-level effective reset, and beep is the driving signal of the buzzer.
Figure 4: music_beep model
When designing, first store the notes in the musical notation; use a counter to generate a pulse with a period of 1/4 second, and under the drive of this pulse, output the previously stored notes one by one; calculate the frequency division ratio according to the value of the note; and generate a waveform of the corresponding frequency according to the frequency division ratio. Then output this waveform.
Figure 5: Architecture diagram
When designing multiple modules, you can only design the ports for each module, and then design each module separately after the architecture is completed.
There are 8 four-beats in the simple score of "Only Mom Is Good in the World", and we use 8 notes to represent each four-beat, totaling 64 notes. In speed_ctrl, the output cnt is 6 bits, which can represent 64 states.
In speed_ctrl, just increase cnt by 1 every 1/8 second.
The design code of the speed_ctrl module is as follows:
The notes are stored in music_mem. The storage method is that the bass is represented by 1 to 7, the middle is represented by 8 to 14, and the treble is represented by 15 to 21. The music is 5 bits wide.
The design code of the music_mem module is as follows:
According to the relationship between frequency and note, the frequency value corresponding to the note is taken out, and the frequency division ratio is calculated according to the frequency value. The driving clock is 50MHz, so the frequency division ratio is 50MHz divided by the frequency.
The design code of the cal_divmum module is as follows:
After knowing the frequency division number, you can use any frequency division method to generate the correct waveform.
The design code of the wave_gen module is as follows:
After designing the above four modules, connect them using the connection method of the previously designed architecture.
The design code of the music_beep top-level module is as follows:
The RTL view is as follows, which is the same as the designed architecture.
Figure 11: RTL View
In testbench , change T_250ms in the speed_ctrl_inst module to 10.
defpa ram can redefine parameters.
The testbench code is as follows:
Since the output frequencies are low, the simulation time is very long.
Reducing the parameter will only speed up the frequency of switching output notes. Since the wave_gen module and the frequency division module are the same, we will not verify them. Just check whether the frequency division number is correct in the RTL view.
Figure 13: RTL View
In the RTL view, we can also see that cnt increases by 1 every 10 cycles, and then the corresponding note is output. The note derives the frequency, and the frequency division number is obtained based on the frequency. After verification, the data is correct.
Assign pins, compile and generate Download file, and you can listen to the song "Only Mom Is Good in the World" after downloading the board.
By changing the speed of the control note in speed_crtl, you can control the playback speed. If the speed is controlled to 1/2 second, the song you hear will be slower. If the speed is controlled to 1/8 second, the song you hear will be faster.
Previous article:What conditions are needed to move from intelligence to super intelligence?
Next article:SGM3715 high-fidelity analog switch opens the door to wonderful audio
Recommended ReadingLatest update time:2024-11-16 11:46
- Popular Resources
- Popular amplifiers
- Analysis and Implementation of MAC Protocol for Wireless Sensor Networks (by Yang Zhijun, Xie Xianjie, and Ding Hongwei)
- MATLAB and FPGA implementation of wireless communication
- Intelligent computing systems (Chen Yunji, Li Ling, Li Wei, Guo Qi, Du Zidong)
- Summary of non-synthesizable statements in FPGA
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
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
- CCS usage problems and solutions
- 【FAQ】BQ76930: Battery balancing issue
- ST60 Short Range Contactless 60GHz Millimeter Wave Connector Unboxing and Analysis
- Free Review: Pengfeng Artix 7 FPGA Development Kit
- C2000 CLA FAQ
- Hardware Engineer Recruitment
- [Sipeed LicheeRV 86 Panel Review] 5. WAFT First Experience
- Ultra-small packaged IC chips VKD233DS and VKD233DR for wireless Bluetooth headsets
- PCB board level shielding design
- DSP Basics--Fixed-point Decimal Operations