Midi Foot


MIDI FOOT
Designed by Paul Sobczak, Peter Arendt, and James Pachan

The Midi Foot is a foot controlled switch box that interfaces with a computer via Midi (Musical Instrument Digital Interface).

Midi Foot Front.

Design Criteria:

  • The project should be as cheap as possible
  • Easy for somebody else to make, meaning open-sourced
  • Constructed in 2 months or less as part of our design class requirements

These pages will walk you through how we built the Midi Foot.

Our original design called for the Midi Foot to control the open-source live looping Sampler SooperLooper

SooperLooper Logo
The design incorporates 6 different foot switches to control 6 different functions on the Sooperlooper program.

The Pic 16F876A Microchip Mircocontroller was chosen to control the midi output.

PIC
we chose the 16F876A for several reasons:

  • We all had experience programming it.
  • Microchip has an open software suite for code editing.
  • We were able to use the C language to program it.
  • We already had a proto-board ready for use.

Code:

You can download the source code here.
The compiled hex code is here.
It is also available at the bottom of this page.

The code is self explanatory and commented throughout.

In the code we make use of the Pic’s internal TX routine to send Midi data. Below is an example. It show the TX code for one switch.

if(RC0 == 1)
{

while(!TRMT); TXREG = 0b10010000; //Note On, Channel 1
while(!TRMT); TXREG = 0b00111100; //Middle C
while(!TRMT); TXREG = 0b01111111; //Velocity = 127
Wait_ms(50); //used for debouncing

while(RC0==1){}

while(!TRMT); TXREG = 0b10000000; //Note Off, Channel 1
while(!TRMT); TXREG = 0b00111100; //Middle C
while(!TRMT); TXREG = 0b00000000; //Velocity = 0
Wait_ms(50);//used for debouncing

}

This code waits for RC0 to go high (switch 1 to close) then immediately it sends midi data.

while(!TRMT); TXREG = 0b10010000; //Note On, Channel 1
while(!TRMT); TXREG = 0b00111100; //Middle C
while(!TRMT); TXREG = 0b01111111; //Velocity = 127

The while(!TRMT); TXREG = 0bxxxxxxxx; routine is responsible for the midi sending data. In the beginning of the source code (not shown here) we initialize this TX routine to send data with the correct baud rate, and format.

Here the TX routine waits until we are not sending any data “While(!TRMT)”, then the TX register gets loaded with 8 bits of data and sends it immediately on the port RC6.

Midi data consists of 3 different bytes of information.

byte 1: m00ncccc
byet 2: 0kkkkkkk
byte 3: 0vvvvvvv
m=”midi message” where “1” means a midi message is being sent
n=”Note On/Off” where “1” denotes note on and “0” denotes note off
cccc= “Chanel” denotes the channel where “0000” is channel 1 and “1111” is channel 16
kkkkkkk=”Key” the Key value, the range is 0-127
vvvvvvv=”Velocity” How hard you press the key, the range is again 0-127.

In the example that we are looking at

  • m=1 a midi message is being sent
  • n=1 a note on message is being sent
  • cccc=0000 channel 1
  • kkkkkkk=0111100 Key = Middle C
  • vvvvvvv=1111111 Velocity = 127 the Highest (switch on)

Once the button is let go the program sends another midi message saying Note OFF and Velocity = 0, everything else is kept the same.

That is how all of the midi data is sent throughout our code.

More information about midi can be found at the links below:

http://www.borg.com/~jglatt/tech/midispec.htm
http://tomscarff.tripod.com/midi_info.htm
http://www.audiomulch.com/midipic/

Full Source Code:


// **** MIDIFOOT**********************
//
// 4/29/07 Initial Code
// James Pachan, Peter Ardent, Paul Sobczak
// 5/15/07 Midi Send on Channel 8 update, more comments
// Paul Sobczak
//
//************************************

// Subroutines
#include **pic.h>
//my blog program does not like the include statement, so I added ** to confuse it, anyways //if you want to compile this code remove the “**” and insert a less than symbol in its place.

// bootloader routine
#asm
org 0x0000
clrf 3
movwf 0
movlw 0x0A
goto start
#endasm

// Wait_ms routine This routine waits x amount of milliseconds,
// it is used for simple debouncing purposes.

