Monday, January 19, 2015

Polysynth voice controller

The hardest thing right now is getting hold of paper. Fake t-shirts, booze and other crap, no problem, but finding a decent notebook is nearly impossible in the town of Patong. I found this at last (the killer bunny in the background is the daily art left by the cleaners):



So, we've looked at some of the tings we want to do on the voice card mcu, but what mcu should we use?

We have some initial requirements:
- dual SPI/I2C interface
- data flowing through the matrix should be 16 bit
- we want the run-through of the matrix to be fast to achieve a high output update rate, maybe as close to 44.1kHz as possible.

This last requirement may not be possible with "home made" samle and hold outputs but let's for the moment assume it is.

So far i have almost exclusively worked with the Microchip PIC16 and PIC18 MCU families. These are 8 bit, but it is still possible to work on 16 bit numbers. However, when it comes to multiplication of 16 bit integers, tings start taking a loooong time. In our matrix we want to do a lot of multiplications, so this is bad. To speed tings up we may precalculate a lookup table, but this would have too many entries to be possible, as the amount of ram available is very limited"

Another limitation is the maximum speed possible. From memory I think the maximum clock frequency for the 18F is around 40MHz. But each instruction takes 4 clock cycles, so the maximum speed is 10MIPS (million instructions per second). If we are aming for 44.1kHz, this leaves us with 226 instructions per refresh! Takling into account that multiplications take a lot of these and you quickly realize that the PIC18 doesn't quite cut it. I know the Matrix 12 probably does not have a lot more power than this, but it used 8 bit variables. If we did the same we could possibly make tings work, but we won't.

If we want to stick with the PIC family this leaves us three options - the dsPIC and PIC24, both 16 bit, and PIC32 which is 32 bit.

The PIC32 runs at up to 200MIPS, 20 times faster than the PIC18F. It packs a whooping 512kB of ram and has plenty of serial i/o and whatnot. It even has built in support for ethernet. Also, it can do 16bit x 16bit and 32bit x 16bit multiplications in 1 instruction! With 200MIPS we get 4535 instructions per update, so we should be able to use a quite large matrix.

So what are we waiting for? The PIC32 wins the shootout, right? Well, there are two things worth considering. First of all, the price. A PIC32 running at 200MIPS and with 512kB Ram costs close to $9 in quantities of 5000 and up. Not something that breaks the bank, but considering we need one per voice, it gets a bit expensive.

More importantly though, the PIC32 comes in surface mountable versions only. This makes it harder to prototype things. We may of course add in-circuit programming posibilities (and this is such a good idea that I would consider doing it any way) but it still is a bit of a hassle.

That leaves us with the PIC24 and the dsPIC. These are so similar that they share the same data sheet. The difference is that the dsPIC has a set of instructions specialised for digital signal processing, like doing large sum-products in a single instruction. Right now I see no use for this in our matrix (funny, as matrix multiplication is possibly something the dsPIC is very good at), so lets see if the PIC24 can do the job.

The PIC24 runs at up to 70MIPS, 7 times faster than the PIC18, so we get 1587 instructions per update. Not as much as we may have hoped for but still something. The PIC24 can also do 16bit x 16bit multiplication in one cycle (though i need to get this confirmed). It has two SPI interfaces and it comes in (among others) a 28pin through-hole version.  The cost is  around $3.50, which is a lot cheaper than the PIC32. All in all I am willing to give it a try. Except for having to redo the digital voice pcb much of the code and circuitry from a PIC24 version can be reused for a PIC32 version. One could also reduce the update frequency to get more time between updates. Besides, part of the fun is using a mcu with limited resources, you have to be clever :-)

No comments:

Post a Comment