MIDI Controller Footpedal


Here's a simple project that sends continuous or switch controller MIDI messages that correspond to the position of a potentiometer. Given a few parts and a cannibalized volume or wah-wah pedal, you can build this MIDI controller pedal and have the ultimate source of controller data in the Universe. This pedal is especially useful in live performance, but it's also great to have around when sequencing. An added bonus: the MIDI Footpedal sports a panic button that will silence any stuck notes that come your way.

Parts, Parts, Parts

Here is the list of parts that you'll need to build the MIDI Footpedal. Most of these parts are available from electronics distributors such as Digi-Key, Marshall Electronics, Jameco, B.G. Micro, and others. A programmed, ready-to-go PIC16C57 microprocessor is available. Order here.

Qty Part Number Part Description Reference Des.
1 4AA Battery Holder BT1
2 Cap, 0.1 uF, 50V, Metalized Film C1, C2
1 Cap, 0.1 uF, Ceramic C6
2 Cap, 27 pF, Ceramic C3, C4
1 Cap, 10 uF, 50V, Elect. C5
1 Connector, DIN, 5 pin, 180 Deg.
2 2N2222A Transistor, NPN, TO-92 Q1, Q2
2 Resistor, 220, 1/8W R1, R2
1 Resistor, 1K, 1/8W R3
1 Resistor, 10K, 1/8W R4
1 Potentiometer, 100K, 3/4 Turn R5
1 Switch, SPST, Momentary, Footswitch S1
1 Switch, Dip, 8 Pos. S2
1 Switch, Dip, 4 Pos. S3
1 Switch, SPST, Slide S4
1 PIC16C57-XT/P Microprocessor U1
1 Socket, 24-pin Dip, for U1
1 Crystal, 4 MHz, HC-49 X1
1 Footpedal (Volume pedal, etc.)

If you did not purchase a pre-programmed microprocessor, download the firmware and program the PIC using a suitable device programmer.

Buy, borrow, or steal a suitable footpedal. Look for one that is sturdy and has enough room to hold the electronics and battery pack. Most footpedals have some sort of mechanism that turns a potentiometer in proportion to the position of the pedal. Some pedals may move the shaft of a linear (sliding) pot instead. The most durable pedals use a sealed Allen Bradley rotary pot that is turned via a chain and gear mechanism.

The selection of footpedal may affect the values of certain parts used in the circuit. Measure the resistance of the potentiometer; most volume pedals use 100K pots. Any value between 100K and 10K is useable. If the pot is an audio taper type you may need to replace it with a linear version. Try it first, though. The MIDI Footpedal circuit is quite forgiving.

If you use a value of potentiometer other than 100K, use the chart below to determine the corresponding values of C1 and C2. In all cases, these two capacitors must be of good quality metalized film or polystryene construction. Disc ceramic parts will not do.

Potentiometer R5 Capacitors C1 and C2
100K 0.1 uF
50K 0.22 uF
20K 0.56 uF
10K 1 uF

Construction

Construct the circuit shown in the schematic on a small piece of perf board. Keep in mind that this circuit is likely to see a lot of abuse. It will be stomped on, kicked and thrown. Beer will be spilled on it, dirt will enter every crack and crevice. Build it accordingly. And don't forget to use a high-quality socket for U1.

Depending on your footpedal case, you may be able to use a PCB mounted MIDI connector. Otherwise, use a panel-mount connector and rivet it to the case. If the footpedal was originally a battery-powered somethingorother, you'll probably already have an access panel for the batteries and the two dip switches. Don't be tempted to use a 9 volt battery with the MIDI Footpedal. You'll kill the PIC with such a high voltage. Unless you need to change the controller number and channel often, it is probably best to keep the switches inside the footpedal case.

If there is room on the footpedal case, mount a footswitch for the panic button. Some footpedals can actuate a switch by pushing the pedal against one end of its travel. This type of action would also work for the panic button. But be sure that the switch is a momentary contact version.

[Footswitch Schematic]
Fig. 1. The MIDI Footpedal Schematic
Click on the image to see a larger, printable version.

Testing

Install the microprocessor in its socket and apply power to the circuit. Close all of the dip switches (i.e., set them to the "1", on, or closed position). Connect the MIDI output to a computer that is running MidiSpy or to a MIDI Viewport and move the footpedal from one end of its range to the other. The pedal should send controller messages as the pedal is moved.

