Xiao CV Sequencer

by analogsketchbook in Circuits > Audio

2798 Views, 8 Favorites, 0 Comments

Xiao CV Sequencer

Xiao CV Sequencer

Many modular synthesizer systems use Control Voltages (CV) to pass note information from one module to the other. When I started building my first modular VCO, I didn't have a keyboard/sequencer capable of outputting CV signals, so I cooked up this project that uses a Seeduino Xiao microcontroller and a handful of parts to make a fairly respectable CV sequencer.

The code and schematics can be downloaded from my github.

DISCLAIMER: Use at your own risk! In other words, before you hook this up to your fancy modular system or analog system, test it out on a multimeter, test equipment, junky module or whatever you're not worried about in case you get the magic smoke. I've tested it on a couple of my DIY oscillator modules and nothing has blown up. But do your due diligence and test it carefully before you roll it out as part of a larger system.

Supplies

Simple Version:

  • 1x Seeeduino Xiao microcontroller
  • 1x 3.5mm mono audio jack (or ¼” audio jack if you prefer)

For Full Version Add:

  • 1x additional 3.5mm mono audio jack (or ¼” mono audio jack if you prefer)
  • 1x rotary encoder 1x 10 potentiometer (linear taper)
  • 4x LEDs 4x 100 ohm resistors 1x SPDT (ON-ON) switch

For Modular Panel Version Add:

  • 1x Schottkey Diode
  • 1x Transzorb (TVS) Diode
  • 1x 10uF ceramic capacitor
  • 1x SPST (ON-OFF) switch
  • 1x USB panel mount cable (optional)

Simple Version Hardware

simpleGrab.jpg

An easy way to test things out is to have the Xiao to output voltages in 1-volt increments. This basic version could be used to tune a VCO if you wanted to keep it simple. And as far as hardware setups go, this is about as simple as it gets:

  1. Setup the Xiao to work with the Arduino IDE. You can find the details out about doing that here https://wiki.seeedstudio.com/Seeeduino-XIAO/ . Make sure you set it up to use the Arduino language as that’s what I’m using.
  2. Place the Xiao on a breadboard. You’ll want it straddling the center channel with the USB connector hanging off one end.

  3. Connect an audio jack to the Xiao. You can use a 3.5mm or ¼” audio jack depending on your preference but the wiring is the same either way. Connect a wire from the jack’s signal lead to the A0 pin of the Xiao. Then connect the jack’s ground lead to the Xiao’s GND pin (Pin 13). On a mono audio jack, the terminal that connects to the sleeve is the ground and the terminal that connects to the tip is the signal. Remember that the Xiao's pinout numbers start at pin 0.

That’s it for the hardware setup. How crazy is that?

You can do this setup on a breadboard. For my initial version, I used a terminal block breakout board (as shown above) which kept things a bit more portable/stable.

Simple Version Software

IMG_3440.jpg

For the software part we’ll also start simple.

  1. Upload the octave tuner sketch to the Xiao. Download the xiao_CVout_octaveTuner.ino file from my github site here , and upload it to your Xiao.This sketch outputs a CV signal in 1V increments from 0-3V from the analog out pin.
  2. Test output with a multimeter. Connect a 3.5mm mono cable to your jack. On the free end of the cable, touch one lead of a multimeter to the tip of the cable and the other lead to the lower part of the cable (sleeve) as shown in the pictures above. Then set the multimeter to read voltage. You should see the voltage update in approximate 1V increments.

This setup can be used to tune VCOs. Just plug the other end of the cable into your VCO’s one-volt-per-octave (1V/O) input. The default tempo is at 10 second intervals but you can adjust the speed by changing the RATE variable to whatever you want.

At this point you have a simple version that can be put in a small case and used as a standalone for tuning oscillators. I’ve put details of the tuning process in the notes at the beginning of the sketch if you're interested in doing that.

Full Version (Sequencer)

IMG_3383.jpg

The simple version works well enough on its own as an octave tuner, but I decided to make a fancier version that can play back sequence in addition to the octave tuner version. The completed circuit has the following features:

  • Analog Sequencer output capable of outputting a range of 41 semitones.
  • Analog input for reading in analog CV signals (up to 3.3V max).
  • Two Modes: Octave Tuner and Sequencer. The sequencer mode plays eight-step sequences of CV notes. There are 24 pre-programmed sequences but you can add your own as well. Modes are selected via a physical switch.
  • Tempo control knob. Playback speed of sequences / tuner is controlled with a potentiometer.
  • Sequence/octave selection knob. You can select the sequence via a rotary encoder. Turning the knob cycles through the sequences. Pressing the encoder knob increases the base octave of the sequence.
  • Beat/Octave LED indicators. When in Octave Tuner mode, the LEDs indicate which octave is being played. When in Sequencer mode, the first LED flashes on the first beat of the sequence as well as which octave is being played.
  • Power switch. So it’s not drawing power when not in use.
  • USB port on the front panel for programming without removing the module.

