Tuesday, March 12, 2013

Polysix - Replacing the 8049 Key Assigner

I've finally resumed work on my earlier plan to replace the key assigner in my Korg Polysix. My purpose is not actually related to the key assigner -- my purpose is actually related to adding aftertouch and velocity sensitivity to the Polysix. In order to achieve these goals using my new Fatar 61-note keybed, I felt that the best course would be to replace the key assigner so that I had full knowledge and full control over all the signals. To jump to the end of today's story, here's a picture of MIDI control of my Polysix using an Arduino!

OK, stepping back to the proper place in the story, the last work that I had reported was on extracting the timing of the control signals generated by the 8049 microprocessor that is at the heart of the Polysix's key assigner. My plan is to replace the 8049 with an Arduino, so I needed full knowledge of all the control signals. Since that post, I've begun developing software for an Arduino Mega 2560 to recreate all of the control signals generated by the Polysix's 8049. That work has been going well, so I felt that it was time to actually start plugging into the Polysix...it was time to make the rubber hit the road.

To physically get the control signals from the key assigner PCB to the Arduino (and back), my plan is pop the 40-pin 8049 out of its DIP socket in the Polysix and to connect a bunch of wires between the Arduino and the now-empty socket in the Polysix. Basically, this is a less elegant version of same approach used by these folks, who are replacing the microprocessor in a Prophet 600 with another type hobbyist microprocessor, the Teensy++. Whereas the Teensy already comes in a nice 40-pin DIP form and can be dropped directly into the Prophet 600 board (with a minor mod), the pin-out for the Polysix is radically different -- too different to enable easy use of the Teensy. So, unfortunately, I'm stuck using the much-larger Arduino Mega.

To get the wires from the empty 8049 socket on the Polysix PCB to the Arduino, I've chosen to take a new 40-in DIP socket, to solder a bunch of wires to it, and to insert the newly-wired socket into the empty 8049 socket. Unfortunately, as you can see in the picture below, a plastic DIP socket isn't really meant to be soldered to -- you can see in the picture that the plastic around each soldered pin got quite melted. It would be really easy to push a pin right on through the socket's frame. Be careful!

Soldering a Wires to a Soft-Plastic 40-Pin DIP Socket

Of course, you just can solder wires all willy-nilly -- you have to have a plan of which pin from the 8049 socket is needed for what purpose. So, after looking at the Polysix schematic, I came found that I needed 27 wires to attach to 27 of the 8049's connections (see my hand-drawn pin-out below). Add another wire for power and another for ground and that's a total of 29 connections. With that number of connections, you can see why I needed an Arduino Mega instead one of the more-common (and cheaper) Arduino variants.

Signals from the Polysix 8049 that I Need to Bring to the Arduino Mega

So, after soldering all of the wires to my DISP socket, I pulled the Polysix's 8049 out of its socket and pushed my new socket into its place. Pushing it into the socket was actually pretty difficult because my socket had round pins and the existing socket was expecting flat pins. I was worried about breaking the socket or over-stressing the PCB. So, I unscrewed the PCB and pushed some material underneath the PCB to give it plenty of support. Eventually, I was able to push hard enough that it finally and decidedly dropped into place.

My Colorfully-Wired DIP Socket Inserted in Place of the Polysix 8049 Processor.

With the socket wired-up and finally in-place, I brought the wires back to the Arduino Mega. I dropped the software onto the Mega and fired it all up. There was no magic smoke released, so I was pleased. Of course, it also couldn't do anything because I had no keybed attached yet. So, I attached a Sparkfun MIDI Shield to the Arduino, which is the picture shown at the top of this post. Using an external MIDI keyboard (along with MIDI parsing software routines that I wrote for the Arduino), I could now tell the Arduino what notes to play and, theoretically, the Arduino would command the Polysix to play them.

Did it work? Well, no. Software always has bugs. Did it work eventually? Yes. Totally.

