31 Equal Temperament Keyboard Project

Here I will describe my design and building of a 31 equal temperament (31-ET) keyboard.

Key Arragnement

I have chosen an isomorphic arragnement for the keyboard and to also ensure the keys "line up" with the traditional 12-ET layout. Here each 12-ET white note is broken into three 31-ET light-coloured notes (pale red, white, pale yellow) and each 12-ET black note is broken into two 31-ET dark-coloured notes (dark green, dark blue). I have chosen to use the plus sign for semisharp and the minus sign for the semiflat. The two octave arrangement is shown below.

This arrangement is essentially a two octave single manual version of the Fokker Organ.

Design

The keyboard is made from tactile switches mounted on stripboard, with the stripboard in turn mounted on a wooden board using spacers and bolts. A second stripboard provides a basic control panal with eight rotary potentiometers and five buttons. The wiring tends to be on the underside of the stripboard to keep the playing surface clean. Finally, diodes are required to convert the 62 keys into 16 signal lines for connection to a MIDI encoder. The chosen encoder is a mkc64u from MIDI boutique providing USB connectivity.

The caps of the tactile switches are avaliable in a number of colors and are easy to change. One could choose to have just white and black keys, or perhaps, the white, pale blue and black scheme as used by Adriaan Fokker.

Parts

Parts and related information is given in the table below.

CostOrderUsedItemMakePartSizeSpecDataShop
0.91 70 62Small Signal DiodeFairchild1N4148 100V 200mA 1V 4ns 1A 1934602 Farnell
13.09 70 67Tactile Switch MulticompMCDTS2-4N 12x12 160gf 1662341 Farnell
0.98 15 14Switch Cap MulticompKTSC-22Y 13x13 yellow round 1486988 Farnell
0.98 15 14Switch Cap MulticompKTSC-22I 13x13 ivory round 1486988 Farnell
0.70 15 14Switch Cap MulticompKTSC-22S 13x13 orange round 1486988 Farnell
0.58 10 10Switch Cap MulticompKTSC-22B 13x13 blue round 1486988 Farnell
0.99 10 10Switch Cap MulticompKTSC-22G 13x13 green round 1486988 Farnell
0.30 5 5Switch Cap MulticompKTSC-22R 13x13 red round 1486988 Farnell
17.68 8 8Rotary Pot Bourns 3310Y-001-103L9x9 1653582 Farnell
28.40 8 8Knob Elma 021-1220 9 black 283200 Farnell
1.77 2 2Wire To Board Phoenix 1725672 4 positions screw 5117 Farnell
2.64 2 2Wire To Board Phoenix 1725698 6 positions screw 1697162 Farnell
2.78 2 2Wire To Board Phoenix 1725711 8 positions screw 5117 Farnell
9.05 1 1Hook Up Wire Alpha 3051/1 GR005 30.5m 22 AWG green 1684295 Farnell
9.05 1 1Hook Up Wire Alpha 3051/1 BL005 30.5m 22 AWG blue 1684295 Farnell
10.26 1 1Stripboard Kelan 147899 365.8x114.3 41 tracks of 143 holes316820 Farnell
4.04 1 1Stripboard Vero 01-0171 214.6x38.1 81 tracks of 15 holes da4392RS
4.46100 50PCB Spacer Richco 9.5x4.8 M2.5 screw 02e298RS
11.79100 50Socket Cap Screw PTS M2.5x25 DIN 912 A2 A91202525PTS
0.92200 50Flat Washer PTS M2.5 From A DIN 125 A2A125025A PTS
3.50200 50Hexagon Nut PTS M2.5 DIN 934 A2 A934025 PTS
1.91 10 10PCB Spacer Duratool 5x5.5 M3 screw 1733418 Farnell
3.81100 10Socket Cap Screw PTS M3x20 DIN 912 A2 A9120320 PTS
0.98200 10Flat Washer PTS M3 From A DIN 125 A2 A12503A PTS
2.34200 10Hexagon Nut PTS M3 DIN 934 A2 A93403 PTS
4.13 1 1Chopping Board IKEA 802.334.30 450x280 Bamboo wood IKEA
84.71 1 1USB-MIDI Encoder mkc64u Manual Wiring MIDI Boutique
2.47 1 116-way Break-Out bo15 MIDI Boutique
0.53 1 1Ribbon Cable dci16-16/25 MIDI Boutique

