MIDI Controller using the Arduino MIDI Library

Here’s a school project by Alban de Lanlay and Rachid Namoussi, an Arduino-based MIDI controller using the MIDI Library.

They sent the messages from the controller in serial format through the USB port, and translated it in MIDI with a piece of software they developed on the target computer. This way, they successfully controlled a software synthesizer.

Congratulations to them!

MCO – Analog Modulations (CV)

Generally, in an analog synth you can find lots of analog sources of modulations (LFOs, envelope generators, etc..). Providing multiple inputs for analog CV modulations is one of the requirements.

This is easy, as a simple OpAmp mixer will perfectly do the trick. The problem is that the sum of all these modulations is going to be fed to the microcontroller’s ADC input, which does not tolerates voltage lower than -0.5V and higher than 5.5V. Asking the designer/user to limit the input to these voltages is risky, as a combination of small values could lead to potentially harmful voltages (for the chip, not for you :p).
Just after the input mixer is a limiting stage, using two Zener diodes to clip the voltage. I found that low voltage zener can be harder to find, so the mixer actually boosts up the signal (2.2 gain) and gets clipped by 5V Zener diodes (so that the signal after limiter stage is between -5V and +5V).
To keep the 1V/Octave scale, we need to scale down by the same factor after limiting. An inverting OpAmp with a 1/2.2 gain will do the job, with an additional 480K resistor to -12V to inject a -2.5V offset, which is going to be inverted to centre the whole signal around 2.5V.
Here we have a 1:1 scale between the inputs and ADC signal. but we could accept any range (let’s say -5 to +5 volts, for a larger frequency sweep) for the inputs, and by changing the mixer’s gain and ADC representation, have a different range of modulation. So far it’s set to -2.5 to +2.5 to simplify the calculation for the DAC.
The DAC will convert the input voltage to a 10bit value (0 to 1023), centred to 512 when all the inputs are grounded. In the code, these values will be rescaled to match the number of cents to detune from the base frequency.
For example, with a direct 1V/Octave scale (-2.5 to +2.5 octaves), the highest pitch will be 2.5 * 100 * 12 =3000 (100 cents in 12 semitones times 2.5 octaves). So the ADC input will be scaled to -3000 to +3000 cents. The step (precision) will be (2 * 3000)/1024 = 5.86 cents per ADC step. For that reason, it’s preferable to use the digital control to set a precise frequency, and use modulation for dynamic signals (like vibrato or envelopes).

MCO – Specs & Processor

The Mixed Control Oscillator is inspired by Tom Wiltshire’s (aka Electric Druid) article on how the Roland Juno series DCO (Digitally Controlled Oscillator) work.

It’s called Mixed Control because it’s capable of both digital and analog control.

Digital control is done with an SPI interface (this is very common, you can find one on almost every microcontroller these days, including the Arduino, Propeller and LaunchPad).

Analog control uses the 1V/Octave scale, meaning that increasing the input modulation voltage by 1 volt will double the output frequency. It is limited to -2.5V to +2.5V of range so far (meaning 2.5 octaves below the base frequency, given by digital control, to 2.5 octaves above).

The central part of the MCO is the microcontroller (the Driver), that does the following:
  • Read SPI messages to change the base frequency (among other commands)
  • Read analog input to modulate this frequency
  • Generate the clock and slope signals, needed by the Saw generator.
  • Handle a few other features, like
    • Portamento
    • Hard Sync
The microcontroller is an ATtiny84 from Atmel, programmed with C/C++ code (which is going to be published soon).


It uses the internal 16 bit timer to generate the clock, and a 8bit timer to generate the slope (which requires less precision as it sets the Saw amplitude). These timers (and the whole microcontroller) are clocked using a 16MHz quartz.

Digital control handles the following control messages:
  • Change coarse base frequency, as MIDI notes (semitones)
  • Change fine base frequency, as MIDI notes + 1 to 99 cents detuning (semitones + cents)
  • Set Global detune frequency (the frequency for A4 is default 440Hz, but it can be set to anything else).
  • Portamento settings
    • Mode: Constant time or constant speed (more about that in a dedicated post).
    • Amount
  • Enable/Disable some features on the fly
    • Hard sync
    • Analog modulation
    • Digital lowpass filter on modulation
Analog modulation uses the internal 10bit ADC (Analog to Digital Converter). The signal is centred on 2.5V, so that positive and negative modulations (around the base frequency) can be achieved.

Hard sync can be done using an interrupt pin. When the sync pulse occurs, the timer resets, and a new waveform cycle begins.

Next time: Analog input.

Opening the Mixed Control Oscillator

I recently read this article on Make: Magazine about the “unspoken” rules of Open Hardware.

