Is this PNP transistor in my MIDI IN correct?



I'd like to verify if my MIDI IN circuit is correct. I tried to stick to the electrical specification.
But I also read that a PNP transistor will complete the circuit and specification. So I'd like to check if I've done it right (or if anything else has to be changed).

It will be used with Arduino, Teensy and STM boards if that is a neccessary information.
Also I'd like to be able to power it with either 5V or 3.3V

I don't think your circuit is correct. I can't read the name of the transistor you are planning to use, and the pinout doesn't make sense to me, but if it is a PNP transistor, there should be a resistor 'in line' between the transistor and the opto-coupler.

Where did you read that ?

That should be fine. Midi itself will be powered with 5v , but that is all fully separated by the opto-coupler. Whatever logic you want to use beyond that is all up to you.

Specify the parts you want to use. If you are using a BC807, it appears the arrow is pointing the wrong way to me, but that may be due to the poor resolution of you picture. I still think there should be a current-limiting resistor between the BC807 & the H11L1, or both will burn out.

1 Like


Thanks a lot for your answer.
About the resistor in line between transistor and opto-coupler: Is a value of 10k correct or do I need to pick another value?

I read about the PNP here: MIDI 3.3V circuit - #8 by mirasderbissalin

I have been making MIDI interfaces for over 30 years. The TX side should actually pass through a PNP transistor in order to fully meet the specifications for the current drive because you don’t say what processor and what pins you are using. Some processors have a limit current capacity and your circuit as it is might exceed this. At best this circuit is a fudge.

Edit: I just realized that might be for MIDI OUT. So I could just remove the BC807 and 10k resistor? Should I leave the new resistor where it is or is the 280 one sufficient?

I selected a BC807 but I just picked it to have the symbol. Any smd based one will do.
Sorry about the bad resolution I will improve that for the next post. I may look like the arrow is in the wrong direction but that is indeed the resolution. It is facing downward on the original picture.

I hope it is better on this one. I already added the resistor but am not sure about a sensible value.

I have two options for MIDI out as well. One with buffer and the other with NPN transistor.
But I'm not sure which one is "better" or they are "equal"

The PNP transistor inverts the signal. There are other ways to do that, and with other Opto-couplers other solutions make sense.

I'd say it should work. You are only opening up the transistor with it.

1 Like

The BC807 is connected as an inverter (NOT). The emitter is returned to Vcc - if the base voltage is >= Vcc - 0.7V then the device will turn off and its collector voltage will be logic 0. If the base is < Vcc - 0.7V then the device will turn ON and its collector voltage will be a logic 1.

1 Like

You should not use 3.3v for midi-out. I know that with those resistor values it should work, but you lose a safety feature. You circuit won't be protected against short circuit anymore, which with male-5pin-din plugs isn't that unlikely. Even if you are using a 3.3v board, there will more than likely be a 5v power source available with which you can power a TTL, and which responds to 3.3v logic levels just fine.
If the BC817 is fast switching enough (it is as fast as a BC807, but also there i have some doubts), it doesn't matter, but a 74LV1G14 is quite a lot faster and for sure fast enough

1 Like

First of all: Thank you very much for all the info and insights.
You are right a 5V power source will somehow be available and I like to play safe first.

I'm not sure if adding a PNP as inverter for MIDI IN is what I want so I removed it on the revision. But should I add a resistor?
Also I will keep the MIDI OUT with 5V only and the buffer. (I will compare the buffer I had and the one you mentioned)

Ah yes that does look a lot better.

The original specs did not have a 3.3v method. Of course those logic levels were not common in those days, but you understand my objection to those '3.3v specs' . The creators of midi were protecting their own equipment that was going to get connected to 3rd party equipment using 3rd party cables, and that is what they came up with.

No that is fine like that. If you find that you do need the signal inverted, you could move the pullup to between GND an pin 4 of the Opto-coupler, connect pin 5 to VCC and connect RX between the pulldown (which it is by then) resistor and pin 4.
I am not familiar with that specific Opto-coupler but confident they all work the same way pretty much (but no guarantee of course)
Midi is a bit funny with signal inversion. It is the data pin going 'LOW' that lights the LED in the Opto-coupler opening the optical transistor up, so as far as i could tell the signal does not need to be inverted, and the circuit is correct the way it is.

