UNO + Olimex Midi Shield (Resolved)

Hi, I'm new and I'd like some advice or help. I have an Arduino UNO r3 and an Olimex Midi shield. The function of the box is to receive midi signals via the MIDI IN and then process or handle the notes and trigger events such as program changes, NRPN messages. And then those messages are sent out MIDI out.

I do not want to use MIDI over usb, I'm not using a computer for performance.

One of the challenges is that the UNO apparently only has 2 serial channels (TX,RX) and the midi shield, when installed, uses those. I have to physically remove the shield when I want to upload to the arduino UNO r3.

The other challenge is that if I wanted to use software serial, I don't think it would work, would it? Assuming I have my UNO loaded, I reinstall the shield, plug in midi chables, power it on via 9v battery; softwareserial sends via the 2 digital channels, but those are being 'occupied' by the sheild AND my usb cable isn't connected, so the monitor wouldn't show anything (and COM3 wouldn't be available anyway).

So can I use software serial AND have the shield on AND have the USB cable connected? I would say NO.

I'll post my code shortly.

Here's the code I'm using (below). I'm using MIDIOX to send midi messages via a USB to MIDI cable. The code should do 2 things as a test, 1) turn on the LED when a noteOn is sent and send a noteOn message every second.

my hardware is a Uno R3 (programmed via USB). I was able to figure out that the Olimex MIDI shield has a jumper that you can remove to program it, and then replace to run it. This way I don't have to remove the shield every time.

There's a lot commented out, because I couldn't even get simple things to work, let alone the rest.

#include <MIDI.h>
// set NRPN to set volume to zero for part xyz
// read existing program/patch number ??? 
// send stop control 

int ledPinRed = 06;                 // LED connected to digital pin 6
int ledPinGrn = 07;                 // LED connected to digital pin 7

void HandleNoteOn (byte channel, byte note, byte velocity){
  //int program =0;  //program or patch always begins at 0

    //if note1 or note2 is sent, send program change control to go up or down
  //if (note == 60){   //need to get the actual note number that I'll assign
   // MIDI.sendProgramChange(1,10);
      digitalWrite(ledPinGrn, HIGH);   // sets the LED on
  delay(1000);      // waits for a second;
      digitalWrite(ledPinGrn, LOW);   //set the LED off
  //}
  //if (note == 62){  //need to get the actual note number that I'll assign 
   // MIDI.sendProgramChange(2,10);
   //   digitalWrite(ledPinRed, HIGH);   // sets the LED on
  //delay(1000);                  // waits for a second;
    //  digitalWrite(ledPinRed, LOW);  //set the LED off
//  }
}
//if note3 is sent, send nrpn to set volume to zero


void setup() {
 pinMode(ledPinRed, OUTPUT);      // sets the digital pin as output
 pinMode(ledPinGrn, OUTPUT);      // sets the digital pin as output
   
  //int program =0;  //program or patch hardcoded to begin at zero
  MIDI.begin(MIDI_CHANNEL_OMNI);
  MIDI.setHandleNoteOn(HandleNoteOn);
//  MIDI.sendProgramChange((program),10);   //channel is hard coded to 10 for now
}

void loop () {

  MIDI.read(); //is there incoming MIDI?
  
  // LED Tests
  //digitalWrite(ledPinGrn, HIGH);   // sets the LED on
  //delay(1000);                  // waits for a second
  //digitalWrite(ledPinGrn, LOW);    // sets the LED off
  //delay(1000);                  // waits for a second
 MIDI.sendNoteOn(60,127,10);
 
 delay(1000);
 
 MIDI.sendNoteOff(60,127,10);
 

}

You can comment out blocks of code using the /* */ style of comments more easily. You cal also use the IDE to do comment blocks with one menu.

The way your loop is structured there is no delay between the note off and the note on at the start of the loop. You need to add a delay at the bottom of the loop so that you can hear a break in the note.

Do your LEDs come on at all?
Does OMNI work? Try a different channel number?
Have you checked that MIDIOX actually sends out the midi characters?

You also need to get rid of the delays in your code. Delays will stop the rest of the program from working properly. For example, while you delay in loop you are not processing midis messages arriving.

thanks for the quick reply,

I can do an LED test in the loop and they come on, which is encouraging.

  /* LED Tests
  digitalWrite(ledPinGrn, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPinGrn, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
  */

Also, if I didn't mention it, there's a jumper on the Olimex board that allows you to upload without having to remove the whole shield.

At this point I'm just trying to test 2 things: if the shield can send and receive MIDI. So when the device is ON, (powered by a 9v battery, not the usb, just to be clear), the loop here should send (TX) a noteOn and Off. (Granted, I need to add a delay for testing purposes, as you mentioned).

