1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

talking to CTK 571 synthesizer

Discussion in 'PC Hardware' started by Allan Adler, Oct 31, 2007.

  1. Allan Adler

    Allan Adler Guest

    Thanks to all the help I got in the power down thread, today I expect to
    be able to write to a floppy's bootsector and have it execute a simple
    program, such as Hello World or power off. That opens the door to writing
    other programs that either run from the bootsector or which can be loaded
    by such a program.

    I have a lot of reasons for wanting to be able to run programs without
    an ambient operating system. One in particular is one I have asked about
    on at least one occasion on this newsgroup. I purchased a Casio CTK 571
    synthesizer keyboard a few years ago and have never been able to get
    my PC to talk to it. It is supposed to support MIDI. My efforts to work
    with the old pre-Alsa Linux or with installation and use of programs
    running under DOS were complete failures and for stupid reasons, i.e.
    either the OS didn't support what I was trying to do or it did but there
    was no way to figure out why something didn't work. So, I decided it was
    worth trying to figure out how to do it without the enormous distraction
    of working with the operating system.

    I don't really care which I/O device the PC uses to communicate with the
    synthesizer. If there is a way to do it through the parallel port, for
    example, that's fine with me. I'm not sure at the moment what it does
    have. It is an old PC minitower so it probably has a serial port. It also
    has a sound card of some kind, but not Sound Blaster and I don't think it
    is any well known card; don't remember at the moment. These are all things
    I can try to explore using simple programs run from the bootsector, for
    practice, or maybe by looking at dmesg or something under Linux. At one
    point, I purchased an adaptor that connects to the 15 pin D output of the
    sound card and branches into two connectors that plug into the midi ports
    of the CTK 571 synthesizer. So, in principle, I think that means that I can
    talk to the synthesizer through the Game port of the sound card. Unfortunately,
    I don't know anything about the card, although I once looked up some
    documentation on the chip that it uses and found it entirely unhelpful. That
    sounds like sufficient reason not to use the sound card, unless there are some
    simple bootsector programs I can run to probe it and figure out how to use it.
    The only real advantage it offers presently is that I have this connector that
    at least plugs into the appropriate ports of the CTK 571 synthesizer keyboard.
    That's not much, but I don't have anything comparable for any other output
    device (e.g. the parallel port).

    One thing I have found very confusing is that most of the literature I have
    seen is about using the sound card to produce sounds, not about talking
    to an external device through the Game port.

    Maybe the sound card has some BIOS associated to it and maybe now is the
    time to try to read it. The first obstacle is finding out where exactly
    this BIOS would be located. Nothing like this seems to be mentioned in
    the informative page

    In order to make this very concrete, the short term goal now is to write
    a program that resides on the bootsector which will, after POST, cause
    the CTK 571 synthesizer to play one note. Hopefully, such a program would
    just be a few lines long.

    Does anyone know how to do this or how to attack the problem in the absence
    of any useful documentation? It would be best if I don't have to buy anything,
    because buying stuff when I don't know what I am doing (as I did when I
    bought the game port to MIDI adaptor) can be a very expensive activity.

    Hmm, now that I think about this again, for the first time in years, it
    occurs to me that maybe one of the MSDOS programs that is supposed to talk
    to the sound card comes with source code that can be imitated or adapted
    or scavenged to run on the boot sector.

    In the interests of full disclosure, I should also say that I have, since
    then, received a damaged Compaq Presario 3000 - model 3045US laptop which
    I'm in the process of trying to repair. It has a version of Ubuntu on its
    HD which supports Alsa and I may eventually be able to just use the CTK 571
    with it. So, it may not be absolutely necessary to try to figure out how
    to write a bootsector program that will play one note on the synthesizer
    keyboard. But it will still be very educational to solve this problem,
    so I'm still interested in doing it.
    Allan Adler, Oct 31, 2007
    1. Advertisements

  2. Allan Adler

    Allan Adler Guest

    According to the book, "PC Hardware in a Nutshell", the only pins on
    the D-connector (i.e. the game port) that are relevant to MIDI are pins 12 and
    15. Also, the book says that the base address of the game port is 201h and
    that writing to that address resets the monostable multivibrators, but that
    information is based on using the port in connection with a joystick or
    paddle plugged into it. It may not have anything to do with MIDI or what
    one has to do to use MIDI. It does, however, emphasize that there is no
    IRQ associated with the game port. That's around p.575. Around p.521,
    it briefly describes the format of MIDI. I think that I don't need much
    more information to do this, but that is all I have right now.
    Allan Adler, Nov 5, 2007
    1. Advertisements

  3. Allan Adler

    Arno Wagner Guest

    Midi is by Motorola (originally) M8050 UART (serial interface chip),
    if I remember correctly. There are no handshake lines and one direction
    of the interface (input) is supposed to run through an opto-copupler,
    probably omitted on todays cheap hardware. The output is a 10mA
    current loop and drives an opto-coupler on the other device.
    So for a proper MIDI input, you may have to add said opto-coupler
    to get proper electrical insulation.

    Here are some references for the hardware:


    Arno Wagner, Nov 5, 2007
  4. Allan Adler

    Allan Adler Guest

    Let me try to understand this: you're saying that the game port to
    midi cable I bought from Comp USA, which is supposed to solve the problem
    of connecting the Game Port of the sound card to the synthesizer's MIDI
    port, doesn't solve the physical problem and reduce the rest to programming?

    Regarding the UART, that is another point of confusion. The web site
    gives base addresses for various I/O ports. It mentions the Game Port
    at hex addresses between 200h to 20Fh, sound cards at hex addresses
    220h to 233h and also a MPU-401 UART at 330h to 331h. So, if the Game
    port is really a UART, I'm not clear on the first versus the last set of
    base addresses (not that I would know what to do with the base address even
    if I were clear on that point).
    I took a quick look but I don't really understand the problem these
    constructions are supposed to solve, nor how to decide whether I have
    that problem.
    Allan Adler, Nov 5, 2007
  5. Allan Adler

    Arno Wagner Guest

    If the cable contains the opto-coupler, the driver chips and the other
    parts, then it is fine. If not, it can cause real problems.
    You do not care about the game-port. The MPU-401 UART is what drives the
    MIDI interface. And, no, the game port is not an UART at all.

    It a) isolates the input line and b) drives the output line with
    10mA. Both things the MITI port on the PC does not do itself.

    Arno Wagner, Nov 5, 2007
  6. Allan Adler

    Allan Adler Guest

    I have the cable in front of me but I no longer have the packaging it
    came it. I don't think it ever contained any documentation. I don't know
    how to tell whether it contains an opto-coupler, driver chips and other
    parts, but it seems doubtful. I don't see any way to open it up to find
    out for sure and I don't see any writing on it that would shed any light
    on it.

    So, apparently one can't simply go to Comp USA and tell the salesperson
    that one needs a game port to MIDI port converter.
    Thanks for clarifying that the game port is not a UART. So, if I were going
    to use the game port, the base address 201h would be the right one.

    Why does the book "PC Hardware in a Nutshell" say that one can use the
    game port for MIDI? Are there connectors one can purchase (e.g. from
    Comp USA) that are appropriate for what I'm trying to do?
    So, these pages basically tell me how to build the connector that Comp USA
    should have sold me instead of what I bought?

    What do you mean by (a)?

    Now, suppose I promise never to use the input line and only to send music
    out to the synthesizer keyboard on the output line. And suppose I try to
    measure the current of the output line and find that it can be 10mA. Is
    it then ok to use the connector I bought from Comp USA?

    Maybe instead of immediately connecting the game port to the synthesizer,
    I should instead get it to talk to a solderless breadboard, where I can
    conveniently connect pins 12 and 15 to test equipment.

    I'll look more closely at the two web sites you referred me to and try to
    make sense of what they are really doing.
    Allan Adler, Nov 5, 2007
  7. Allan Adler

    Arno Wagner Guest

    No, you cannot get to an end-user store and expect them to
    know specialist equipment. Ok, you can use a multi-meter
    to see whether the MIDI-IN pins on the far side of the cable
    are connected to the MIDI in pins on the 15 Pin gameport connector.
    If so, no Opto-coupler and the cable may induce 60Hz hum or
    damage things. However if this is indeed a full-spec MIDI
    cable, then it should have the coupler. The drivers are not strictly
    The game port can be used for MIDI. It is really two devices in one
    connector: A joystick port, that has no connection to MIDI and a MIDI
    port. However the joystick port controller is not the game port
    controller, as there is no such thing. I guess that often people will
    call the joystick controller the "gameport controller".
    Depends. You may have gotten the real deal. No idea.
    There is no electrical connection between input and output. The midi
    standard specifies that midi connections between devices have
    to be electrically insulated, i.e. no electrical connection between
    the devices.
    Again, the nsulation is necessary. It does not matter if you use
    the signal line.
    Good idea.
    Maybe a hint what an opro-coupler in this type of application is:
    It gets a current signal on one side and has a switch on the other
    (simplified). These two are connected purely optical, and isolate
    input from output.

    Arno Wagner, Nov 5, 2007
  8. Allan Adler

    Allan Adler Guest

    OK. The only way I know to test the output pin for 10mA capability is
    to put it in a circuit where it would have to output that current in
    order to work. I can figure out how to do that, but I'd like to be sure
    that I won't damage the port if the output pin really isn't capable of
    that much current.
    Your comments are this topic are really very helpful. I keep finding out
    that everything I thought I knew is wrong. I just now did a google search for
    joystick port circuit
    and found an article by Michael A. Covington
    which includes a circuit diagram for joystick ports, experiments one can
    do with joystick ports (e.g. measuring temperature, voltage, etc.) and
    some supporting programs. He doesn't explicitly identify any part of the
    joystick port circuit as being a MIDI port. When you say that the joystick
    port consists of a MIDI port and the real joystick part, these being
    unrelated to each other, can you perhaps identify which is which in the
    diagram in Michael Covington's article?

    Regarding the distinction between the joystick port and a UART, I did a
    little reading in The Undocumented PC and in PC Hardware in a Nutshell.
    In both, necessary details about MIDI get lost in the shuffle. In the
    former, UARTs are only discussed in the context of serial ports and especially
    modems. In the latter, MIDI is mentioned as something you can do with a
    joystick port but there is not a word about the need for a breakout box if
    you do it that way.

    For example, since the machine in question can use a dialup modem
    (external, I think) maybe I can use the 25 pin connector for the modem
    to send MIDI output to the Casio CTK 571 synthesizer keyboard. Somehow
    I'd need to make an adaptor to go from the 25 pin D connector to the
    midi ports of the CTK 571. But are you saying that I would no longer
    have to worry about whether the input line is isolated (since it presumably
    would be) or whether the output line is capable of supporting 10 mA
    (since presumably it would)?

    I can use the software that comes with the book, The Undocumented PC,
    to find out some things about the hardware, including serial ports,
    so there might be other UARTs I can use (I think the book mentioned the
    mouse port, e.g.).
    Thanks. But I'm not sure about the detail about supporting 10 mA, for the
    reason I mentioned above.

    I still haven't done so. Hopefully, tomorrow I'll be able to get to a library
    and print them out.
    I vaguely recall that Radio Shack used to sell pairs of infrared LEDs
    that could be used to send signals, one sending the IR light and the other
    receiving it. My impression (maybe wrong) is that this is what an opto
    coupler amounts to.
    Allan Adler, Nov 6, 2007
  9. Allan Adler

    Allan Adler Guest

    I think I'm starting to understand what is going on. Some pins of the connector
    connect to the UART. Those are the pins that are relevant to MIDI. The other
    pins are just for the joystick functions. Memory location 201h pertains to
    the latter and those relevant to MIDI are elsewhere.
    I printed out and read the article. He seems to be talking about actual
    joysticks built into an old IBM PC. It's irrelevant to the present
    I'm informed that the UARTs used in the serial ports can't be used for MIDI.
    I connected the PC to the synthesizer via the game port to MIDI cable. There
    are no menacing 60 cycle hums. I'm hoping that this means no serious damage
    will be done if I just try to do this without a breakout box, even though
    it might not work in case the output pin can't support 10 mA. So far, no

    By looking at /proc/isapnp from the RedHat 7.3 Linux partition, I found out
    that the sound card is made by Avance Logic and I'm now to initialize the
    PnP device. In setup, I told it that PnP OS was not installed, which resulted
    in a message about successful updating of ESCD. Next, I'll install a file
    AWCONFIG.EXE from ALS110.ZIP from
    on the FREEDOS partition and see if that helps. This is the result of good
    advice on a MIDI group.

    I'm advised that initializing the PnP sound card is not something I would
    normally want to do in assembly language. That is probably correct, but
    I'd like to know how it is done. Maybe it is possible to scavenge from
    AWCONFIG.EXE the part that actually does the initialization (if that file
    works) and use it in the boot sector of the floppy I'm trying to create.
    I wouldn't know where to find that part of AWCONFIG.EXE, but maybe there
    is source code available somewhere. I googled
    awconfig source code
    but it appears there a lot of programs named awconfig.
    Allan Adler, Nov 8, 2007
  10. Allan Adler

    Arno Wagner Guest

    I am unsure about that. It may be possible, but it certainly
    would need interface electronics.
    For get about initializing the soundcard. You only need the UART, and it
    is strictly speaking not part of the soundcard. It also is easy
    to initialize. Best get a datasheet for the 8250 chip and read that.

    Arno Wagner, Nov 8, 2007
  11. Allan Adler

    Allan Adler Guest

    OK, I'm looking. So far, the best I've found online is
    which is pretty skimpy on details. I'll keep looking.

    Assuming I get a complete data sheet, how do I use that information to
    address the UART in an assembly language program?
    Allan Adler, Nov 9, 2007
  12. Allan Adler

    Arno Wagner Guest

    That seems to be for a ''core'', i.e. something you can put into
    an FPGA or ASIC.

    You can get a datasheet for the 16c450 here:


    It is very close to the roriginal 8250, but supports faster speeds.
    The 8250 did not support the 38kBaud (I think) MINID uses anyways,
    so the MIDI port likely uses someting like this chip.

    Arno Wagner, Nov 9, 2007
  13. Allan Adler

    Allan Adler Guest

    OK. Since then, someone sent me an 8250 data sheet.
    I've downloaded it.

    So, now I have data sheets for two UARTs. Assuming one of them to be the
    right one for my old machine and old sound card, how do I use the information
    contained in it? More precisely, how do I use this information to write
    an assembly language program to talk to the chip?
    Allan Adler, Nov 9, 2007
  14. Allan Adler

    Allan Adler Guest

    I've had more time to think about it and I think the most likely way
    to interpret Arno Wagner's suggestion to look at the data sheets is
    that I need them to decide whether the MIDI output line can support
    10 mA and, therefore, whether I need to build a breakout box. It isn't
    relevant to the question of how to write a program that specifically
    talks to the UART.

    The only data in the data sheets that specifically addresses current (apart
    from negligable leakage currents) is that the average power supply current
    is is 10 mA. That doesn't address what the individual output pins can support.
    The only other clue is that the power dissipation of the chip you suggested
    is between 0.8 W and 1.1 W.
    Allan Adler, Nov 10, 2007
  15. Allan Adler

    Allan Adler Guest

    Since Arno Wagner approves of this idea, I'm encouraged to try it. But I
    think I need some advice on inexpensive and reliable ways to connect the
    relevant pins to the breadboard. I don't own any D15 connector other than
    the one that converts to the MIDI and I don't want to destroy it.

    Likewise, I'm considering connecting the MIDI ports of the Casio CTK 571
    to the solderless breadboard and seeing what they are doing. For example,
    the port that is supposed to send signals from the synthesizer to the PC
    could instead be connected (but how, exactly?) to the breadboard and I can
    see just what signals do go out when I play notes on the keyboard. Such
    exercises might remove some of the mystery from what I'm trying to do.

    How about this: is there a simple circuit I can build on a solderless
    breadboard that I can use to send signals to the keyboard through its
    midi input port to get it to play one note?

    Instead of having two machines, the PC and the synthesizer, neither of
    which I really understand, and trying to figure out how they relate to
    each other, maybe there are simple ways to simulate each electronically
    one while studying the other.
    Allan Adler, Nov 10, 2007
  16. Allan Adler

    Arno Wagner Guest

    Aehm, by writing and reading from/to its registers with port commands?

    Arno Wagner, Nov 10, 2007
  17. Allan Adler

    Arno Wagner Guest

    Actually the datasheet is the programming reference for the
    UART. It will not help you decide the 10mA Issue. The UART
    itself will have some kind of output driver in addition, given
    that it is not present as physical chip anyways.
    You can ignore that.

    Arno Wagner, Nov 10, 2007
  18. Allan Adler

    Arno Wagner Guest

    Well, get some more DB15 connectors you like (there are different
    versions with regard to the solder-side) from an electronics-parts
    Indeed. Do so.
    No. If I remember correctly, you need to send several bytes to
    play anote. Doing this in hardware takes a lot of effort.
    Doing it in software (microcontroller) is more effort
    than doing it via the PC.
    Not really. You could look up some info on how a serial port signal
    works. The MPU401 is really the same, except that it does not have
    handshape lines, its baud-rate is fixed and it does 10mA current
    loop insted of the +/-12V an RS232 does. The signal timing is the
    same. The relevant info is e.g. in the datasheet of the UART.
    Don't worry if you do not understand it on first reading. But
    all the information (except the electrical stuff) is relevant to
    understand its functionality and how to programm it, so it is
    really worthwile reading that datasheet carefully until you
    understand it. I learned a lot doing that a long time ago.

    Basically it works like this on sending:

    Write stuff to registers to set baud-rate, start-bit, stop-bit(s)
    and some other config things.

    To send, write the byte you want to sent to the appropriate
    register. Then loop checking the status register to see whether
    the byte was sent. This takes some time, at 8bits roughly
    300usec. Then repeat.

    An UART is not complicated, but has zero intelligence of its
    own. Baiscally it can not do more than send ore receive a byte
    and then wait. IOt looks for instuction and data in its registers,
    which can be read and written from the PC.

    Arno Wagner, Nov 10, 2007
  19. Allan Adler

    Allan Adler Guest

    OK, that makes sense. But how does one find out which port refers to
    the UART?
    Allan Adler, Nov 10, 2007
  20. Allan Adler

    Allan Adler Guest

    Thanks for clarifying that the data sheet for for programming, not
    for deciding whether I need to build a breakout box.

    I didn't know that the UART is not a separate chip.

    Pursuant to your recommendations in your other posting, I'll print out
    the data sheets and study them.

    I'll also see if I can locate a cheap supplier of DB15 connectors,
    MIDI connectors, etc.
    Allan Adler, Nov 10, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.