If there is no output, recheck your wiring. If you have access to an oscilloscope, check to see that the crystal is oscillating (pins U1-26 and -27). Check the T1 and T2 signals (pins U1-6 and -7). With the pot set to midrange, these two signals should look roughly like sawtooth waves, as shown below.

If the MIDI output is working, the lowest value should be 0 and the highest value should be 127 (0x7F). Slowly move the pedal across its range and observe the resulting controller values. Each value should be present at some position of the pedal, and the values should change smoothly as the pedal is moved. Skipping values (e.g., 0, 2, 4, 6...) is usually caused by C1 and C2 being too small for the value of R5. The RC time constant of each capacitor and the pot should be greater than about 5 ms, and both capacitors should be the same nominal value. The circuit can tolerate considerable variation, but extreme values may make it skip some values. Too long a time constant (i.e., 20 ms or more) may cause the MIDI output to lag the pedal position as it is changed or to "wrap" the value around in the middle of its range (e.g., 6E, 6F, 0, 1...).

Using the dip switches, select various channels and controller numbers and observe that the proper values are sent when the pedal is moved. Open the CONT/SW dip switch. Move the pedal over its range and observe that a 0-value event is sent when the pedal is below the midpoint and a 127-value event is sent when the pedal is above the midpoint.

Finally, hit the Panic button. The footpedal should send note off messages for all notes on all channels. This process will take about two seconds to complete, since there are over 6000 bytes to be sent.

Using the Footpedal

Using the dip switches, the pedal can send events for any controller on any channel. Set the channel using the values shown in Table 1.

Table 1. SW3 channel settings

Channel 3210
1 0000
2 0001
3 0010
4 0011
5 0100
6 0101
7 0110
8 0111
9 1000
10 1001
11 1010
12 1011
13 1100
14 1101
15 1110
16 1111

The footpedal can be set to any controller between 0 and 127. Controllers above 120 are reserved for special purposes by the MIDI Specification and should normally not be used. Table 2 lists a few of the more useful controller numbers and their corresponding switch settings. See your device documentation or the MIDI Specification for information on other controller values.

Table 2. SW2 controller settings

Controller SW2
76543210
Function C/S
1 00000001 Modulation Wheel C
4 00000100 Foot Controller C
5 00000101 Portamento Time C
6 00000110 Data Entry MSB C
7 00000111 Channel Volume C
8 00001000 Balance C
10 00001010 Pan C
11 00001011 Expression Controller C
12 00001100 Effect Control 1 C
13 00001101 Effect Control 2 C
64 01000000 Sustain Pedal S
65 01000001 Portamento On/Off S
84 01010100 Portamento Control C

SW2-8 selects whether the controller is handled as a continuous controller (switch=closed) or as a switch controller (switch=open). A continuous controller uses all 128 possible values to indicate the relative adjustment of the controller. Zero normally indicates minimum and 127 indicates maximum. On the other hand, a switch controller has only two states, on and off, where 0 indicates off and 127 indicates on. For most switch controllers, values between 1 and 126 have no meaning. When set to switch controller mode, the footpedal will output an "on" event when the pedal is higher then the midpoint position and an "off" event when below this point. Note that some "switch" controllers can respond to continuous data by interpreting values between 0 and 63 as off and values between 64 and 127 as on.

Theory of Operation

The MIDI Footpedal measures the position of the potentiometer by timing how long it takes two capacitors to charge from ground up to a threshold voltage. The ratio of the two times indicates the position of the potentiometer. Figure 2 shows the waveforms that appear at the RB0 and RB1 inputs.

[RC Waveforms]
Fig. 2. Voltage waveforms measured at RB0 and RB1.

The algorithm works like this:

Thus, the position of the potentiometer is calculated from the ratio of two time periods. This eliminates all adjustments and makes the circuit tolerant of wide variations in resistor and capacitor values. A minimum RC value is necessary in order for the measured times to have enough significant bits. Otherwise the calculated Pos value may skip some values. For example, if the RC time constants were short enough so that there were only 6 significant bits in the measured times, the calculated Pos value would skip every other possible value (e.g., 0, 2, 4, 8...). On the other hand, if the time constants are too long, the timer may overflow, causing errors in the calculated position. A reasonable (calculated) RC time constant is 10 ms. While an RC time constant is the length of time to charge to 69.3% of the voltage, the actual times used by this circuit are shorter, since the threshold is approximately 50% of the supply voltage.