This program demonstrates how to receive MIDI input data by using the Maxim 3110 serial UART chip.
This program just echos the MIDI input data it receives back to MIDI output, acting like a MIDI thru port. The MIDI output is sent straight from a BS2SX output pin instead of through the UART since it is faster to do so (the UART needs 16 bits to transfer 8 bits of data). The MAX3110 chip can buffer up to 8 bytes of input data and 8 bytes of output data.
Below is a schematic of the circuitry connected to the Basic Stamp IIsx for MIDI I/O through the UART. Click on the diagram for a description of abbreviations and other commentary.
Here is a picture of the actual wired circuitry for the MIDI I/O with the Basic Stamp IIsx and the MAX3110 UART:
You should be aware of the following limitations with this setup:
There are limitations to MIDI input on the Basic Stamp IIsx microcontroller. The fastest synchronous serial transfer speed is 42k. The MAX3110 UART sends 8 bits of status information with every byte of data transfered between itself and the BS2SX; therefore, the effective fastest transfer rate of data between the MAX3110 chip and the BS2SX is 21k. The rate for MIDI is 31.25k which is faster than the transfer rate between the MAX3110 UART chip and the BS2SX, so you cannot use this setup for dense MIDI data transfers.
The measured limitation of this setup is:
No more than 9 MIDI bytes (3 MIDI messages) can follow each other in succession without placing a gap so that the data can be read from the UART's 8-byte input buffer. The minimum gap after nine bytes (3 typical MIDI messages) should be greater than 36 milliseconds, or 39 milliseconds after the first of the three successive messages has been received. This is assuming that you are not doing anything else on the Basic Stamp while the MIDI messages are being processed.
MIDI throughput can be improved by using the Scenix microcontroller without the Basic Interpreter, because the synchronous transfer rate is better than 1.1 MHz instead of 41 kHz:
Craig Sapp, email@example.com
Florian Vogt, firstname.lastname@example.org