Hacking the SX-150. Building an Arduino-based sequencer - Part 1
[Update: This article has been continued with Part 2 & Part 3]
Out of the gate with the first blog post of the new year, and this is one I'm particularly excited about because it gets me to the point of starting to hack things that make cool sounds. I've long had an interest in experimental electronic music, so I'm excited that I have something to share in that arena.
In the past I've mentioned my wonderful wife (who is wonderful, if I didn't say so), and this Christmas she doubly earned that distinction by buying me a Gakken SX-150 Analog Synthesizer. As far as a 'kit' goes, it isn't much to speak of -- just installing the pre-built board* and speaker into the plastic case and wiring up the stylus controller -- but it is such a simple design that it seems built to be hacked on, and that's what I wanted to do.
I did find a number of cool SX-150 hacks, but often they were a bit more advanced than I'm ready for, so I figured I'd start with something simple and slowly build on it and make this a multi-part project. Since I'm really enjoying getting into Arduino programming, an Arduino-based sequencer seemed like a good candidate -- so let's get started with part 1!
Follow up:
Replacing the Stylus
The SX-150 has a simple but fun little synthesis circuit, but the input is a bit limited. There's a stylus, which is a great alternative controller (especially for keyboard challenged people like me), and there's a neat external input that I haven't had a chance to play with but seems to really open up the potential for the SX-150, but I wanted to hack the SX-150 itself and not just feed in a new signal, so finding a way to reuse the stylus input circuitry was the way to go.
Analog synthesizers often use a control voltage to determine pitch, and a little playing around with a multimeter showed that that was exactly what was happening, with the voltage being scaled based on the position of the stylus. That sounded a lot like a potentiometer to me.
Testing this is pretty easy and doesn't require soldering or altering the synth. The hookups to the stylus & strip are just screwed on, so I reused those screw connectors and ran some wires out from under those screws:


And then hooked it up to a spare pot I had lying around:

And, just like that, I had dial-controlled pitch. I only had a 10K pot, which seems to provide only a small amount of range in the pitch, but it worked!
Controlling a Digital Pot Through the Arduino
Getting it hooked up to the pot was cool, but it's not going to help much if I want to control it digitally, so I need to go from a regular analog potentiometer to a digipot. I'd never used one of these before, but I figured they had to exist. Just a little googling around and I found an Arduino.cc article about connecting to one via the Arduino using the SPI serial protocol. They used the Analog Devices AD5206 IC and after some questions to the guys on the arduino forums, I found that they could be purchased from Digi-Key. The AD5206 is a neat little chip -- it has 6 separate potentiometer circuits, and each can independently set to one of 256 different resistance values.
I followed along with the arduino digipot article, but it was honestly more complex than I needed for an introduction. There were some basics that I was missing, so what follows here is based on the code from that article and a simplified schematic.
That article has 6 different LEDs (since the AD5206 gives you 6 different circuits), I need just one, so here's what I did instead:

You can see it's a pretty simple circuit. On the left side of the chip we have a ground and 2 Voltage-ins (one positive, connected to +5V; one negative and connected to ground) and the 3 lines for the SPI interface. On the right there are the 3 lines that typically make up a potentiometer. The actual output from the pot is on pin 17, and here we've hooked it up to an LED just so you can see it working before we connect it to the SX-150.
When it's all hooked up, it will look like this:

The source code is drawn primarily from the Arduino article except they are using all 6 pots, and I'm just using #1 (or #0 in code). I've changed some of the names and packaged it a little different, but I'm not taking much credit for it. ![]()
I'll break the code down like this...first there's the code that manages the SPI interface:
//--- SPI code
#define DATAOUT 11 //MOSI
#define DATAIN 12 //MISO - not used, but part of builtin SPI
#define SPICLOCK 13 //sck
#define SLAVESELECT 10 //ss
void SPIInitialize()
{
byte clr;
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(SLAVESELECT,OUTPUT);
digitalWrite(SLAVESELECT,HIGH); //disable device
SPCR = (1<<SPE)|(1<<MSTR);
clr=SPSR;
clr=SPDR;
delay(10);
}
char SPITransfer(volatile char data)
{
SPDR = data; // Start the transmission
while (!(SPSR & (1<<SPIF))) // Wait the end of the transmission
{
};
return SPDR; // return the received byte
}
Then there's code that uses the SPI specifically for controlling the AD5206:
//--- AD5206 code
byte SetPot(int address, int value)
{
digitalWrite(SLAVESELECT,LOW);
//2 byte opcode
SPITransfer(address);
SPITransfer(value);
digitalWrite(SLAVESELECT,HIGH); //release chip, signal end transfer
}
And finally there's the (small) amount of code that actually does something with the digipot:
//--- Application code
void setup()
{
SPIInitialize();
SetPot(0,255);
}
byte resistance=0;
void loop()
{
SetPot(0,resistance);
delay(5);
resistance++;
if (resistance > 255)
{
resistance=0;
}
}
Put it all together and compile it and push it to the Arduino and you should see the LED turn on and then fade out slowly until it's out, and then it'll go bright and fade out again, over and over.
Controlling the SX-150 Through the Arduino
We're finally here, and this is the easiest part of the whole project so far. You've already got a digipot hooked up, just pull the connections from A1, B1 & W1 and replace them with the wires hooked up to the SX-150. A1 & B1 go to Pad1 & Pad2 on the SX, and the stylus wire (Pad3) goes to W1.
Schematic:

My final setup looked like this:

Turn everything on and you should start to hear the aural equivalent of what you saw with the LED. The tone will jump up and then drift down, then jump up and drift down again. If you reverse Pad1 & Pad2, the tone will rise instead.
Try varying the value in the delay() statement in the code and you can control how fast the pitch changes.
And there you have it, your SX is being controlled not with the stylus but by code running on the Arduino!
Looking forward
Flush with this success, I went and picked up a cheap digital instrument tuner, then I changed the delay() value to 2000 -- 2 seconds on each level.
Setting the tuner up close to the SX-150's speaker, I was able to watch as the synth zoned in on a specific note. I changed the code a bit to send the current resistance level (0-255) to the serial port so I could watch it. When the synth had properly hit a note, I recorded the note & the resistance value. If I wanted to, I could set those resistance levels in order and play a musical scale...
...or at least part of one. Being the clever lad I am, I ordered the 10K resistance version of the AD5206 which leaves me in exactly the same place I was with the reduced pitch range (less than an octave) as with the 10K analog pot.
Ah well, they're relatively cheap (less than $5 each) and are available in 50K & 100K versions, so I'll just pick up one of those...nothing else should change in my code or my circuit, I can just plug the replacement straight in.
Hopefully this has been helpful in getting started hacking your SX-150 using the Arduino to drive it. Watch for Part 2 sometime soon!
* It's worth noting that the SX-150 board itself seems to be pretty poorly built. I'm seeing a lot of cold solder joints, and a number of places where they didn't bother with solder at all, some pins just sitting in the holes in the PC board. It does seem to have some problems with inconsistent sound, etc., but even with all that, for $55 it's hard to complain too much. I'm having a lot of fun, and that's what matters.
Feedback awaiting moderation
This post has 1 feedback awaiting moderation...
01/01/10 01:17:31 pm, 