Shop OBEX P1 Docs P2 Docs Learn Events
SOLVED: Help needed: MIDI Serial Communication issue — Parallax Forums

SOLVED: Help needed: MIDI Serial Communication issue

WurlitzerWurlitzer Posts: 237
edited 2013-02-18 14:25 in Propeller 1
SOLVED: see post 3

First: I have a working Prop program which scans my pipe organ keyboards for any digital input changes and creates MIDI messages for each. This program has been working for 3 years.

Second: To create something unique and solve key travel issues which plague most organs I have taken that original program and substituted an analog capture system which, using the Prop Serial terminal is working perfectly. I can see all the data being entered into a circular queue and can see exactly the message which is being processed by the cog handling the MIDI out function. This new program is being run on a standalone Prop with the MIDI output circuit being replicated from the original.

Third: I only have an analog scope and as best as I can tell, the waveforms look similar but as I am looking at a trace which is only triggered when a message is sent it is virtually impossible to tell if the bit duration or pattern is correct. What I can verify is that the Start/Stop bit control is working right.

At this point, again as I am using a cog program for MIDI out which is known to function, I am looking at the output hardware which is as simple as could be but I am open to suggestions as to how to evaluate this serial communication without the purchase of a digital scope, which I am afraid may be my only solution.

The output consists of a 2.2K resistor from the prop to the base of an NPN transistor (already tried replacing it. The emitter is at ground and there is a 220 ohm resistor at the collector which goes to the MIDI plug, then the return from the MIDI plug goes through another 220 ohm resistor to +5 VDC. That is the configuration which is running perfectly fine using the original prop circuitry.

At first I thought maybe the prop clock was off freq but the serial terminal works perfectly @ 38400 baud.

I even played with the baud delay value up to +30/-30 counts from what should be the proper delay.

I have tested the output with 2 programs {MIDI-OX, Hauptwerks} and neither seems to even detect a transmission even though I can see it on the scope.

So again, what I am looking for is any suggestions, short of a digital scope to verify what is actually occurring on this serial communication.

The routine shown below is the MIDI output subroutine copied and pasted from the original working program. (NOTE: there are 2 MIDI out pins controlled by this one for the PC and another for the real pipe organ.) I am only looking at the PC output now.


SendMIDI  '2-7-2013 send  Status, Data, Velocity  sending MSbit first for each
 'SEND START BIT (0)                                            '   
                        mov     tmp2, #8        '8 data bits
                        mov     tmp1, #0         wz      ' all this does is set the zero flag
                        muxz    outa, MIDI_Out_PC 'send Start Bit for pipe chamber if DIRA is enabled
                        nop     'keeps timing between PC and Pipe midi bits the same
                        muxz    outa, MidiOutPipe
SendDataBits                
                        call    #BaudDelay  'waits the appropriate time based upon selected baudrate
                        
                        ror     MIDI_PC_Out_Msg,#1 wc  'the carry bit reflects the status of the LSbit
                        muxnc    outa, MIDI_Out_PC '
                        ror     MIDI_Pipe_Msg, #1 wc
                        muxnc   outa, MidiOutPipe                        
                        djnz    tmp2, #SendDataBits  wz  'keep dec tmp2 until all 8 bits sent                      
                        
                        call    #BaudDelay   'waits the appropriate time based upon selected baudrate
                        mov     tmp1, #0 wz      ' all this does is set the zero flag
 'SEND STOP BIT (1)                             
                        muxnz   outa, MIDI_Out_PC' send Stop Bit for pipe chamber if DIRA is enabled
                        nop     'keeps timing between PC and Pipe midi bits the same 
                        muxnz   outa, MidiOutPipe
                        
                        call    #BaudDelay    'waits the appropriate time based upon selected baudrate
                       
                        rol     MIDI_PC_Out_Msg, #16 'shift byte just sent then 1 byte more. Next databyte=LSByte
                        rol     MIDI_Pipe_Msg, #16 'shift byte just sent then 1 byte more. Next databyte=LSByte
                        djnz    NumBytesToSend, #SendMidi wz'number of bytes must be set prior to call SendMIDI                        
SendMIDI_ret            ret 
.

Comments

  • kwinnkwinn Posts: 8,697
    edited 2013-02-15 10:47
    I would suggest using another prop to receive and display the data going to the midi plug rather than buying a digital scope. That is what I use for monitoring communications on RS485 and other serial busses, and it makes a pretty good protocol analyzer.

    Can you post a diagram of the circuit you describe below along with whatever it connects to at the other end?
    Wurlitzer wrote: »
    The output consists of a 2.2K resistor from the prop to the base of an NPN transistor (already tried replacing it. The emitter is at ground and there is a 220 ohm resistor at the collector which goes to the MIDI plug, then the return from the MIDI plug goes through another 220 ohm resistor to +5 VDC. That is the configuration which is running perfectly fine using the original prop circuitry.
    .
  • WurlitzerWurlitzer Posts: 237
    edited 2013-02-15 11:25
    kwinn, used the same prop similar to your suggestion to verify the bit patterns, I wrote the bit patterns from the MIDI_Out Pin to a hub variable then displayed them and they were perfect.

    HOWEVER, I found the problem and I can say BLAME the Chinese.(via Radio Shack)

    I have 4, 3 foot long MIDI cables. I now know one of them is mis-wired and guess which one I grabbed to do this test. Pins 4 and 5 are swapped. Fortunately no damage was done due to the design of the PC's sound card MIDI Opto input device. The other 3 are wired correctly.

    3 days lost thinking I had botched the code somehow.

    Thanks for taking the time to read my saga.
  • kwinnkwinn Posts: 8,697
    edited 2013-02-16 13:02
    Definitely a case of Murphy paying close attention to you! Good troubleshooting though, a mis-wired commercially produced cable is not something you would expect to find.

    I know what you mean about blaming it on China though. I am really getting sick and tired of the cheap "made in China" Smile. I bought a can opener at Walmart a couple of days ago and it quit working on the second can I was opening. I expected a bit better for 10 bucks. Unfortunately it seems to be almost impossible to any household goods, tools, clothing, or similar items that are not made in China.

    Who would have thought made in Taiwan, Malaysia, Korea, etc would become a sign of quality?
  • WurlitzerWurlitzer Posts: 237
    edited 2013-02-18 14:25
    What made this very difficult to diagnose is in the audio card, it would appear that there is a diode which would normally be reversed biased so because the wiring was reversed, it was completing the circuit from the +5 volts through the audio card then returning to the transistor's collector (via a 220 ohm resistor). The wave form looked exactly like it should have. Had this diode not been in the audio card's MIDI input circuitry I would have found this early in the game.
Sign In or Register to comment.