Go Down

Topic: Arduino Uno will not respond to inputs at serial cycle rate of 31250. (Read 522 times) previous topic - next topic

sbl19

Hi Adruino Forum,

My goal is to create a MIDI controller which outputs a MIDI signal in the same way that's described in this tutorial:http://arduino.cc/en/Tutorial/Midi. The Arduino is outputting the signal directly from it's output pins. It's important that instead of the usual serial cycle rate of 9600, the MIDI standard requires a serial cycle rate of 31250. This why the code in the tutorial starts with
Code: [Select]
Serial.begin(31250); .

My plan was simple: I will add a switch to the tutorial setup, so that activating the switch will activate the MIDI signal. I'm using an Arduino Uno.

Unfortunately, the Arduino won't recognize the switch activation at a serial cycle rate of 31250. I've tried to use the SoftwareSerial.h library to allow one pin to cycle at 31250, while the rest of the Arduino cycled at 9600. This resulted in no signal being produced. Here is the code I used to test this implentation:

Code: [Select]

=#include <SoftwareSerial.h>

// Variables:
  byte note = 0;            // The MIDI note value to be played

//software serial
SoftwareSerial midiSerial(2, 3); // digital pins that we'll use for soft serial RX & TX



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

  }

  void loop() {
    // play notes from F#-0 (30) to F#-5 (90):
    for (note = 30; note < 90; note ++) {
      //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
      noteOn(0x90, note, 0x45);
      delay(100);
      //Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
      noteOn(0x90, note, 0x00);   
      delay(100);
    }
  }

  //  plays a MIDI note.  Doesn't check to see that
  //  cmd is greater than 127, or that data values are  less than 127:
  void noteOn(byte cmd, byte data1, byte data2) {
    midiSerial.write(cmd);
    midiSerial.write(data1);
    midiSerial.write(data2);

  }


How can I output a MIDI signal at a serial cycle rate of 31250 and still have the arduino respond to switches? Please respond if you need any more information about my set-up or trials.

pharaohamps

Have you thought about using SoftwareSerial for the 9600 baud connection and the hardware serial for the MIDI?  That might work a little better.

Also, please upload the actual code you're using, including the parts that don't work.  Right now I'm not seeing anything in your code regarding a switch.

Go Up