Introduction: Euclidean Rhythm Drum or Synth Sequencer Module

About: Physics instructor and robotics coach at the Loomis Chaffee School

I teach a lot of electronics in my high school engineering and robotics classes. Concepts like filters and resonance and their underlying mathematics can be really abstract and difficult for students to grasp. This year, I'm working with my Junior students to build an analog modular synthesizer to demonstrate these and other concepts - plus it's just darned cool! One of the modules I knew we needed in our rack was a sequencer, but not just any sequencer - I wanted a Euclidean Rhythm generator!

The term Euclidean Rhythm was first coined by computer scientist Godfried Toussaint in his 2005 paper on the topic. Euclidean Rhythms consist of "n" events evenly spaced across "m" possible positions in a repeating pattern. Allocation of the events is determined using Euclid's method of repeated subtraction commonly used to determine greatest common divisors. Toussaint observed that Euclidean Rhythms crop up in music around the world, making it a very useful algorithm for generating things like drum patterns. A number of virtual and physical implementations of these rhythm generators exist, but my favorite has to be Qu-Bit Electronix's Pulsar Eurorack module, which served as the inspiration for my design.

The module presented in this Instructable is based around an Arduino Nano, and can drive four drum or synth voice triggers spread out over a 16 beat pattern. Tempos can be produced using an internal or external clock. The number of triggers for each part can be specified independently and rotated to produce interesting rhythmic interactions between the voices. The panel design is based around Sam Battle aka Look Mum No Computer's "Kosmo format," but it could be easily adapted to Eurorack or another standard.

Supplies

1 Arduino Nano - You can use other Arduinos, but I like the Nano's compactness and low cost

1 Adafruit 16 Bit NeoPixel Ring - You can get cheaper knockoffs, but please support Adafruit!

5 Multicolored Momentary Push Buttons

1 SPDT Mini Toggle Switch

1 B100K (Linear Taper) Potentiometer

1 Rotary Encoder with Switch

5 Mono 1/4" Female Audio Jacks

1 TL074 Quad Operational Amplifier - Optional if you feel lucky!

1 14 Pin IC Socket for TL074

1 10 Pin Male IDC Socket Box Connector for Eurorack power

4 5mm LEDs (Red, Blue, Green, and Yellow)

1 220 Ohm Resistor

6 1K Ohm Resistors

1 2.2K Ohm Resistor

1 4.7K Ohm Resistor

2 10K Ohm Resistors

Jumper Wire

Stranded Wire

Breadboard

2 4cmx6cm Protoboards

Male and Female Header Pins

Acrylic, wood, or aluminum sheet for front panel - I laser cut mine from black acrylic


You will also need a soldering iron, solder, and a multimeter with continuity test mode if you plan to move beyond breadboarding the circuit.

Step 1: Prototyping

I start any new Arduino/circuit project by breadboarding my ideas. I usually add a few components and test them with the software feature they're associated with before moving on to additional components. In this case, the NeoPixel and Encoder were new to me and were the first to go on the board for testing and software development. These are both digital devices.

The NeoPixel's data line is attached to digital pin 2 on the Nano through a 220 Ohm resistor. The rotary encoder has two lines that are attached to pins 3 and 4 to count pulses that come out of the encoder. Pin 5 is used with an internal pull-up resistor in the Nano to read the switch that is closed when the encoder knob is pressed down. We'll be using this to switch between modes in the module.

Note that the NeoPixel must be supplied with 5V to power it. The Nano's 5V output and ground pins are attached to the labeled pins on the NeoPixel. The encoder has two pins that must be connected to the Nano's ground. These are shown most clearly in the circuit schematic.

Once those were working I added some temporary pushbuttons to switch between the four triggers. It might be tempting to assign each button to a separate digital pin, but those are precious commodities. When I have a bunch of push buttons to deal with, I wire them up in series with resistors that become inputs into a voltage divider. The divider's output voltage varies depending on which button(s) are pressed and are easily decoded using one of the analog inputs on the Nano. It's a neat trick that can help you squeeze more out of an Arduino's available I/O. This is made a little more clear in the breadboard circuit schematic.

Lastly at the prototyping stage, I added a potentiometer that allows the pulse width of the outputs to be varied. I thought this was an important feature to add based on how the module might be connected to other modules. Sometimes you might just want a short "blip" or trigger pulse to coincide with each step. For other applications you might want a longer gate pulse to use as an envelope for the audio signal. The potentiometer gives you that flexibility.

For breadboard testing, I just connected jumpers to the appropriate digital output pins on the Nano. This allowed me to quickly check that the digital outputs were correctly positioned using an Oscilloscope. The output side of the circuit will get some TLC when we move the design over to a soldered protoboard in Step 3. For the moment though, let's take a look at the software that actually generates the Euclidean Rhythms.

Step 2: Coding

As mentioned in the previous step, I tend to add breadboard components and write code features to support them a bit at a time. Debugging and refining each feature before moving on to the next. The complete code for the project is included here with extensive comments. You will need to install two libraries using "Manage Libraries" under the Tools menu - Encoder and Adafruit_NeoPixel. Download the code onto your Nano using a USB cable and the Arduino IDE.

