Forum Top Banner Ad

Collapse

Ebay Classic organs

Collapse

Announcement

Collapse
No announcement yet.

Decoding bussed keyboard?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Decoding bussed keyboard?

    Howdy.

    So, I have that old Allen T-12a, which I am MIDIfying into a VPO.

    I don't have a schematic, but it looks like the key switches ground the input contact when the key is pressed (that's how I'll wire it, anyway, even if it isn't really doing that currently). It's a bussed keyboard, rather than a matrix.

    I plan to do my MIDI encoding with a Teensy 2.0 microcontroller.

    In web-searching and head-scratching about the best way to decode a bussed keyboard, I am finding circuits that use shift registers. That seems a little too complicated to me.

    So yeah, I apologize if I am being really dumb, but....

    I am kinda wondering why I can't just use 8 octal tri-state buffers (for a single 61 key manual), whose inputs are pulled low when the keys are pressed. The outputs of the tri-state buffers could then be tied together and fed into 8 pins of the microcontroller. Then 8 output pins on the microcontroller could be used to select which of the tri-state buffers would be turned "on" at a time. It would kinda look like a matrix keyboard to the software (and only use 16 pins instead of 61).

    Or heck, might just be able to use transistors instead of tri-state buffers, but I am extra-dumb about electronics that aren't strictly digital.

    So rather than clocking a shift register, you'd just set "bank enable 0" low, read the 8 bits of input for the first 8 keys, set "bank enable 0" high again and "bank enable 1" low, read the next 8 bits for the next 8 keys, and so on and so forth until all the keys were read. I would assume that a 16MHz AVR microcontroller would be able to do this fast enough that timing would be a non-issue, even if one doubled the number of octal tri-state buffers and implemented velocity sensitivity with a second row of switches (I think I can modify the Allen manuals to do this by sliding a piece of tubing over half of each of the wooden bars in there, to make the whisker contacts stand out at different distances, but that's a discussion for another time lol). I would think that a scan rate above 100/sec would be plenty sufficient.

    However, if it were actually that easy, you'd think that's what everyone would be doing, instead of using shift registers. I would assume nothing bad would happen if more than one of the octal buffers was active (outputs trying to drive each other) until the microcontroller initialized and turned them all off? (Edit: After hmm-hawing a little, I am pretty sure that all the IO pins on the AVR board are tri-stated when it boots up, so as long as the software doesn't do something stupid it all ought to be alright......... I suppose if one wanted to be ultra-paranoid, one could use an address decoder on the enable lines to make sure that only one could be pulled low at a time, regardless of the state of the microcontroller.)

    What do y'all think? I haven't done anything like this since I was in college, which was uh... Several years ago. I'm afraid I may no longer know what I am doing (assuming I ever did to begin with). :P

    Would it be a little more clear if I scribbled a schematic and posted it? Here:



    I omitted the pull-up resistors, but you get the gist, right?
    Last edited by Mr. Polecat; 10-27-2018, 07:29 PM.
    1914 Estey Parlor Organ. 196x Allen T-12a "Special" (MIDI VPO project). Digital piano. Various guitars. Autoharp. Banjo. Bowed saw. Musical Cat.

  • #2
    Shift registers are used to convert parallel to serial, hence greatly reducing the number of long-distance wires, and the number of inputs you need. In fact, there's no reason you couldn't handle every key on every manual and pedalboard, with a single input. If I were you, that's how I would do it.

    Comment


    • #3
      Thanks for the advice!

      So reading one bit at a time using shift registers would be fast enough to scan ~350 inputs (two velocity-sensitive 61-key manuals, 32-key pedalboard, stops, and various switches) around 200 times per second? That would be a, what, ~100kHz clock on the shift registers, and I am not sure how many cycles it would take the uC to do the clock+read+store+sendMIDI operation. It would have to do each such operation in < 200 uC clock cycles, I think, to use the 14 MHz AVR unit (which I want to use because it operates at 5v instead of 3.3). I'd have to send USB-MIDI messages, too, so that would take some cycles, but probably not enough to matter assuming the software wasn't too stupid.

      That seems like enough clock cycles, but maybe cutting it a little close. I just have no idea how many it would really take. It seems like maybe reading 8 bits at a time would be faster, assuming that accessing the IO pins would be the performance bottleneck. Hmmm, reading 8 bits serially would take uh... 24 IO operations (clock low, clock high, read, repeat x8), whereas 8 bits in parallel would take uh... 3 IO operations (disable previous, enable current, read) plus some bit banging once the byte was read (but I assume that would be much much faster than IO port access).

      Whaddya think? Like I said, I don't really know what I am doing, so.... Haha.

      Although I guess if I used 74HC165 shift registers, I'd only have 4 lines from the uC to the bank of shift registers, so 3.3v<->5v logic conversion wouldn't be a big deal. Then I could use one of the 48MHz boards (which is cheaper anyway), or an even faster one.

      That's still a whole lot of chips though, urgh. At this rate I'd be better off to buy an off-the-shelf MIDI conversion board for bussed keyboards, which would spoil half the fun. :P

      Maybe the best idea would be to cut the ground bar on the manuals into sections an octave wide and turn them into key matrices. Then all I'd need is a perfboard full of diodes and the uC board. Small. Cheap. Already have a big bundle of wire coming down to where the boards will be anyway, with the original wiring I was gonna reuse. Hmmmm.
      1914 Estey Parlor Organ. 196x Allen T-12a "Special" (MIDI VPO project). Digital piano. Various guitars. Autoharp. Banjo. Bowed saw. Musical Cat.

      Comment


      • #4
        If I remember correctly, this sort of analog Allen organ used +14V keying on the key contacts--certainly you could use this to switch ground instead, if that's the way you want to go.

        The keying system works as follows;

        1. Each key lifts one end of a crank shaft rod, causing the crank shaft to rotate, pivoting the rod towards individual pitch register contacts.

        2. The pitch register contacts pass through insulating strips (one strip per pitch register), and fixed at one end to an insulating plate, where they are wired to connect to oscillators. The insulating strip slides laterally when engaged by a solenoid.

        3. The key contacts, thus, only make contact to the output wires when the key is pressed and a solenoid or solenoids are engaged.

        To use this sort of contact system you'll have to have a solenoid engaged--a strong rubber band pulling the armature might be the easiest way to do this, or perhaps a simple Nylon cable tie. You could use multiple solenoids to add some redundancy to the system in case of individual contact failure. It will, however, be difficult to separate the voltage supplying the crank shafts into octaves as the mechanism which supplies the voltage runs the length of the keyboard and isn't easily cut apart.

        Some sort of parallel input system is the easiest approach with key contacts like these, thus the common use of serial shift to parallel shift registers for this application.

        Note that pipe organs have virtually no velocity sensitivity. Any design work to add velocity sensitivity would be for MIDI non-organ applications rather than for VPO implementation.

        Comment


        • #5
          Frankly the easiest thing to do is what someone mentioned recently in another thread: Find three junk cheapo electronic keyboards, remove the keys and case, connect your keyswitches where the keyboard's keys yoostsaby, and Bob's your uncle, you've got MIDI.

          But the thing with the shift registers is that it's done synchronously. You don't need a 100kHz clock. You send a clock pulse whenever it's convenient for your processor to read the next key, then reset the clock to low. If for some reason that isn't fast enough, you dedicate a processor to this task and do your other work with another processor. But at a few MHz, you should be able to do everything in one.

          I would use shift registers even if all the shift registers were at the processor, and you had wires from all the keys running to there. You'd only need one input and one output. I/O is expensive, especially if you have to do level conversion. This is why things like MIDI and USB are serial. You can do all your console indicator outputs the same way with just two more lines! That's 4 I/O lines for everything your console does, leaving all the rest of your I/O for MIDI, USB, a character display, etc.

          Comment


          • #6
            I did something like this back in 1977, the age of 74LS logic and wire-wrap. I used a tree of TTL multiplexer chips: 74150 16:1 muxes and 74LS151 8:1 muxes. 74150 is long obsolete, but you can still get 74LS151, though pricey (at least at Digi-Key). One nice feature of 74LS TTL is that you get input pull-ups for free. It's 5V technology, so you'll need to protect your processor inputs unless they're 5V tolerant. 3.3V CMOS outputs are compatible with 74LS input levels, though you may need buffering if driving a lot of mux select inputs.

            I personally prefer multiplexers to shift registers since they're purely combinational and don't need a clock. Whenever you need to distribute clocks any distance you need to deal with transmission line effects, whereas with multiplexers you don't care about ringing as long as you leave enough time between changing select lines and sampling the output.

            I recently scored a Rodgers Trio 321C which mostly works and I plan to add VPO capability at some point. The Trio uses +12V for most of the keying so I'm planning on trying CD4512B 8:1 multiplexers. Those are true CMOS and work with VDD from 3V to 15V, so I can connect Trio circuits directly to the CMOS supplies and inputs. I'll need a few transistors to convert between 3.3V microcontroller I/Os.

            Comment


            • #7
              I highly recommend the SPI port approach using shift registers, specifically the 74HC165 devices. I normally reuse existing keyboard wiring and keep the input boards with the shift registers close to the main encoder board. It's easy to run SPI at 5Mhz without issues. That's way faster than you need to handle multiple keyboards.

              One of the issues with the Teensy is that only one of the SPI channels is fully buffered though you can do two keyboards at a time (128 buffered bits) if I remember correctly. You can also enable chip selects for two keyboards at a time so that would allow you to get good results from a Teensy. I like the PIC32 MX and MZ chips as they support 4 or 6 fully buffered SPI channels. They require C programming which isn't as easy as the code to do a sketch for a Teensy, so that's the tradeoff.

              The advantage of independent SPI channels with buffering is that they run without the supervision of your own code. They can all run simultaneously (nearly) which is a huge advantage for a MIDI encoder system. You end up spending much more time processing bits than collecting them.

              EDIT: Additionally I'd recommend keying to ground unless it is essential to keep the old circuitry running. It is NOT necessary to use high keying voltages if you start with clean contacts. I've gotten consistently excellent, reliable keying on numerous consoles using 3.3v with 10k pull-up resistors. It it's necessary to keep a 12v keying source then use voltage dividers to get the 3.3v that any up to date MCU will require. Also, beware of 3.3 to 5v convertors which are often too slow.

              I do a fair amount of matrix encoding as well. A matrix has it's own speed issues as well as radiating a lot of signal that is a potential problem.
              http://www.nwmidi.com

              Comment


              • #8
                I have a board available at OSH Park for the Teensy 3.6 for use as a MIDI Encoder. There are also a couple of input board designs. All at https://oshpark.com/profiles/jkinkennon

                EDIT: corrected URL. Note that there are also inputs for 8 pots so you can handle expression pedals or volume controls. I don't have a complete Arduino/Teensyduino sketch but could provide the code I used for a Moller Capture System which could serve as a starting point for a complete encoder/decoder.
                Attached Files
                http://www.nwmidi.com

                Comment


                • #9
                  Thanks for the feedback, guys. I really appreciate it!

                  I hate to be "that guy" who asks for advice and doesn't take it, but..... :)

                  I was looking at the organ some more today (I don't have it in my house yet; I'll have to take it apart to get it inside and upstairs, so it's hanging out in a nearby garage for the moment heh), and it looks like I can convert it to a matrix very easily.

                  The ground bar for the key switches connects to one side of the key switches via springs, and the bar sits in a diagonal slot in the back of the frame of the manual, held in by the pressure of those springs. I believe I can temporarily unhook those springs, remove the ground bar, cut it into several sections that are electrically isolated from each other (probably 16-key sections), and then reassemble everything. I'll bring a wire from each of those, along with all of the individual wires that already come from the other side of the key contacts, down to a protoboard with a bank of diodes on it (to keep the keys from crosstalking), and tie everything together into a matrix there.

                  I think that'll be a minimum of hardware required; only the microcontroller board, some diodes, and some pullup resistors. If I were gonna read two 61-key bussed keyboards with two switches per key, that'd take 30 8-bit shift registers or multiplexers, heh.
                  1914 Estey Parlor Organ. 196x Allen T-12a "Special" (MIDI VPO project). Digital piano. Various guitars. Autoharp. Banjo. Bowed saw. Musical Cat.

                  Comment


                  • #10
                    Matrix works great. It uses a lot of pins on the Teensy as you will need a 16x16 matrix to get 4 sets of 8x8. The usual approach is 16 columns that are at a high logical output. 16 inputs with 10k pull-ups or even 4.7k for faster capability as matrix settle time is the resistance times the cable capacitance. Short cables and strong pull-ups are great. Matrix errors from running too fast are not easy to troubleshoot so if there are errors just slow things down a little. Or process 8 keys (8 bits x 2) between columns to give the matrix time to settle. Read 16 bits, change to next column, process the 16 bits, read, etc.
                    http://www.nwmidi.com

                    Comment


                    • #11
                      If you want to go matrix and have limited MCU pins, you might want to go with a 32 x 8 matrix (4 sets of 8 x 8) and use 74x138 (or similar) decoders to select rows of the matrix. Some decoders can sink lots of current (24 mA for the TI 74LVC138A) so you can use stronger pull-ups. The '138 has 3 enable inputs so you can probably get by with 6 MCU outputs to select one of 32 rows.

                      Comment


                      • #12
                        I think I will have more pins than I need. The Teensy++ 2.0 has 42 IO pins (as I recall, 42 or 46, I never can remember). That ought to be more than enough for both manuals, the stops, and the pedalboard (assuming a 14 MHz AVR is fast enough to process all that at an appropriate rate, heh).

                        Though I may convert the pedalboard separately with a regular Teensy 2.0 (25 IO pins), as a completely separate MIDI device, so I don't have such long runs of wire. Will have to see how troublesome it is in prototyping.

                        I might hook the swell pedal to the pedalboard controller as well if I have enough pins left, but I'll more likely take it out and mount 3 MIDI expression pedals somewhere. I want two swell pedals and a crescendo.
                        1914 Estey Parlor Organ. 196x Allen T-12a "Special" (MIDI VPO project). Digital piano. Various guitars. Autoharp. Banjo. Bowed saw. Musical Cat.

                        Comment


                        • #13
                          The Teensy++ 2.0 is an 8-bit processor running at 16 MHz. For an extra $15 the Teensy 3.6 runs at over ten times the speed with four times the data width. For a single pedalboard or a single keyboard the 8-bit approach will get the job done but my advice is to spare a lot of frustration and get the blazingly fast Teensy that can handle as many manuals as you like along with pistons, toe studs, stops, and analog inputs. Just running a USB output is a serious task for an 8-bit processor.
                          http://www.nwmidi.com

                          Comment


                          • #14
                            Thanks. I'll do that.
                            1914 Estey Parlor Organ. 196x Allen T-12a "Special" (MIDI VPO project). Digital piano. Various guitars. Autoharp. Banjo. Bowed saw. Musical Cat.

                            Comment

                            Hello!

                            Collapse

                            Looks like you’re enjoying the discussion, but you haven’t signed up for an account yet.

                            Tired of scrolling through the same posts? When you create an account you’ll always come back to where you left off. With an account you can also post messages, be notified of new replies, join groups, send private messages to other members, and use likes to thank others. We can all work together to make this community great. ♥️

                            Sign Up

                            Working...
                            X