MIDI.sendNoteOn(60,127,10);
 
 delay(1000);
 
 MIDI.sendNoteOff(60,127,10);

I'm not getting anything in MIDIOX. The MIDI OUT of the Olimex shield is connected to my laptop via a USB/MIDI converter (Roland UM1). So, as I understand it (which could be wrong), the code should send the initial noteOn, jump to the HandleNoteOn, light up the LED, then send noteOff. ? I'll try adding a delay after noteOff to see if it helps.

Does OMNI work? How would I tell? Its supposed to listen on all channels, so are you saying I should try to listen to a single channel? I can try that as well.

MIDIOX has a MIDI In/Out monitor and that's how I'm monitoring the MIDI in/out. I'm sending MIDI by using the keyboard functionality of MIDIOX. It shows the midi messages going outbound, but my board doesn't respond. I've used MIDIOX in the past to send MIDI this way and haven't had any issues.

Again, thanks for the help.

On my USB to serial converter, the are a couple of LEDs that tell you if messages are being sent on the out and in lines. Does yours have the same? If so, do you see those LEDs flash at all when you send messages?

I would also suggest that you try to get one direction working at a time. Fix up your sending loop so that you toggle a led on and off with the note on/off that you send. Then verify that you get that message in MIDIOX by monitoring the input window. If you don't work on that first as you are more in control of timing and message.

Then also check the config for MIDIOX. You need to make sure that it is actually using the USB interface for output. The LEDs on the cable would be a good indicator, but you can also check the config to make sure your device paths are set up correctly.

I think OMNI does not work with the midi library. Check the comments on the header file.

An obvious one, but make sure the jumper on the olimex board is replaced after you upload, or you will get nowhere.

my USB/MIDI doesn't have lights that light up.

an observation: right after I upload via USB, I see the UNO TX led light up every second. I assume this is the MIDI message that I told it to send. I open up the serial monitor and see garbage coming through each second:

1øÿÿøÿÿ1øÿÿøÿÿ1xÿÿøÿÿ1xÿÿøÿÿ

the baud rate on COM3 is set to 38400bps.

I tried just having the UNO send MIDI data and I see nothing coming through in MIDIOX.

I tried to simply have the UNO send MIDI msgs with LED light up. The LED lights up, but that's it. No MIDI sent to MIDIOX.

Here's the schematic to the MIDI shield. I'm not an electrician, but can someone look at this and give feedback?

I mean, I'm at a loss. I've tried example after example and tutorials, but I get nothing. No midi In or out.

If you see the messages appearing on the serial monitor then they are making it to the PC and I would look at how you have configured MIDIOX. Have you goat a synthesiser or music keyboard the you can connect to the arduino to see if it plays a note? You can also use the same to see if MIDIOX plays the note on the kid.

My bet is on MIDIOX not being configured correctly, though.

I've used Midiox and the usb/midi converter cable tons of times, I mean all I usually have to do is make sure the Roland UM1 is selected as input & output. I can flash the UNO to just send MIDI (to only test TX) and still get nothing in MIDIOX. LED flashes on the Olimex shield, but as near as I can tell nothing is coming across the wire.

To clarify, when I said that I saw data in serial monitor, that was when I still had the usb cable from PC->UNO plugged in. It was not the USB/MIDI cable. The serial monitor won't work for my tests because the serial is being used by the midi shield. Any serial communications sent or rxd by the UNO must go through the MIDI shield. Know what I mean? :slight_smile:

That's why this is such a challenge. I can't monitor the serial communication. All I have is MIDIOX. I tried using a USB monitor, but it didn't pick up anything. I dunno. It would be great if Olimex would respond. :slight_smile:

You should be able to find a ttl or terminal program that you can use instead of MIDIOX to verify that you can get data to the PC from the arduino. It may be the Roland thingy is stopping your messages. You should see the same or similar rubbish as the serial monitor. If you google 'terminal program free' you should get a few that will fit the bill.

Once you have established you get messages on a regular 1 second, then you move onto the next part of the chain.

It may seem obvious, but a logical approach that builds on what you know is working is the only way to go when you are looking at these or any other sorts of problems. Work outwards from what you know works. In your case:

Arduino seems to send messages
You assume that they are reaching the PC but don't know, so you need to verify.
Once this is verified then turn to MIDIOX

Similarly in the reverse direction, although here your midi callback would imply you are not getting messages, you need to prove to yourself that these are actually leaving the PC.

Not sure a terminal prog would work. Dont forget, the uno isnt connected via a COM port when its running. Its connected via usb to midi cable, which shows up as a midi device.

connected to the UNO usb port to the pc's usb port:

I downloaded realterm, and I definitely see data coming over.