The cost is in UKP and excludes VAT (tax). It is for the order quantity listed at the time of purchase. This information is not being kept up to date.

Component Test

The mkc64c provides 64 inputs, also known as scan points, arranged in an 8x8 scan matrix. The scan matrix allows 8 * 8 = 64 keys to be easily encoded into only 8 + 8 = 16 signals, provided 64 diodes are used to prevent ghosting and masking problems. This means that one side of the 64 key switches are connected to 64 diodes, which in turn are connected to the 8 rows of the mkc64c. The other side of the 64 key switches are connected to the 8 columns of the mkc64c. The combined row and column connections are then the 16 signals required to determine the keyboard key presses.

Six switches and diodes are first arranged in a 3x2 scan matrix and connected to the mkc64c encoder using 3 + 2 = 5 signals to form a simple test. The MIDI output of the encoder is routed to a keyboard to generate the sounds. This is still in 12-ET tuning.

The six tactile switches with caps and six small signal diodes are simply pushed into some breadboard. The scan matrix setup for the mkc64u (on the right) is column 0 black, column 1 red, row 0 right, row 1 center and row 2 left.

MIDI Tuning

The 31 notes of an octave will be distriburted over a number of different MIDI channels, where each channel makes use of a unique constant global pitch bend. This is to avoid using MIDI Tuning Standard (MTS) messages which seem to be poorly supported on hardware synthesizers. There are 31 notes to allocate over a maximum of 16 MIDI channels. If we choose to allocate no more than three notes to a single channel, then 31 / 3 round up shows that 11 channels are required. The task now is to distribute no more than three 31-ET notes to each of the 11 globally tunable channels. However, within a channel the tuning separation is still 12-ET, and as the numbers 12 and 31 are coprime, it is to be expected that there will be some small tuning errors.

Let us divide the octave into 12 × 31 = 372 parts to give us a fine granulation to work to. As it is also customary to divide the octave into 1200 cents we compute this granulation in cents as 1200 / 372 = 100 / 31 ≈ 3.2258. Since we are going to allocate three notes to a channel, let us begin by tuning the 11 channels 3 × 100 / 31 = 300 / 31 = 9.6774 cents apart. If we name the 11 channels i, where i runs from -5 to +5, then channel i is tuned to i × 300 / 31. The table below shows the tuning pitch bend amount in cents for the 11 channels.

MIDI Channel Tuning
Named ChannelPitch Bend Cents
-5-48.3871
-4-38.7097
-3-29.0323
-2-19.3548
-1 -9.6774
0 0.0000
+1 +9.6774
+2+19.3548
+3+29.0323
+4+38.7097
+5+48.3871

Up to three notes of the octave are now assigned to each channel. If for every 31-ET note we choose the channel with the nearest 12-ET tuning then we are able to allocate the notes in such a way that one note is exact, one note is 3.2258 cents too low, and the other is 3.2258 cents too high. The table below shows this note to channel mapping over the octave.

