MIDI Passthrough Control with Op-Amp

Status
Not open for further replies.
Hi Folks,

I'm back again, in need of some advice! Here's what I'm looking at:

Goal: MIDI passthrough from input to output enabled/disabled by a PWM pin on a microcontroller (Teensy 4.0).

I previously tried to accomplish this with a MOSFET with no success. It was recommended to me to consider using an op-amp, due to their low current draw. So after lots of reading up on op-amps, I managed to work out the circuit below.

In my tests, using +5v as a stand in MIDI signal, I read an output of +5v when the PWM pin is set LOW, and +0.04v when the PWM pin is set HIGH. Which indicates to me that the op-amp circuit is working as expected: I can switch between +5v and (essentially) +0v using the microcontroller.

However, when I replace the +5v stand in for a MIDI signal, I get mixed results. I previously had this circuit setup on a breadboard and it was acting mostly as expected, I could toggle MIDI passthrough with the microcontroller. I rebuilt the circuit on the breadboard, to clean things up, and now I can't seem to get any messages through the op-amp circuit at all.

Any thoughts or insights into how I might best achieve the results I'm looking for would be super appreciated!

Thanks!
 

Attachments

  • Screen Shot 2020-12-11 at 10.28.08 AM.jpg
    Screen Shot 2020-12-11 at 10.28.08 AM.jpg
    68.7 KB · Views: 97
Any thoughts or insights into how I might best achieve the results I'm looking for would be super appreciated!

Thanks!

MIDIMinion:

There's a discussion on another thread <here> that talks about how to disable MIDIthru in software. Is there some other factor necessitating the op-amp approach, or would disabling MIDIthru with software fit your need ??

Good luck & have fun !!

Mark J Culross
KD5RXT
 
Hi Mark!

There is: This circuit is part of a larger project that I've been working on, where we've already built some prototypes. In testing the most recent prototype (using the teensy's built in MIDI thru function), I measured an average latency of 120ms to 160ms from the time a MIDI message was sent to the time it was received. With just a cable connecting the input to output of my interface, I measures an average between 2ms and 3ms latency. The op-amp circuit is my attempt to get as low a latency as possible in our project!

Thanks!
 
MIDI uses a current loop. I think you need to tap off the Thru signal after the opto-isolator.

midielectric.gif
 
Hi JKIM,

That didn't seem to make much of a difference. My hope in using the op-amp is that it would present such a small current draw (600nA idle, 1uA max according to the datasheet) that it would be practically invisible to the MIDI circuit. I appreciate the help though!

Thanks
 
I am wondering how that circuit is supposed to work.

The the opamp has no explicit reference for the signal it gets from J1 (MIDI-in). It might be getting it via its output which manages to have a route back to the input. But that is also a problem. The only return path for the opamp output is through R4. A10K resistor which makes sourcing current to the next device a bit difficult.
 
Ah! It seems I have made a drafting mistake. The MIDI in from J1 is meant to go into the non-inverting input, while the control signal from the teensy is meant to go into the inverting input. The feedback resistor is also meant to feed the inverting input. I've attached the correct schematic here:

Screen Shot 2020-12-13 at 3.13.28 PM.jpg

I've triple checked that THIS circuit is in face what I have built onto my breadboard, and is not working as expected.

The op-amp's reference voltage comes from the teensy PWM pin. When I set the pin to LOW, the op-amp output swings to the +5v supply rail, allowing MIDI to be replicated on the output of the op-amp. When I set the pin to HIGH, the op-amp output swings to the negative supply rail (in this case ground) and blocks MIDI passing through the op-amp.
 
You didn't fix it. The only way that can have any hope of working is if there is a connection between the opamp ground and the ground of whatever is driving J1. Which defeats the purpose of the optocoupler.
 
@MIDIMinion:

Maybe take a look at using a "digital switch" (CD4066) or maybe even an analog MUX (8-channel 74HC4051 or 16-channel 74HC4067 - both are way overkill, but will certainly do the job). If you use the digital switch, your Teensy control signal can turn the switch ON/OFF to either connect & pass your MIDI signal (to turn MIDIthru ON) or to disconnect your MIDI signal (to turn MIDIthru OFF). If you use one of the MUXs (note that they are described as "analog" MUXs, but they pass digital signals just as well), you would simply ground the upper address signals (upper three for the 74HC4067, or upper two for the 74HC4051), & only drive the lowest address signal with your Teensy control signal. This will allow you to select between the channel carrying your MIDI signal (to turn MIDIthru ON), or to select the next channel (which would be grounded, to turn MIDIthru OFF).

Good luck & have fun !!

Mark J Culross
KD5RXT
 
Hello, I thought I would weigh-in, since I've been looking at MIDI IN/Out/Thru recently. I think a buffer between the MIDI In and Out/Thru with an enable is all that is needed and simpler. I think a 74HC125 that can work at 3V3 is appropriate here. Also, I believe that MIDI In shouldn't be grounded.

Screenshot 2020-12-16 122924.jpg
 
I think a 74HC125 that can work at 3V3 is appropriate here.
View attachment 22853

Yes, that should work. But 68 ohms is getting a little higher resistance which means lower current, which could be marginal for driving some MIDI inputs.

Using 74HCT125 powered from 5 volts, and 220 ohm resistors, would probably be a better choice. The HCT chips (and others with letter "T") are compatible with 3.3V input, even though they're powered from 5V and give a full 5V output signal. If you've going to buy a chip, might as well get the better HCT part since it costs about the same.


** - HCT isn't universally better. The speed is a few nanoseconds slower, which means nothing for MIDI, but can matter is other ways these chips are sometimes used.
 
Status
Not open for further replies.
Back
Top