Hacked Whammy Pedal

I bought a toy foot pedal for $10. I didn't know how to communicate with it, but for some reason that didn't bother me until I had it in my hands and was wondering what to do with it.

React Guitar Hero pedals

Teaching Arduino to talk Playstation

I wanted an electronic footpedal, and wasn't prepared to drop $50 on a wah-wah case. What were the DIY options? Making the mechanism from scratch seemed laborious and likely to disappoint. Hacking a sewing machine pedal was a possibility but I couldn't find anything suitable. What I ended up with was an obsolete Guitar Hero peripheral.

The box contained a set of two pedals, a radio dongle, and a Playstation adapter cable. The pedals traveled smoothly, springing back into position after use. On the downside they were rather small for my feet and the plastic box didn't look terribly durable. It wouldn't stand use in any serious application but it was fine for a toy. And wireless operation was a bonus — if I could get it to work.

I hadn't thought at all how I was going to get my Arduino to talk to the pedals. Fortunately there are plenty of resources out there to help would-be hackers, including an Arduino library curated by Bill Porter and a great tutorial with details about the serial communication protocol.

Armed with information, I confidently chopped the adapter cable in half so that I could plug the wires into my Arduino Uno. After a bit of head-scratching, I discovered that the colours weren't quite the same as in the picture below: white was the ground wire. So I plugged the white wire into GND, the red wire into 3.3V, and the blue, yellow, orange, and brown wires into pins 10-13 as the Data, Command, Attention and Clock controls respectively.

Playstation controller wiring diagram

The example in the library seemed to work pretty much out of the box. I could establish radio contact with the pedal, request input from its controls, and read the response by serial communication with my Arduino. One question I had, at least, was answered in the affirmative: whether the Arduino running on 5 V would accept inputs from 3.3 V lines. But when I pressed the pedals there was no response. What was going wrong?

Reverse engineering a Guitar Hero controller

The reason, I decided, was a hardware problem. Although the pedal was marketed as "standalone" device, the radio dongle that connected to the Playstation was designed to have a guitar-shaped controller plug into it. And I didn't have one. No doubt I could have scoured the local junk shops, but I decided to program a chip to talk like a fake guitar.

I flashed a bootloader onto an Atmega8, set it up on a breadboard with a 5V supply and a 16 MHz crystal, and programmed it with a modified version of the PSX library so that the chip would emulate a Guitar Hero controller. Then I plugged it into the radio dongle using the other end of the adapter cable that I had cut in half. (I used the Atmega8 because it is the cheapest Arduino-compatible chip around at about $1 each.)

The PS2X library allows an Arduino to emulate a Playstation controller. I programmed an Atmega8 to send the other side of the communication protocol. At first it didn't work, but then I realised I needed to program the Acknowledge (ACK) line as well. As another primer on the protocol states: "if a selected controller does not ACK the PSX will assume that there is no controller present."

I brought out the green ACK wire out to the breadboard, added a few lines of code, and finally! I had a working footpedal. I put the Atmega8 on a piece of perfboard along with a 16 MHz crystal along the lines of the stripboard Arduino. Then I housed the fake guitar hero controller in a project box and gave it a daft looking aerial from a junk cordless phone.

Atmega8 guitar emulator

Gratuitous warranty voiding

Now I had the pedals working, but I wasn't happy with the response on the Whammy pedal. It was giving 100% signal with the pedal pressed only half way down. A bit more modding was required, so I got out my screwdriver and prised open the case.

Inside were 2 spring loaded potentiometers and a PCB. I tested the pots with a multimeter. The Whammy bar pedal had a 10 KΩ linear potentiometer. The Star Power switch used a pot with a very nonlinear response. It was easy enough to bias the Wammy Bar potentiometer with a couple of resistors to improve its performance. I experimented with different values of resistor by plugging them into a machined pin DIP socket (circled in picture below). I settled on 4.7 KΩ in series with the 10 KΩ pot, and 5.6 KΩ in parallel with them. I fixed everything back together with wads of hot glue.

Finally I added the aerial from the cordless phone base. I am pretty sure this would have used the 2.4 GHz band just like the wireless pedal, and hopefully it will extend the range.

Success! Now I had a foot pedal and switch that I could use to make sweet music (maybe) on a real guitar. An easier project would be to use it to govern a servo that pans a webcam... but that's a story for another day.

Technical details

All the code snippets can be found at https://github.com/t0mpr1c3/Arduino-PS2X. For reasons best known to myself [1] I changed the way that the pins are specified in the PS2X_lib library. The code that determines which pins the DAT, CMD, CLK, ATT, and ACK lines connect to is given in the PS2X_lib.h header file and uses the AVR PORT/PIN format instead of Arduino PinCodes. Debug mode can be turned off by commenting out two lines in PS2X_lib.h but I wouldn't recommend it. At least in my hands, the PS2X library worked much more reliably in Debug mode.

To use the Arduino front end to compile for the Atmega8 I had to let it know that I was using a new target chip. First I located the boards.txt file in the /hardware/arduino subdirectory of the Arduino application directory. (By default this is under C:\Program Files\Arduino\arduinoXXX\ in Windows, Applications/Arduino.app/Contents/Resources/Java/ on a Mac, and /usr/share/arduino/ on a Linux machine.) Then I appended the following text:

uno8.name=Uno with ATmega8

Construction tips

This project is Tricky. Debugging can be a bit of a challenge if the Arduino won't talk to the pedal first time around. I would certainly have found it handy to have had a logic analyser around.

And finally...

If you haven't checked out Bill playing his million volt guitar, now is the time. The lab coat is a nice touch.

1. Attempted port to the Attiny2313. I gave up after discovering that the bitbanged serial communication was dependent on the specific way that delays were implemented in the Arduino base code. Atmega8's are cheaper anyway.


Flexible PCB said...

This is one of the highly informatics and attractive blogs that has not only educated also informed me in a very effective manner. There are very few blog like this one I have read.

Tom said...

Thanks for compliment. Keep reading, I hope you learn more.

Post a Comment