void Wait_ms(unsigned int X)
{
unsigned int Y;

do {
Y = 500;
do {
Y -= 1;
} while (Y > 0);
X -= 1;
} while (X > 0);
}

void main()
{
TRISB = 0x00;
TRISA = 0x00;
TRISC = 0x3F; // RC0-RC5 are input RC6 output
ADCON1 = 6;
PORTC = 0;
PORTB = 0;
PORTA = 0;

//****************************************************************
// Initialize Serial Port

SPBRG = 9; // 31250 baud @ 20MHz , X=9
SYNC = 0; // Fosc/(64*(X+1)) = Baudrate is the eqn of
// choice asynchronous mode
SPEN = 1; // enable synchronous serial port.
TXIE = 0; // no interrupt on xmit
TX9 = 0; // do not transmit 9 bits
TXEN =1; // enable transmition

TXSTA = 0x22; // 8-bit no parity serial port send Master
TX9D = 1; // mode TSR empty
BRGH = 0; // slow speed

//*****************************************************************

Wait_ms(100); //initial wait

do
{
// This is the main routine, RC0-RC5 are connected to each swith.
// Everytime a switch is pushed, A midi value is send
// It waits until the switch is “un”pushed then sends another
// midi value.

if(RC0 == 1)
{

while(!TRMT); TXREG = 0b10011000; //Note On, Channel 8
while(!TRMT); TXREG = 0b00111100; //Middle C
while(!TRMT); TXREG = 0b01111111; //Velocity = 127
Wait_ms(50); //used for debouncing

while(RC0==1){}

while(!TRMT); TXREG = 0b10001000; //Note Off, Channel 8
while(!TRMT); TXREG = 0b00111100; //Middle C
while(!TRMT); TXREG = 0b00000000; //Velocity = 0
Wait_ms(50);//used for debouncing

}
if(RC1 == 1)
{
while(!TRMT); TXREG = 0b10011000; //Note On, Channel 8
while(!TRMT); TXREG = 0b00111110; //D
while(!TRMT); TXREG = 0b01111111; //Velocity = 127
Wait_ms(50); //used for debouncing

while(RC1==1){}

while(!TRMT); TXREG = 0b10001000; //Note Off, Channel 8
while(!TRMT); TXREG = 0b00111110; //D
while(!TRMT); TXREG = 0b00000000; //Velocity = 0
Wait_ms(50);//used for debouncing

}
if(RC2 == 1)
{
while(!TRMT); TXREG = 0b10011000; //Note On, Channel 8
while(!TRMT); TXREG = 0b01000000; //E
while(!TRMT); TXREG = 0b01111111; //Velocity = 127
Wait_ms(50); //used for debouncing

while(RC2==1){}

while(!TRMT); TXREG = 0b10001000; //Note Off, Channel 8
while(!TRMT); TXREG = 0b01000000; //E
while(!TRMT); TXREG = 0b00000000; //Velocity = 0
Wait_ms(50);//used for debouncing

}
if(RC3 == 1)
{
while(!TRMT); TXREG = 0b10011000; //Note On, Channel 8
while(!TRMT); TXREG = 0b01000001; //F
while(!TRMT); TXREG = 0b01111111; //Velocity = 127
Wait_ms(50); //used for debouncing

while(RC3==1){}

while(!TRMT); TXREG = 0b10001000; //Note Off, Channel 8
while(!TRMT); TXREG = 0b01000001; //F
while(!TRMT); TXREG = 0b00000000; //Velocity = 0
Wait_ms(50);//used for debouncing

}
if(RC4 == 1)
{
while(!TRMT); TXREG = 0b10011000; //Note On, Channel 8
while(!TRMT); TXREG = 0b01000011; //G
while(!TRMT); TXREG = 0b01111111; //Velocity = 127
Wait_ms(50); //used for debouncing

while(RC4==1){}

while(!TRMT); TXREG = 0b10001000; //Note Off, Channel 8
while(!TRMT); TXREG = 0b01000011; //G
while(!TRMT); TXREG = 0b00000000; //Velocity = 0
Wait_ms(50);//used for debouncing

}
if(RC5 == 1)
{
while(!TRMT); TXREG = 0b10011000; //Note On, Channel 8
while(!TRMT); TXREG = 0b01000101; //A
while(!TRMT); TXREG = 0b01111111; //Velocity = 127
Wait_ms(50); //used for debouncing

while(RC5==1){}

while(!TRMT); TXREG = 0b10001000; //Note Off, Channel 8
while(!TRMT); TXREG = 0b01000101; //A
while(!TRMT); TXREG = 0b00000000; //Velocity = 0
Wait_ms(50);//used for debouncing
}

}while(1);//wash rinse repeat
}


