ACS MIDI CV/Gate : Firmware
The firmware is the heart of the system. It gets the MIDI data, filter them and send the usefull one to the Digital to Analog Converters.
The MIDI Protocol
To understand how this firmware works, a basic knowledge of the MIDI specification is needed. There are a lot of information about MIDI on the Web. Here you will find just what is important to know. Those of you who are interested in this material can consult this excellent Web Site.
The only MIDI messages that are used by this module are Note, Velocity, Pitch Wheel and Modulation. This messages are made up 3 Bytes. The first one shows the type of the message (Note, Velocity...) and the 2 others contain the data. For example, to sound a note in MIDI a Note On message is sent when you press a key and a Not Off message is sent when you release the key.In binary, the messages are :
1001 cccc, 0nnn nnnn, 0vvv vvvv - Note On1000 cccc, 0nnn nnnn, 0vvv vvvv - Note Off
The first byte is the Status Byte with the high-bit set. The two others are the Data Bytes with the high-bit clear. The number 1001 shows that this is a Note On message, the 4 bit cccc give the Channel number (4 bit = 16 channel). The second Byte 0nnn nnnn gives the note number (C, D, F#,...). Only 7 bit are used here. The pitch is in the range 0 to 127 where middle C is pitch number 60. The third byte 0vvv vvvv, gives the Velocity which is how quickly the key was pressed. The range is also 0 to 127.
When the key is released, the Note Off message is sent. It has the same structure, the only difference is that it begins with the number 1000. For example, if you play a A on the Channel 1 the messages will be (hex) :
(Note On) 90 2D 64, (Note Off) 80 2D 00.
Modulation and Pitch Bend Wheel send the same type of messages. Only the first 4 bits change. For Modulation the message begins with 1011. For the Pitch Wheel, it begins with 1110. The pitch value can be coded on 7 or 14 bits. The message is :
1110 LSB, MSB.
The firmware don't use the 2nd byte.
Unfortunately, most of MIDI devices do not use this kind of messages.
First, the Note Off message is never sent. Instead, a Note On message with a Velocity value of 0 is used so when you play a A the byte stream will be :
(Note On) 90 2D 64, (Note Off) 90 2D 00
Secondly, the first byte of the sream is often sent once. This is called "Running Status". The speed of the MIDI protocol (31 250 baud) is not very high so reducing the number of byte save the bandwidth. If you play the melody A, B, C with the Velocity of 40h on the channel #7, the stream of byte will be :
96 2D 40, 2D 00, 2F 40, 2F 00, 30 40, 30 00. Only 13 byte are sent instead 16.
The firmware
This program was written in C with the HI TECH PICC Compiler. If you use an other compiler you will have to change the instructions relative to the Port of th PIC.
I am a beginner, this program is not very professionnal.
MONO - POLYPHONIC VERSION
The version 2.1 of the firmware is now avaliable (07 dec 2009). It corrects the bug of the Gate 4.
DOWNLOAD THE HEX FILE ACS_MIDI v2.1. hex
DOWNLOAD THE SOURCE CODE IN C ACS_MIDI v2.1.c
The new version 2.2 of the firmware (released 18 december 2009) adds a new function. It's now possible to have an independant MIDI channel for each output (very useful with a software sequencer). A slight modification of the PCB and the switch is necessary (see the PCB page).DOWNLOAD THE HEX FILE ACS_MIDI V2.2.hex
DOWNLOAD THE SOURCE CODE WRITTEN IN C ACS_MIDI V2.2.C
LITE VERSION
DOWNLOAD THE HEX FILE ACS_MIDI Lite V1.hex
DOWNLOAD THE SOURCE CODE IN C ACS_MIDI Lite V1.c

