Circuit Design of Electronic Piano Based on Single Chip Microcomputer

Publisher:美丽花朵Latest update time:2012-10-15 Source: 21ic Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

With the penetration of computers in various fields of society, the application of single-chip microcomputers is becoming increasingly in-depth, while driving the rapid updating of industry, agriculture, commerce, home appliances and toys, greatly improving the quality and efficiency of electronic circuit and system design.

The single-chip electronic keyboard with storage function designed in this paper is composed of STC89C51 single-chip computer, small keyboard, LCD, audio power amplifier circuit and speaker. With this electronic keyboard circuit, users can freely input notes, use the single-chip computer to generate different frequencies to obtain the required scale, make the speaker emit pleasant music, and finally play the music they want to express at will. At the same time, the design process and key technologies of the system are discussed in detail.

1 System Hardware Composition

The control circuit of the electronic keyboard is divided into several parts, including single-chip microcomputer STC89C51, working indicator LED, LCD display, key input, speaker interface, etc. Its hardware circuit structure block diagram is shown in Figure 1.


1.1 Introduction to the STC89C51 microcontroller

The STC microcontroller is an enhanced 5l microcontroller, fully compatible with MCS-51. STC89C51 can replace AT89C51, and it is more powerful, faster, longer life and cheaper. The microcontroller has 40 pins and is packaged in a dual in-line DIP-40 package. STC89C51 can complete the ISP online programming function, while AT89C51 cannot. Therefore, after the program in AT89C51 is directly burned into STC89C51, STC89C5l can directly replace AT89C51 to work. The series 51 microcontroller chips launched by STC are fully compatible with other 51 microcontrollers. STC89C51 has an internal E2PROM, which can be modified in the program, and the data will not be lost when the power is off. In addition, two levels of interrupt priority are added, etc. The basic characteristics of the STC89 series microcontrollers are shown in Figure 2.

Usually, the scale values ​​entered by the electronic keyboard are first stored in the variable array, and then taken out one by one to play the single tone when playing. The variables in the program use the internal memory RAM, which ranges from space 30H to 7FH. Therefore, the program memory planning is: RAM address 30H to 70H stores the scale value, and the maximum memory space is 64 bytes; RAM address 71H to 7FH stores other program variables. After the program is executed, the work indicator LED flashes, indicating that the program has started to execute. When the relative key in the keyboard group is pressed, the piezoelectric speaker will emit a relative scale single tone. The whole system has 2 octave scales, DO~SI, HI DO~HI SI, 14 scales, and the input single tone will be stored in 89C5l. Up to 64 single tones can be entered and played together. There is also a clear storage function, which can clear the original data and re-enter it.

1.2 LCD Hardware Interface

The pins of the LCD used in this design are shown in Figure 3, where DO~D7 are bidirectional data buses, and the LCD data read and write methods can be divided into 8-bit and 4-bit. If 8-bit data is read and written, DO~D7 are all valid. If 4-bit data is read and written, only D7~D4 are used. RS is the register selection control line. When RS is 0 and a write operation is performed, the instruction register can be written; if RS is 1, it is used to read and write data registers. P/W is the LCD read and write control line. When R/W is 0, the LCD performs writing. When R/W is 1, a read operation is performed. VO is the brightness adjustment voltage input control pin. When 0V is input, the character display is the brightest.


The LCD can display the currently played single note code in real time, and can display the stored single note count in real time. Button 9 is the clear key, which can clear the stored single note count to 0; button 8 is the play key, which can play the single notes in the memory one by one. You can press the K4 key to interrupt during the performance. This design uses a general LCD display to display music performance messages and single note codes. Press the keyboard group button, and the speaker will emit a relative scale. By storing these scales and then playing them, it can become an automatic playing electronic piano.

1.3 Keyboard Scanning

Each key on the keyboard is identified by two unique values. Why two values ​​instead of one? This is because a key can be pressed and released. When a key is pressed, it generates a unique value, and when a key is released, it also generates a unique value. We save these values ​​in a table, and then we can know which key was hit by looking up the table, and whether it was pressed or released.

The schematic diagram of the distribution and configuration of the entire 4x4 keyboard keys is shown in Figure 4. Figure 4 shows the 16-key control circuit, which uses the 8 I/O lines of AT89S51 port 2 to scan the 16 keys, and P2.0~P2.3 ​​sends the scan signal, while P2.4~P2.7 reads the key data return code. Table 1 lists the correspondence between 4x4 keys and scales.

[page]

2 Electronic keyboard hardware parameters

Keyboard (keys): The keyboard of the electronic piano is divided into standard force keyboard, semi-weighted keyboard, fully weighted keyboard, and graded weighted keyboard (also called graded hammer keyboard).

Standard force keyboard: a tension spring structure keyboard, which is used from low-end pianos to mid-to-high-end pianos. Its advantage is its fast key return speed (that is, the speed at which the key bounces back after being pressed), and its disadvantage is its inaccurate force transition and positioning.

Semi-weighted keyboard: It is also a keyboard with tension spring structure, but it has more weighted lead blocks than ordinary tension spring keyboard. This kind of keyboard structure has been used in mid-to-high-end synthesizers before, but now many popular pianos also have this configuration. The advantage of the standard velocity keyboard is that the velocity positioning is more precise.