Full Version Hardware

xiaoSequencerSmall.png

Now we're ready to lay out the components on a breadboard as shown in the image above. All of the components should fit on the board, but in the image I've left them off the board to help show the connections better.


  1. Place the Xiao on the breadboard. It should be straddling the center channel and the USB connector is hanging off one end.
  2. Connect up the power rails. Connect the 3.3V pin from the Xiao (Pin 11) to the positive rail of your breadboard. Connect the GND pin from the Xiao (Pin 12) to the negative rail. Then connect the breadboard’s negative rail to the negative rail on the opposite side, and the positive rail to the positive rail on the opposite side.
  3. Connect audio jack(s). Connect up the audio jack as before with the tip connection going to the Xiao’s Pin 0 and the sleeve connection going to the negative rail. I’ve also added a second, optional audio jack to serve as an input to serve as a test input (you could read in the voltages your sending out. The second jack’s tip connection goes to Pin 1 and the sleeve to the negative rail.
  4. Connect the tempo potentiometer. Place the potentiometer on the breadboard and connect the left pin to the negative rail and the right pin to the positive rail. Then connect the center pin to the Xiao’s analog input Pin 6.
  5. Connect the rotary encoder. Place the rotary encoder on the breadboard. The rotary encoder should have five connections total as follows: GND to the negative rail. V+ to the positive rail. CLK to the Xiao’s Pin 2 DT to the Xiao’s Pin 3 SW to the Xiao’s Pin 5
  6. Connect the LEDs. We’ll connect four LEDs to the Xiao through four 100-ohm protection resistors. Connect the negative end of each LED to the negative rail and connect their other end to a resistor. The other end of the resistors to the Xiao’s Pins 7 through 10...that is, you should have one resistor going to each pin.
  7. Connect mode switch. Your mode SPDT switch should have three connectors. Connect one of the side pins to the positive rail, and the other side pin to the negative rail. Then connect the center pin to the Xiao’s Pin 4.

Full Version Software

IMG_3151.jpg

Now, we'll upload the code and test it out:

  1. Connect a cable from the analog output jack to the analog input jack as shown. This will route the CV signal we’re outputting back into the Xiao so we can verify what we’re outputting.
  2. Connect the Xiao to your computer via USB.
  3. Upload the xiao_CV_Sequencer.ino sketch. Launch Arduino and upload the sketch to the Xiao. Your LEDs should either be lighting up one at a time or the first LED is blinking periodically, depending on which way your switch is set. If the LEDs don’t appear to be lighting up, try centering the the knob on the tempo potentiometer which gives you a faster playback rate.
  4. Test voltages on the Serial Monitor. In Arduino, open up the Serial Monitor (Tools->Serial Monitor) and make sure it’s set to a baud rate of 9600 (this is the only baud rate the Xiao supports). You should see the voltages being printed out. Depending on the position of your switch, the voltages will either be changing in 1V increments (octave tuner mode) or in .083V increments (sequencer mode). Note: We lose a little something along the way, so your voltage may not be EXACTLY those values, but pretty close.
  5. Test the tempo knob. Rotating the tempo knob should increase the speed of the voltage changes.
  6. Test the mode switch. Flipping the mode switch should switch the Xiao from Octave Tuner mode to Sequencer mode. In Octave Tuner mode, the four LEDs light up in sequence and the voltage output voltage will correspond to LED with each 1V step. So when the first LED is lit, you should see 0V on the Serial Monitor, 2nd LED=1V, 3rd LED=2V, and 4th LED=3V In Sequencer mode, only one LED with flashes on the first beat of the sequence.
  7. Test rotary encoder. Set the mode switch so you’re in Sequencer Mode (only first LED should be blinking). Then, while you watch the Serial Monitor, turn the knob one way or the other. You should see a message which indicates which sequence number it’s playing back and the voltages being printed should also change to different values. You can change the sequence as you like by rotating the knob. If you hit the end of the list of sequences in either direction, it will loop around to the other end. Now try pressing the knob on the rotary encoder to activate its switch. This should bump up the voltages by 1V each time you press it (effectively increasing the output by one octave). The second LED will be the one flashin now. If any notes go past 3.3V they cap off at 3.3V to avoid exceeding the output range of the Xiao. Note: The rotary encoder only works in Sequencer Mode.
  8. Test the output going to your VCO. If you’re satisfied everything’s working, you should be able to disconnect the one end of the cable from the input jack on our breadboard and feed it into a 1V/O CV input on your VCO and see if it produces notes.

Module (Standalone) Version

IMG_3439.jpg
IMG_3296.jpg
IMG_3297.jpg
IMG_3376.jpg
IMG_3384.jpg

If you prefer to keep this as a standalone you could transfer it to protoboard, put it in a small box, and run it off USB power with no problem. If you want to convert it into a module, the main change to the circuit is that we’ll need to add some additional components to allow us to power the Xiao from the modular power supply. There’s a few important considerations here:

  • The Xiao can be powered by a maximum of 5V DC. This power should be regulated to avoid damaging the Xiao. My modular power supply has a regulated 5V output so I used that. The schematic shows the modular power connections to the Xiao’s voltage pins (5V=Pin 13, Ground=Pin 12) as well as a few additional components for power protection.
  • A Schottky diode has been inserted into the 5V connection to prevent current from leaking back into the modular power supply (this could happen if the modular system is off but the Xiao is powered by USB). I didn’t have a Schottky and used a 1N4001 rectifier diode instead which seemed to do fine.
  • The transzorb(TVS) diode and 10uF capacitor that span the positive and ground rails are there to help dampen any power spikes. These might not be needed if your power supply is regulated. I got away with only using the capacitor.
  • I also added a switch in the power connection so that the module could be turned off when not in use.
  • The full schematic for the modular version can be found here.

Building the module can involve a lot of trial and error in order to work out the best front panel layout and how the components will attach to the back. All of this depends on how you want to set it up, but here’s the process I use:

  1. Determine which components need to be on a protoboard/pcb and how you will mount that board to the faceplate. In this case, I needed a board for the resistors, LEDs, diodes, capacitor and header pins for the Xiao. Rather than use bolts and standoffs to mount the board to the faceplate I used pcb-mount audio jacks. The audio jacks will hold the board in place so I don’t need to drill any other holes in the faceplate. The other components can be attached to the panel independently (the rotary encoder, the potentiometer and the switches). There wasn’t a good way to mount the Xiao on protoboard in such a way that its port was accessible from the front panel. So I ordered a USB panel-mount extender from Adafruit. This would allow me to put the Xiao wherever I wanted and run the cable from the Xiao to the front panel.
  2. Create the proto board with the fixed components. Once I knew which components would be mounted on the board I arranged the fixed components on the protoboard. This took a lot of experimenting. I ended up having the two audio jacks near the bottom with the LEDs in a v-shape. Since there wasn’t enough clearance between between the board and front panel for the Xiao, I used header pins soldered on the back of the board instead. Then I used the resistors and wires to connect the various LEDs and jacks to the appropriate header pins for the Xiao. I also had to solder on a few extra header pins that would be needed to run power to the encoder/pot/switch, as well as a header pins for drawing 5V power and ground from the external source.
  3. Create a drill template. Once I knew how the components would be laid out on the board, I used the open source vector graphics program Inkscape to create a lifesize temple of the front panel. I made the dimensions of the panel as well as the exact dimensions of the holes needed for the various components. Since the fixed components spacing/positioning has already been created, I measure it carefully on the real board and make sure that my template matches. When that part is finished, I worked out where the off-board components could go. It’s important to leave space for the modular rack’s mounting rails, and to also to leave room for the body of the potentiometers/wire connectors on the back side of the panel etc. I occasionally would print out my template and do test lineups to see how thing will fit on both the front and back of the panel.
  4. Make a cardboard prototype. Once I’ve plotted out everything in Inkscape, I print out a copy at actual size and then mount it on a piece of cardboard to test the fit. I cut out all the holes as indicated and then try and mount all the components to it. This allows me to fine tune the positions and correct any mistakes I might have made.
  5. Create the actual panel. I like to make my panels out of a sturdy .64” thick aluminum sheet I get at the hardware store. The .032” will work, it’s just not as beefy. I’d avoid going any thinner than that because it’s too easy to bend and warp as you work on it. I cut a piece of the plate with either a jigsaw or hacksaw and file any rough edges. I tape the template to the panel and use a center punch to mark the center of each hole and then use a step drill bit to drill to drill them out. At this point I also lightly sand, spray paint and add the labels, and then finally, coat them with a clear lacquer.
  6. Assembly. Once I have the panel made, I assemble all the pieces. I connect the protoboard to the panel and each of the loose components. Rather than solder my wires together I like to put crimp connectors on the various wires which make it easier to connect (although if I were gigging with this unit, I’d consider soldering to make things more bulletproof).
  7. Testing on computer. Before hooking it into the modular’s power supply, I tested it out by connecting the front panel USB port to the computer and uploaded the sketch. This allows me to make sure that all the components are behaving as expected and that the USB extender is working as well.
  8. Testing in the modular. After that, it’s just a matter of connecting the power supply 5V pins to the two power headers I added on my board (and disconnecting from computer’s USB). I plugged a cable from the new panel’s output into the CV 1v/O connection on my VCO module and verified it was working.

As I mentioned at the beginning, I threw this together out of necessity and it seems to work well. If you have any suggestions or see anything amiss, let me know in the comments.