Go Down

Topic: can't get basic midi sketch to work (Read 2730 times) previous topic - next topic

zyathus

hi,

i have a bit of a problem getting the the basic midi thing to work - Arduino uno r3.

http://arduino.cc/en/Tutorial/Midi


i copy and pasted the code, the little tx led is blinking, i wired the midi.jack, i double checked all connections (by now, a few times more) ... yet nothing happens.
i'm using midiox for monitoring.

johnwasser

Does your MIDI-OX installation work with other MIDI devices such as a keyboard?

Have you tried hooking the Arduino to the input of a MIDI instrument to see if anything plays?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

zyathus

midiox is receiving data from other midi devices, on that midi-in.

no, other midi instruments don't receive data from the arduino as well.

johnwasser

Could the 220 ohm (Red Red Brown) resistor be faulty?  Do you have a meter you could check it with?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

zyathus

i allready did ... seems fine to me ... replaced it (just in case)

johnwasser

The electrical specifications for the MIDI connector (http://www.midi.org/techspecs/electrispec.php) shows a second 220 Ohm resistor from the TX pin to Pin 5 of the MIDI connector.  Couldn't hurt to try that.

It might also help to connect the MIDI Ground pin (pin 2) to the shell of the MIDI connector.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e


johnwasser

For the output are you using Serial.write(value) or Serial.print(value, BYTE)?  Are you using Arduino 0.23 or Arduino 1.0?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

zyathus

arduino 1.0

and i just copied the mentioned sketch.

mattsd

#9
Feb 18, 2012, 08:37 pm Last Edit: Feb 21, 2012, 07:38 am by mattsd Reason: 1
This doesn't help solve, but I'm having the same problem with my R2.  I'm a noob too, but I was able to reflash my UNO R2 with LUFA firmware and get it working via USB.  This is no fun when you are trying to develop though, cause you have to constantly flash/reflash to get back to a state you can upload programs and do simple tests.

I've got the two 220ohm resistors, the connections appear to check out.  I've done a loopback test and seen that my TX And RX pins appear to be working.

This is in Arduino 1.0, and before and after flashing to Arduino-usbserial-atmega16u2-Uno-Rev3.hex

Is something different about the UNO, or the UNO R2?  I've triple checked my connections, even reversed them after reading it wouldn't hurt.  I get nothing via MIDIOX, plugged into two different devices (Audiofire 4/Microkorg) and just can't get anything.  I use the same cable and same midi in and get activity from other devices.

I've tried the midi library and just straight up serial at 31250.

Checked the midi cables, they are fine.  I've tried two known working MIDI cables, a longer one, and one that is just 1ft long.  I've also tried using only a wall wart power supply.  What gives?

Matt

TKHouse

Wanted to add further to this discussion. I'm on a brand new Arduino Uno R3. Mac OS 10.5 for development. I'm new to working with the Arduino and new to Midi as well (at least from a hardware standpoint).

I also am unable to get the basic midi sketch to function. I've constructed the midi output exactly to spec with the midi.org electrical specifications (even going as far as including the buffer). At one point my midi device, a Motu 828mk3 Interface was receiving midi messages in sync with when I sent them, however the message information was nonsensical. I have been unable to repeat this result with the same setup and code.

Neither Software Serial nor onboard Serial output seems to work. I've tested with the Arduino Uno still connected via USB to the computer and disconnected with an external power source.

I'm getting a 6N138 in within a day or so to try and receive midi input to spec. Hopefully that may shed some more light if this is purely a serial output problem of if it's having trouble receiving at this rate as well.

Other things I've tested:

I've tested sending a byte from Software Serial at 13250 into the Arduino's built in serial port and this works fine (10 consecutive bytes received correctly, then output over hardware serial port to a computer). This worked correctly at 9600, 13250, and 14400.

I hooked things up to an oscilloscope today and the timing looks well within tolerance (every bit taking approx 32 microseconds) so this doesn't seem to be a timing issue. Everything is completely as expected, start bit etc.

I'm certain the midi input I'm using works and the software (Logic Pro) can monitor valid midi input.

Will post further updates as I try some more things.

mattsd

Interesting.  I forgot also to mention that I also had no luck with the SoftSerial or NewSoftSerial libraries.  I saw you mentioned 13250 twice, you mean 31250 right?

I don't have an oscilloscope, so I think I've exhausted most of the things I can do from a multimeter and software troubleshooting angle.  Really disappointing cause this is my first hardware project and I had to go the USB Flash software route to make it work.  :)

Same sketch works with MOCO for Lufa, so I think that rules out the code or the MIDI library.

TKHouse

^Yes, 31250, not 13250. I don't think the onboard Serial connection will work very well at 13250, haha.

Strange and frustrating indeed.

shooking

Like John said on reply 5, use a real midi circuit.

I use the 6N136 (I had some spare) and this is the non-Darlington Pair version of the 6N138.
If you choose to also use a 6N136, then use a 4.7k resistor instead of the 280 ohm spec'd in the midi standard.

I dont always use the two not gates (7404) but you should since it really cleans up the edges.

The common issues with Arduino and midi appear to be


  • Not using an approved midi circuit - you do want to protect your Arduino/other Midi gear right?

  • Using Serial (ie pins 1/2) whilst the program is uploading/Midi is sending

  • When receiving, not checking for available bytes (Serial.available()) -- the -1 will be interpreted as 255
    and this is a valid midi status ... one you really dont want to deal with

  • Not considering running status, if your gear sends running status

  • wiring the 5 pin din round the wrong way



You can find my hardware sketch half way down my http://miniaktools.sourceforge.net/ page.
I havent used the 7404 in this one (they were still on order :-().

I have various issues with UART buffer lag when handling large sysex, but the hardware/software I wrote works well enough.

Good luck with your midi project.

Regards

Steve H

TKHouse

Thought I would update the thread since I'd replied earlier.

Currently I'm successfully both receiving and transmitting midi messages (Software Serial and hardware Serial).

I got some new parts in this week, and that seems to be doing to the trick. I built the circuit to the specs on the midi electrical specification schematic. For the output I used an inverter and an NPN transistor as the buffer, 1K resistor into the base. One thing that continued to throw me was that the midi spec shows pin values as they appear on a midi cable (male), not as they are on a 5-Pin DIN  jack (female). This makes a rather large difference.

For the midi input I used a 6N138 optocoupler. The input side of the 6N138 was exactly as specified on the midi spec. On the output side, I used a 220 ohm resistor into the V0 pin and a 1K resistor into the Vcc pin (both resistors getting 5V from the Arduino's power supply). The data receive line from the Arduino was connected at the same point as the 220 ohm resistor and the V0 pin's connection.

Everything seems to be working great now. Hope any of this might help.

Go Up