It is currently Fri Mar 29, 2024 9:30 am


Lighted Stop Rail Scanner: Arduino

Building organ consoles for use with Hauptwerk, adding MIDI to existing consoles, obtaining parts, ...
  • Author
  • Message
Offline

Coenraads

Member

  • Posts: 73
  • Joined: Fri Feb 01, 2019 10:13 pm

Lighted Stop Rail Scanner: Arduino

PostSun Feb 24, 2019 6:12 pm

Some time ago, someone asked whether the Arduino was compatible with lighted stop switches, and I gave assurance that almost certainly the answer is yes. Giving it some thought, I realized that there is one simple solution. In a matter of minutes, I had implemented it using Jeux d'Orgues on my iPad.

I programmed one Arduino using my Parallel Scanning program and a second with my Decoder program. I wired up four momentary switches to the encoder and four LEDs to corresponding pins on the decoder. I then connected the two boards to a MIDI shield. The encoder was connected to the Tx (transmit) pin and the decoder to the Rx (receive) pin. For this, the shield cannot sit on one of the Arduinos, so make sure it receives power and ground from one Arduino and that the Arduinos share a common ground.

I programmed four of the stops on the iPad organ to respond to the switches and set the stops to toggle mode. Next I set each stop to send out an On or Off signal as the stop toggles. And soon the lights were turning on and off as I turned the stops on or off, either through the touch screen or my external momentary switches.

The tabs on lighted stop rails usually have one momentary switch for On and another for Off. Even lighted drawknobs work this way with a pull being On and a push, Off. To operate in the toggle mode just described, the On and Off switches can be wired in parallel so that pressing either one causes the stop to toggle. Of course it is possible to code the scanner to respond properly to the On and Off buttons (so called "Normal" mode) thereby simulating a stop that physically toggles. Let me know if you would like to see the code for this and I'll see what I can do.

One problem arose, however, the lights did not properly respond to the general cancel button. Although the stops nicely retired, only one of the lights turned off. Any thoughts on why this might be would be welcome. Again, it is possible to have the decoder detect the cancel button and clear all the lights, but that strikes me as a wart.

About the lights: If the lights are incandescent, the most elegant solution is to replace them with LEDs in series with about 300 ohms. Although each pin can drive 40 mA, if many pins are on simultaneously, make sure the total current drawn does not exceed 200 mA. So if each LED draws 5 mA, say, then, at most, 40 can be on simultaneously.

If the lights are incandescent and running on 12 V DC, some kind of driver is needed. See my discussion on MOS FET drivers in my Decoder post, even though these units would be gross overkill. Check to see if the drivers already in the organ can be adapted.
John
Offline

Coenraads

Member

  • Posts: 73
  • Joined: Fri Feb 01, 2019 10:13 pm

Re: Lighted Stop Rail Scanner: Arduino

PostSat Mar 02, 2019 5:16 pm

I asked the question why my encoder/decoder setup, although it responded properly to individual stop changes, made either through the touch screen or the external buttons, did not respond correctly to the general cancel, or the combination action for that matter. This turned out to be an interesting debugging exercise which I hope will prove instructive.

Since the general cancel (all stops off) seemed to only affect one of the four stops drawn as indicated by my lights, my first thought was that Jeux d'Orgues must be sending messages employing running status. Normally MIDI messages consist of three bytes: Status, Note Number and Velocity. That is easy to decode. But MIDI also allows for the sending of a single Status byte followed by multiple pairs of Note Number and Velocity which are meant to share that initial Status byte. I began to wonder whether my code, designed to handle this, was at fault by recognizing the first message only.

So I printed off the relevant page of code and, on paper, stepped manually through a sequence of messages using running status. I could not find an error in this code I designed and used years ago.

Next, I thought that maybe Jeux d'Orgues was not putting out the MIDI messages I was expecting. Time to download the MIDI Wrench and Midi Tool apps onto my wife's iPad to observe what Jeux d'Orgues, running on my iPad, was really sending out. It was exactly what I expected. During a general cancel, it sent out not only turn off messages for any stops drawn, for good measure it sent out the piston number assigned to the All Stops Off button.

I heartily recommend both apps just mentioned. They have been a great help in many a debugging situation. They operate slightly differently, so keep both on hand.

Time to test the circuit again, but with one change. Whereas last time I was using the USB port on my PC to power one of the Arduinos, this time I connected each to its own power transformer. And suddenly everything behaved flawlessly. Clearly the USB port which also uses serial port 0 was interfering despite setting the switch on the MIDI shield to On which should disconnect the USB port.
Lesson learned? Maybe not!

After a nap, the scientist in me insisted that I see if the original problem could be replicated. Using USB power again, everything continued to work just fine.
Lesson learned! Don't trust a test circuit connected with jumpers.
John

Return to DIY organ consoles / MIDI

Who is online

Users browsing this forum: No registered users and 1 guest