Schematic and PCB:

Below is the schematic for the MidiFoot

Schematic for the Foot
Parts list:
1 Pic 16F876A Microcontroller
2 22pf ceramic capacitors…………..c1,c2
6 1k to 2kohm resistors…………….R1-R6
1 220 ohm resistor…………………Ra
1 20Mhz crystal …………………..Osc
6 SPST Foot Switches……………….S1-S6
1 power jack
1 midi jack
1 enclosure
1 5volt power supply
1 PCB or stripboard or Protoboard
and wire

PCB
Clean
Estimated Price:
1 Pic 16F876A Microcontroller……….4.70 (Digikey)
6 SPST Foot Switches………………12.00 (ebay)

Various Parts:
2 22pf ceramic capacitors
6 1k to 2kohm resistors
1 220 ohm resistor
1 20Mhz crystal
1 power jack
1 midi jack
and wire………………………..~10.00 for all (Digikey)

Other:
1 5volt power supply……………….? ~2.00
1 enclosure……………………….? ~10.00
1 PCB or stripboard or Protoboard……? ~5.00

Estimated Total…………………..43.70

You can buy a new 5v power supply (wall wart) for about 5 dollars at a store but you can pick one up from your local thrift store for 1 to 2 dollars.

The enclosure that we used was a Hammond Manufacturing enclosure model number 1455T2202BK, it is rather expensive around $30 so. You by no means have to use this enclosure, look around you home and try and find something that works, you should be able to find something for suitable, or buy a box for around 10.00.

For the PCB you can etch your own like we did or you can use stripboard or proto-board. Usually these come in packages so there is no way to tell how much one would cost for this project.

What we built it for:
Parts list:
1 Pic 16F876A Microcontroller……….0.00
2 22pf ceramic capacitors…………..0.00
6 1k to 2kohm resistors ……………0.00
1 220 ohm resistor…………………0.00
1 20Mhz crystal …………………..0.00
6 SPST Foot Switches………………12.00 (ebay)
1 power jack………………………0.00
1 midi jack……………………….0.00
1 enclosure……………………….0.00
1 5volt power supply……………….0.00
1 PCB or stripboard or Protoboard……0.00
1 pack of stickers…………………2.00

All of the parts with price 0.00 we had laying around or acquired for this project.

Total Price……………………….14.00

MidiFoot Design Pictures

You can see some of the construction photos and other various MidiFoot pictures Here

You can also download our short Power Point Presentation here.

