It is currently Wed May 22, 2024 1:10 pm


DIY MIDI-fying keyboards using phototransistors

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

fransbart

Member

  • Posts: 5
  • Joined: Fri Oct 17, 2014 12:48 pm

DIY MIDI-fying keyboards using phototransistors

PostFri Feb 18, 2022 10:26 am

Hello,
May I ask your most appreciated attention for my DIY organ-challenge?
I'm thinking for quite a while about making a 3-manual organ console for playing Hauptwerk samplesets.
I would like to use old keys (from old harmoniums) or make them myself.
The keyboards should be velocity sensitive (as I learned some samplesets are velocity prepared).
I would like using LEDs and phototransistors (2 per key for velocity sensing) to detect the travel of the key, midifying these signals by a microcontroller.

My questions:
I've browsed the internet a bit, but couldn't find any practical indications how to accomplish this.
Do some of you have any advice, recommendations, perhaps even (DIY-)manuals? More specific I would like to know which microcontroller(s) fit(s) my wishes (for 3 manuals and pedal; Olimex A20?) Also I would like to learn the right way(s) to connect the LEDs, the phototransistors en the microcontroller (matrices? and how to do it?).
I only have rudimentary knowledge of electronics (i.e. I know actually Ohm's law and I have soldered components sucesfully onto a circuitboard).

8 years ago I've already posted questions on this subject (viewtopic.php?f=15&t=13550) I very much appreciated your reactions. Today my questions are more specific. For now I would like to continue this project and hope you would help me further once again.

Kind regards,

Fransbart, the Netherlands
Offline

GrahamH

Member

  • Posts: 621
  • Joined: Tue Sep 09, 2008 6:39 am
  • Location: Near Manchester, England

Re: DIY MIDI-fying keyboards using phototransistors

PostFri Feb 18, 2022 2:50 pm

Hello Fransbart

I did some work with opto-switches (phototransistors) a few years ago - but only for single key contacts. I wouldn't like to try doing two contacts per key for velocity sensitivity!
I fitted opto-switches to two types of manual keyboard and also a pedal board.
You may find some of this material useful:
https://1drv.ms/u/s!AkOZ2I3AWrKRh3avh2jDyJUKXLyM?e=bMF7Ka

Good luck
Graham
Offline

larason2

Member

  • Posts: 771
  • Joined: Thu Feb 04, 2016 9:32 pm

Re: DIY MIDI-fying keyboards using phototransistors

PostFri Feb 18, 2022 4:54 pm

Thanks Graham for your response, I knew someone had done something along those lines and posted it here, I just couldn't remember who!

I agree with Graham that trying to get velocity sensitivity to work with phototransistors is going to be difficult. Just to be clear, it's important to distinguish phototransistors from photoresistors or light dependent resistors (LDR's), which have quite a bit of latency associated with them (whereas the phototransistors not so much). Most organs don't need velocity sensitivity, and many of the sample sets that do have that feature (such as the St. Georgenkirche Rotha) still implement some kind of alteration of cut off of the sample loop based on the amount of time the key has been held (as far as I understand). So my perspective would be that using two phototransistors to establish velocity sensitivity wouldn't really amount to a significant benefit. Maybe Martin would say more regarding this, as he probably understands the relevant programming more in depth.

Graham has done some good work in this area, and if you want to go this route, I would copy his ideas as much as possible! Still, I prefer using magnets or metal leaf contacts instead, and this is based more on familiarity. You also will have to spend more time with the phototransistors building the enclosures to ensure there is no light interference. Like magnets, alignment of the components is important, and also like magnets, there are less mechanical issues compared with contacts. LED's will eventually burn out, but that typically takes a very long time, whereas reed switches do break, and contacts corrode.