31-ETNearest 12-ETMIDI
NoteIndexCentsNoteIndexCentsNamed ChannalBendError
C− 0 -38.70C 0 0-4-38.7097 0.0000
C 1 0.00C 0 0 0 0.0000 0.0000
C+ 2 38.70C 0 0+4+38.7097 0.0000
C# 3 77.41C#/Db 1 100-2-19.3548+3.2258
Db 4 116.12C#/Db 1 100+2+19.3548+3.2258
D− 5 154.83D 2 200-5-48.3871-3.2258
D 6 193.54D 2 200-1 -9.6774-3.2258
D+ 7 232.25D 2 200+3+29.0323-3.2258
D# 8 270.96D#/Eb 3 300-3-29.0323 0.0000
Eb 9 309.67D#/Eb 3 300+1 +9.6774 0.0000
E−10 348.38D#/Eb 3 300+5+48.3871 0.0000
E 11 387.09E 4 400-1 -9.6774+3.2258
E+12 425.80E 4 400+3+29.0323+3.2258
F−13 464.51F 5 500-4-38.7097-3.2258
F 14 503.22F 5 500 0 0.0000-3.2258
F+15 541.93F 5 500+4+38.7097-3.2258
F#16 580.64F#/Gb 6 600-2-19.3548 0.0000
Gb17 619.35F#/Gb 6 600+2+19.3548 0.0000
G−18 658.06G 7 700-4-38.7097+3.2258
G 19 696.77G 7 700 0 0.0000+3.2258
G+20 735.48G 7 700+4+38.7097+3.2258
G#21 774.19G#/Ab 8 800-3-29.0323-3.2258
Ab22 812.90G#/Ab 8 800+1 +9.6774-3.2258
A−23 851.61A 9 900-5-48.3871 0.0000
A 24 890.32A 9 900-1 -9.6774 0.0000
A+25 929.03A 9 900+3+29.0323 0.0000
A#26 967.74A#/Bb101000-3-29.0323+3.2258
Bb271006.45A#/Bb101000+1 +9.6774+3.2258
B−281045.16A#/Bb101000+5+48.3871+3.2258
B 291083.87B 111100-2-19.3548-3.2258
B+301122.58B 111100+2+19.3548-3.2258

We can see the resulting pattern is quite straight forward. Note that 31-ET notes E− and B− are, respectively, nearest to 12-ET notes Eb and Bb. The r.m.s. error of the above scheme is sqrt((20 / 31) × (100 / 31)²) ≈ 2.5910 cents.

The above tuning system works fine, and is in fact the system I initially used. However, the allocation can be slightly altered so that 31-ET notes E− and B− are, respectively, based on the 12-ET notes E and B. Clearly, this requires the tuning of the named channel +5 to be altered. The advantage of making this modification is that if all 11 MIDI pitch bend amouts are set to zero, then the 31-ET keyboard nicely collapses into a 12-ET keyboard. That is, the keyboard as constructed can be used for both 31-ET and 12-ET playing, although in 12-ET it is 'not quite' isomorpic.

As only two notes are assigned to named channel +5 we can compute the new tuning to also better average out the error by ((1200 × 9 / 31 − 400) + (1200 × 27 / 31 − 1100)) / 2 ≈ -53.2258. Similary, as only two notes are assigned to named channel -5 we can also better average out the error by ((1200 × 4 / 31 − 200) + (1200 × 22 / 31 − 900)) / 2 ≈ -46.7742. The table below shows this imporved note to channel mapping over the octave.

31-ETBase 12-ETMIDI
NoteIndexCentsNoteIndexCentsChannalBendError
C− 0 -38.70C 0 0-4-38.7097 0.0000
C 1 0.00C 0 0 0 0.0000 0.0000
C+ 2 38.70C 0 0+4+38.7097 0.0000
C# 3 77.41C#/Db 1 100-2-19.3548+3.2258
Db 4 116.12C#/Db 1 100+2+19.3548+3.2258
D− 5 154.83D 2 200-5-46.7742-1.6129
D 6 193.54D 2 200-1 -9.6774-3.2258
D+ 7 232.25D 2 200+3+29.0323-3.2258
D# 8 270.96D#/Eb 3 300-3-29.0323 0.0000
Eb 9 309.67D#/Eb 3 300+1 +9.6774 0.0000
E−10 348.38E 4 400+5-53.2258-1.6129
E 11 387.09E 4 400-1 -9.6774+3.2258
E+12 425.80E 4 400+3+29.0323+3.2258
F−13 464.51F 5 500-4-38.7097-3.2258
F 14 503.22F 5 500 0 0.0000-3.2258
F+15 541.93F 5 500+4+38.7097-3.2258
F#16 580.64F#/Gb 6 600-2-19.3548 0.0000
Gb17 619.35F#/Gb 6 600+2+19.3548 0.0000
G−18 658.06G 7 700-4-38.7097+3.2258
G 19 696.77G 7 700 0 0.0000+3.2258
G+20 735.48G 7 700+4+38.7097+3.2258
G#21 774.19G#/Ab 8 800-3-29.0323-3.2258
Ab22 812.90G#/Ab 8 800+1 +9.6774-3.2258
A−23 851.61A 9 900-5-46.7742+1.6129
A 24 890.32A 9 900-1 -9.6774 0.0000
A+25 929.03A 9 900+3+29.0323 0.0000
A#26 967.74A#/Bb101000-3-29.0323+3.2258
Bb271006.45A#/Bb101000+1 +9.6774+3.2258
B−281045.16B 111100+5-53.2258+1.6129
B 291083.87B 111100-2-19.3548-3.2258
B+301122.58B 111100+2+19.3548-3.2258

