KEYBOARD MANIA

by Carole-Jean Wu & Yang Ching Chang

 

INTRODUCTION

 

HIGH LEVEL DESIGN

 

PROGRAM/HARDWARE DESIGN

 

RESULTS

 

CONCLUSION

 

APPENDIX A: CODE

APPENDIX B: SCHEMATICS

APPENDIX C: PARTS LISTING

APPENDIX D: TASKS

 

REFERENCE

 

 

 

 

Carole-Jean Wu

Yang Ching Chang

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

High Level Design

 

Explanation of our Project

The keyboard mania displays its menu through HyperTerminal on the PC where users can first choose one piano score to practice using the computer keyboard and the welcome page on the TV screen. After the user enters his/her choice of piano score in HyperTerminal, the chosen score will be displayed on the TV screen. He or she can start to play the chosen piece of piano score by pressing the ‘s’ key, which stand for start, or to exit at any time by pressing the ‘q’ key, which stands for quit. When starting the piano score, the user has to follow the pacer, functioning as a tempo guide, below each note on the piano score and to play the correct key, such that middle C is ‘A’ on the computer keyboard and so on. [Figure 4 Program/Hardware Design] If the user hit the wrong key, the keyboard mania will display ‘x’ above the corresponding note on the TV screen; otherwise, the keyboard mania will display check mark above the corresponding note on the TV screen. At the same time, the user can listen to notes, which he/she plays using the computer keyboard. As a result, he/she can correct himself/herself when a wrong key is hit or when playing too fast/slow. After the user finishes the chosen piano score, the keyboard mania will display a brief evaluation report stating his/her current piano skill, his/her score, and the highest score of the chosen piece on record.

 

Background Math and Physics

Piano Score Generation

There are four pre-coded pieces of piano score stored as matrices in the flash memory. Each note is represented by two integers. The former integer indicates music note and the later integer represents the note’s duration.

First Integer: Note

Second Integer: Note Duration

Note Image

Note

Integer Representation

Middle C

1

D

2

E

3

F

4

G

5

A

6

B

7

C

8

Note Image

Note Name

Note Duration

Eighth note

1

Quarter note

2

Dotted quarter note

3

Half note

4

Dotted half note

6

Whole note

8

 

Piano Score Drawing

The keyboard mania displays two lines on the TV screen every 1/60-second. It traverse the matrix representing the chosen piano score, takes the first integer as an offset to the base note and the second integer as the note’s duration, and displays the note on the TV screen with its correct representation.

 

Note Generation

Keys, ‘A’, ‘S’, ‘D’, ‘F’, ‘G’, ‘H’, ‘J’, and ‘K,’ on the computer keyboard are encoded to notes, middle C, D, E, F, G, A, B, and C, on the piano keyboard respectively.

Range of piano notes which the keyboard mania is designed to play (from middle C to one octave above).

The corresponding key on the computer keyboard.

The corresponding key on the piano keyboard.

 

Tone Generation (Pitch)

 

Our keyboard mania generates waves with specified frequencies above. We reused audio codes from Lab 4: Lunar Lander Video Game. [Reference]

 

Logical Structure

The HyperTerminal residing on the PC serves as the menu of the keyboard mania. It allows users to choose a piece of piano score to practice through the HyperTerminal. After the request is sent to the microcontroller, the TV will display the chosen piano score on the screen. Then the user has to enter ‘y’ to start playing or ‘q’ to quit at any time. While the user is playing, the TV will display the correctness of notes hit using the computer keyboard. After the user finishes playing the chosen piano score, the TV will display an evaluation stating the user’s score and the highest score on the record.

The keyboard mania uses the computer keyboard, the HyperTerminal on the PC, the Mega32 MCU, and the TV as its I/O devices. The interaction between these I/O devices is presented in the flow chart on the right. The HyperTerminal on the PC communicates with the serial ports on the STK500 development board. At the same time, programs are compiled using CodeVision on the PC and loaded to Mega32 MCU on the STK500 development board. Then the audio and video signals generated by the MCU are connected to analog circuits on the breadboard and output through the TV.

 

Hardware/Software Tradeoffs

Hardware tradeoff

One hardware tradeoff of our keyboard mania is that the range of music notes is only one octave above the middle C because of the physical constraint of a computer keyboard. There are only 11 keys in a row on the computer keyboard; therefore, we decide to have our keyboard mania to output only one octave above middle C, 8 keys.

 

Software tradeoff

One software tradeoff of our keyboard mania is that the conversion calculation from input of computer keyboard to the corresponding note’s frequency. The floating-point calculation usually takes too long which cannot be finished within one frame time; therefore, we have to store it as char, but instead of float, where the conversion is done faster but the frequency accuracy is sacrificed.

 

Standards

RS-232

RS-232 is a standard specified by the Electronics Industry Association (EIA) for serial binary data transmission of data between a DTE (data terminal equipment) and a DCE (data communication equipment). The data terminal equipment used in our design is the PC using HyperTerminal program; the data communication equipment in our design is the STK500 development board.

For complete RS-232 standard, refer to

http://www.lammertbies.nl/comm/info/RS-232_specs.html

 


NTSC video

NTSC, which stand for National Television System Committee, is the analog television system used in the United States . Using the NTSC standard, frames are refreshed about every 1/30 second with interlacing technique, meaning odd and even lines are redrawn at about 60 frames per second.

For complete NTSC video standard, refer to

http://instruct1.cit.cornell.edu/courses/ee476/video/index.html

 

 

Existing Patents

With regards to intellectual property, we do not find any existing patents relative to our keyboard mania.