Sunday, September 29, 2013

Midi to control voltage converter

I've started working on this little circuit which will allow me to use a MIDI keyboard as control voltage for my VCO. Since MIDI is a serial protocol, I will need a microcontroller to interpret these signals. I will also need a DAC to get my control voltages. The DAC needs to be of the higher bit-type, since the VCO will need careful tuning to sound nice. I didn't find any simple microcontroller with more than 5 bits DAC, which is all little small. I did however find a nice cheap combo. A 12-bit I2C controlled DAC, MCP4725, and a 8 pin microcontroller with built in support for both UART and I2C, PIC12F1822. The DAC needs a voltage reference as both reference and supply, ZRC400F01 seems to work. All components are on the cheap and costs me less than 3€ for the lot. DAC and reference are small, surface mount components, so they are trickier to prototype with.
Midi 2 VCO converter, first steps. 


The DAC part can be seen to the right in the schematic. I've tested it out using an Aardvark I2C host adapter I borrowed from work, and it seems to work fine. When I choose the voltage reference, I thought that the 4.096V reference would fit well with a 12 bit DAC (0.001V/bit), but the DAC isn't perfectly rail to rail, so I effectively get a 0-4V DAC. I might just upgrade this with a 5V reference instead. Ideally it would be better with a higher voltage DAC since I intend to build a 1 octave/V VCO, and 0-4 V only gives me 3 octaves (4 if I upgrade to 5 V).


Microcontroller  is seen to the left in the schematic. The symbol for the PIC doesn't have the correct pin descriptions, but is generally the same as the one I use, regarding supply, IO's and programming pins. I made a hello world program that blinks an LED using interrupts. This may seems simple, but it gives me a starting point where I know that IO's, clocks and interrupts are working. 
Next thing will be getting some UART communication working, and connecting it to the I2C bus.
Some Hello World!-action. Microcontroller to the right, DAC and reference to the left.

Microcontroller source code

1:  //Hello world with LED connected to RA0 on a PIC12F1822  
3:  #include <xc.h>  
5:  //Configuration bits  
9:  void main()  
10:  {  
11:    //0 Internal oscillator, 3 <fosc> on, 6-4 31kHz  
12:    OSCCON = 0b00000000;  
14:    //Interrupt controller  
15:    //5 Timer0 overflow interrupt enabled  
16:    //7 Global interrupt enabled  
17:    INTCON = 0b10100000;  
19:    //Timer0  
20:    TMR0 = 0x00;  
22:    //Option Register  
23:    //2-0 Prescaler 1:4  
24:    //3 prescaler assigned to Timer0  
25:    //4 timer edge, high to low  
26:    OPTION_REG = 0b11010001;  
28:    //TRISA  
29:    //All A I/O's are set as outputs  
30:    TRISA = 0b0000000;  
32:    //PORTA  
33:    //RA0 is set  
34:    PORTA = 0b00000001;  
36:    //Loop forever, interrupts when Timer0 overflows  
37:    while(1)  
38:    {  
39:    }  
41:  }  
43:  //Interrupt routine  
44:  interrupt void isr (void)  
45:  {  
46:    //Ghost register of PORTA  
47:    int GPORTA;  
49:    //Read latch A into ghost register  
50:    GPORTA = LATA;  
51:    //Toggle bit 0  
52:    GPORTA = GPORTA^(1<<0);  
53:    //Write back into port register  
54:    PORTA = GPORTA;  
56:    //Clear interrupt flag  
57:    TMR0IF = 0;  
59:    return;  
60:  }  

Saturday, September 14, 2013

White Noise Generator + updated keyboard and mixer

Keyboard and mixer

I updated the keyboard by buffering the output with an emitter follower op amp. First I used a rail to rail op amp from microchip: MCP6271. I did forget that it had a maximum power spec of 6V, and I fed it 9V, so it started smoking after a while. It did work for quite a some time though... I replaced it with a ua741, but needed to fed that one with +-9V, to get a low enough output voltage. I really need to stock up on op amps...
 The mixer was updated with some 1% resistors for the inverter. I should probably use 1% resistors for the unity gain input and feedback resistor, to get a gain closer to 1 for that input. I also AC-coupled the other input, since DC-coupled signals puts the synthesiser out of tune.