The updated channel tuning is given below, where each pitch bend amount is a multiple of 1200 / (12 × 31 × 2) = 50 / 31 ≈ 1.6129.

MIDI Channel Tuning
Named ChannelPitch Bend CentsMultiple of 50/31
-5-46.7742-29
-4-38.7097-24
-3-29.0323-18
-2-19.3548-12
-1 -9.6774 -6
0 0.0000 0
+1 +9.6774 +6
+2+19.3548+12
+3+29.0323+18
+4+38.7097+24
+5-53.2258-33

The r.m.s. error of the above scheme is sqrt((40 / 31) × (50 / 31)²) ≈ 1.8321 cents.

The MIDI notes and channels can now be assigned to the keyboard keys, choosing middle C (C4)¹ in the centre. In MIDI middle C is note number 60, so starting at middle C we assign notes increasing from 60 to the right and decreasing from 60 to the left, guided by the table above. The MIDI note numbers for the octave to the right (C4 to B5) are given by the 12-ET index plus 60, and note numbers for the octave to the left (C3 to B4) are given by the 12-ET index plus 48. The diagram below shows the key to channel and note mapping for the two octave board. This process easily extends to more octaves.

¹ Yamaha choose to label middle C as C3.

Keyboard Wiring

To keep a visual relationship to the standard 12-ET keyboard layout the chosen 31-ET keyboard layout is such that keys corresponding to white or black notes are placed in their own column. The wire routing will be easier if the assignment of the keys to scan matrix points ensures that note columns are not broken accross scan matrix columns. The table below shows that this is possible, with the unused scan points marked by an asterisk.

Column
01234567
Row 0C−D#F#A−C−D#F#A−
1C EbGbA C EbGbA
2C+E−G−A+C+E−G−A+
3C#E G A#C#E G A#
4DbE+G+BbDbE+G+Bb
5D−F−G#B−D−F−G#B−
6D F AbB D F AbB
7D+F+* B+D+F+* B+

Scan matrix columns 0 to 3 yeild the left octave (C3 to B4), and columns 4 to 7 yeild the right octave (C4 to B5). The row column co-ordinates of the scan matrix are shown on the keyboard in the diagram below.

The keyboard wiring is shown below, looking down from above. The green Phoenix connectors and orange diodes are mounted on the top side of the stripboard, the green and blue wires are predominantly on the underside of the stripboard with the horizontal copper tracks. Although the green and blue wires are physically on the underside they are drawn in the diagram over the top of the tactile switches so it is easier to see where they go.

The wires of alternating scan matrix columns are shown in different shades of blue and green. The 8-way connector is for the eight row signals, and the two 4-way connectors are for the eight column signals. Two 4-way connectors are only chosen over one 8-way because placement of an 8-way proved to be more difficult. Note that the wires from the two 4-ways connectors are not fully shown in this diagram.

MIDI Data

In the implementation MIDI channel 10 will not be used as this is often reserved for percussion. Channels 1 to 4 will also not be used so that other instruments can use them. Hence, named channels {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5} are mapped to MIDI channel numbers {5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16}.

The default pitch bend range of ±2 (12-ET) semitones (±200 cents) is assumed. The MIDI pitch bend wheel resolution is -8191 to +8192. We have already seen that each channel is tuned to multiples of 50 / 31 ≈ 1.6129 cents. To compute the bend amount we take first the proportion of 50 / 31 cents of the 200 cents, which is (50 / 31) / 200 = 1 / 124, and then multiply by 8192 to give 8192 / 124 = 2048 / 31 ≈ 66.0645. The pitch bend amounts in MIDI resolution are then multiples of this number, rounded to the neareast whole number.

