In my previous post on the FXBOX, I described a series of PureData patches used for guitar effects, and the need for a Foot Controller to operate it.
I happened to have a suitable case for this project – the remains of a previous mixer project which was never entirely finished. It was a large console-style case, about 18″ square, which I had already drilled with about 80 or 90 holes. The holes were too close together for all of them to be foot controller buttons, but about half of them could be used.
There were to be 4 sections to the controller, which would be: 1. Audio in/out and Audio to USB; 2. Audio to MIDI and MIDI to USB; 3. Keyboard Letters and Numbers, output via USB; and 4. Also via USB, Buttons and Potentiometers from a game controller.
The audio section was slightly more complicated than it might have been, as I’ve been using a twin-necked (6 and 12-string) guitar, and at some point intend to separate the output of the two sets of pickups. For this reason, I added two audio input channels to the Controller.
The system basically works so that it can accept inputs either via a 6.35mm stereo socket or separate 6.35mm mono sockets, and can be routed either to a 6.35mm or 3.5mm stereo output, or two 6.35mm mono outputs. Each channel has a separate mono Send and Return, and there is stereo Send and Return covering both channels.
The 3.5mm output was included simply because this is the normal type of audio input socket on a laptop – which I was using to run Pure Data – and this would remove the need for a 6.35mm to 3.5mm adapter. Internally, there are connections to a Sonuus G2M Audio-to-MIDI converter – described in the next section – and an Audio-to-USB converter.
I took a chance on a cheap Audio-to-USB converter. I tried a few of the very cheapest type (99p on eBay), which worked OK, but I experienced too much latency, and these can only be used when the delay between playing and sounding isn’t important – on automatic or aleatory devices, for example. In this case, the next cheapest type (£2) seemed to work fine.
The intention of the Controller was that all four elements (the Audio to USB , the MIDI to USB, the keyboard numbers and letters, and the gamepad controls) would all be capable of output via a single USB socket. To accomplish this, I added an extremely reasonably priced (£3.95) 7-input USB hub. Given the number of items it would need to cope with, I got a powered one, which came with a 2-amp 5v mains adapter.
The inside of the box was going to be a bit like an enclosed pedalboard, and I simply velcroed this unit in position inside the case.
The hub was connected to a double USB socket unit – the type that would be fitted on a PC – with one socket connected to the type B output socket on the hub, the other one serving as an extra external input.
I added the MIDI section for two reasons: the first was that although MIDI implementation wasn’t really the point of this Controller, it could, I thought, come in handy for later applications, and be a convenient place to house my Sonuus G2M – a monophonic guitar-to-midi converter. The G2M, like the USB hub, was velcroed in place and linked up via internally-connected plugs.
Secondly, I’d successfully used a very cheap MIDI-to-USB converter in a previous project (‘A new use for USB keyboards‘), and decided for £3 or £4 that one could be included here. In this case, I didn’t even remove the outer casing as I had done the previous time, but simply shortened the IN, OUT and USB leads to fit and velcroed the unit to the inside of the case.
Audio and MIDI inputs would normally be via internal connections, but I added two 5-pin DIN sockets to the outside of the case. The first was for MIDI Out; the second, via a DPDT toggle switch, allowed input to the converter to be internal or external in case I wanted to connect a MIDI instrument or controller, such as my Behringer FCB1010, use another audio-to-MIDI converter, or decided not to use the G2M inside the case.
3. LETTERS & NUMBERS
I had worked out for the previous project referred to above how to use the PCB from a defunct Apple keyboard as a means of outputting ASCII codes. The [key] function of Pure Data can be made to interpret and take action on these in any way required. I wanted to include this feature to help in using my looping program, Jesse Chappell’s Sooper Looper.
As well as being controllable via MIDI, many of the Sooper Looper functions are controllable by input from the computer keyboard. I wanted to include a simple system which would output some of the keyboard letters required to record, overdub, reverse and so on.
A 10×4 matrix would output all the letters in the alphabet, and the numbers 0-9, so I could put up to 40 buttons on the Controller (including a couple which represented punctuation marks), but I wouldn’t need anything like 40 buttons for this application.
I started confidently, as before, disassembled one of my collection of broken keyboards and took out the PCB. It was very similar to the one I had used before: very wide, and with two USB input sockets on the ends – but it was a completely different make! So, I plugged the USB out cable into the computer, got the crocodile clips out, started up Open Office and began touching the matrix points together to see what letters came out – it had an entirely different layout from the one I’d used before!
However, after a certain amount of testing, it became clear that the matrix lines were essentially the same, but just in a different order on the board, which meant I could still get the 40 letters and numbers I wanted, and the pinouts on the sockets I planned to use (15 pin DIN HD) would still be compatible with the unit I had previously built.
In fact, it didn’t really matter about compatibility, as this would – at least as initially conceived – be a self-contained Controller unit, but I wanted to keep things consistent across my range of devices, and perhaps at a later date allow for an alternative or supplementary control unit to be connected to the Foot Controller.
I carefully connected the appropriate pins of the matrix to a ‘break out’ board, to which I connected a 15-way PCB header.
This would make it a relatively simple job to connect buttons later.
4. GAME CONTROLLER
Again, I had used a game controller before, for the Theresynth/Cybersynth project, using the PureData [hid] function; but this time I needed to be more ambitious and use the joystick potentiometers as well as the buttons.
Of course, there are companies which produce USB controller modules, mainly for arcade controller enthusiasts, for example Ultimarc: http://www.ultimarc.com, and GroovyGameGear: http://groovygamegear.com. The best value seemed to be the ZD (Zero Delay) Arcade controller, which is readily available on eBay.
I bought a couple of these two years ago at £8 each, but they seem to be even cheaper nowadays.
Good though they are, however, these units are limited to 12 buttons and two potentiometers. Game controllers tend to have quite a large number of buttons – especially if you include the hatswitch buttons – and potentiometers on a single circuit board.
I needed 18 buttons, so I decided to use a game controller board for this part of the project.
There are a number of explanatory articles on the internet, such as this one: http://kevinreems.com/WorkShop/Joysticks//, and a lot of valuable information on this forum: http://forum.arcadecontrols.com/, as well as a few videos on YouTube. I like this one, which, although not captioned in English, is nicely visual: http://www.youtube.com/watch?v=9Y6ZqgT4Uk0.
Even Nic Collins’ classic book Handmade Electronic Music [http://www.nicolascollins.com/handmade.htm] has a chapter on the subject.
There are many different makes and models of gamepad, and one thing I’ve learned is that they’re all different – or liable to be different – in their electrical connections, so a certain amount of cautious experimentation is required to find out, for example, whether button connections are made to ground or some other voltage value in the circuit; if they’re arranged in a matrix; or if there’s a mixture of different systems. Sometimes this can readily be determined by looking closely at the circuit board and following the tracks around, sometimes it can’t.
So, if you’re reading this for hints on how to make the connections, use it as a guide to the type of thing you may need to do, but you may not necessarily be able to copy the steps precisely.
The other thing to note is that the connections on these PCB’s are usually very delicate, so you need to proceed carefully to avoid the narrow copper tracks coming away from the board.
As far as my gamepad was concerned, I used a Nyko Airflo, which was around £5 on eBay.
I removed the outside and an internal plastic piece which supported the two main PCBs and the fan which gives the Airflo its name.
The idea was to reconnect the gamepad’s buttons to buttons on the FXBOX foot controller, so I detached the fan and looked for the button connections on the PCBs.
Four of the 12 buttons were on their own mini-PCBs, connected by wires to the main board; the function of the wires was marked on the board, so I cut off the small PCBs and left the wires.
The various hatswitch connections and 6 of the remaining buttons were on the main board. These all had suitable spots in the copper tracks where it would be possible to solder wires.
The remaining two buttons were part of the joystick assembly on the second main board. It was easy to see the connections, and as the buttons were normally open (not connected), it would just be necessary to connect wires to the two sides of each one – or one side if the buttons all proved to have a common side, which is the usual practice.
I also needed to use the 4 potentiometers, two on each joystick, and wasn’t looking forward to de-soldering them, as I was anxious about damaging the tracks on the board. It doesn’t look too difficult on the videos, but I noticed on mine that there was small gap above the board where you could see the three legs of each potentiometer – the small ‘preset’ type – just enough room to insert a hacksaw blade and cut them off. This is what I planned to do.
First, as with the other devices in the Controller, I needed a much shorter USB out cable to connect to the hub, so I shortened the lead, but reconnected it before going any further, as this would be needed for testing.
The next step was to bring out the button connections to a ‘breakout’ board and find out exactly which ones I needed.
In most cases – perhaps all – I was sure that it wouldn’t be necessary to use 2 wires per button, as I had done with the Cybersynth; one side of the button connection would usually be Ground, and I hoped it would be possible to use one Ground connection for all of the 12 buttons.
This did prove to be the case, and I didn’t have the problem reported by some others of the unit not working at all without the joysticks connected.
I connected the 13 wires (one for each button + one for Ground) from the gamepad board to the breakout board, and a 13-way PCB header to give easy access to them.
The hatswitch connections looked as if they might be the same – except that there were 4 buttons, and I knew that 8 separate outputs are available from a hatswitch, meaning that 4 outputs were available from the 4 buttons individually and 4 outputs were available by connecting adjacent buttons simultaneously.
The connections at the top go to buttons in the Controller, and connections 1, 3, 5 and 7 at the bottom go to the 4 button positions on the circuit board; connections 2, 4, 6, 8 and 9 don’t need to be connected directly to the board.
This arrangement means that, for example, pressing Button 1 activates only Button 1, and pressing Button 3 activates only Button 3, but pressing Button 2 activates both Buttons 1 and 3 at the same time.
Only adjacent buttons are meant to be connected at the same time, which is why a hatswitch has 8 different outputs; but I discovered that connecting any two non-adjacent buttons on this particular board produced a ninth different output, recognised by PureData, which is why a ninth button is shown.
As a Ground connection was already available on the breakout board, I only needed 9 further connections for the 9 hatswitch buttons. This meant that 21 separate buttons would be available altogether.
The next task was to replace the two 2-axis joysticks with 4 potentiometers. Two of these would eventually be footpedals so that certain settings – volume and pan, for example – could be adjusted while playing.
I started by cutting through the legs of the existing potentiometers, as described above. Once cut off, the potentiometers were easy to remove, exposing the three connections for each one.
Tracing the lines on the PCB, I could see that the ‘top’ and ‘bottom’ connections of each one were the same: only the middle pins had individual connections.
The bodies of the joysticks didn’t need to be removed from the board – and in fact were best left where they were, as some Ground connections from one part of the board to another appear to made through them.
I knew the potentiometers were likely to be more difficult to make use of than the buttons, but I was puzzled that I wasn’t able to get them working easily when I connected them to the board. For some reason they didn’t move smoothly from zero at one end to 255 the other as they were supposed to; on occasions they would return to zero and then refuse to move.
In the end, I read something that doesn’t seem to be mentioned much in articles on gamepad hacking, which seemed to be the root of the problem: joysticks are sprung to return to the centre of their travel, so a gamepad is expecting a midway reading on each one when it’s plugged in, and calibrates itself at that point to make sure the joysticks go back to the middle when let go. If potentiometers are used, and left at random values when the unit is plugged in, then the gamepad will get confused, try to calibrate itself wrong, and consequently fail to work properly – or at all.
The value of the joysticks in my gamepad was 100k, and they looked to be connected as voltage dividers, with the ‘top’ and ‘bottom’ tags all connected together, so, assuming these were +v and 0v (although it doesn’t really matter what they are) – I created a midpoint 50k from the top and 50k from the bottom (two 100k resistors in series = 50k). This would be connected to the centre tags of the potentiometer inputs to the board when the unit was turned on, the circuit would be calibrated, then the actual potentiometers could be connected and would correctly produce values from 0 – 255.
The writer of the article quoted above [http://kevinreems.com/WorkShop/Joysticks//] had a neat solution to this, using switched jack sockets, but I wasn’t able to use this method, as I wasn’t always going to be plugging into sockets. Instead, I connected the centre tags of the four potentiometer inputs to the centre tags on a 4 pole, two-way switch: this switch would be in the ‘off’ position when the unit was plugged in, which would connect the inputs to the ‘halfway’ voltage, enabling them to be calibrated, then when the unit was ready to be used the switch would be moved to the ‘on’ position, where the potentiometer inputs would be connected to actual potentiometers.
As a result, I ended up with a breakout board with 12 pins representing the 12 buttons numbered on the board, 9 pins representing the hatswitch buttons, 4 pins representing the 4 potentiometer outputs, and 3 pins representing +5v, 0v and +2.5v.
I also used 2 further pins for the game controller LED which lit up when the USB connection was made: I connected these to an LED on the outside of the case where I could see it and verify that the board was working.
That made 30 pins. Even when I calculated that I needed only 6 of the 9 hatswitch buttons, that still made 27 pins, plus 15 pins from the Apple keyboard PCB described earlier.
All the connections needed to be in place while the case was still open, so I needed to join all these pins on one side of the box where the circuit boards were to connectors on the other side of the box where the buttons were. To bridge this gap, I decided to use 40-pin ATA cables, normally found inside a desktop PC, which are inexpensive and compatible with the PCB connectors I was using.
These cables (as in the above picture) frequently have two separate connectors quite close together at one end. This made it easier to make connections not only from one side to the other, but also to special output sockets on the back of the case. These could be used if alternatives were required to the buttons on the unit.
The 15-way socket on the back of the Controller has the same pin designations as my previous keyboard PCB-based project; the 25-way socket is a new arrangement, specific to the game controller:
Finally, there was one downside with internal fixing of the Sonuus G2M ‘Guitar to MIDI’ unit – it runs off a PP3 battery: this would mean firstly that the ‘Battery low’ indicator couldn’t be seen from outside the case and secondly that the battery couldn’t be changed without taking the case apart. As this is held together with about 10 self-tapping screws, this would be too much trouble.
The main electrical supply was the the 5v adaptor that came with the USB hub, so I bought a small step-up voltage module for a couple of pounds to provide a 9v supply for the G2M.
I adjusted it to slightly over 9 volts, to make sure the G2M would be operated reliably and added a second power on/off switch for the 9v supply.
This is the almost finished base of the unit, showing the 7 elements. All the connections are in place, except the power connector lead, which runs from connector 7 in the picture over to the power switches on the front of the unit:
1: MIDI to USB
2: 7-port USB hub
3: Audio to USB
4: Apple keyboard PCB
5: Sonuus G2M, Audio to MIDI
6: Gamepad PCB
7: Power connector
This is the almost complete top section:
I gingerly put the two halves of the case together, and all the functions seemed to work, so I screwed it firmly together.
Now, with minimum use of the laptop keyboard, I was able to control the Looper with the buttons on the Top Panel:
and the FXBOX PureData program with the buttons on the Front Panel:
I left space for additional button descriptions as the unit isn’t limited to controlling the Sooper Looper and FXBOX: in fact, it could be used to control any PureData patches which required [key] or [hid] inputs.
In addition to this, I had made provision on the front of the case for 4 footswitches which could duplicate the effect of any of the buttons on the panels:
So far, I have just implemented two of the four possible: Footswitch 1 duplicates the ‘Overdub’ control in the Looper; Footswitch 4 duplicates the FXBOX ‘Freeze’ control.
I obtained some very nice momentary footswitches for only about £3 each from eBay. They are apparently intended to operate tattoo machines, and have the advantage of coming with 1/4″ (6.35mm) standard mono jack sockets attached, perfect for this application.
As for the footpedals, I haven’t implemented those yet. When I do, I’ll describe this in a further post.