Making my Big Button Cartesian Sequencer

Hi folks, I am just getting my parts in order to put together one of Sam’s Arduino based 8 step Keyboard Sequencers in the Kosmo format.

Now I firmly understand the principles in play with this one, and have over the past few weeks been toying with the notion of putting together a ‘Step Board’ pcb layout and a ‘Main Board’ that the step boards are connected to via a bus. This would also afford me the ability to add a few features that I would really want in an 8 step sequencer.

Some of these are easy enough as I can implement in software or with very basic electronics. A switch to allow you to turn off an individual steps gate output and a random mode that activates via a momentary push button that tracks where in the sequence it should be so when you release the button (or CV as that would be easy to add) it snaps back to where it would have gotten up to (I.e. push the button before the sequencer should transition to step 6, hold it for 4 random steps, release and on the next trigger it snaps back to step 2). Maybe also add its own internal clock source and normal it to the clock input with a latching switch to act as a ‘Start/Stop’ so it can run by itself and you can stop the sequencer at will (and an obligatory master clock output to synchronise other things even if the sequencer itself isn’t running). Not sure yet if I would have to use a bigger Arduino than Sam’s nano, but that’s no biggy.

Problem is I am falling down on the bloody electronics for the more complicated (I think) feature I am really after.

What I really want it to do is give triggers and not gates on the step outputs, bussed to a master trigger out that both outputs any triggers that are firing, but also convert the master trigger into a gate that I can control the length of via a master ‘Gate Length’ pot. If the gate is longer than the step it just retriggers after the step finishes (so always making sure it goes to 0v briefly at the beginning of its cycle if it would otherwise be high). This is, however, waaay beyond my abilities.

Now, whilst I have a good grasp of the basics, and can follow a stripboard layout or a silkscreen and handle a soldering iron just fine, analog circuit design is something I haven’t done for a very long time, and even when I had to do it at school it wasn’t exactly complex.

Can anybody assist in working this out? Links with decent explanations would also be much appreciated.

Thanks!

1 Like

Probably, but I’m having a little trouble following the worded description. One thing that often helps is to lay it out in a block diagram first, then the problem becomes modular-just like the instruments you’re using it with, so the mindset is similar! If you drew it up and posted it, I’d be willing to help anyway I could. I’m sure others would too!

1 Like

Thanks for getting back to me!

Yeah I relised after posting this could probably do with a diagram and a better explaination of what I am thinking.

So, first things first, its based on one of Sam’s projects - https://www.lookmumnocomputer.com/projects#/sequencer-keyboard

I’ll build the front panel in a similar layout, only I envision dropping the LED that shows the active channel and combining it into an illuminated push button and using the extra space to put in a switch to control whether that individual step produces a trigger or not (so I can use it rhythmically as well as for CV).

Each step will have its own (identical) PCB chicklet so I can use alpha pcb pots from thonk to attach them to the front panel, and the gate and cv busses will be a ribbon cable between the step boards. The step board also needs a little circuit that puts out a trigger when it first recieves power, then drops to zero and then the trigger select switch is just in line with the power input for this trigger generator (do I just use a cap to turn the +v into a spike?). The power is supplied either directly from the 5v pin output from the arduino, or using that to connect it to the 12v line (I think this is one of the things transistors are for… but I may wrong) to give it a wider cv range. The program running on the microprocessor will be turning on and off the outputs on recieving a clock trigger so that only one step recieves power at any time. The way it does this is influenced by the forward/backward/random/reset controls.

There will also be some extra switches on the front panel. One in line with the arduinos clock input to serve as a run/stop switch and one to a digital input to trigger my random mode.

The main board has the clock generator circuit, the arduino itself, and the bus outputs and buffers along with something that can convert a trigger into a variable length gate that you can control with a pot, along with power conditioning for the whole module (not drawn)

I have also noticed now I upload this that I have left out the reset input to the arduino, so it actually needs 13 inputs, not 12.

Thanks again for taking an interest!

2 Likes

If it was me I’d move as much of this as possible to the software (since you’re already using the Arduino.) The first thing that comes to mind is that if you want to have a variable length gate, it may be best to program the clock into the sequencer. If the clock is external you can kind of have a predictive algorithm based on the last few beats but if there’s a sudden shift in tempo that sends a clock pulse before the last gate has closed, it’s going to get ugly. Using a clock internally would let you have one pot for the tempo and one for the gate length. There’s a similar bit of code here:
Dual Timer Git Repo
I used an encoder, but it should be easy enough to see how to modify it for pots. I would probably map an Analog In to minimum-maximum percentages to set the pulseWidth variable by multiplying that by a calculatedInterval value. If you used the external clock, you could track the last two or three pulse intervals to predict the next one and multiply the pulseWidth percentage times that.
Having a master gate could be pretty much this clock pulse on a single pin, with a check that the gate percentage was <100 before it turned off the clock.
Schematically all you’d have to add to Sam’s design would be something like this:


