Ebay Classic organs

Collapse

Announcement

Collapse
No announcement yet.

MIDIfy Allen Keyboards: revisited

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Coenraads
    commented on 's reply
    I have since added the code for the Great and Pistons.

  • Coenraads
    commented on 's reply
    You figured it all out on your own and got it running. In the end, that's all that matters. You put a lot of work into your project and I enjoyed seeing how someone else tackled the same problem.

  • Larason2
    replied
    Thanks for sharing this, very useful! I would have perhaps gone this route if I had not already rewired mine to work with my Arduino!

    Leave a comment:


  • Coenraads
    replied
    After an hour trying to figure out why I could not get the pistons to work and why I was getting strange behaviour such as weird ouputs if I so much as touched the Arduino pins, I discovered that I had forgotten to turn on the pullup resistors for the piston inputs. Everything is now working. Lesson learned!
    I checked the ouput using a MIDI monitor and the results look clean. I could only elicit a double turnon/turnoff by flicking a key with my finger when I could actually see the key bounce.
    In any case, I left the debounce count at 6 which takes care of noisy contacts.
    I've downloaded the final result for Swell, Great and Pistons only since my pedal already has an encoder.

    https://sites.google.com/site/casava...-keyboard-midi

    Let me know if you find this useful.
    John

    Leave a comment:


  • jbird604
    replied
    Great work. Nothing better than real Allen keyboards, and this is a perfect way to make them work with any MIDI project.

    Leave a comment:


  • Coenraads
    replied
    The code, for the Swell only, has been placed on my website:

    https://sites.google.com/site/casava...-keyboard-midi

    Readers are welcome to use or adapt this code in any way they see fit.

    Leave a comment:


  • Coenraads
    started a topic MIDIfy Allen Keyboards: revisited

    MIDIfy Allen Keyboards: revisited

    Larason2 has kindly shared his approach to MIDIfying Allen keyboards and there is little that needs to be added. But in tackling this myself on a pair of MDC 20 keyboards, I took a slightly different approach which may be of interest. My main goal was to salvage the existing wiring. For this you will need the schematic provided by jbird604. (Thank you)

    https://organforum.com/forums/forum/...c-schem-needed

    All the keyboard wiring goes to edge connector J95 so I was careful to salvage the parts of the wiring harness running from it to the keyboards. This edge connector clearly indicates the pin numbers corresponding to those in the schematic. A note in the corner of this schematic warns that some of the wires run between the two keyboards, so I was careful not to cut those. Of course, I also retained the wiring for the pistons.

    Examining the schematic, I noted that the diodes are oriented with the diodes pointing away from the bus bar indicating that Allen uses "active HIGH" logic meaning that the keys switch to a positive voltage. This is opposite to an Arduino which is best operated as an "active LOW" device. The reason is that unconnected inputs "float" and can give spurious readings. The Arduino design has a most useful feature that allows you to connect pullup resistors to any inputs ensuring that they normally remain HIGH. The keys then, switch the inputs to ground (LOW). From a programming point of view, it just means that the rolls of row and column in the switch matrix get reversed.

    Next I assigned the Allen pins to Arduino pins using a more logical order than the Allen's somewhat haphazard numbering. I then removed one wire at a time from the J95 connector and connected each to the corresponding Arduino pin. The wire used is wire wrap stuff but it solders just fine.

    As far as coding goes, one could put a single

    if (digitalRead(i) == LOW) {turnONswell (noteNumber);} else {turnOFFswell (noteNumber);}

    inside a pair of nested FOR() loops. This will lead to a short and elegant program but I worry that if I come back to this program a year from now, I'll have trouble remembering how the loop counters and noteNumber calculations work.

    The alternative is to use what I call "linear code" i.e., for a given keyboard the digitalRead statement is written out 61 times. Then you end up with a verbose and repetitive program looking like this:

    digitalWrite (22, LOW);
    if (digitalRead(37) == LOW) {turnONswell (37);} else {turnOFFswell (37);}
    if (digitalRead(38) == LOW) {turnONswell (43);} else {turnOFFswell (43);}
    if (digitalRead(39) == LOW) {turnONswell (49);} else {turnOFFswell (49);}
    etc.

    This may seem tedious but it isn't. Using copy and paste the statements are quickly reproduced and then it's just a matter of going through and editing the numbers which takes less time than figuring out FOR() loops. But the big advantage is that one can see how the program works at a glance.

    Program length is not a concern since I have only ever used a tiny fraction of the program space an Arduino makes available. And as far as speed goes, the longer program will actually run slightly faster since the processor is not burdened with maintaining loop counters and calculating noteNumber values.

    The procedures turnONswell and turnOFFswell check to see if the note is already ON or OFF and send out the appropriate MIDI messages where necessary. They also take care of the debounce count, usually set to 4, or longer if the switches are particularly noisy (not the case with the Allen key switches).

    //MIDI ON message is sent only if note is not already ON.
    void turnONswell (byte noteNumber)
    {
    if (swellDebounceArray[noteNumber] == 0)
    {
    Serial.write (0x92); //note ON, channel 3
    Serial.write (noteNumber);
    Serial.write (0x7f); //medium velocity
    swellDebounceArray[noteNumber] = debounceCount;
    }
    }

    //MIDI OFF message is sent only if note is not already OFF.
    void turnOFFswell (byte noteNumber)
    {
    if (swellDebounceArray[noteNumber] == 1)
    {
    Serial.write (0x92); //note ON, channel 3
    Serial.write (noteNumber);
    Serial.write (0); //zero velocity = OFF
    }
    if (swellDebounceArray[noteNumber] > 0) {swellDebounceArray[noteNumber] -- ;}
    }

    As usual, the program formatting got lost in copying it over, but no matter.
Working...
X