Updated mixer schematic

White Noise Generator

I also built a simple white noise generator. It works by putting a NPN transistors base-emitter junction in reverse bias and overcoming the breakdown voltage of about 6V. By doing this, the junction will create white noise. Since the junction will conduct at first, and when it conducts the emitter voltage will drop, causing the transistor to stop conducting, which builds up the voltage above breakdown again, and so on. This happens really fast and thus noise is produced. The noise is very low voltage. I couldn't pick up the unamplyfied noise with my scope, and amplifying it with a 10000 gain opamp amplifier barely made it visible above the noise floor of the scope. So I used two opamps and amplified to the whole swing af the opamps.
 The noise can now be mixed  with the VCO control voltage, but it really creates a very broken and harsh sound. So it's probably better to mix it with the VCO output. I'll try that next time. I should probably also build another mixer, so that I can mix a wave with the control voltage, and the noise with VCO output, now I need to choose...
 On the next mixer I will get an op amp that can be turned off, so that I can use a gate signal from the keyboard to turn it on when playing a tune. As it is now, a high amplitude AC-coupled signal can have levels high enough to stimulate a VCO tune, which cause background noise when not pressing any buttons.
White Noise Generator schematic

White Noise Generator and mixer sharing the same quadruple op amp.

Monday, September 9, 2013

Summing amplifier mixer

I made a simple mixer for the synthesiser . It's a summing amplifier with two inputs, of which one is AC-coupled with a 47uF cap, so that the created high pass filter will still pass 0.1Hz signals through. My first idea was that this could be used to add some signal on top of the voltage passed on to the VCO, to create some pitch vibrato. This idea worked, but still failed, since the synthesiser gets totally out of tune when doing this. The problem is that what I thought of as unity gain from the summing amplifier, isn't really unity gain, since I'm using 5% resistors. The small change in gain can throw of the tuning, there is as little as 200mV difference between two semitones.
 Also, the simple keyboard uses a wild variety of potentiometers, who's resistance will be a part of the feedback network of the summing amplifiers. Thus the keyboards output needs buffering. I'll get back on the topic as soon as I'm done doing that.

Summing amplifier mixer, schematic

Summing amplifier mixer, actual board

Thursday, September 5, 2013

Simple VCO keyboard

To be able to play a bit on the synthesiser, I made a simple keyboard out of some old scrap I had in the junk bin. The construction is very simple: a potentiometer as voltage divider between rail and ground and a push button between output and wiper. Each button is tuned with the potentiometer and output is connected to the VCO. I made a full octave, starting with C, which gives 12 buttons and 12 potentiometers. Its was a bit boring to assemble, but works great.
VCO keyboard

Sunday, September 1, 2013

Unstable opamps, VCO and low pass filter

As I mentioned earlier there was some oscillation problems with the VCO sawtooth output. The problem was easily solved by biasing the opamp high. This makes the opamp faster and gives it a higher phase margin, thus making it more stable when driving capacitive loads. Since this solved the problem, I removed the opamp buffer from the output. The low pass filter had the same kind of issue, and it was solved in the same way.
 The filter also suffered from some clipping, which I solved by replacing R1 with a potentiometer and trying out the best value, which was 3.45k\(\Omega\). When P1 was set to the lowest resistance, there where some oscillations in the output. This was solved by putting 1k\(\Omega\) in series with each potentiometer terminal. I'll see if I can get my function generator to sweep out a bode plot of the filter, to see some details on it's characteristics.
Updated active filter schematics

 To get some higher tones out of the VCO, replaced C1 with a smaller capacitor. I needed a few tries to find a good match. A small capacitor gave a higher frequency, but the wave forms got scewed, probably due to unmatched resistors in the input stage. A smaller capacitor also raised the lower end frequency too high. This shows that I probably need to find a better VCO design, to get a higher bandwidth.