As of right now, I've got the following Polysix functions working correctly: Poly, Unison, Chord, Hold, and the Octave knob. The only Key Assigner mode that is not yet implemented is the Arpeggiator. I even have a few new functions already implemented: (1) a sustain pedal, and (2) user toggling between retrigger every note (like a normal Polysix) and no-retrigger when playing legato (like a Moog). I'm particularly enjoying the sustain pedal functionality.

Now that I've demonstrated that it works, the next step is to begin to install it more permanently into the Polysix. Then, I can install the new keybed (along with its controller). At that point, I can finally start implementing the aftertouch and velocity sensitivity. What a long road!

10 comments:

Hi! Thanks for the complement. Yes, I installed the Fatar keybed myself. Yes, the end product would probably be more robust if I paid a keyboard technician to do the work, but I like the challenge and knowledge that comes from doing it yourself.

Probably would have worked fine...but I'm a noob, so I wanted to stick with Arduino. I got a little bit burned when I went with the Arduino-like Maple board, which was lacking some library compatibility. So, I stuck with a core Arduino board. The Mega is a lot more expensive than the Teensy 2.0++, so I should have given it a 2nd look.

There are couple small things that the Mega has that the Teensy doesn't: (1) the Mega has mounting holes and the Teensy doesn't, (2) the Mega has extra holes for ground and for +5V for supporting peripherals and switches and stuff. That's kinda helpful. Probably not worth all the extra money, but still kinda nice.

What is nice about the Teensy is that it has holes and not headers. I had to desolder the Mega headers, or just use wires and tape them in place. It would have been a lot nicer to just solder a wire into the hole. Much nicer. Totally nicer.

Before you dive in, you need to recognize that one of the Key Assigner's important jobs is to scan keybed to look for key presses. When I replaced the Key Assigner, I also chose to replace the keybed. Since my new keybed came with electronics, it simply output MIDI. Therefore, my new Key Assigner did not need to scan the keybed.

If you are going to use the Polysix's keybed, you will need to program the Mega to also scan the keybed. I did not do that with my Mega, so I can't help you figure that part out.

DB0 to DB7 are either digital high or digital low (0 or 5 volts). Those high/low values go into that resistor network and summing op-amp, which together act like a digital-to-analog converter (DAC). Therefore the input to pin 5 is an analog voltage.

The trick is that all six voices are multiplexed in time as described in one of my other posts: http://synthhacker.blogspot.com/2013/02/polysix-basic-key-assigner-timing.html

You are going to need an oscilloscope in order to get enough information do this modification. You're going to have lots of questions like this, and my replies will not be adequate (just as this reply isn't really adequate). Then, once you actually do the modification, you are going to need an oscilloscope to figure out why it doesn't work. If you do not have an oscilloscope (or if you cannot borrow one), I would not start this modification...you will just end up with a Polysix that does not work.

Hi,I have an oscilloscope and logic analyzer. I read your post based on timing. Very good and my result is same.For now, I don’t know how to organize signal output of DB0-DB7 for multiplex. What sort of signal have you used for this?On original CPU, signals DB0 to DB7 are numeric and change each key press.For now is a mystic!I will do some testsAll function of P6 work with your Arduino?Thanks for your help!Chris

The signals for DB0-DB7 are arranged as a binary counter. Pressing the lowest note on the keyboard results in 00000000. Press the 2nd note yields 00000001. Press the 3rd note yields 00000010. Etc. That's the general idea...though the whole thing could also be reversed (replace all zeros with ones)...I can't remember.

You could hook up your oscilloscope (or your logic analyzer), put your P6 into unison mode and press a key. Then, probe each pin DB0-DB7 to see what you get. Then press the next key and see what you get. After a few key presses, you should be able to quickly work out the pattern.

Note that my Arduino code is now available: http://synthhacker.blogspot.com/2014/03/polysix-sharing-my-arduino-code.html