Go Down

Topic: can arduino do 31250 bps? for midi ? (Read 890 times) previous topic - next topic

kuuk

Sep 06, 2006, 12:14 am Last Edit: Sep 06, 2006, 12:15 am by leKuk Reason: 1
hi there,

i'm trying to read midi signals with arduino.
for debugging purposes i wanted to receive the midi data on my computer instead of the board.
i noticed that zTerm or any other serial application can't be set to 31250 bps. this is due to fact that speeds are created by multiplying the speed from an internal crystal in the serial port/card. 28.800 and 38.400 will work. 31.250 NOT ! which is the speed midi uses.

that's the reason that i can't use a serial port to read (actual serial) data from my midi keyboard.

what hit me now is that probably arduino will not be able to run serial with 31.250 neither. since it runs on 16MHz !?!  :-/

anyone please tell me i'm wrong.

best, kuk_

mellis

Some brief Googling found me this thread: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=253069, which says that MIDI was designed for whole number MHz clocks, like 1 MHz or 16 MHz, so you should be fine.

"Serial communications depend that both receiver and transmitter use the same speed to send and receive data. One data byte is sent with a start bit and a stop bit. Therefore if the math is done, no more than about 2% of error in speed is tolerable, otherwise the received bits are clocked in at the wrong moment and when time cumulates over the 10 bits then the last bits are sampled wrong. But the thing is to select a MIDI data rate friendly crystal speed like 4MHz, 8MHz or 16MHz, this way the bit rate is exactly 31250. For serial communications with PCs and stuff people use crystal speeds like 3.6864MHz, 7.3728MHz, 11.0592MHz to get exactly bit rates such as 9600 or 38400. This includes 14.7456MHz, so do NOT use that for MIDI communications as there is a better alternative. Actually, serial port friendly crystals get you around 1.7% error when trying to get 31250, so this is within specs. "

kuuk

THANK YOU
that's what i wanted to hear. on the first look 16 doesn't look 31250-friendly :-)

i'm going back to the midi thread now...

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1152354897


kuk

Go Up