I'm not sure I would use the Olimex A20. It looks like it is a bit much, and programming looks overly complicated compared to Arduino and the like. It has a lot of advanced features you basically don't need for a midi encoder. That being said, if you are already familiar with it, it does have 160 pins, so you would be able to avoid having to make a matrix (though I'm not sure whether or not you might need an IO expander to take advantage of all 160 of those pins). It also looks a bit pricey compared to Arduino's and the like. It's also unclear whether it can do Serial Midi or USB Midi. Those functions don't appear to be a priority.

Arduinos are easy to program, cheaper, and there is already a lot of resources out there (and more skill using them here!). Most arduinos are only compatible with Serial midi unless you reprogram the board. Exceptions are the Leonardo, etc. Teensy is a good choice, and they are all compatible with USB midi, which is convenient. If any other models you are looking at don't have enough pins, you can always daisy chain them (easy), or use a matrix (not as easy, but you can often get away with just one board).

You could have the same board light the LEDs and do the sensing, but it might just be easier to have a separate power supply going to the LED's. Then you don't have to worry about brightness vs. how much power you're feeding into your microcontroller. If Graham has a particular strategy for this he wouldn't mind sharing, that would be helpful!
Offline

GrahamH

Member

  • Posts: 621
  • Joined: Tue Sep 09, 2008 6:39 am
  • Location: Near Manchester, England

Re: DIY MIDI-fying keyboards using phototransistors

PostFri Feb 18, 2022 6:10 pm

You could have the same board light the LEDs and do the sensing, but it might just be easier to have a separate power supply going to the LED's. Then you don't have to worry about brightness vs. how much power you're feeding into your microcontroller. If Graham has a particular strategy for this he wouldn't mind sharing, that would be helpful!


In all of my installations, the power supply and circuit for lighting the opto-switch infra red LEDs is entirely separate from the transistor switch circuit and MIDI encoder board. Details can be found in the "Opto-switch experiments" pdf.

You also will have to spend more time with the phototransistors building the enclosures to ensure there is no light interference. Like magnets, alignment of the components is important, and also like magnets, there are less mechanical issues compared with contacts.


Prior to trying opto-switches, I fitted several keyboards with reed switches. In my opinion, opto-switches are easier to align and adjust than reed switches and of course there are no issues with hysteresis or interference from adjacent magnets. I didn't encounter any problem with light interference once the keyboards were installed in the console, though I did have problems when I was doing bench experiments in a brightly sun-lit conservatory!
Given a choice I would now go for opto-switches rather than reed switches. The main problem I initially experienced with the opto-switches was mounting them on the stripboard, but since my early experiments I have figured out a better way that doesn't involve so much bending of the opto-switch's "legs".

Regarding Arduinos - with 8 x 8 matrix wiring you can scan four 61-note keyboards with a single Arduino Mega or Due.

Graham
Offline

jkinkennon

Member

  • Posts: 1208
  • Joined: Thu May 07, 2009 9:43 am
  • Location: Vancouver, WA

Re: DIY MIDI-fying keyboards using phototransistors

PostSat Feb 19, 2022 10:20 am

My suggestion would be to avoid the complexity of optical or magnetic switching and use more conventional key contacts. Graham mentioned the potential for interference from strong ambient lighting and I certainly found that to be the case when working with a pair of old American Organ Builders manuals. Optical technology is theoretically ideal, but the extra parts and complexity aren't likely to produce a more reliable keyboard in my opinion.

Velocity is not particularly difficult to implement in code. It's great to be able to send a MIDI signal to a piano module or other external instrument. For Hauptwerk I personally wouldn't bother with velocity just to mimic the defective pipe attacks possible on tracker organs, but that's an individual preference. If the keys have dual contacts it's possible to use the bottom contacts for a conventional encoder while working on reading the time difference between the top and bottom contacts for an improved velocity version of the encoder.

Are Teensy boards readily available in the Netherlands? I highly prefer this Arduino variant for the enhanced performance capabilities and easy USB-MIDI connections. The Teensy 4.1 is an amazing platform and the needed development libraries are readily available and free just like with the conventional Arduino boards. I would avoid the A20 and anything that is primarily designed to run Linux. These are a little faster than a Teensy 4.1 (600 Mhz) but will be slower in practice due to operating system overhead. There are lots of interesting MCUs. I am currently experimenting with the STM32H7 series which is what Arduino uses in the Arduino Pro Portenta. The problem with getting away from mainline Arduino or Teensy boards is that you may find yourself needing to write your own USB-MIDI code and that is not a trivial pursuit.

Best of luck and if we can offer any assistance just ask.
Offline

fransbart

Member

  • Posts: 5
  • Joined: Fri Oct 17, 2014 12:48 pm

Re: DIY MIDI-fying keyboards using phototransistors

PostWed Jul 19, 2023 7:03 am

removed, sorry for the inconvenience
Offline
User avatar

vpo-organist

Member

  • Posts: 310
  • Joined: Wed Apr 29, 2020 6:49 am

Re: DIY MIDI-fying keyboards using phototransistors

PostWed Jul 19, 2023 5:28 pm

Oh, why removed? I was looking forward because I also have a four division Console project in front of me. I will be starting a test project in the next few weeks using a RaspPi Pico with cascading some MCP23S17 and Hall sensors 4905.

I will report on this in the German Hauptwerk forum, where we are already talking about Arduino, RaspPi and DIY projects:
https://www.vpo-forum.de/f58811-Spielti ... stbau.html
Best regards

Return to DIY organ consoles / MIDI

Who is online

Users browsing this forum: No registered users and 2 guests