J_glow_small.JPG(4171 bytes)Control Code            

wpe5.jpg (1696 bytes)

wpe3.jpg (1696 bytes)

wpe4.jpg (1696 bytes)

wpe2.jpg (1696 bytes)

button.gif (1824 bytes)

wpe6.jpg (1696 bytes)

wpe6.jpg (1696 bytes)




                MIDI, or Music Instrument Digital Interface, is a standard protocol for sending musical information between electronic devices.  The protocol was established in 1982 and is used by professional and amateur musicians alike.  A typical setup which employs MIDI is shown below:

MIDI_fig.gif (1666 bytes)

        In this setup the sound module has sythesized or sampled sounds which we want to turn on and off at the right times to create music.  The MIDI signal tells the sound module when to turn the sound on, which note and type of sound to play, and controls sound effects (such as volume, reverb, velocity, panning, etc…).  Note that the MIDI signal does not contain any of the sounds themselves, that is in the sound module.  If an example MIDI signal were translated into words it would simply be:

Turn sound #5 On and play a C# with a velocity of 100

                  Midi is a asynchronous serial connection operating at 31,250 baud.  It uses a 5-pin din connector to transmit the signal.  The signal consists of 1 start bit, 8 information bits, and 1 stop bit.  A single MIDI message is typically 2-3 bytes long.  Most MIDI messages are sent on to a single channel, which is specified in the MIDI message.  Each channel is associated with a specific sound (eg. Violin, piano, harp, etc…) in the sound module which is defined at the beginning of the song.  When a message such as “turn note on at channel 2” is received the module knows that a piano (or whatever instrument is assigned to that channel) is supposed to be turned on.  There are a maximum of 16 channels that can be used.  Although this may appear limiting, the instrument associated with a channel can change throughout the course of a song. So a maximum of 16 different sounds can only sound at the same time.

                  There are 2 types of MIDI bytes that make up a single MIDI message: status bytes and data bytes.  A status byte defines the action which will take place, such as note-on or note-off.  Status bytes also tell the sound module which channel the MIDI message is directed at.  Data bytes define which note is to be played (eg. C# or Bb) and how that note is to be played (ie. Volume or velocity).  Velocity, which is typically the second data byte of a MIDI message, defines how “forcefully” the note is to be played.  A typical MIDI message is shown below:

note_on.gif (1523 bytes)

                MIDI controls the timing of when notes play in the simplest possible way, all MIDI events happen immediately when they are received.  So no timing information is contained in the MIDI signal, the controller or keyboard is what determines the timing of MIDI events.  This also means that since MIDI operates on a serial interface MIDI cannot turn more than one note on or off at a given time.  It is still possible to have many notes playing simultaneously but they cannot be turned on and off at exactly the same time.  The message length determines the smallest time delay between MIDI events.   Since MIDI operates at 31,250 baud this time delay is usually inaudible.  However, for complicated music where several messages are sent simultaneously, the delays can add up to be noticeable.  To help prevent these delays the status byte will sometimes be left off in a series of MIDI messages which all have the same status byte. 

Guitar Specs.

                The device built in this project is a MIDI controlled guitar using the HC11 Motorola Micro-controller.  The guitar is solely controlled through the MIDI interface.  The guitar can play the first four frets on all six strings plus all open strings.  This gives the guitar a range of approximately an two and a half octaves.  All out of range notes are not played.  The guitar is set up to only respond to MIDI messages sent to channels 1 and 2.   When the velocity portion of the MIDI message is received all values greater than 0 are played the same way.  At a velocity of 0, though, the note does not sound.  The guitar can be controlled using a keyboard, computer sound card, or any other controller which sends a MIDI signal.  For this project we control the guitar with a keyboard and a sound card.   The computer control with the sound card is achieved via MIDI sequencing software.  This software enables the user to view, edit, and play MIDI events.


                A block diagram of the program is shown in the figure below.  This program has two main functionalities:

(1)     The program reads and interprets the incoming MIDI data and prints the received message on the screen

(2)     The program sends control signals to the guitar based on the received information

 Interpretation of the MIDI data is based on the guidelines outlined in the MIDI Specification 1.0 published by the MIDI Manufacturers Association.  The MIDI information is received through the serial port on the HC11 (Pin PD0).  Since the MIDI messages must be immediately interpreted and acted on, the software uses interrupts for all MIDI processing.  The software also checks for read errors, improper messages (eg. 2 status bytes sent back to back), and filters non-applicable messages (eg. Out of range notes).  

code_flow.gif (18324 bytes)

 The text writing portion of the program (not shown in above figure) uses a circular buffer to store the interpreted MIDI information that will be printed to the screen.  The text writer functions outside of the interrupt service routine.  Therefore the text writer will pause when new MIDI information is received to give the reading and interpretation of MIDI data (the interrupt portion of the program) a higher priority.  If the text writer is overloaded it will stop receiving data from the MIDI interpreter until the old MIDI data is written to the screen.

 The HC11 sends control signals which turn the fingering and plucking solenoids on and off.   Controlling the guitar was complicated by the fact that there are only 21 outputs from the HC11 and we needed to control 35 solenoids.  We solved this problem using addressable latches (these will be further discussed in the Circuitry portion of the paper).  Each latch holds data in its output pins till the HC11 rewrites new data to the pin.  The output pins of each latch control each solenoid.  The signals that the HC11 sends to  pluck and finger each note are shown in the Fingering and Plucking conversion table (below).


FINGERING CONVERSION TABLE (PORT C)      PLUCK = [ A2 | x | A1 | D2 || A0 | N(WE) | D1 | n(CLR) ]
MIDI # Note A2 N(WE3) A1 N(WE2) A0 N(CLR) DATA N(WE1) NOTE ON NOTE OFF Note On Note Off
$28 Low E 0 1 0 1 0 1 x 1 $57 $55
$29 F 0 1 0 1 0 1 x 0 $56 $54
$2A F# 0 1 0 1 1 1 x 0 $5E $5C $11 of $03 $05
$2B G 0 1 1 1 0 1 x 0 $76 $74
$2C G# 0 1 1 1 1 1 x 0 $7E $7C
$2D A 0 1 0 1 0 1 x 1 $75 $55
$2E Bb 1 1 0 1 0 1 x 0 $D6 $D4
$2F B 1 1 0 1 1 1 x 0 $DE $DC $19 or $0B $05
$30 C 1 1 1 1 0 1 x 0 $F6 $F4
$31 C# 1 1 1 1 1 1 x 0 $FE $FC
$32 D 0 1 0 1 0 1 x 1 $57 $55
$33 Eb 0 1 0 0 0 1 x 1 $47 $45
$34 E 0 1 0 0 1 1 x 1 $4F $4D $31 or $32 $05
$35 F 0 1 1 0 0 1 x 1 $67 $65
$36 F# 0 1 1 0 1 1 x 1 $6F $6D
$37 G 0 1 0 1 0 1 x 1 $57 $55
$38 G# 1 1 0 0 0 1 x 1 $C7 $C5
$39 A 1 1 0 0 1 1 x 1 $CF $CD $39 or $2B $05
$3A Bb 1 1 1 0 0 1 x 1 $E7 $E5
$3B B 1 0 1 0 1 x 1 $57 $55
$3C C 1 1 1 0 1 1 x 1 $EF $ED
$3D C# 0 0 0 1 0 1 x 1 $17 $15 $91 or $83 $05
$3E D 0 0 0 1 1 1 x 1 $1F $1D
$3F Eb 0 0 1 1 0 1 x 1 $37 $35
$40 High E 1 0 1 0 1 x 1 $57 $55
$41 F 0 0 1 1 1 1 x 1 $3F $3D
$42 F# 1 0 0 1 0 1 x 1 $97 $95 $99 or $8B $05
$43 G 1 0 0 1 1 1 x 1 $9F $9D
$44 G# 1 0 1 1 0 1 x 1 $B7 $B5