16 step MIDI Sequencer Planning

Hello everyone, I would like some feedback regarding a project I'm planning. I'm currently setting goals and posible features I can include on the project and setting up design boundries, but I doubt about my ideas, so I would like to hear anyones opinion regarding this.

What I want to build? A 16 step MIDI sequencer that outputs MIDI notes over standard 5-pin MIDI connectors, but not just that. I'm aiming to make the interface of this device like those old synth sequencers with similar features.

There are a few designs I thought of for this which I'll describe in a moment. The device would feature 16 sections to control step parameters, such as note value, velocity value, modulation value, a skip/on/off switch and a manual trigger switch, plus a led to display the step is active or not. I was thinking to include note duration too for each step, but I dropped that for now since I would include that in a global section. Global section would have start/stop/reset buttons, tempo knob, sync midi button and channel selector. Also, in the global section I would put 4 or 8 general purpose knobs to send CC values for custom purposes on the software/synth being used. MIDI in/out to hook up other instrumets with it and memory banks to store 4 or 8 sequences and switch between them on the fly.

Those are the features I would like to have, maybe a few more but lets seattle there for now.

I have been researching the past 2 days about MIDI projects with Arduino and the posible problems I would have. There are a lot of resources regardin MIDI and related stuff, but I'm in the blanks about other design features. To start with, most of the knobs would be rotary encoders, simply because given the memory recall feature, if I use potentiomenters, as soon as I move one, it would jump to where the potentiomenter is, instead of adding/substracting per units. Rotary encoders don't have position so I think it's best for this purpose. Problem is that it seems complicated to handle a lot of them. I was thinking to include a small LCD panel to provide feedback of the setting being changed, so if I move a knob, the panel would display information about what values are being set.

So, first design I thought of was with 1 Arduino (probably the Mega, but started thinking about the Uno), then get shift registers of 16 bit to hook up each step's parameters, then loop on the registers to get the information of changes on a step and construct the MIDI command. In between any change to user defined knobs should go along (with interrupts maybe? Haven't read a lot about that yet). Problem with this is that it seems complicated, and I might be pushing the microcontroller too far for this application.

Second design would be similar, but using potentiomenters and dropping the memory feature. I've seen miltiplexers for analog signals and seems more simple to implement. Would be a pitty to drop the memory banks, that would be a key feature on any sequencer.

Third design would be quite complex, using more than 1 Arduino. In fact 18, 16 for step paramters, 1 for global parameters and display and 1 for the main MIDI handling. This way each step can have more independent and responsive controlls, and the main controller just pulls information from them, without needing to pull information from each knob. In this setup, memory banks are smaller, and can be stored in the steps themselves and recalled any time. Finally, for this I would use smaller Arduinos (like the nano or even smaller) and a Uno or Mega for the main controller. Pretty much a modular setup, that can be easily extended with more steps if needed. This setup also lets me push logic and be more flexible on each step, allowing me to posibly include more parameters or feedback elements like a 7-segment displays to show values.

I'm kind of liking the last approach, it would be expensive, but a lot simpler in terms of code and extensible, since I'm delegating responsabilities. Figuring out how a single step module would be constructed allows me to replicate that and build it progressively. The cost of it would be similar to a standard piano-like MIDI controller, but the value would be much greater since it has what I want.

Is it crazy that last approach? What do you think? Some sort of interfacing would be needed between internal modules, but I'm confident I can work around that.

I would prefer to avoid potentiomenters, mainly for the memory recall problem but it might also require much more power to sustain operation, leading to develop a specific power suply for the potentiomenters.

I've been reading about shift registers, and I think I get how it works, although I need to figure out how to scale the design, but I think the first approach should also work. If I got it right, I should be looping between 16 bits x 16 steps to get changes on parameters and store that internally. I fear that would produce delays in other processings thus rendering the whole project as useless. There's not much information on how to handle many rotary inputs like that, some people ended up using potentiomenters, which could get the job done, but to me, rotary encoders are better given the fact that position is not needed here.

So, I guess that's what I have on mind right now. I should note, I'm a decent developer, though not so decent at low level languages, but I'll get the hang of it, and as for electronics, I know the basics only. Much of that will come while actually working and researching about that.

Any comment will be appreciated. And if I manage to get started on this, I might post progress and share findings.

Thanks

Using more than one processor is just silly. However multiple rotary encoders are difficult to handle due to the fast response they need. You need to use interrupts and I would use an SPI port expander chip because these have an interrupt output that changes to signal any change in pin level on the 16 inputs of the chip, then your interrupt service routine only has to look at the port expander to see which one changed.

