Possibility of DIY to create midi for organ stop rail

Status
Not open for further replies.
Wait!!!! I have a PS here! After re-reading PETE's post above, perhaps the wiring error might be that the wiper fin connects on the TAB to both positive and ground fins. If i removed the ground fin from the TAB so when the floating wiper when pressed would only touch the positive fin of the TAB, and the ground fin on the TAB would have a wire from the TAB to the ground rail on the breadboard might that fix the TAB to be correct? So in the end result there would be a wire from the positive side of the Tab to the pin3 column on the breadboard, and a wire from the negative side of the TAB to the ground rail on the bottom of the breadboard, and when the TAB is pressed the wiper fin would onlyl touch the positive wire to pin3 and away we would go! Some options for you guys -- YES, NO, or just give in and GO AWAY! (haha) Also, the reason for the boolean 5 part is because I plan to hook up more switches on pins 1, 2, 3, 4 but felt it better to get just one actually operational before executing my less than wonderful soldering skills on a bunch of tabs!

I should probably consider sending you guys all a check!!!!

Thanks, Tom
 
The code you posted does work. I tried it on Windows 10 with MIDI-OX. When I trigger each pin in order, MIDI-OX reports this:
Code:
 TIMESTAMP IN PORT STATUS DATA1 DATA2 CHAN NOTE EVENT               
 Opened MIDI Input
 
 0005B5C5   3  --     C0    01    --    1  ---  PC: Brite Acc. Piano  
 0005BFB2   3  --     C0    02    --    1  ---  PC: Elec Grand Piano  
 0005C97A   3  --     C0    03    --    1  ---  PC: Honky-Tonk Piano    
 0005DA3D   3  --     C0    04    --    1  ---  PC: Electric Piano 1   
 0005E733   3  --     C0    05    --    1  ---  PC: Electric Piano 2

If it doesn't detect anything for you then I think you have a wiring error.
For each tab stop, the wiper should connect only to its corresponding Teensy pin. With code similar to your example, there will be a pullup resistor on each pin pulling it up to +5V when the stop is off. The tab should then be wired such that when the tab stop is pushed, the wiper is connected to ground. That is all that should be connected.

