How Do MIDI design

TheWinterSnow

Den Mørke Natt
Oct 22, 2008
3,087
4
38
34
Sacramento, CA
I am currently in the stages of designing my first tube amp (I might give details in the near future) and I have been wanting to utilize purely midi for the foot switching. Unfortunately I haven't been able to find any sources (books/webpages etc) on the protocol and design of midi. If anyone most likely the other EE guys around here know of such sources to help me out then please point me in the right direction. I am more concerned in terms of basic circuit design and protocols that allow MIDI to be used as a switching device and be able to work with other midi devices (loops/pedalboards).
 
Yep, read the official midi developers book with all the specs first(they make you pay for it, ridiculous).

As for using it as an amp switcher, all you need to do is pick out a decent chip that will do everything you need. Take a look at schematics from amps like the Framus Cobra, it gives you a good idea of how the chips need to be set up for midi.

Other than that, it's all about how you program it. It's a little easier in an amp, because you just need to worry about midi in (no need to worry about midi out). There are some good write ups about the programming on a bunch of forums I have saved, I'll have to dig them out and post them for you. Basically the chip in the amp stores amp presets that you save, and when the foot controller sends it a message for that specific note, the amp will call up the settings and switch the proper relays/LDRs/ssr's, whatever. It's kinda nice since the micro-controller in the amp takes the place of those complex switching logic gates, and leaves you to be able to program it in code.

When I was messing with it last, I ran into issues with the chip I chose not being fast enough to clock the midi coming in. So make sure you read up on that area, because it needs to be dead on or else it won't work.
 
I am really liking looking at the Cobra's schematics. I just got done with a class that involved programming an 8051 and the Cobra is using an 8951 which by the looks of it (and from the numbers 80 and 89) they are the same thing but the 89 can handle higher clock rates which is obvious with the 12MHz crystal oscillator. The 80 has a built in oscillator but only runs at 930KHz.

Thats cool to know, my biggest issue then would be to update my Assembly language skills to get the programming up to par.

Now that I think about it though, I have gotten a bit ahead of myself with the whole MIDI thing, considering that analog foot switching still confuses the hell out of me and always has. My initial idea of using relays has brought up the issue that with most amps, they have both the buttons/switches in the front but when the footswitch is plugged in, the FS overrides the panel controls of the amp. Unfortunately I haven't found a schematic that actually shows the whole footswitch setup including the front panel switches. I am thinking that with my initial idea of a digital setup that the switches would be easier to implement, but that is only because I understand the digital side of FS better than an analog approach. So if I could get anything on amp FS circuits that would be great to. I have tried to look it up but by simply typing in "footswitch" in google every other word you type is ignored and you are given a list of foot controllers for sale.
 
Yeah, I actually understand the whole midi aspect a bit better than standard switching matrix designs.

The nice thing about using a micro-controller is that if you have enough inputs on the chip, you can use all sorts of front panel buttons and standard footswitch buttons. You are only limited by the number of inputs.

As for the whole footswitch thing, that's a problem that's dealt with in different ways on different amps. Some amps you literally have to turn a knob to a footswitch position to be able to use it(over riding the front controls, some Mesa amps are like this), or some are set up that the footswitch only works when you have the amp set on a certain channel to begin with(I think my XXX worked that way), and then some just work over top of each other(my SLO switching for example).

Most of the switching logics confuse the hell out of me, which is why in any build I do over 2 channels, I'll be going the microcontroller route. Much easier to write a few lines of code :)
 
8051! They still use those? I remember studying electrical engineering, I spent a lot of time program 8051 microcontrollers and they were old then. That was years ago. I don't remember anything, can't say I've ever touched one since!
 
8051! They still use those? I remember studying electrical engineering, I spent a lot of time program 8051 microcontrollers and they were old then. That was years ago. I don't remember anything, can't say I've ever touched one since!

They are still used for training purposes because they are very simple and still use the same code that is used today. Like I said the Framus Cobra is using an 8951 for the MIDI switching. And yes the 8051 is very old. IIRC they where originally made by Intel back in the late 70's/early 80's.

@Wolfe: I am the same way, the MIDI setup seems to make much more sense and seems to be immune to the issues that analog seems to have. Looking at the Cobra schematic they have the front panel button on one port and the midi in and the footswitch on another. The programming can selectively use or ignore inputs depending on priority of information being sent to the chip which will be decoded to the output so that the switching can take place. It really comes down to programming.
 
The programming can selectively use or ignore inputs depending on priority of information being sent to the chip which will be decoded to the output so that the switching can take place. It really comes down to programming.

Yep that's all there is to it. You could even completely forgo the MIDI if you wanted to, but since the microcontroller is there anyway and it's just a little more work, might as well. I've been trying to source out a decent chip to use for my 3 channel amp, lots to choose from but I don't know if buying the programmer is going to be affordable yet.
 
I also like how on the Cobra they use Opto Couplers instead of relays which as advanced as the switching will be on my amp would be a much better candidate. I have thought of alternatives for relays considering with all the switching I have going on relays aren't as practical.

You might as well program the chip for midi so then that way you could control the amp with a third party foot controller along with loops and other effects. That brings the whole concept of using midi to switch more than one device at the same time through preset patches.