(Note that “Reset” isn’t an input really-it’s built into Arduino as a to-ground reset so it doesn’t have to be an input.)

2 Likes

I can totally see the logic of using the Arduino to produce the gates, looking at the code you have posted there it would seem pretty simple. I could even have it analyse the frequency of the clock to produce multiple triggers per step a la the Ryk M185. I will still want to add something to the step boards to convert that gate to a trigger though, so that the individual steps are producing them too rather than whole step gates.

How fast are these arduinos at actually processing lots of conditional statements though? If I am running the clock, the sequencer with 4 possible modes depending on input and the trigger to vari-gate/multi trigger function on the same microprocessor board that’s going to end up with a lot of nested if’s and read/write pin operations every cycle through the loop.

Oh and the reset I am talking about is not to hard reset anything, but to send the sequencer back to Step 1 on the next clock pulse if it’s high, or has been high since the last step was activated

2 Likes

Maybe I’m not grasping what you’re saying Here:

But if I am, then you’d probably want to use something like one of these instead of the nano/pro/micro format:

That way you have a separate digital pin for each step’s separate gate. Unless you’re running polyrhythms you don’t have to worry too much about processor speed. With a monophonic sequencer you could get away with using delay() for the length of the gate.

I think that may be going a little far. This being my first (properly) DIY sequencer I think keeping it as simple as possible is the aim of the game. Although I may go and do something similar at some point in the future, possibly on a more usable 16 step one. I would love to make something like a Clee at some point, I always liked that shift register design, and that would benefit from the extra flexability.

On this one though, there is a jack output wired (essentially) to the power of each step. This means there is a very basic gate out on each individual channel, which then get sent down the Gate Bus on Sam’s orginal design. Now I don’t want to do anything fancy here, I just want to turn the per channel output from a gate to a 5ms trigger pulse that occurs when power is first supplied to the step board. This then gets routed down the bus to the arduino input firing the vari-gate output as well as being wired in parallel to a master trigger output.

To make things super easy I might even (for the first prototype at least) just wire the gate out from the arduino to be a fixed length set by the length pot, rather than fractional based on the clock input. Then make it so that the the gate generators code ignores triggers when its output is already high, and only fires when its low. Then if the length is too long for a single step, the sequencer will sound like its missing steps, but you can just shorten them with the pot control to get a length that is pleasant. Any retriggering would then be based on the clock at least, preventing odd rhythmic behaviour. This would also mean I could add super simple CV control of the gate length by adding a vactrol across the control pot.

1 Like

Works for me! As the wise man said-“Don’t be afraid to try it!”

Well, in order to have the features I want I am going to have to use an Arduino Mega in order to have the inputs and outputs I want, so thats arriving tomorrow and I can start making it work with dummy led ‘steps’ on ye olde breadboard.

I might end up putting variable gates on the individual steps since I will already have the outputs in the controller board so I might as well, lol. I figure if I route the steps power through a simple voltage divider on the step board, and bus it to an analog input, along with a switch to set whether the step is active going to a digital input. I can then set the gate value per step, then send a trigger from the boards extra digital outputs to the relevant step trigger out socket… I’ll be doing an updated block diagram tomorrow, before actually breaking it out into schematics over the week and putting together the code.

1 Like

You could consider using a couple shift registers to get more out of your I/O.

74HC595 8 BIT SHIFT REGISTER IC
https://www.taydaelectronics.com/74hc595-8-bit-shift-register-ic.html

If you get what you want from the MEGA, go with that if you dont want to shrink your design. Just know you got options when it comes to this sorta thing.

1 Like

Yeah, I have a few different notions for a sequencer design, one of them is indeed a shift register based design like the Clee where you can set the voltage range on the channel pots, then using shift registers to activate multiple steps simultaneously and sum them, but that shall come later.

I spend all day at work programming in C so I figured a nice simple arduino sequencer from the ground up is probably the best way to start. Custom PCB’s for it will also be easier to design and fabricate if I keep it simple. I intend to use my Sainsmart desktop CNC to make them as a challenge for the prototype which thus far has only really been used to make my rail holders (to ensure proper spacing after ballsing up my first cases measurements) and a few very basic flashy light with a rate pot kind of electronic toy projects.

Either way, the Mega has arrived (along with a 0-Coast T-shirt that cost so much more than I expected, thanks customs) so I shall be starting to hack it all together when I get home.

3 Likes

Ok, I am having some issues with my clock code. Namely I want to be able to both clock the module internally from the Arduino and also from an external clock.

The way I had initially thought to do this was by setting up one of the digital out pins to put out clock pulses based on time elapsed and then having it come out of the arduino, normalled through a jack socket for the external clock in which then routes through to the clock in pin. The main loop() checking if it has gone high since the last iteration. That way I could have it disconnect the internal clock as soon as an external clock was plugged in, and then cut back in as soon as it was removed.

What I had failed to consider is that an Arduino (being a microcontroller and all) has no way of truly multitasking, meaning that whilst I was generating the clock out, the clock in would not be detected because my code was off doing something else and not looking for it.

