sinosoidal Posted April 19, 2007 Report Share Posted April 19, 2007 Hi,I would like to know how the MIDI BOX implements the MIDI OUT. I'm building a custom MIDI controller based on a AVR microcontroller and i'm having problems putting MIDI coming out.The most strange thing is that i've already done it a few months ago in a breadboard.- I'm connecting UART out to a 220 omhs resistor and then to pin 5.- I'm connecting VCC to a 220 ohms resistor and then to pin 4.- I'm connecting ground to the pin 2.Well, i'm not getting an output.In the MIDI electrical specification exists 2 logic ports that seems to me inverters.Which component should i use? Are they really important?I know this kind of question is not a MIDIBOX particular question but i cant find any other place when so many MIDI people are togheter.Many thx,Nuno Quote Link to comment Share on other sites More sharing options...
Lall Posted April 19, 2007 Report Share Posted April 19, 2007 Hi,As you can see from the Core diagrams, these inverters are not used.My understanding is that these two inverters are used as a kind of buffer that act as a protection because the micro-controller is not directly connected to the MIDI port and also as a driver that makes sure that the MIDI out will be strong enough to drive the other end when maybe the UART output wouldn't be strong enough. You can use inverters like 74HC04 or 74HC14, they should be strong and fast enough for MIDI. I've also seen gameport-MIDI adapters made with simple transistors.Maybe a stupid point, but have you double-checked the pinning on the MIDI plug itself? This rear vs front view can be a cause of error sometimes.Best regards, Lall Quote Link to comment Share on other sites More sharing options...
seppoman Posted April 19, 2007 Report Share Posted April 19, 2007 Hi,a buffer is not neccessary, MIDI will work fine without it. Which AVR do you use at which frequency? I don´t know how much experience you have with AVRs - one popular newbie mistake is the oscillator fuse, gone through that myself ;). if you don´t set the fuse correctly, AVRs run on the much slower internal oscillator. Are you sure that you´ve set the correct baud rate depending on the processor frequency? For an AtMega32 with 16 MHz, the UART initialization looks like this: // USART initialization // 8N1, Asynchron // USART Baud rate: 31250 UCSRA=0x00; UCSRB=0xD8; UCSRC=0x86; UBRRH=0x00; UBRRL=0x1F;Seppoman Quote Link to comment Share on other sites More sharing options...
sinosoidal Posted April 19, 2007 Author Report Share Posted April 19, 2007 Hi,This is my code for the UART: #define MYUBRR ( F_CPU / (16*BAUD) - 1 ) void USART_Init(unsigned int ubrr) { // set baud rate UBRRH = (unsigned char) (ubrr>>8); UBRRL = (unsigned char) ubrr; // enable transmitter UCSRB = (1<<TXEN); // set frame format: 8 data, 2stop bit UCSRC = (1<<URSEL) | (1<<USBS) | (3<<UCSZ0); } void USART_Transmit(unsigned char data) { // wait for empty transmit buffer while (!(UCSRA & (1<<UDRE))); UDR = data; } Maybe the front/rear view is really a problem...Using this as a reference:http://www.midi.org/about-midi/electrical.shtmlHow should i interpret?My interpretation is: when i look at this i see my soundcard midi ports in a front view. Is this correct?Thx,Nuno Quote Link to comment Share on other sites More sharing options...
Lall Posted April 19, 2007 Report Share Posted April 19, 2007 Hi,I prefer looking at the Core schematic for the front/rear: http://www.ucapps.de/mbhp/mbhp_core_v3.pdf.In that one, it's clearly explained and still every time I had to solder wires on a MIDI connector, I had to think twice...There are no numbers on the pins of the MIDI connector but by comparing both documents, you'll be able to derive them.For the output buffers and even if lots of midiboxes around here are working so indeed they are not that needed, I still prefer putting one and that's what I'll do in the SEQ I'm currently working on. These inverter chips costs really nothing and having them will not hurt at worse and may help at best...Best regards,Lall Quote Link to comment Share on other sites More sharing options...
seppoman Posted April 19, 2007 Report Share Posted April 19, 2007 MYUBRR looks ok (if F_CPU is correct).The UCSRs I can´t tell from memory. One thing that caught my eye: 2 stop bit? Midi is normal 8N1, i.e. no parity one stop bit!about polarity: in the first picture at your link you see the midi cable from the front (or the jacks from the rear!).Seppoman Quote Link to comment Share on other sites More sharing options...
sinosoidal Posted April 20, 2007 Author Report Share Posted April 20, 2007 Hi guys,Yesterday i achivied the communication.Maybe the 2 stop bits were messing everything up.Thx a lot!!Best regards,Nuno Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.