I noticed that your code occasionally 'bounces'. The code below uses the Bounce library to debounce each pin and also allows you to specify the input pins in an array in any order (doesn't have to be in numerical order). The code sends a Program Change message whenever a stop is pushed, which causes the pin to change from +5V to ground and thus the code is looking for a 'fallingEdge'.

Code:
/*
  171116 Now named HW_PC_MIDI_send_2 and modified to use an
    array of Bounce objects and send a MIDI PC message for
    each pin.
    
  170131
  _2
    Instantiate an array of buttons using the Bounce2 library
    
  170131
  _1
    Heavily modified by Pete (El Supremo) to test several buttons.
    Uses serial output to identify which button was grounded.
    One at a time please :)

See #24 in https://forum.pjrc.com/threads/28816 for example of
using an array of objects to handle the buttons
  
  Button
 created 2005
 by DojoDave <http://www.0j0.org>
 modified 30 Aug 2011
 by Tom Igoe
 
 This example code is in the public domain.
 
 http://www.arduino.cc/en/Tutorial/Button
*/
#include <MIDI.h>
// Channels are numbered 1-16. Internally, the MIDI library takes
// care of mapping this range into 0-15.
const int midichannel = 1;

#define NUMBER_OF_PINS (sizeof(pin_numbers)/sizeof(pin_numbers[0]))

// Use the Bounce2 library
#include <Bounce2.h>

// debounce interval
const int ms = 10;

// Fill this array with the input pin numbers which do not
// have to be in numerical order. The first entry in the array
// will correspond to a MIDI message of PC 0 (no matter what the
// actual pin number is). The next will be PC 1, etc.
// They just happen to be in numerical order here.
int pin_numbers[] = {
  0, 1, 2, 3, 4
};
Bounce *buttons[NUMBER_OF_PINS];

void setup()
{
  Serial.begin(9600);
  while(!Serial);

  // Initialize the pins
  for(int i = 0;i < NUMBER_OF_PINS;i++) {
    pinMode(pin_numbers[i], INPUT_PULLUP);
    // Create a new Bounce object and store its address in the array
    buttons[i] = new Bounce();
    // Configure the pin number and debouncing interval for this
    // Bounce object
    buttons[i]->attach(pin_numbers[i]);
    buttons[i]->interval(ms);
  }
}

void loop()
{
  // Update each button
  for(int i = 0; i < NUMBER_OF_PINS; i++) {
    buttons[i]->update();
  }
  // Check each button for falling edge
  // If one is found, identify it.
  for(int i = 0; i < NUMBER_OF_PINS; i++) {
    if (buttons[i]->fallingEdge()) {
      // Use 'i', not 'i+1', so that PC 0 is also used
      usbMIDI.sendProgramChange(i, midichannel);
    }
  }
}

When each pin is pushed in order, MIDI-OX outputs this:
Code:
 Closed MIDI Input
 Opened MIDI Input
 0000186F   3  --     C0    00    --    1  ---  PC: Acc. Grand Piano  
 00001DF8   3  --     C0    01    --    1  ---  PC: Brite Acc. Piano  
 0000213B   3  --     C0    02    --    1  ---  PC: Elec Grand Piano  
 00002409   3  --     C0    03    --    1  ---  PC: Honky-Tonk Piano  
 000027BC   3  --     C0    04    --    1  ---  PC: Electric Piano 1
Note that my version also uses the PC 0 message which your code did not.

Pete
 
In my previous message, I was assuming connection of simple buttons. In your case you are using lighted tab stops. Their connections will be a bit more complicated because they need to provide power to the light when the tab is pushed. This power will have to come from somewhere other than the Teensy because it won't be able to provide enough to light more than a few stops at a time. When you want to pull out all the stops you would burn up the Teensy!
Do you have a circuit diagram of one of the tab stops showing each of its pin connections?

Pete
 
Tom posted....
"I should probably consider sending you guys all a check!!!!"

I think Tom you should post either a hand scribbled picture or wiring diagram of what you are trying to do....??

Are you trying to get Teensy to emulate something like this..... "A MIDI LIGHTED PUSH-BUTTON CONTROL BOARD MLPB-1" .....??

"The MLPB-1 MIDI Lighted Push-button Control board is a stand-alone unit that can control up to 128
push-buttons with LEDs as well as a separate MIDI device. The LEDs would normally be integral with the
push-buttons but could be wired separately. The MLPB-1 generates a MIDI signal from the push-button
switches to control an organ system, such as Hauptwerk, via a computer connected to the USB receptacle,
although it could be used to control almost anything via MIDI note-on (Patch) messages. Each push-button
switch has a momentary-on action and sends a message on one MIDI channel only when pushed."

Details of these are at webpage....... descriptions and schematic wiring etc and loads of MIDI message info
http://www.organworks.com/index.php/products/data-sheet

Have you got Teensy to move virtual keys or sound any of the virtual keys on screen in your Hauptwerk software....?
If it doesnt then it is not enabled or setup in Hauptwerk....?? The USB port needs to be detected as a MIDI in.
Teensy needs to be behaving like a keyboard first and foremost, before worrying about the switch wiring or lights.
The only difference between playing a note or changing a program or stop is the MIDI message that teensy or any keyboard sends.

You do not have just one big problem to solve.......you have many little problems to solve.....so break the project down into little bits, slove them then move on to the next..

Even consider the problem of eating an apple.....you dont eat it all in one bite....you take several small bites..... "chew" over each one ...then get the next.

.................... Stepwise Refinement and Logical Thinking ..........
 
Good good morning!!! The problem is partially solved. I have been able thanks to the wonderful advice here, to trace the problem back to the physical switch (TAB) I am trying to use. When I straightened the wiring out, and which is now much more logical, and instead of my TAB mounted on the breadboard a microswitch which came with the learning package i purchased when I got the Teensy ++, the code ran and it did exactly what I wanted it to do. HW automatically detects, Push the microswitch once and stop turns on and remains on,; push microswitch a second time and stop turns off.

So now I just need to know what kind of "Button" I need to purchase so it could be mounted on the console and then wired with one lead going to the pin and one lead going to the ground rail on the board and I'd be in business.

I was very much hoping to refurbish and use the original stop TABS but have learned from the HW Forum that this particular type of TAB is quite difficult to manage as it was originally designed and wired to not only turn the stop on and off but also to move the TAB up or down at the same time == they are called SAMs. These are odd ones made by Reisner and present a problem because there are electro magnets involved which are also grounded to the stop frame. I thought, foolishly, that if I simply stripped all the original writing out of the frame of the SAM that I could utilize it to register on the Teensy ON position when pressed, and OFF when not pressed, but apparently the floating wiper is also grounded to the frame and causes everything to nuts. Working with my multimeter, i was able to establish NO SIGNAL when wiper fin not touching the + and - fins, and signal when wiper fin was in down position touching both the + and - fins. In my head I thought that would work, but well it didn't!!!!

So i think in the interest of getting off your backs and moving forward I will get some buttons and abandon the old TABS. My confusion with buttons is exactly what buttons to get. I don't think I'm qualified to handle anything that lights up the button but it would be nice, so I'd better settle for a simple push on push off situation (maybe there's one that locks down when pushed and pops back up when pushed a second time?

Any suggestion would be greatly appreciated in this regard.

And to all who have so graciously taken the time to be of such great help --- IT IS MOST APPRECIATED ON THIS END!!!!!

Tom
 
"the code ran and it did exactly what I wanted it to do."
"HW automatically detects," ...... so I assume you mean Teensy was detected by the Organ software.
"Push the microswitch once and stop turns on and remains on,; push microswitch a second time and stop turns off." what code are you running....?? The examples above will always send the same code each time the button is pressed and its contacts are closed...???.....assuming one side of the switch is connected to GND of teensy...this is falling edge. Also depending on the code teensy may send another message when the switch opens...rising edge.
Does the Organ Stop toggle on and off if sent the same program change message...??? ...... OR have you a latching switch...??

I assume your microswitch is just a small push button switch with 2 or 3 connections on it. Is it the Latching type...ie press it ...ON... and it stays on until pressed again OR is it monentary ... Press it for ON and let go for OFF...???......you can tell this by checking with a multimeter.

"So now I just need to know what kind of "Button" I need" .... Yes, establish this fron the above tests.....a simple piece of wire from GND on teensy and touch the corresponding input pin on teensy should tell yuu what is happening......Probably a momentary switch will be best but the program in teensy needs to correspond......Normally open contact, close contact when pressed.

Regards lights and need to power these fron a separate power supply, you could use small relays or opto isolators controlled from pins on teensy.


The switch "mounted on the console and then wired with one lead going to the pin and one lead going to the ground rail on the board".....I assume you mean one switch lead to the teensy pin and other switch lead going to teensy GND......only
 
The Hauptwerk software handles the toggling of the stop when the one Program Change message is sent. Pressing the switch once activates the stop. Pressing it again deactivates it.

Pete
 
UPDATE!!!! Well I think i've got it even with the rehab'd TABs. Two things seemed to make it all congeal. First in the code, I increased the delay from 25 to 70 (I'm thinking the delay was really another way of the original program using debounce) maybe). At any rate, I then took another TAB that I had not been fooling with, and using multimeter touched here and there until I got continuity which was acquired when the wiper fin was in the TAB down position, and when in the up position lost continuity. Then did a temporary (not soldered) wire from the gromet on the left bottom end of the TAB as ground, and another wire on the right bottom gromet and ran it to the input pin. Sure enough, when plugged into the breadbord with the left gromet wire in ground rail and right gromet wire into the pin, HW software recognized it as a momentary switch, sent the program change message for on, and when wiper in up position, turned stop back off Now, I don't really understand why, but the wiper in down position comes in contact with both the left (gnd) and right (signal) fins and all works as intended. I also discovered that I hadn't been wearing glasses when I hooked up initial TAB I was working with and the wire going to the ground was stranded vs. solid core which might have made a difference as on the new TAB that hadn't been messed with I made sure I had my hands on the solid core wire!

So next, if I solder the wires onto the TAB gromets (these gromets run directly up and become the fins both left and right), all should be well.

I hope this makes more sense to you than it does to me ... I've got a long way to go wtth this learning curve. I could have accomplished the same task by just putting a Novation Launchpad on but that teaches me nothing and I really enjoy learning what it is that makes things do what they do. I am still very very fuzzy about code writing but plan to continue to study as it looks to be quite fascinating!

Thanks,

Tom
 
The pin is initialized to use INPUT_PULLUP mode which means that it is internally connected to +5V through a resistor of about 20k ohms - this saves you having to add an external resistor for each stop. If nothing is connected to the pin, this pullup resistor keeps the pin at 5V so that whenever you use digitalRead to check its state, it will always read as HIGH (1). When the tab is pushed and connects the pin to ground, it will read as LOW (0).
If the pin had been initialized to just INPUT mode there would be no internal pullup and the pin would float. In this case digitalRead would return very inconsistent results which would drive Hauptwerk crazy, continually turning the stop on and off.

Pete
 
Thanks Pete for all your help. Last night i studied you example code and it worked beautifully. The only problem I have left to solve, is the TAB functions like a push button now. TAB down STOP ON, and TAB has to be placed back into up position and then into down position again to turn STOP OFF. I was hoping to have it the TAB between on position (TAB down) and off position (TAB up). Could I accomplish this with a statement somewhere in that code to read the pin as either HIGH (TAB up stop off) or LOW (TAB down and stop on). Perhaps with an "else" or "another "if". Sorry to be such a bother. Anything you could recommend to point me in the right direction would be most appreciated!

Thanks

Tom
 
My code only sends a MIDI message on a falling edge. I think you need to send the same message on a rising edge too.
Change this:
Code:
    if (buttons[i]->fallingEdge()) {
to this
Code:
    if (buttons[i]->fallingEdge() || buttons[i]->risingEdge()) {

Pete
 
Pete -- Again many thanks. That did the trick. Believe it or not i was getting close to that -- While showering I began to think about if it was looking for a rising edge and then sending program change I somehow needed to have it also recognize a rising edge and turn it off but was baffled by how to express than in the code. The || the boolean operator for "or" that was missing from my thoughts. Again, I can't thank you enough for your help and support with this particular project. i can now proceed with cleaning up and fixing the wiring on the rest of the stop TABS. I plan though to spend some free time i working very simple codes out just for fun and in order to be able to do more with Arduino and the Teensy on my own without having to be so bothersome to you and the forum folks. Thanks again -- if we don't speak again before the holidays -- have a great one!!!!

Tom
 
Status
Not open for further replies.
Back
Top