If you have a 74LVC1G07 as you show in you schematic, then it is fine. the 17 is a Schmitt-trigger as far as i know, though the wiki-list does not show that as a spec. Ordinary buffers are fine for a true digital signal, the Schmitt triggers were used in the days when generating a 'square' data signal was not nearly as easy as it is today.
If you have a 'retail' source for 74LVC1G07's let me know, i would interested.

1 Like

I surely will let you know.

The other thing I have is the same schematic but varied for TRS.
I'm tired of those different "standards" and want a solution that will take Type A and B
or on the output Type A or B selected by a line.

Here is what I cooked up depending on your and other people's input:

Seems like you are going for an input which works with the pins swapped, but why ?
TRS is not a standard midi cable at all, with the obvious reason that shorting while plugging is almost a certainty, and the confusion that can cause in the studio. It is all up to you of course. Personally i make units that have 1 or 2 inputs (if i want to merge or listen on 2 channels), and midi-out and midi-thru, and sometimes an extra midi-out port. Every output port with it's own resistor pair.
nb. I wouldn't actually use mounting holes as terminals, it may cause some issues when designing the PCB. Go for connectors or screw-terminals.

1 Like

Yes, it is, it has become standardised.

1 Like

OMG what a terrible idea. Imagine that icw the 3.3v specs ..

Well it started with having a device that follows the official standard (Type A) and another device that follows Type B. And my fair share of cable problems.
Then I started researching about the issue and found some Elektron devices that can take whatever TRS type as input and have a switchable output. So I thought: Why not build your own and solve the issue for your set up? Then I thought about making a module for later use.

The mounting holes came as a rescue because I'm coming from eagle and now am trying out Kicad but I will surely transform it to something more sensible.

Any TRS device would have it's own TRS to 5-pin Din adapter. TRS is still rare, and i am pretty sure i don't want to accidentally plug a midi-cable into the mixer. Mind you 5-pin Din is expensive and a b^%$ to solder.

connector conn_ 01x01 (or more pin & rows) works, or screw terminal. you can anyway assign whatever footprint you want. The mounting holes are actually a bit of an afterthought / workaround. You need to add the symbol to the schematic or you won't be able to create the holes on the PCB without a footprint.

1 Like

While this is true there are a lot of devices that follow the official or the Type B and I'm a bit fed up with this shenanigans. Maybe someone else will have a use for this, too.
Also I have some funky ideas of merging and distributing MIDI. And there are other ideas like note generation and I just want to be independent of the cable I use. And of course some minor synth programming I wanted to do. Where the size really does not matter but could come in handy.

And I most often do want to go for TRS instead of DIN for spatial reasons. But I've thought about the issue with the mixer, too. Some synths do opt for audio and cv being interchangeable. But currently I'm not sure how to tackle a "mispatch" and avoid circuits getting fried.

I'm really thankful about your help and will look into the connector you've mentioned.

Long-term I'd really to release my own synth project with midi on board. As physical product for people to buy or open source (and in the best case both, that's what I'm really after) and I'm all for user convenience.

either people can buy it, or it's open source. These possibilities are exclusive, you can not do both for the same thing.

I have never even seen the TRS midi version. All i see is either 5-pin Din or USB-midi, which isn't midi-really, but that exists and can be done with an Arduino, though preferably with a 32u4 based board.

Merging i have done, but the timing can be an issue. Most midi-devices do not send more commands than can be transmitted. At 312500 Kbps, 3 bytes take a little less than 1ms to transmit. Midi is a command stream, so any merging will mean you will cue those 3 (or 1 byte) commands for several inputs. Now if there is a constant incoming stream on both ports you may have some issues. Also for reliability, a UART (hwSerial) is definitely preferred, so you may want boards with more than 1 UART.

I recon it's 3.5mm TRS we are talking about here, you know if T was 5v+ and S was data, and R would just simply not be connected, i wouldn't even mind so much.

Well the issue may not be all that problematic. 5-pin Din used to be the most common Audio connection plug when Midi was originally specified. the switch to RCA only started a few years after that. So the current limiting resistors on a midi output probably suffice, and probably on the input as well. (this is for 5v specs of course .. 3.3v may be different.)

Yes that is directed to a MIDI output interface. So no transistor needed.
On the output side I always use one for a 5V or 3V3 system.

1 Like

Makes sense, or just a logic-buffer. If something breaks it is something small.