Serial7 as MIDI2 looses data when USB is disconnected.

mcgeekly

New member
I have a project where a Teensy 4.1 reads 640 inputs from a pipe organ console, encodes the info to midi and sends that midi out two ports. The fist port on serial 2 goes to the pipes and their decoder. The second port on serial 7 sends midi to console controls when stop changes are triggered. ( activates on/off coils of the stop switches.) Everything is working fine until I unplug the USB ( yes external +5v is provided). Serial 2 continues to work fine transmitting data. Serial 7 now transmits empty midi frames where there was originally data. If I plug the USB back in the data appears again. I am using MIDI.h as recommended by pjrc site. and have two instances set up as midi2 and midi7. I cannot understand why port still transmits MIDI1.noteOn(note(data), veloc, channel) but the note data is all zeros.

//Midi out #1 pins rx7,tx8
MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI2(Serial2);
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>> MIDI2((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>&)serialMIDI2);

//Midi out #2 pins rx25,tx24
MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI7(Serial7);
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>> MIDI7((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>&)serialMIDI7);


ENCODING ROUTINE ... CALLS
NoteOn(note, 127, channel);
NoteOff(note, 127, channel);

// main MIDI channel (OUT TO CHAMBERS)
void NoteOn(int chan, int note) {
MIDI2.sendNoteOn(note, veloc, chan); // Send a Note on (note, velo, channel)
void Noteoff(int chan, int note) {
MIDI2.sendNoteOff(note, veloc, chan); // send a note off (note, velo, channel)
}

ENCODING ROUTINE ... CALLS
// Second Midi to console stop control
MIDI7.sendNoteOn(note(data), veloc, channel);

It all works except the data on MIDI7 goes to zero when the USB is unplugged.

Any ideas?
Full code attached.
 

Attachments

  • Relay1-005.ino
    12.9 KB · Views: 23
Last edited:
SOLVED... This was a problem with the power supplies that operate each unit. When the computer was unplugged the V+ rail dropped on one unit and while the Teensy still continued to run, the data output pin was not reaching a proper 'high' signal level that could be read by the second Teensy.
 
Back
Top