Multiple MCP4922 SPI DACs on an Arduino

Pastedgraphic-1

I’ve had a few days on and off fiddling with getting an Arduino Nano, trying to get it to talk to a couple of Microchip MCP4922 DACs hanging off the SPI bus.

The diagram over at the excellent tronixstuff site (in Arduino and the SPI bus part II) was a good starting point – essentially connect the clocks/data outputs to all the inputs, and use digital output pins for selecting the SPI slave to output to, but it still wasn’t having it.

The solution in the end was to attach pull-up resistors to the DAC chip select pins, like this.

Multipledac

I had a thought that it could be possible to use the internal pin pull-ups, but a discussion over at Society of Robots suggests that this might not be reliable. I don’t know if all SPI devices need a pull-up resistor on chip select, but from my experiments, the MCP4922 certainly does need it.

Here’s a quick and really irritating demo of four oscillators (“sines” from ASys RS-95, RS-95e and Doepfer A-111, triangle from Roland System 100 Model 101) being swept by the four outputs of the DACs – the resulting LFOs should each be 90 degrees out of phase. There’s also a pot wired to an analogue input, which controls the speed of the oscillations.

This is a spectrogram (from everyone’s favourite old PC sound editor from years back…) of part of the above demo which proves the phasing of the LFOs. One of the oscillators was tuned a lot lower, hence one of the lower peaks.

Spectrogram_quadrature_lfo_ard

Must be turning into a hippy or something, I could stare at this spectrogram all day. I think I need an oscilloscope.

6 Comments

Arduino control voltage quantizer

Heard about the Toppobrillo Quantimator over the weekend from a fellow modular nut, and wondered if I could write a quantiser from bits of the code and hardware from my still unfinished CSQ-100-ish sequencer project. So ta-da, here’s a demo.

It’s a bit annoying, but you get the idea – the Arduino is taking a random input (from an MFB Dual LFO) and forcing it to the selected key and scale on a trigger from a TR-606.  Hopefully you can tell that it’s displaying the key, scale, incoming CV value and output note value. When I flip the switch down, it stops accepting CV input and starts looping back over the last eight notes quantised.

It should be easy enough to expand the modes available. There’s a good list in this electro-music thread on building a PIC-based quantiser.

I used the second output of the MCP4922 DAC to provide a harmony part (the “h” value on the display), although it’s not attached to a oscillator in this demo. It’s tempting to add another DAC and have four outputs for chords, in the style of the Quantimator. IS FUN.

2 Comments

CSQ-100-style Arduino sequencer, part 2

Cardboardsequencer

I’ve been working on my silly cardboard-faced Arduino CV/gate sequencer thing. My previous post (Beginning CV/gate sequencing with the Arduino) outlined the idea, here’s my criteria:

  • it should work like the Roland CSQ-100 (or SH-101) step sequencer
  • sequence hz/v or 1v/oct synths
  • allow the user to change patterns and record/edit sequences while it plays (like the TR-606)
  • should be tighter than your sister

Here’s a video of where I’ve got to, with lots of annotations to explain what on earth these unlabelled buttons do.

It’s now based on an Arduino Mega, mostly because I was always on the edge of running out of pins. I got fed up with having to wire up shift registers for the buttons. And then I got fed up with having to wire buttons, so having been obsessed with the idea of the Roland MC-4, I added a numeric keypad. (Eventually it’ll be able to email as well, right?). It’s handy having the seemingly endless 128KB of program memory, I was bumping up against the Atmega168 memory limit of 16KB on a previous project.

I wanted lots of LED displays, mostly because I was trying to ape the MC-4’s measure, step, and data display – so the previous version had three of them (demo video here). But carelessly I killed one of them, and then realised they were expensive for the amount of information they display. Instead I got hold of a suitably retro Samsung 20T202DA2JA vacuum fluorescent display (datasheet), which is lovely. Here’s my first childish first fiddle with it:

Vfdbollocks

I’m using Ladyada’s SPI_VFD library to talk to it, which works really well.

This time, rather than just storing voltages (read in by the onboard 10-bit ADC), I’m using a lookup table to store a key number based on the input voltage from the synth keyboard. This saves a bit of EEPROM space, but it also means I can allow for transposing the sequence from the connected keyboard, which is a replication of the KCV Add feature on the CSQ-100.

On playback, the program uses another lookup table to convert the note number to a number between 0 and 2048, corresponding to 0 and 5v. I’ve fiddled around with these numbers to get them as close to the note frequencies as possible. I’d use a different lookup table for v/oct and hz/v synths – this has a nice side effect in that I could have a hz/v keyboard controlling a 1v/oct synth. Also I could use further custom lookup tables for synths that are scaled differently, so it could be handy for controlling my cv/gate modded SH-1000 that runs closer to 1.3v/oct.

Because it can only output a maximum of 5v (using a very cheap Microchip MCP4922 dual DAC, following along with Mr Book’s post Controlling a Gakken SX-150 synth with Arduino), this means I’m getting just over 2 octaves on the MS20, but should be over 4 on anything 1v/oct. Before I added the slide circuit, I was getting better than +/- 2 cents across the range on the MS, which is acceptable to me.

Currently each (max 32 step) pattern uses a byte each for note number, gate length, aux control voltage, and switches, which are currently rest, tied note, and slide. I’ve had another trigger output (called MPX on the MC-4) working as well, which worked well for switching in LFO modulation for certain notes on the MS20.

Each pattern uses 129 bytes of storage space – 128 bytes for the pattern itself and one for the length. On my previous attempt I was storing patterns in the Arduino internal flash, but on this version I’ve moved to an external 512 kilobit (64 kilobyte) 24LC512 EEPROM, following Cutedigi’s tutorial. Writing a 128 byte page is slow, taking at least 5ms, so to avoid interrupting the playback, saving and loading is scheduled for directly after a note trigger. This currently has the side effect that it has to be playing to save something, which isn’t so good. As far as possible I also update the screen directly after a note trigger, although it may not such an issue with the SPI VFD display as with the slower Sparkfun LED displays. Here’s one that I’m currently using for the step display, glowing ultrabrightly:

Sparkfunled

Because it’s so much fun to play with, it’s easy enough just to sit there twiddling with it and not actually getting it finished. It seems to spit out little melodies that I wouldn’t naturally come up with sitting at the keyboard.

In particular, the transpose function is a lot of fun. When it can’t transpose the note any higher because of the limitation on the maximum voltage output by the DAC, the software forces it to wrap round underneath; so rather than a F4 which it can’t reach, it (should) play an F0, which makes for some unexpected but pleasantly varied lines.

Here’s a quick demo of the transpose function from the MS20 perspective; I’d already recorded a short sequence:

I’m finding designing the physical user interface design fascinating, and difficult. I always wanted synths and sequencers with a knob or button per function, but now I come to designing my own instrument, I can easily see why the 80s thing was to sling in a screen and an alpha dial. And like I say, it’s a pain to wire up the buttons. There’s also a temptation just to keep adding features ad infinitum. Currently I’m giving in to it, although I’ll need to make decisions if I’m ever going to get it boxed up.

I’ve been looking at the Mutable Instruments Shruthi-1 for inspiration for a box, particularly Hannes Pasqualini’s Shruti-1, which looks really good. Slowly getting there… will get it done eventually.

7 Comments