1

I recreated this circuit to send MIDI notes to my MIDI-USB adapter to my computer. enter image description here

It works fine when the Arduino is powered via USB. When I power the Arduino Nano with 9v on Vin however, the output is gibberish. It just spams the input monitor on my computer with random midi commands. For testing I used this code:

    #include <MIDI.h>

    MIDI_CREATE_DEFAULT_INSTANCE();

    static const unsigned ledPin = 13;
    bool on = false;
    void setup()
    {
        pinMode(ledPin, OUTPUT);
        MIDI.begin(MIDI_CHANNEL_OFF);
    }

    void loop()
    {
        digitalWrite(ledPin, on);
        on = !on;
        MIDI.sendControlChange(12, 127, 1);
        delay(1000);
    }

The Arduino itself seems to be working fine when powered with 9v (note that I tested with both a wall power supply as well as a 9v battery) as the TX-led still flashes briefly and the built-in led also toggles nicely.

At first I blamed my power supply and/or my power supply, but both work fine on my MIDI-keyboard so I don't think they are to blame.

Worth mentioning: When the Arduino was powered by Vin, I also as a test plugged in the USB-cable in the Arduino, But only touched the connector on the USB-port on my computer. I then received the correct notes.

Because of this I think it is an issue with the grounding. What am I doing wrong?

EDIT: Thanks for the response guys. I think I diagnosed my problem incorrectly. I'm using a cheap Chinese MIDI-adapter which I pried open, and it lacks an optocoupler. I'm getting a decent MIDI adapter now. Thanks!

  • What USB MIDI adapter are you using? That one? i.stack.imgur.com/yA3dT.jpg – CL. Jun 14 '17 at 6:28
  • Do you really need to use port 1? – Code Gorilla Jun 14 '17 at 10:35
  • @CL. Yup, that was the one I was using. After some after some googling on it I found out that it could lack an optocoupler, and after opening it confirmed that mine didn't have one as well. I ordered a good adapter now! Thanks! – Guido Jun 14 '17 at 20:25
1

If you are connecting multiple devices then they have to share a common ground.

I only know about British mains sockets, they all have an earth pin connecting to a common ground, so usually you are OK.

Plug in transformers 'wall warts' sometimes don't connect to ground, the give away is the plastic pin. In this case you need to provides a separate earth and connect it to the rest of the equipment.

PCs normally have a good earth and this is passed by the USB to connected devices. So "the Arduino always works when it is connected to the PC" is usually a good indicator of an earthing issue.

I think your keyboard uses a wall wart and therefore when you remove the USB they both float. Touching the USB lead to the Arduinos USB socket grounds it all again.

So it looks like you diagnosed the fault correctly :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.