MIDI Part 3 - DIN MIDI

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey folks is Andrew Kilpatrick and this is part 3 of my series about MIDI and today's topic is talking about the 5-pin din MIDI connection that's the original sort of MIDI plug that everyone sort of knows and recognizes and we're going to be talking about some of the electrical details and a little bit about how the actual bits go over the wire so let's get started so in this video we're going to talk about the electrical design of MIDI we're going to talk about the actual data protocol that goes over the wire the MIDI cable and then we're just going to briefly discuss some of the differences between din MIDI and USB MIDI so let's go to the bench and take a look so the din MIDI protocol is sort of the de facto standard for MIDI MIDI as we talked about in the first video can be sent over all kinds of different types of connections but this sort of the traditional 5 pin cable is still the sort of the standard by which everything else kind of has branched off and you know putting MIDI over USB and network interfaces and things like that but this is where it all began and the protocol that's actually used is the same no matter what you're sending MIDI over it's based on what was designed to go over this connection here so let's look at the electrical part first I actually have a printout from the MIDI spec this is the MIDI spec that you can download on the MIDI Manufacturers Association website let's look at this top part first this is the detailing the receiving side and down here actually I'll just slide this up this part here is detailing the sending side now there are some differences in modern implementation means some different components get used and so on but basically it's all MIDI ports more or less work exactly like this so let's start by looking at the sending side the sending side ah one one thing to keep in mind is if you look at the pin outs here here's the receiving side pin out and here's the sending side pin out so the MIDI in port actually only uses two pins the middle pin here says NC no connect and then these to say no connect and in fact on the setting sending side it's the same situation these two outer pins are not used at all and the middle pin pin too is actually connected to ground so that's that's like used as a shield but you'll notice the ground is not connected on the MIDI in so let's talk about the MIDI out first what is what's really going on here well we've got data this data is coming from our microcontroller or some sort of a digital processor inside our device and we're going to send it these are some representing some buffers it you know it depends on what you want to design the circuit like how you want to do that but basically this gets amplified so that it has enough strength to drive this cable goes through a resistor right here and then it goes into pin five and that's the that's the signal line that actually goes up and down driven by the the actual data signal and then the other pin is actually just connected via a resistor two to five volts which is the power supply inside our system so this might seem a little strange this is kind of like the signals on one wire and then we just got 5 volts on another wire what's the deal well if you look at the MIDI inside up here you'll see that what happens when this signal gets connected on this end is actually pin 4 you'll see is the plus I would call this plus and minus let's put plus and minus on here well the plus-side goes in here through another 220 ohm resistor so now we've got 660 ohms in series with the whole thing goes past this diode we'll talk about that in a second and it goes into this little guy here and this is an opto isolator so this is basically I have another video on my channel talking about opto isolator z-- this is basically two components in one that are not electrically connected to one another there's an LED it's usually an infrared LED like the kind in a TV remote and then there's a photo transistor that responds to the IR light inside and those are both packaged in a plastic housing and then the photo transistor actually sends out our data to the receiving side so the microcontroller in the synthesizer let's say would get the data from here and there's a resistor just pulling this up the values you'd use on modern systems might be a little different than this because this is an older device but basically this is the concept when when there's nothing plugged in or when no current is flowing because this guy isn't isn't on remember when the data is not being sent this sits at the high state so it's the same voltage is here so no no currents flowing these two pins at the same are at the same voltage when no currents flowing this LED is off and this then this photo transistor is off and that means that this resistor here just pulls up the signal to a one-state we've got one and zero so it's just looking like this there's no data being sent that's kind of the idle state for the system when we want to send a bit a zero bit we turn this on this goes low and now this is at 5 volts and this is at 0 volts and now current will flow through here and light up this LED and this photo transistor will turn on and then we'll pull this line here down to ground and now the signal will go down to a zero so this is a 1 and this is a zero and basically just by pulsing this on and off this LED will flash over here and then the output signal will come out and it will be in the same polarity when you send a one here you get a one here when you send a zero here you get a zero here but the only time current ever flows is when you want to send a zero and so this might seem a little overly complicated just for sending some bits across a wire but there's a really really important point and the people who worked on the design for MIDI originally we're really smart in realizing that audio and data don't always get along very well because audio has a large dynamic range it is really easily susceptible to noise because you we can hear really really small disturbances to our audio signal and I think they realized right away that if we started sending five volt digital pulses around between synthesizers and and so on that it was likely to cause problems with being able to hear this data signal leaking into the audio and in fact if you have a Mis wired system then you may actually have heard that noise the easiest way to test for it is to move the pitch Bend wheel on a synthesizer because it sends quite a lot of data or turn a knob and you'll probably hear quite a lot of buzzing noises and stuff and that probably means that there's some sort of a path that shouldn't be there but the basic idea of the opto isolator is that this section of the MIDI in circuit is actually not electrically connected to anything else in the synthesizer because this ground is lifted there is a shield on the cable it's only connected on this end because we've plugged it into this grounded pin here which is connected to the shield on our cable but on this end is just lifted so I the normal terminology for this would be called a telescoping ground or something like that where basically we just ground it shield it from this end it's not really as good as a ground connected on both ends but it solves this problem that current flowing in this side will never flow this is the rest of our the sides are here the current will never flow in the rest of our synthesizer and we won't get a ground loop with any audio cables and that's a really really cool feature of MIDI that actually isn't present in many other protocols for instance USB doesn't have isolated grounds like that unless you use a special device like a USB isolator and in fact I just bought a piano last last year digital piano and it didn't have didn't MIDI ports and I was almost ready to not want it because of that and I thought well you know USB MIDI it's the future or whatever so I bought it as soon as I plugged it into my mixer and then plugged it into my computer I got a ground loop which could only be solved by either using an isolation transformer on the audio which I didn't have and didn't really want to get into or a USB isolator that does something similar to this where it electrically disconnects the two sides and I ended up going with the USB isolator which actually worked but that's a good example why some very simple low-cost circuit like this really is the reason why MIDI can work so well in the studio and it doesn't cause noise and disturbances to the audio signals so that's a really interesting point of about about MIDI and it's one of the things that's really a good design decision right from the beginning just to make it kind of just work really well because fighting with ground loops and especially in unbalanced cables and things that's hard enough in the studio let alone add a whole bunch of data wiring going in other directions around and and and that's that just makes things more difficult so now let's talk about the actual protocol and I'm not talking about the kinds of oops sorry Pro how do you spell that protocol like that that's not talking about the actual messages themselves but the a little bit lower level details of like what actual bits are going over this cable so we've got this cable we know that there's there's a current loop going over that's light up an LED so the signal is actually going all the way around and coming back and we've got this isolated situation here so this is kind of like a remote LED on the end of this cable blinking away oh I forgot to mention the purpose of these resistors and this diode so let's just get into that these resistors are sort of current limiting resistors so that if there's a short circuit on this cable there's a limit to how much current can flow to ground or somewhere else through these connections we don't burn out stuff in our system same thing here that if we plug the wrong kind of cable in here this would limit how much current goes through this LED so that it won't be destroyed by plugging into some onion oh other kind of device with a five pinned in and then this diode here protects this LED from being hooked up in Reverse because as soon as as soon as the if these pins were flipped because we had a badly wired cable this diode would turn on and it would short out this led and then you would get any reverse breakdown on this LED so anyway let's talk about the actual protocol so there's a few things about the middie protocol that are kind of interesting and they're based on things that were popular around the time when MIDI was invented in the early 1980s the most common one that we probably would still at least have heard of if not still used from time to time is rs-232 and that's kind of the de facto standard on old computers for things like mice and modems and stuff like that rs-232 implements some other kinds of voltages that work totally differently from MIDI but the actual data that goes over those kinds of connections is pretty much the same as what we have with MIDI and the way that the bits work whenever we're talking about the ones and the zeros a moment ago the bits basically sit at one here's one and here's zero and when there's nothing happening there's a one there's no current flowing on our cable if we unplug our cable nothing changes but if we want to send data then we want to zeroes and ones and every message is byte-oriented which means that every bite is a separate entity there's no clock it's called asynchronous which means that the clock is sort of known by how fast we've already decided MIDI goes so MIDI goes at 30 1.25 kilobits per second about the speed of a dial-up modem basically and that's as fast as it ever got and it still works fine there's some things called turbo MIDI electron uses to send MIDI faster but basically standard MIDI is the speed and every if you want to figure out how fast things can actually go over the wire at that speed every 10 bits basically equals a byte because we know a byte has 8 bits but there's some other bits that are needed so when we want to send a message let's say we would divide this up into 10 parts so let's call them like this so we have F this is our start bit this is always 0 this is how we know that there's a new bike coming in so as soon as this goes low the receiving side will be thinking oh okay we're getting a new new byte of data okay I need to wait a little bit don't oh I'm going to wait till here and now I'm going to measure the state at this point and at this point and at this point so that we can have time for the edges to go up and down and we make accurate measurement in the middle of the bit and that's basically how it works so it's like Oh 0 ok I got a start bit this is cool and then it says ok I got another bit and I got another one too etc all the way to 8 or 7 sorry and then the eighth bit is the stop bit stop and that's kind of a casanetti check that means this this bit has to be 1 if it's not 1 then it's called what's called a framing error and that means that there's like oh we didn't get a stop bit where we expected it we counted all these bits we recorded each one what they were and we need to get that stop it for the byte to be considered sort of correct there's no error checking or error correction in MIDI so if there's a bit that's out of place then there's no way for us to know about it other than maybe it makes like an invalid type of message but if some of the bits are messed up we could actually get a valid message and we would actually act on it and that might be bad it might cause the wrong note to play or something like that so that's basically how it works most messages I have a little sheet here showing sort of the this is also from the MIDI spec by the way showing the sort of the breakdown of different types of messages and this is the important part up here single messages these are like the system and channel messages that we talked about before that are not the sysex messages these there's only three kinds there's one with one byte one with two bytes and one with three bytes and the first byte is always called what's called a status byte and a status byte is special because it has the most significant bits set to one so when we're talking about our bits over here we get two bit seven if bit seven is one that means it's the status fight and that's how in MIDI that's how we know that we we've got the beginning of a new message so if we plug in our cable partway through a message we just get some random data it maybe doesn't even make sense but as soon as we get a status byte we know okay yep this is the beginning of a new message and what this does is it means that the messages are really short and compact and that's the reason why most messages are seven bits worth of data like Huck CC messages notes or only seven bits the velocity is seven bits because that eight bit is reserved for the status byte it can only be used in a status byte and all the rest of the data is is designed in such a way that it fits within the remaining seven bits and we'll get into the more details on what these are later and how they work in kind of message but basically that's the structure of the MIDI and then there's one more part that I want to cover in this video which is a common thing that people sort of discuss the difference between USB and din MIDI the sort of the five pin MIDI so USB versus din and this is in relation to the low-level stuff that we're talking about today and there's a few things that are interesting about MIDI that make it I think in some ways better than USB in that messages can be sent any time the sending side the MIDI out port decides that system decides when it will send data it can send it any time now it's not very fast but it can send data whenever it wants and the receiving side has to be ready to get that received message anytime it wants it or anytime it's received as well so din MIDI and we've said it's asynchronous in terms of the way that the the actual bits come out but it's asynchronous also in the way that the actual messages are sent there's no need for the other end the receiving side to say okay do you have any messages for me now or anything like that but the video port just blasts out data and that's it in USB USB I don't know how many people really looked under the hood of USB I've done some use the implementation of drivers and so I've sort of seen the low-level details maybe more than I would like to have seen but anyway USB is is polled and what that means is that the host which is normally a computer is in charge all the time there's a there's a special tip on your motherboard that controls all the timing of USB and when data will be transferred and all that kind of stuff and that's that's the the host controller and that means that every device gets asked hey do you have any data hey do you have any data hey do you have any data and if it has some data then it can bond and say yes here's my data and if it doesn't have any data it says knack which is the USB terminology for I don't have anything for you sorry go away and and as much as there's extra time left over and there's not other devices using the USB then it will ask over and over again so sometimes it can actually ask quite often but that's not necessarily guaranteed in MIDI it's more or less guaranteed that once every millisecond every one millisecond it should go to your device and say hey do you have anything for me but a lot of this kind of stuff in us be because of the way MIDI works and MIDI what kind of what kind of USB device a MIDI device is it not won't necessarily go that often so there could be let's say there's a lot of stuff happening on the usb on you've got a hub with a bunch of stuff plugged into it audio devices work differently they have reserved bandwidth that's that's given to them so that they can stream without hiccups and clicks and pops but MIDI doesn't work that way and that means that if there's no time there's no extra bandwidth on the bus sorry you're just your message we'll just have to wait till next time and when it comes around and it says those you have any data for me now you know maybe there's some data that had been building up in a buffer and then that will all get sent now the good thing is USB goes faster than did MIDI so every one millisecond it can have a chance to send up to 64 bytes of data whereas in dim MIDI based on the baud rate we can only send around three bytes so you know there is more data a bandwidth available but USB can also carry up to sixteen MIDI cables over the same connection and because it's got this kind of unknown timing it has the potential of being a little bit more unreliable in terms of how how rock-solid the timing is and you'll hear people talk often about you know old sequencers and running on old computers having better timing or have Hardware drum machines and hardware sequencers having timing and part of its because of how those kinds of systems are made but another part of it has to do with the fact that the data transmission is really a lot more low-level a lot more immediate when you want to send data there it is now because if you want to send a lot of data at once obviously that won't go as fast over din as over USB but in most cases because things are kind of happening notes are not always at the same point clocks happen in between notes and things there's usually enough bandwidth to go around and so that kind of you know there's advantages and disadvantages of each technology but the way MIDI originally was designed I think was really really smart and really advanced for its time it's still impressive to say the least so anyway that's part three did MIDI protocol where we're going to get into the sort of the message stuff and some of the the more sort of meet mid-level details of like how the actual messages are put together and stuff in upcoming videos we're going to cover USB MIDI in more detail as well and and then we'll see where that leads us so please like and subscribe and if you have any comments or questions please leave them in the comment section below thanks a lot bye now
Info
Channel: Shiftedphase
Views: 18,095
Rating: undefined out of 5
Keywords: electronic music, synthesizers, MIDI
Id: V0LmHM54nwc
Channel Id: undefined
Length: 23min 45sec (1425 seconds)
Published: Thu Jun 01 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.