Key software features include:

  • NeoPixel ring display of the active pattern selected by one of the four pattern select buttons.
  • The active pattern is displayed in one of four colors (Red, Green, Blue, or Yellow)
  • A blinking pixel rotates around the pattern indicating the tempo and encoder mode
  • A white pixel indicates tempo mode
  • A violet pixel indicates Euclidean mode
  • A yellow pixel indicates rotation mode
  • Pushing the encoder knob in (activating its switch) cycles through three modes of operation:
  • Tempo mode - Where the encoder knob speeds up and slows down the internal clock
  • Euclidean Rhythm mode - Where the encoder knob increases and decreases pulses in the active pattern
  • Rotation mode - Where the encoder knob rotates the active pattern clockwise or counterclockwise
  • Flipping the clock select toggle switch allows the module to be clocked internally or by an external trigger source
  • Tempo mode has no effect on the module speed when an external clock is used
  • A pulse width potentiometer varies the width of pulses generated by the module
  • Fully counterclockwise will produce short, trigger-like pulses
  • Clockwise settings increase pulse widths suitable for use as a gate
  • The module produces four outputs that correspond to each of the four Euclidean rhythms and the tempo
  • The digital outputs can be used to trigger LEDs, or other synth modules
  • Step 4 of this Instructable shows how to construct the module to do both

Step 3: Soldering the Main Protoboard

With the software complete and tested on the breadboard, it was time to start working on the module itself. Breadboards are fine for temporary circuits and testing, but to produce a more durable module that could be installed in a rack requires a soldered circuit board of some type. I used a pair of 4cm x 6cm protoboards to hold the components. One board would hold the Arduino Nano, resistors, power connector, and a quad-operational amplifier to buffer the output signals from the module. A second board would hold the NeoPixel ring and Encoder and act as a "landing zone" for all the front panel jacks, switches, and such. I designed the two boards to piggy back onto each other using a set of male/female header pins on the left and right sides of the board. The header pins carry power, ground, and signals back and forth between the boards.

Begin by laying the components on the board to get a sense of spacing and orientation. Obviously the Nano takes up a good bit of space, and needs to be oriented so that the USB plug is accessible for programming. If you intend to power the board with a Eurorack-style power bus, then you'll need a 2x5 male pin box connector for +12V, -12V, and ground. I wanted to include a TL074 operational amplifier on the board to buffer the outputs from the Arduino. A buffer provides the module output signals with a bit more "oomph" and prevents the Nano from being loaded down. If you don't intend to hook the module to many other things, then you might be able to forgo the op-amp, but I don't recommend it.

The Eurorack power connector can be soldered straight onto the protoboard. The Nano and Op-Amp should NOT be soldered directly to the board. For the Arduino, solder a pair of female header pins onto the board and plug the Nano into the headers. Similarly solder a 14 pin IC socket onto the board where the op-amp will go. This will prevent you from inadvertently damaging the Nano and op-amp during the soldering process. In the future if the Nano or op-amp are damaged, you can simply pop the old components out of their sockets and replace them.

A few comments about power connections are worth noting. Eurorack connectors use Insulation Displacement Connection (IDC) ribbon cable, and plugs have a notch so they can only go in one way. Vin on the Nano should be connected to +12 volts from the Eurorack connector, but the op-amp requires both + and - 12 volt connections. Pay close attention when making connections between the Eurorack jack and Op-Amp to avoid mixing the two voltages up. If you don't have a Eurorack power supply or don't want to use one, you can power the Op-Amp (and Nano) using a pair of 9 volt batteries. Connect one of the negative leads from one battery to the positive of the other. Voila! The unconnected positive and negative leads become + and - 9 volts, and the connected leads are now ground.

Use the provided circuit schematics as a guide for what pins to connect between the Nano, Op-Amp, resistors, and board edge connectors. For pins that are adjacent, create small solder bridges between the pins. Use solid core jumper wire to make connections between components that are further away, carefully bridging the wire and pins with solder as shown in the board photos. Use a multimeter with a continuity test feature to make sure you have connected the pins you intended, and don't accidentally create solder bridges between adjacent pins. Careful planning, patience, and consistent testing really pay off during the soldering stage; and you'll be rewarded with a module that works reliably.

Step 4: Preparing and Connecting the Panel

I'm fortunate to have access to a laser cutter, and frequently use it to make custom panels for our synthesizer modules. I typically lay these out in Adobe Illustrator or Corel Draw, and print copies on paper to make sure I'm happy with component fit and spacing before cutting in acrylic. Illustrator and encapsulated postscript files for the panel design are included here for use with an engraver. Alternately, you could cut a workable panel out of wood or aluminum and drill holes using a paper copy of my panel as a guide. Part of the fun in creating synth modules is making them your own, so feel free to modify the panel to your taste!

The last part of the module build involves wiring up the jacks, pushbuttons, switch, potentiometer and LEDs. I find it easiest to mount components on the panel before soldering stranded wire to them. This helps me figure out wire lengths and routing. Resist the temptation to use solid core, jumper wire. Solid wire is great for breadboarding and making short jumps on protoboards, but it won't hold up to flexing and will break at the worst possible time. Stranded wire is a must for connections between the board and panel components.