Now I could just use a seperate clock source, either in the form of an analog circuit or a second Arduino (most likely the cheapest nano I have kicking round in my spares box), but this is not exactly optimal when it comes to power draw, especially considering the main sequencer is being run off a big Mega board.

I think ISR Interrupts may be the answer, but I am having issues finding examples. Another solution I am considering is having the Clock In alter the internal clock rate to match freqency of clock it is recieving, which would give me a little breathing room when it comes to timing in the software and mean that if it takes a fraction of a second or so to update the delay may not actually be noticable once the thing is up and running, but that seems like a huge ballache.

Has anyone else managed to pull off anything like this? Ideas?

Whilst I am letting this percolate I am just ignoring the issue of the clock and cracking on with the sequencer code monitoring the clock in pin and assuming an external clock, but it won’t be long til I am back tearing what is left of my hair out

[EDIT] Just realised that if I alter the internal clock rate to sync with an external source, suddenly I will get odd behaviour if I tried to clock it from something like a Euclidian rhythm generator, so thats out :frowning:

2 Likes

I don’t have any ideas to offer, but I just love following along. Sorry about the hair loss, though :stuck_out_tongue_winking_eye:

1 Like

I did something kind of like that on the “Big Knob” sequencer that I shared in the Patreon forum right before this discourse was started:


I don’t know if you can reconcile it with the internal clock/sequencer option though.

2 Likes

Yeah, I had though about that one, it wasn’t an internal thing, but more running the clock out to the normal pin on the clock in socket, so the only way to get a clock at all would be through the clock in pin, thus sidestepping the need to change the pin modes. There will always be one outputting the internal clock, and that is referenced nowhere else but in its clock generation code, and a second pin for inputting in the clock that will drive the sequence itself.

I’m just looking over your code now to see if I can find any relevant inspiration. Ta!

1 Like

And lo! It most certainly does!

So, if I am reading this right, and please correct me if I am wrong, when I run the setup() I want to set up an interrupt on my clock input pin using an attachInterrupt() on the rising edge of the pulse, have that fire a function to change the state of a global variable (something like a boolean called clockTriggerWaiting).

Then in my main loop, whenever I iterate round and want to know whether I have recieved a clock pulse to trigger on I would check the clockTriggerWaiting variable to determine if a clock has been recieved since the last time through the loop before (as part of the function called on the vaiable being seen as true) setting the clockTriggerWaiting back to false to wait for the next clock pulse and then run the code to actually advance the step and generate the step triggers/gates etc.

2 Likes

I think the global would be more like “currentClockStep” and the ISR would advance it, something like (for 16 steps) currentClockStep=(currentClockStep==16)?0:currentClockStep+1; Then you set the outputs based on the current clock step in the main loop. The issue then is switching back and forth between the internal clock and the clock input. The easiest thing to do would probably be to read a toggle/slide switch on another pin (if you have one to spare) to decide which source to use and bifurcate the main loop based on that.

I thought that myself at first, but I realised that since my steps are going forwards, backwards and various randomly (whilst tracking the step value in accordance with the forward/backward inputs) depending on its mode, I don’t think a ternary operator would adaquately handle it. Plus I would rather not store the next step value in a volatile variable.

If I make sure that my main loop is fast to execute I am hoping I won’t end up with a noticeable lag.

1 Like

Well, a quick update for anyone following along with my efforts on this one.

After much effort over the weekend, I managed to get my arduino to behave as both a variable clock and run the sequencer circuits, only to find that the interrupts that I was using to drive the step changes was causing a drift in my timing that started off very small but would soon drift longer and longer as more interrupts paused the internal counter being used for the millis() function. SO… long story short, I am dropping the clock portion of the module and spinning this out into its own (probably 5cm wide) little companion module as it will give me space to actually do more than just a single clock out, maybe some different divisions/multiplications or euclidian rhythms etc, but that can wait.

Instead, I am using the extra inputs on the Mega I picked up for this project to build the sequencer as a 16 step cartesian sequencer (so the steps laid out in a 4x4 grid a la the MN Rene Mk 1 only with arcade buttons rather than the touch plates, an X clock in and a Y clock in for either direct control over movement or a variable ‘pattern’ mode plus random) with two channels of CV control on each step and triggers firing on changes in X coordinate or Y coodinate and a variable gate firing on steps where a toggle switch is active.

I have worked out the new panel layout (it fits on my exsiting 40cm panel blank thankfully) and am now waiting for payday so I can order a load of extra pots (since I have essentially doubled the pot count). I’ll upload my 1:1 layout showing the panel if anyone is interested so you can get a better idea of how it will work, although be forewarned it is hand drawn on graph paper (so I could put knobs on the sheet and see what the final spacing would be like). Obviously will also post the code for the arduino and the eventual final schematic when its properly working in case anyone is mad enough to try and make their own.

5 Likes

Yes, please. Share anything you have :heart_eyes:

3 Likes