Remember you only have two hands so the number of actual pulses you have to cope with will be small.

Thanks for the reply. I've looked up a bit about the expanders, they seem to use analog pins on the Arduino, so that's a good way to make usage of more available pins. Interestingly, they have address too, so it seems that I could connect multiple expanders and manage them by address to know what has changed. However, it seems software demanding to assert first which expander has changed and then assert which rotary control changed and how.

Good point on having 2 hands only, I entirely skipped that.

In this setup, I imagine that each step control group would be simply triggers that changes internal state of the sequence. Doing some numbers, a single expander allows me to hook up 8 rotary encoders (2 pins per encoder). So 2 expanders for a full row of encoders. Given I would have 3 rows, that would be 6 expanders so far. Plus 2 more for the gate controls, I figured I could represent a gate control with 2 bits to represent the 3 posible states skip/on/off. Which makes a total of 8 expanders for all the step controls. An article I read a few moments ago mentioned that you could put up to 8 expanders on a single bus. I still need to figure out how that would be, but it's a nice start. I can imagine handling interruptions on up to two expanders at a time and asserting which parameter changed.

Do you think it can be done with a single Arduino?

I was thinking last night that it would be nice to make stand alone interfaces for the rotary controls. An extra circuit that already pre-processes the rotary input and keeps a count for the parameter, so the Arduino would read that count instead of reading the rotary and figuring out what happened. But some schematics I found implement chips I can't get easily on my region, so I dropped that for now. Don't know if anyone did something like that.

I'll keep reading about expanders and try to think how I can achive the goals with them, seems like the way to go.

they seem to use analog pins on the Arduino,

Well the I2C bus uses the A4 & A5 pins if that is what you mean. BUT all the analogue pins can be used as digital inputs and outputs as well as analogue inputs. Note they do not work as analogue outputs.

The MCP23017 is a port expander that uses the I2C bus. The MCP23S17 is a very similar device only it uses the SPI bus. I would recommend that latter as it is much faster to get data into and out of it. They both have three external addresses and so you can connect 8 of them at once without resorting to any other tricks.

However, it seems software demanding to assert first which expander has changed and then assert which rotary control changed and how.

Yes that is a good thing. The interrupt output can be monitored by a simple pin read or all combined together and generate an interrupt. This is good because just reading all the pins on all the expanders takes time and you save the time because you only read when there is something worth reading.

you could put up to 8 expanders on a single bus. I still need to figure out how that would be,

You set the three external address lines to a different combination of HIGH and LOW on each chip.

Do you think it can be done with a single Arduino?

Yes.
It is very rare that you need more than one Arduino, most of the time it is more trouble than it is worth.

Grumpy_Mike:
Yes.
It is very rare that you need more than one Arduino, most of the time it is more trouble than it is worth.

That was my biggest concern, but it's all fitting toghether now and I think I should be able pull this off.

The idea of multiples Arduinos was originated by the fact that some components might be hard to find, and shipping from foreign countries to here is complicated usually, plus it costs even more than it should. That already happened to me while trying to build a theremin a while ago. Had the schematics, PCBs and tools, but I couldn't get some key componentes and finding replacements wasn't easy. I can get as many Arduinos as I need, so the modular design was kind of a posibility, quite complex though. In any case, a quick search led me to find that I can get both MCP chips quite easily, and having an Arduino Mega with that many extra pins should allow me to sort out as many encoders as I need. The rest is just coding.

Out of curiosity, the SPI bus concept seems to use a few pins to orchestrate multiple chips connected. Most of the articles I've seen so far seem to use always the same pins on the Arduino. Is it that the Arduino has these pins specifically for those purposes so in essence there's a single SPI bus? or is it posible to have a secondary bus with other stuff connected to it? As long as all chips share the clock, a program should be able to define another SPI bus in the same fashion and read/write to them.

the SPI bus concept seems to use a few pins to orchestrate multiple chips connected.

No it uses more pins than the I2C.

Is it that the Arduino has these pins specifically for those purposes so in essence there's a single SPI bus?

Yes, there is hardware inside the Arduino that handles the serial / parallel conversion and this attached to these pins.

s it posible to have a secondary bus with other stuff connected to it?

Yes if you drive it by a software emulation of the SPI bus, this is known as bit banging the bus.

As long as all chips share the clock, a program should be able to define another SPI bus in the same fashion and read/write to them.

No that is not how it works.

But there is no need you can put banks of 8 port expanders on the same bus, all you have to do is to have a separate CE signal for each bank. So that is for each extra bank you need another pin.