The MIDI bend data values are the amounts described above offset by first adding 8192 and then expanded from the 14-bit value to two 8-bit bytes by inserting two zeros. For more information on the MIDI data format see MIDI Messages at MIDI.org.

MIDI Pitch Bend Messages
ChannalBendBinaryHexa-
decimal
NameNumberMultipleAmountStatusLSBMSB
-5 5-29-19161110 01000000 01000011 0001E4 04 31
-4 6-24-15861110 01010100 11100011 0011E5 4E 33
-3 7-18-11891110 01100101 10110011 0110E6 5B 36
-2 8-12 -7931110 01110110 01110011 1001E7 67 39
-1 9 -6 -3961110 10000111 01000011 1100E8 74 3C
011 0 01110 10100000 00000100 0000EA 00 40
+112 +6 +3961110 10110000 11000100 0011EB 0C 43
+213+12 +7931110 11000001 10010100 0110EC 19 46
+314+18+11891110 11010010 01010100 1001ED 25 49
+415+24+15861110 11100011 00100100 1100EE 32 4C
+516-33-21801110 11110111 11000010 1110EF 7C 2E

The mkc64u is able to send up to 32 bytes for every note on and note off event. The mkc64u will be programed so that the a key press will send the appropriate pitch bend and note on event, and the key release will send just the note off event. The MIDI data for the first octave (C−3 to B+3) is given below.

31-ETmkc64uMIDI
NoteIndexScan
Point
ColRowChannal
Number
Note
Number
Pitch Bend
and Note On
Note Off
C− 0 100 648E5 4E 33 95 30 6485 30 40
C 1 2011148EA 00 40 9A 30 648A 30 40
C+ 2 3021548EE 32 4C 9E 30 648E 30 40
C# 3 403 849E7 67 39 97 31 6487 31 40
Db 4 5041349EC 19 46 9C 31 648C 31 40
D− 5 605 550E4 04 31 94 32 6484 32 40
D 6 706 950E8 74 3C 98 32 6488 32 40
D+ 7 8071450ED 25 49 9D 32 648D 32 40
D# 8 910 751E6 5B 36 96 33 6486 33 40
Eb 910111251EB 0C 43 9B 33 648B 33 40
E−1011121652EF 7C 2E 9F 34 648F 34 40
E 111213 952E8 74 3C 98 34 6488 34 40
E+1213141452ED 25 49 9D 34 648D 34 40
F−131415 653E5 4E 33 95 35 6485 35 40
F 1415161153EA 00 40 9A 35 648A 35 40
F+1516171553EE 32 4C 9E 35 648E 35 40
F#161720 854E7 67 39 97 36 6487 36 40
Gb1718211354EC 19 46 9C 36 648C 36 40
G−181922 655E5 4E 33 95 37 6485 37 40
G 1920231155EA 00 40 9A 37 648A 37 40
G+2021241555EE 32 4C 9E 37 648E 37 40
G#212225 756E6 5B 36 96 38 6486 38 40
Ab2223261256EB 0C 43 9B 38 648B 38 40
A−232530 557E4 04 31 94 39 6484 39 40
A 242631 957E8 74 3C 98 39 6488 39 40
A+2527321457ED 25 49 9D 39 648D 39 40
A#262833 758E6 5B 36 96 3A 6486 3A 40
Bb2729341258EB 0C 43 9B 3A 648B 3A 40
B−2830351659EF 7C 2E 9F 3B 648F 3B 40
B 293136 859E7 67 39 97 3B 6487 3B 40
B+3032371359EC 19 46 9C 3B 648C 3B 40

Note that scan point 24 of the mkc64u is not used. The MIDI data for the second octave (C−4 to B+4) is given below.

