Tuesday, August 24, 2010

Some 4x16 prototype testing

After a couple of weeks (isn't it?) of programming, testing and being lazy, I finally managed to get the sequencer running.
I have now managed to trigger the CS-30 and send CV voltage thus producing a somewhat musical scale :)


Change of PIC


First, I decided to change from PIC16F685 to PIC16F886, because:
PIC16F685
4k word program flash
256 bytes RAM
18 I/O pins

PIC16F886
8k word program flash
368 bytes RAM
25 I/O pins

The winning point was the I/O pins. I needed them to be able to use ICSP without messing around with the circuit too much. I also needed a few extra addresses and some extra pin for the DAC.

I didn't have the 886 at home so of course I had to order it... Yet another component bought instead of using what I had. Bah, I think it's worth it :) Cost me around 4 Euro.

Something I realized about the DAC was that if I have both CS and LDAC pins under my control then I can "preload" the DAC with data during normal execution. Then when a trigger should occur, it's enough to just pull LDAC low and the value already clocked into the DAC will be latched to the output. OK I think it won't take more than some 50 microseconds to clock the data out (I'm using shadow registers for PORTB so it's a bit slow), but at least it's a smaller delay.
Maybe I can try to clock the data by toggling the pins directly without using shadow register on PORTB but I've read it's unreliable (read-modify-write problem).

Breadboard prototype
First I made a prototype of the trigger circuit using only the PIC and an opto-coupler. I don't know why but I have decided to use an opto-coupler for the trigger. One thing less that can burn my precious CS-30, but of course the VCO chip is the worst and that takes CV straight from the connector in to a pin on the chip :/

Anyway, the first prototype was not much to look at, just an LED conneted to the opto-coupler to see that it would conduct at the right interval when a specific BPM was set.
It seemed to be working so I hade a long programming session and added support for the DAC.
I think a project more complex than this, or even as complex as this, is not really suited for assembly programming :) The RAM bank "feature" of the PIC caused some headaches more than once...
But, I chose to do this on a PIC because I had a programmer and I knew some PIC assembly but wanted to do something more advanced than my previous project (the poly 61 data entry knob).
So, PIC and assembly is what I'm using!

When I had satisfactory results in the MPLAB simulator I added the DAC to the breadboard and decided it was time to test it for real.


The connector to the lower left in the photo with black and blue (purple actually) wires is the CV connector. It comes from the output of the DAC and goes to the "Key Volt In" on the CS-30.
The other connector above the breadboard, with black and yellow wires, is for the trigger and goes from the opto-coupler to the "Trigger In" on the CS-30.
The potentiometer to the right is just to set a voltage reference. The DAC needs an external voltage reference so I made one using two resistors with a potentiometer between them for better precision.

I will replace the DAC (currently MCP4921 which needs external voltage reference) with the MCP4821 which has integrated voltage reference of 2,048V or 4,096V if you set the gain bit. That's a very convenient reference voltage since each value in the 12-bit data word increases the output by 1mV.
Also, I have to use a reference voltage below 5V since that is what I will be using as power supply, and there is always some dropout, so I can't use much higher voltage than that anyway.

Oscilloscope plot
Here's a frame from my USB oscilloscope showing the trigger signal in red (note the scale is on the right side) and the CV in blue (scale on the left side). I used a test pattern playing C,C#,D,D#,E,F,F#,G,G#,A,A#,B,C and then 3 C's of different octaves.
The pattern starts in the middle of the 2nd division from the left. Right after the blue high jump.



The trigger is active LOW and you can see I am not triggering on step 2 and 4. It was actually a mistake in the test pattern but it allowed me to test pitch changing without retriggering (it is a planned feature actually) so it was good that I made that mistake :)
You see the nice staircase from the semi-note scale and then the jumps when it plays the octaves. In particular the high C is very obvious.


Enough talk.
I made a video and posted on youtube with some boring information and a demonstration of what I've managed to make so far.

No comments:

Post a Comment