But I still have no way to see if data comes through my USB to MIDI cable. When it's plugged into the UNO and then into my pc's USB port, it shows up as a MIDI device, not a COM port (to monitor via a terminal app).
edit: I also tried BomeSX MIDI monitoring app, and still I get nothing from the MIDI shield.

Are there any other examples of your midi converter used with the arduino? Looks like something is not workin between the two of them.

sort of. check this out. This might be the issue, I'm still reading it.:

I'll need to check out how the UNO is wired to the Atmega...

The post in link I provided above discussed the USB/MIDI cable that I have, in conjunction with the sparksfun midi shield and the UNO and PRO. but in that scenario, it was the PRO that had 'diminished' mA, as to cause the MIDI signal to be too weak for the USB/MIDI cable to pick it up. But the UNO + Roland UM1 USB/MIDI cable + Sparksfun MIDI shield was not an issue. The measured mA on that was 2,5mA under a load. I have a multimeter, but I'm not really sure how I'd measure mA during a MIDI TX. ?

What I have been able to determine is:

While the UNO is running, the MIDI OUT and MIDI THRU have 5v on both pins 5 & 4 ?

Summary:

PC -> Roland UM-1 USB/MIDI cable - > Olimex MIDI shield -> UNO R3 (powered by 9v battery or USB connection (when uploading sketches)

Software: Arduino IDE 1.0.3, MIDI OX or USBlyzer or SendSX (all are supposed to monitor incoming MIDI or USB ports), MIDI library 3.2

Actions:

  1. Connect UNO + Midi shield (with jumper removed to allow upload of sketch) via USB to computer
  2. upload a simple MIDI TX sketch, such as:
 int velocity = 100;//velocity of MIDI notes, must be between 0 and 127
 //higher velocity usually makes MIDI instruments louder
 
 int noteON = 144;//144 = 10010000 in binary, note on command
 int noteOFF = 128;//128 = 10000000 in binary, note off command

void setup() {
  //  Set MIDI baud rate:
  Serial.begin(31250);
}

void loop() {
  for (int note=50;note<70;note++) {//from note 50 (D3) to note 69 (A4)
    MIDImessage(noteON, note, velocity);//turn note on
    delay(300);//hold note for 300ms
    MIDImessage(noteOFF, note, velocity);//turn note off
    delay(200);//wait 200ms until triggering next note
  }
}

//send MIDI message
void MIDImessage(int command, int MIDInote, int MIDIvelocity) {
  Serial.write(command);//send note on or note off command 
  Serial.write(MIDInote);//send pitch data
  Serial.write(MIDIvelocity);//send velocity data
}
  1. observe that TX led blinks on UNO, serial monitor shows data coming across (although its gibberish)
    a. In addition, using usblyzer, Bulk data transfers are logged.
  2. disconnect USB cable from UNO
  3. connect Roland UM1 USB/MIDI cable to PC and to MIDI OUT of Olimex MIDI shield.
  4. connect 9v power supply to UNO
  5. Observe that TX led no longer lights up
    a. although if I code the LEDs on the Olimex to light during main loop, they do indeed light.
  6. Using MIDI OX, selecting UM1 as the MIDI source, no MIDI data transmitted. Close MIDI OX
  7. Using USBlyzer, select UM1 USB device, No data comes over the wire.
  8. Volt meter shows 5v on MIDI OUT pins 4,5.
  9. 5v on THRU pins, 4,5.

To test the UM1 USB/MIDI cable:

  1. connect UM1 to Korg ES1
  2. press play
  3. loads of MIDI data comes through MIDI OX and USBlyzer

The conclusion that I've reached is that the UNO, by itself, is transferring data across a standard usb cable to the PC/SerialMonitor/USBlyzer (or other port monitor app). But when the MIDI shield is attached and the standard USB cable is not connected, no serial data is being sent.

The question remains, how can I verify that serial data (MIDI data) is being send from the TX pin, out the MIDI OUT and across the wire? I haven't ruled out that it's a mA issue, but that seems unlikely since others have reported the mA under load is about 2,5mA. I'm not sure how to measure the mA using a standard multimeter, but I would doubt that I'd be able to detect it.

update: I picked up some 5v 20mA LEDs and inserted into pin 4 &2 of the MIDI OUT DIN, ran a sketch and the LED blinks. However I'm unable to read any mA's. That could be my meter. I am able to see the voltage drop using my meter. So it would appear something going out the MIDI OUT DIN?

update2: new fuse for my meter. so Ive measured the mA on pins 4 & 5, it's right around 10mA.

Does anyone have any more ideas for this?

Sorry, none from me. It looks like the problem is between systems and I don't have any experience with your other stuff.