Fully weighted keyboard: This keyboard is constructed to imitate the piano, simulating the action structure, and there is a fixed weighted lead block under each key, so it is called a fully weighted keyboard. It gives the player a "piano feeling". The advantage is that it is more suitable for the initial replacement of the piano for learning to play, and it has good performance for various playing strengths. The disadvantage is that it is not suitable for playing some songs that require fast playing speed (slow rebound).

Stepped weighted keyboard: Like the fully weighted keyboard, it also simulates the action structure. The difference is that the keys of the stepped weighted keyboard are heavier in the bass range and lighter in the treble range, which imitates the feel of a grand piano.

3 System Software Design

Since this system can generate sounds of various frequencies, the speaker can emit the scale of "DO", "RE", "ME"... Timer O in the system works in mode 0, and the timing duration can be determined according to the frequency of the sound. Table 2 lists the frequency values ​​corresponding to each note. The initial value of the timer count derived from the frequency value can be obtained by the following relationship:

In the formula, f is the frequency value; t is the width of the square wave, expressed in μs; co is the number of times counted by the timer, lo is the low byte of the initial count value, and hi is the high byte of the initial count value. Figure 5 shows the workflow of the main program.

4 Conclusion

By changing the control program of the key-operated electronic keyboard, different types of electronic keyboards can be designed. The memory capacity can also be increased by expanding the RAM, thereby giving full play to the storage function of the electronic keyboard.

Keywords:MCU Reference address:Circuit Design of Electronic Piano Based on Single Chip Microcomputer

Previous article:An assembly lookup program
Next article:Design of smart home security system based on single chip microcomputer

Recommended ReadingLatest update time:2024-11-17 04:45

MCU simple clock
1. Brief Introduction Through Proteus simulation circuit, use 7-segment digital tube to display the current time in real time. Project file: Link: https://pan.baidu.com/s/1CkKAF8h2dzn-bMoqgL-mhQ Password: i3a2 2. Effect 3. Engineering Structure 1. Keil Project 2. Simulation circuit diagram 4. Source Files
[Microcontroller]
MCU simple clock
MCU---HLK-W801 parallel port driver ST7789
Purpose I bought this parallel port screen to make a NES emulator game console. The SPI screen I used before was quite time-consuming to display the game screen because it was serial data. So I planned to try the parallel port screen and understand the driving method of the parallel port 8080. Parallel Port Protocol
[Microcontroller]
MCU---HLK-W801 parallel port driver ST7789
Interface circuit and driver based on ADC081S051 and 51 single chip microcomputer
introduction The signals existing in nature are usually analog signals. In the measurement and control system, the collected analog signals are usually digitized and then handed over to the microprocessor or microcontroller for processing. Therefore, the analog-to-digital converter becomes an indispensable part of the
[Power Management]
Interface circuit and driver based on ADC081S051 and 51 single chip microcomputer
Design of Intelligent Resistance, Capacitance and Inductance Measuring Instrument Based on Single Chip Microcomputer
0 Preface     There are currently three methods for implementing RLC measurements. 1) The bridge method, which has high measurement accuracy and is widely used, has now been derived into many types. However, the bridge method requires repeated balance adjustments, takes a long time to measure, and is difficult to ach
[Microcontroller]
Design of Intelligent Resistance, Capacitance and Inductance Measuring Instrument Based on Single Chip Microcomputer
Design of infrared communication based on 51 single-chip serial port in multi-rate electric energy meter
0 Introduction Multi-rate watt-hour meters are indispensable watt-hour metering products under the current electricity conservation and planned electricity consumption policies in my country. The communication interface of multi-rate watt-hour meters generally has both infrared interface and RS485 interface. In
[Microcontroller]
Design of infrared communication based on 51 single-chip serial port in multi-rate electric energy meter
Design of Indoor Environmental Parameters Automatic Control System Based on Single Chip Microcomputer
This design is a research and design of an environmental parameter control system developed on a single-chip microcomputer, which mainly controls various environmental conditions in the greenhouse and measures data in real time. In the environmental parameter control, the hardware circuit of 51 single-chip microcomput
[Microcontroller]
Design of Indoor Environmental Parameters Automatic Control System Based on Single Chip Microcomputer
Brief analysis of common problems in MCU Keil
  1. Hybrid Programming   1. Interface within the module:   Use the following identifiers:   #pragma asm   Assembly Statements   #pragma endasm   Note: If you use assembly language in your C51 program, be aware that you need to activate the "Generate Assembler SRC File" and "Assembler SRC File" options in th
[Microcontroller]
Design of automatic bad block detection system based on single chip microcomputer FIash memory
With the rapid development of electronic technology, intelligent electronic products can be seen everywhere, such as PCs, mobile phones, PDAs, digital cameras, game consoles, digital TVs, etc., and the core components of such electronic products are often inseparable from memory. Whether it is from the physical struct
[Microcontroller]
Design of automatic bad block detection system based on single chip microcomputer FIash memory
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号