15 Comments

  1. Paul
    January 15, 2009 at 10:48 pm

    Looks pretty cool 🙂 I’m looking to stop lugging my rather large Behringer FCB 1010 around for just a few preset changes. I think your project is just the ticket… Thanks 🙂

  2. themountainfold
    January 15, 2009 at 11:35 pm

    Please take a look at Max Greco’s micro foot, it is a modified and improved version on this project.

    http://www.maxgreco.com/fun/microfoot/

  3. leo
    September 16, 2009 at 1:01 pm

    Can i use this footcontroller only for 1 to 6 patch changes whit your source code?

  4. themountainfold
    September 17, 2009 at 10:47 am

    yes you are correct.

  5. leo
    September 21, 2009 at 11:38 am

    Tank you very much!
    The last question:

    How can i put leds (who bright when the switch is pressed)
    Can the number of the switch be implementated?
    Can i add an bank change switch whit display?

    Im intrested in someting like these!
    http://www.cicognaniamps.com/?file=products.asp&x=4&y=0&z=0&w=29

  6. themountainfold
    September 21, 2009 at 1:14 pm

    Wire up a resistor and a LED to the switch, that is easy.
    Theoretically any amount of switches can be implemented, but you will need to change the code and hardware accordingly.
    Yes, if you program it.

  7. leo
    September 21, 2009 at 1:57 pm

    Tank you! i will try to program the bank change, maybe whit someone’s help!

  8. leo
    September 21, 2009 at 2:13 pm

    Sorry for all this questions!

    Can i use RC6 and RC7 as switch input and RB0 as output?

  9. Wilson
    November 16, 2009 at 1:08 am

    Hello

    I am inexperienced in PIC.
    I built the midi foot but he is not working correctly.
    With the oscilloscope I can see that pulses exist in the output.
    Using the software MIDI-OX I see that it is working but in channel 9. I didn’t recompile.
    However, when I try to control some software in the computer, (for instance, bank select)
    he doesn’t act.
    Please the one what am making wrong ?
    Which compiler to use?
    At once, thank you very much.

  10. themountainfold
    November 16, 2009 at 12:31 pm

    Not sure what bank select is so I can’t be sure that you computer is not working correctly. But if you are having problems with then look at the cccc part of below:

    midi channel the n byte 1: m00ncccc
    byte 2: 0kkkkkkk
    byte 3: 0vvvvvvv
    m=”midi message” where “1? means a midi message is being sent
    n=”Note On/Off” where “1? denotes note on and “0? denotes note off
    cccc= “Chanel” denotes the channel where “0000? is channel 1 and “1111? is channel 16
    kkkkkkk=”Key” the Key value, the range is 0-127
    vvvvvvv=”Velocity” How hard you press the key, the range is again 0-127.

    Use the compiler from Microchip.

  11. Wilson
    November 19, 2009 at 12:23 am

    Hi again

    Thank you for answering quickly.
    I tried to recompile the source code (with CCS), but appears a mistake in ” #asm ”
    Maybe lack some part in the code
    I read that I need to do the definitions of file registers and bit of 16F876a
    Right?
    I promise that I won’t be inconveniencing more.
    Thank you

    PS: Excuse my English

  12. Kiel
    October 7, 2010 at 10:27 am

    Can you only use this pedal with sooperlooper, or could you also use it with something like ableton live?

  13. Eric Heath
    August 30, 2011 at 7:46 pm

    Hi, just found your page. Seems to be going along the lines of what I’ve been thinking about for a while now.

    Basically, I have a Roland SP-404 sampler, I use it in a band along with a midi keyboard to trigger some samples. The keyboard has a midi in and out, but there is a song where I have to trigger a bunch of loops then play bass shortly afterwards. Annoyingly, the last note I play on the bass is at exactly the same time I need to cancel one of the samples playing on the sampler.

    Every midi footswitch/pedal I’ve seen either works on control information or is huge, far too big for what I need. I need to be able to select a midi note (say D2) beforehand then press a button on the switch to turn it on or off. This would effectively tell the keyboard (in turn telling the sampler) that note D2 is being played (for a split second) and the sampler would then stop playing the loop on the pad that note D2 triggers. Of course it would be useful to be able to trigger D2 (or another note, it would be great to be able to select a different midi note for different songs) to turn the sampler on. SP-404 samplers respond to a midi keyboard by just turning the loop on when you press the note assigned to the pad the sample is on, and turning it off when you press that note again, so it should be “note on” each time.

    Would this be possible? It needs to be pretty small. There seems to be something called the “MIDI Mouse” out at the moment, though I’m not sure it sends note commands and it is well over 100 to buy. Far too expensive. It is a real struggle to find things these days that work with MIDI hardware, not USB or computers. I just can’t trust a computer in my live setup!

    I really hope you can help.

    Many thanks,

    Eric Heath

  14. themountainfold
    August 31, 2011 at 1:27 am

    Your email bounced so I’ll post here:
    Check out the arduino and the midi shield it’s exactly what you need.

    http://www.sparkfun.com/products/9595

  15. mao
    March 29, 2013 at 2:36 pm

    hi

    if i want send just a progra change
    for each switch what code i write?

    that’s the example for midi note

    TXREG = 0b10011000; //Note On, Channel 8
    TXREG = 0b00111100; //Middle C
    TXREG = 0b01111111; //Velocity = 127
    Wait_ms(50); //used for debouncing

    thk

Post a Comment

Your email is never shared. Required fields are marked *

*
*