The MCO is not quite finished, but I guess it would be selfish to only post updates on this blog without revealing how it actually works..
For that reason, this project is now under the CC-BY-NC-SA license. For those who are not quite familiar with licenses, I invite you to click that button:

In other terms, you are free to do whatever you want with this project, as long as you mention its source (either a link to the Forty Seven Effects blog, or mention my name), and as long as you do it for personal use only. If you want to sell a project that uses it, feel free to contact me.
Explaining everything into one blog post would be long and boring, so I’m going to split the things to facilitate the reading.
Next time: Reminder of the specifications, and the central processor.

Tutorial: DIY SMD soldering with a frying pan

In this tutorial, I will show you how to solder SMD components on a PCB using the reflow technique and a simple frying pan.
What you need:
  • A PCB and the SMD components to be mounted
  • Solder paste (I used this one from Sparkfun)
  • A stencil (optional, see below)
  • A putty knife (if you go with the stenciling technique)
  • A frying pan or skillet
  • A hob (no induction, that might fry your components)
The frying pan I used is a 2.5€ one I found at Ikea. Very cheap, but that’s exactly what we need. Don’t plan to do any cooking (other than PCBs of course) with the pan you choose for this task. Just make sure it has a flat surface, so the PCB is heated up homogeneously.
Stenciling:
To apply the solder paste on the pads, you can use a stencil. It can be made of acrylic plastic (cheap) or metal (expensive, but lasts longer). I got mine on the following website: http://www.smtstencil.co.uk/
The guy who runs this website is very nice, and the price is not so expensive if you live in the EU (even better for UK residents). It took about a week to arrive, as I chose the cheapest shipping option. Using a stencil is better if you plan to do a few prototypes or even a production run. It can also be useful for a single board if you have a lot of SMD components (as the paste might dry if the application takes too long).
You can find a very good video tutorial (which I followed myself for this board) on how to apply the solder paste to the board with a stencil at Sparkfun:

If you don’t want to use a stencil, you can still use a sharp object (like a needle) to apply some paste on each pad. Put a little drop of paste on the pad (enough to cover 2/3 of the surface) but don’t spread it or flatten it, let the component do the job).
Whatever method you choose, you will want to keep your hands clean after applying the paste, especially if it contains lead or other toxic elements. Same for your stencil, wash it right after using it, so the paste does not dry in the holes.
Laying out the components:
Once the paste has been properly applied, begin with the smaller components (resistors, capacitors, transitors and small ICs) and move on to the big ones last.
It’s okay if they are not totally aligned with the pad, when the paste melts down, it will suck the components into place. This is actually quite fun to watch!
Cooking:
Once everything is ready, put the pan on the hob, the PCB on the pan, and turn the heat all the way up. (oh, and keep the room ventilated, you probably don’t want to breathe lead fumes, do you?)
The paste is going to start melting at around 180-190°C, which can happen quite fast depending on the type of hob you use. As you can see, mine is a diecast iron hob, so it took about 8 minutes to reach that point.
The melt will start in the center of the board, so even for small boards, what you want to do is to move it around to let the edges of the board melt as well without overheating/frying the center.
And that’s it! When all the pads are shiny, remove the pan from the heat, let it cool slowly, and inspect your solder connections.
Note: this tutorial applies only for soldering SMD components on one side of the board. Usually it’s better to design your board so that there are both SMD and thru hole components on the same side. Use the technique described here to solder the SMD first, then the thru hole. These can be on the other side of the board, as long as you have enough space for soldering their leads among the SMD components.
The full gallery of the Mobius Modular Motherboard (the board used for this tutorial) is available on Flickr.

MCO Driver using an ATtiny 84

I’ve been working on the Mixed Control Oscillator recently, it will be using an ATtiny 84 AVR chip from Atmel in the final form factor (so far it’s been running fine on my dev board using an ATmega644P, which is a bit overkill for such an application).


Here are the final specs:

For the driver itself (the AVR chip):
  • Precise control of the frequency via SPI. It is based on the MIDI note numbers, but with every cent between two semitones being accessible (1 cent precision), allowing frequency sweeps and continuous digital modulation.
  • Analog input for modulations (1V/octave, 5 octaves range).
  • Global detune (from reference A4@440Hz, with 1 cent precision).
  • Portamento (work in progress), with two modes: constant time & constant slope.
  • Hard sync input & output.

For the analog part:
  • Saw, Pulse and Triangle outputs.
  • PWM inputs.
  • Special triangle mode where the slope follows the PWM (work in progress). This would allow smooth transition from saw/ramp to triangle using PWM.

The ATtiny84 on AVRFreaks: http://bit.ly/vlMpsp