As mentioned in the previous step, all panel connections are made to the second protoboard that contains the NeoPixel, encoder, and header pins that link it to the main board we've already completed. I tried to place the module inputs on one side of the board and the module outputs on the other to keep things straight in my head. Using colored wire to match buttons and jacks to the same color used in the software and NeoPixel (red, green, blue, and yellow) is also helpful.

Using the schematic as a guide, solder lengths of braided wire to the board in preparation for connection to the panel mounted components. Most components need a connection to ground, and I make these with short lengths of wire that link all the jacks, potentiometer, switch, etc. together. An additional wire links the grounded connections to the protoboard. Components that need 5 volts can be handled similarly.

Colored LEDs placed next to the module outputs make a particularly nice touch. These are added by soldering a 1k resistor to the long leg of the LED. The resistor is then soldered to the tip connector of the output jack and the other end of the LED is soldered to the sleeve/grounded connector of the jack. Carefully bend the LED leads to position the light in the panel hole. It's a good idea to use heat shrink tubing on the exposed leads to avoid accidental shorts.

When everything is in place, it's time to make the final connections between the panel protoboard and panel components. Carefully solder these and check your work using a continuity test with a multimeter. You want to make sure you have good connections from the header pin where the boards will mate all the way to the jack, button, potentiometer, or switch you are testing. Also check to make sure you don't have accidental connections between adjacent pins or components. A little extra time testing continuity now will save you a lot of head scratching later.

Step 5: Using the Module

Once all the connections between the panel components and panel protoboard are made, you're ready to secure that protoboard to the panel. The encoder should have come with a washer and nut. Use these to tighten the encoder onto the panel. Four smaller holes in the panel should line up with holes in the protoboard. Use small machine screws and nuts to fasten the corners of the board to the panel.

You're now ready to mount the main protoboard onto the panel protoboard. Carefully line up the header pins on the board and gently push the boards together. You should have a nice, tight connection between the boards. If you haven't already, insert the Nano and op-amp into their respective header pins and socket. Be sure to orient the op-amp with its notch facing in the correct direction.

You can test most of the functionality of the module just using the USB cable you programmed the Nano with - absent power supplied via the Eurorack connector. The NeoPixel should boot up with four red LEDs and a blinking white LED racing around the ring. The module starts in tempo mode, and you can speed up or slow down the tempo by turning the encoder knob. If you see four red lights but the blinking white LED isn't moving, make sure the clock selector switch is set to internal. Pressing the four trigger select buttons should change the color of the NeoPixel as well as the default patterns you see. If the buttons don't work reliably, read the comments in the CheckButtons function for suggestions.

Press the encoder knob in once. The blinking light should turn violet and the red lights will disappear. Turning the encoder now increases or decreases the number of pulses in the pattern. Pressing the trigger select buttons allows you to specify the pulses for each pattern.

Press the encoder knob a second time. The blinking light turns yellow. Turning the encoder knob rotates the selected pattern. Press the trigger select buttons to switch patterns and rotate them relative to one another. Pressing the encoder knob a third time returns you to temp mode.

Throughout this process, you may have noticed that the LEDs attached to the trigger outputs on the module blink sporadically or not at all. This is because you have likely not provided power to the module via the Eurorack connector. While the Nano is happily running from USB power, the op-amp isn't powered and is unable to drive the LEDs and module outputs. Plugging in a Eurorack power cable or connecting a properly paired set of 9-volt batteries activates the op-amp and drives the module outputs. The Nano can be unplugged from a USB source when the module is fully powered.

When powered up and running properly, you should see each of the output LEDs blinking in tandem with the NeoPixel ring. Each LED should light up whenever the mode indicator light crosses a beat in the Euclidean rhythm for its pattern. Turning up the pulse width potentiometer will cause the LED to remain on slightly longer. This is more noticeable at slower tempos. If the LEDs are flashing correctly, then you should also have trigger/gate signals available at the output jacks suitable for use with other drum or synth modules.

Here is a really simple demonstration of the module driving Barton Musical Circuit's Analog Drum and Digital Hi-Hat modules and Look Mum No Computer's VCO. I hope my Instructable inspires you to build this or another analog synth module and make some noise!

Step 6: What Else Can You Do?

There are still free analog and digital pins available on the Nano! What else could you do to expand the module's functionality? A few ideas I may explore in the future include:

  • Adding more triggers
  • Increasing (or decreasing) the total number of steps in the pattern
  • Adding a "Tap Tempo" feature where you can tap the additional push button to set the tempo*.
  • Adding a fourth mode that allows you to reduce the length of each of the Euclidean patterns.
  • Adding CV (Control Voltage) inputs to the module that control:
  • The number of beats per trigger
  • Trigger rotations
  • Pulse widths

* Astute readers will note that the hardware to do this is already included in my build. I plan to add this soon, and will update the Instructable with new software when the feature is complete.

Made with Math Contest

Runner Up in the
Made with Math Contest