For Microcontrollers the easiest route is the 8951 (AT89C51 to be exact) like the Cobra. When I was taking the microcontroller class we used a program called ProView32 which is an assembly microcontroller compiler that I believe is cheap. There is ven a free version but it is limited to code size however I believe that programming for MIDI would be small enough to work.
 
Unless you really just want to write it from soup to nutz why not find an OMAP based dev board and attach a USB midi controller. You could dev crank it out in C in half the time. Hell you could throw in a bluetooth radio and make the whole thing controllable by your iphone.
 
So at this point it looks like I need to get my programming up to par, as I now know what is going on in a hardware sense. From the books available and a lackluster information on the internet, the whole programing language that goes behind midi is still a big black box. Wolfe I have no clue what book you referred to but there is no such book. There is "The MIDI Manual" and "Ultimate MIDI" but those are the only two that show up in Google and Amazon and even then, the books table of contents don't seem to go over any of the core topic involving programming for guitar amps and foot controllers.

I would really like to see some code that goes behind the whole setup and which functions are used (PC vs CC) to change parameters.
 
You need the 'Complete MIDI 1.0 Detailed Specification Book'. They charge some ridiculous amount for a hard copy (like $60?).
 
And actually, this is probably all you will need when dealing with midi coming from a controller- http://www.midi.org/techspecs/midimessages.php#3

So as long as you have the chip set at the proper clock speed to catch the incoming controller message, you just have to have your program decipher what that controller change message means. Other than that, there is nothing else midi you need to worry about with the coding. The rest is on you making the proper loops, storage functions, etc.
 
Still there is some programming that goes into it. When the chip first boots up it has to go through functions and have ports give it information so that it knows what to do. For example, on startup, you select which MIDI channel you want the amp to receive on by holding down a selection of buttons on the amp (or on Engl's case having DIP switches that you can program). There has to be code for all the variable channels, fortunately for an amp we only really deal with CC so that means only specifying which HEX code specifies for which channel. Regardless code has to be written so that if say you want the amp to use channel 1 that is will only respond to B0h and if say channel 2 then B1h all the way up to BFh. There also has to be some source written so that the microprocessor knows that the information is 3 Bytes wide with the first Byte being greater than 127 and 2nd and 3rd Bytes being less than 128.

If the amp was programmed to run on channel 3 and you wanted to change to the clean channel which the manufacture has specified to CC #20 which is normally undefined, then when the controller sends the message to send the message CC #20 on channel 3 would look like: B2147Fh, B2 meaning Control Change on channel 3, 14 meaning control number 20 and 7F which could be any value for the LSB as it will be ignored, but a value of 127d is said to help with compatibility. Now the program has to know that the first Byte specifies not only the task but for which channel, the program has to accept the channel that it has been preset to and ignore the others. It then has to recognize the 2nd bit as being the specific CC command. Now after that is all said and done the program has to decode that CC command into a Port out so that it can go to a relay or an opto-isolator so change the channels or other circuitry. So my biggest concern is getting the program to differentiate between the Status Byte and the Data Byte(s) and how to ignore the Status Bytes (and the subsequent Data Bytes that goes with that Status Byte) which do not apply to the programs currently selected channel.
 
It sounds like you are on the right track, but from what I recall in my research a few years back, it can actually be done a lot simpler.

I'm thinking about buying the Atmel STK600 developers kit to start playing around with... I downloaded AVR Studio and starting writing up some code, but until I fork the money over for a developers kit I can't really test anything out.
 
Is there a fully midi capable tube amp on the market? I thought that might be kinda cool, but expensive.

There are tons that will do a lot of channel switching and also switch out fx loops/tone shifts/etc.

Or do you mean one that will change pot values and all that as well? I think the closest you can get to that is with the ADA and Mesa tube pre's.

I seem to remember a midi rack tube amp with motorized pots a long time ago, was probably very expensive.
 
Is there a fully midi capable tube amp on the market? I thought that might be kinda cool, but expensive.

In terms of switching, first amps that come to mind are Engl. In terms of everything being midi capable like motorized pots, that is a different story.

Or do you mean one that will change pot values and all that as well? I think the closest you can get to that is with the ADA and Mesa tube pre's.

Unfortunately Rnadall Smith has a patent for that, I don't know how because the circuits existed before, he just pateted that circuits use for all audio, not just guitar amps.
 
Winter Snow-

I dug up a bunch of the old stuff I had worked on. When it comes to channel switching in the amp, all we have to worry about coming from the controller is 'program changes', not CC stuff as I stated above. CC would be to change values of pots and things like that.

So all we need to catch from the controller are the 0-127 program changes. This allows you to store 128 different channel/switching/etc programs on the amp (my Herbert did it this way, don't know about the others).

So we just need to wait for a 0xC0 to 0xCF byte, then the next byte would be whatever preset(0-127) we need to call up from memory. Now dealing with the low nibble part of the first byte(the midi channel) is pretty simple, we simply have the chip initialized beforehand to only care about one specific channel, else the message gets ignored and we wait for another message to come. We can get the amp set to the channel we want by putting the amp in a 'midi mode' via a switch, and then by toggling whatever momentary switches we already have on the amp a certain way will set the channel (once again my Herbert did it this way).