1 Hardware Circuit Principle
The metronome uses the AT89C51 single-chip microcomputer as the control center, and is composed of an LED display module, an adjustment keyboard module, and a sound output module. Figure 1 is the circuit schematic diagram of the metronome. The AT89C51 single-chip microcomputer produced by ATMEL is compatible with the MCS51 instruction system, has a 40-pin structure, and is the control center of the system. The display module is composed of a four-in-one common anode blue LED display, which adopts a dynamic scanning display mode. Q11~Q14 is the LED bit selection switch transistor, and R6~R13 is the current limiting resistor of the digital tube segment light-emitting diode. The four-in-one LED digital tube completes the function of displaying the number of beats, various function codes and parameter values. The keyboard adjustment module is composed of 4 buttons, namely, the function selection key A, the parameter setting selection key B, the parameter increase key C and the parameter decrease key D. The 4 buttons can complete the selection of various functions and the setting of various parameters. The sound output module is composed of a power amplifier circuit centered on Q1, Q2, Q3 and a speaker. Pulses of different frequencies are output from the P2.6 port of the microcontroller. After current limiting and power amplification by R14, the speaker is driven to emit a loud sound. Since the output audio signal is a pulse wave, the triode works in a switching state, with low loss and low heat generation. Q2 and Q3 can use small power tubes C8050 and C8550. The hardware structure of the entire system is simple. 12 V DC is provided externally for direct use by the audio amplifier module, and is stabilized to 5 V by LM7805 for use by the microcontroller and LED display.
2 Software Description
The software system adopts modular structure design, including main program module, metronome module, keyboard recognition and parameter setting module, etc. Each module is composed of several sub-modules. After power-on or reset, enter the adjustment function, and repeatedly press the A key to switch between the adjustment function and the metronome function. After entering the adjustment function, repeatedly press the B key to select different adjustment objects, and then press the C or D key to increase or decrease the parameter value of the adjustment object. The code and parameter value of the adjustment object are displayed during adjustment.
2.1 Main program module
In the main program module, the initialization of the storage unit, the initialization of the timer counter, the initialization of the interrupt, the initialization of the flag bit, the keyboard scanning are completed, and one of the following function modules is started according to the value of the function selection key A: parameter setting function, metronome function.
2.2 Metronome Function Module
The beat speed is adjustable in the range of 24 to 400 beats/min, the beat error is less than 2%, and the beat number is adjustable from 1 to 9. The display shows the beat number, and the speaker emits a beat sound. When the beat number 1 is displayed, a high-frequency sound of 600 Hz is emitted for 0.1 s, and when other beat numbers are displayed, a low-frequency sound of 300 Hz is emitted for 0.1 s. The module consists of a beat delay part, a beat number display part, and an audio pulse forming part. The program flow chart of the beat function module is shown in Figure 2.
2.3 Parameter adjustment module
After pressing the A key to enter the parameter adjustment function module, repeatedly press the B key to select the beat speed and beat division parameter settings in turn. The parameter type code and the number of the parameter are displayed on the LED display. Press the C or B key to cyclically increase or decrease a unit value within the value range of the parameter. Code 1 is the beat number, with a value range of 1 to 9. Code 2 is the beat speed, with a value range of 24 to 400 beats/min. The module program consists of keyboard scanning and recognition part, parameter display part, A key processing part, B key processing part and C, D key processing and other subroutines.
Figure 2 Metronome module flow chart
3 Experiments
Test the display, buttons, sound and beat accuracy.
Display observation: When in the beat working state, the 4 digital tubes simultaneously display the beat number in a loop, and the beat number can be seen clearly with the peripheral vision when practicing the piano. When in the adjustment mode, the highest digit displays the parameter code to be adjusted, and the remaining 3 digits display the parameter value. When the highest digit of the parameter is zero, it is not displayed. The display is correct.
Key test: Press the function key A to switch between parameter adjustment and beat mode. When in parameter adjustment mode, press the parameter change key B to switch between beat number and beat speed; press the increase key C or decrease key D to increase or decrease the parameter value by 1 based on the current value, and change cyclically within the parameter adjustment range. When in beat working mode, the BCD keys do not work. The keyboard works normally.
Sound observation: The beat is short and powerful, and the tone of the initial beat is clearly different from that of the remaining beats. It can be clearly heard in the piano playing environment.
Meter accuracy measurement: Use a stopwatch to measure the time it takes for a metronome to beat 500 times. When the beat speeds are 72, 112, and 144 beats/min, the times are 418.1 s, 268.9 s, and 210.5 s, respectively, with errors of 0.29%, 0.35%, and 1.1%, respectively. The beat accuracy meets the design requirements.
4 Conclusion
The sound of the starting beat of the metronome is different from the sounds of other beats, with good auditory and visual effects, high beat accuracy, and easy adjustment. Many piano children have achieved good results in piano practice using this metronome. The hardware cost is low, not easy to damage, and the appearance can be designed into a handicraft. The metronome based on the AT89C51 microcontroller has good application value.
Previous article:AT89C2051 drive stepper motor source code
Next article:51 MCU input/output port (IO port)
Recommended ReadingLatest update time:2024-11-16 10:14
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
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
- EEWORLD University Hall----Live Replay: Application of TI Precision ADC in Transmitter
- 【TI recommended course】#What is I2C design tool? #
- BQ40Z50-R2 security mode introduction and password modification method
- [NUCLEO-L552ZE Review] Expansion board ws2812 power supply correction
- Don't stop me, I want to do mpy development!
- My Journey of MCU Development (Part 2)
- 【Development and application based on NUCLEO-F746ZG motor】13. Parameter configuration - USART3 configuration
- What is the sound-generating mechanism of a piezoelectric buzzer? How to choose the sound component?
- The mechanical and electrical parts of the intelligent car based on the DFRobot four-way motor driver board have been preliminarily completed.
- [Example] Easily implement wifi remote RS485 bus (multi-node bus)