31-ETmkc64uMIDI
NoteIndexScan
Point
ColRowChannal
Number
Note
Number
Pitch Bend
and Note On
Note Off
C− 03340 660E5 4E 33 95 3C 6485 3C 40
C 134411160EA 00 40 9A 3C 648A 3C 40
C+ 235421560EE 32 4C 9E 3C 648E 3C 40
C# 33643 861E7 67 39 97 3D 6487 3D 40
Db 437441361EC 19 46 9C 3D 648C 3D 40
D− 53845 562E4 04 31 94 3E 6484 3E 40
D 63946 962E8 74 3C 98 3E 6488 3E 40
D+ 740471462ED 25 49 9D 3E 648D 3E 40
D# 84150 763E6 5B 36 96 3F 6486 3F 40
Eb 942511263EB 0C 43 9B 3F 648B 3F 40
E−1043521664EF 7C 2E 9F 40 648F 40 40
E 114453 964E8 74 3C 98 40 6488 40 40
E+1245541464ED 25 49 9D 40 648D 40 40
F−134655 665E5 4E 33 95 41 6485 41 40
F 1447561165EA 00 40 9A 41 648A 41 40
F+1548571565EE 32 4C 9E 41 648E 41 40
F#164960 866E7 67 39 97 42 6487 42 40
Gb1750611366EC 19 46 9C 42 648C 42 40
G−185162 667E5 4E 33 95 43 6485 43 40
G 1952631167EA 00 40 9A 43 648A 43 40
G+2053641567EE 32 4C 9E 43 648E 43 40
G#215465 768E6 5B 36 96 44 6486 44 40
Ab2255661268EB 0C 43 9B 44 648B 44 40
A−235770 569E4 04 31 94 45 6484 45 40
A 245871 969E8 74 3C 98 45 6488 45 40
A+2559721469ED 25 49 9D 45 648D 45 40
A#266073 770E6 5B 36 96 46 6486 46 40
Bb2761741270EB 0C 43 9B 46 648B 46 40
B−2862751671EF 7C 2E 9F 47 648F 47 40
B 296376 871E7 67 39 97 47 6487 47 40
B+3064771371EC 19 46 9C 47 648C 47 40

Note that scan point 56 of the mkc64u is not used.

Tuning Test

To test the tuning system the six button breadboard is tuned to the notes C, E, G, A#, Bb and B. Note that due to the different layout of the breadboard to the main two octave board, the six notes are assigned to different scan points of the mkc64u. From left to right, the red buttons are assigned notes C, E and G, and the black buttons are assigned notes A#, Bb and B. With these notes it is possble to play some 7th chords, including the harmonic 7th which is not possible on a 12-ET keyboard.

31-ETmkc64uMIDI
NoteIndexScan
Point
ColRowChannal
Number
Note
Number
Pitch Bend
and Note On
Note Off
C 111121148EA 00 40 9A 30 648A 30 40
E 111011 952E8 74 3C 98 34 6488 34 40
G 19 9101155EA 00 40 9A 37 648A 37 40
A#26 302 758E6 5B 36 96 3A 6486 3A 40
Bb27 2011258EB 0C 43 9B 3A 648B 3A 40
B 29 100 859E7 67 39 97 3B 6487 3B 40

Some possible chords

Chord NameNotes
C Major CEG
C Harmonic 7thCEGA#
C Dominant 7thCEGBb
C Major 7th CEGB

Build

The first stage of the build was to mount the striboard on the wooden board and then insert the tactile switches. The stripboard was sold as 41 tracks of 143 holes but it turned out to have 144 holes per track. The extra line of holes was chosen to be on the right hand side which is quite welcome.

The next stage of constrcution was the addition of the blue and green wires. As mentioned these wires are mainly on the underside but their endpoints are threaded up and over. This can be interpreted from the wiring diagram by the 0.1 inch horizontal section by each endpoint blob. To aid this construction the diagram below is a view of the wiring from the underside of the keyboard, that is, flipping the stripboard vertically over.

In reality in this view the connectors and diodes would not be visible, but they remain on the diagram as a reference. The photos below were taken after adding the blue wires but before the green wires.

The assembled keyboard from above.

The assembled keyboard from below.

The keyboard connected to the mkc64u.

The keyboard and mkc64u mounted.


© Sam Gratrix, Gratrix.net.