It is currently Fri Mar 29, 2024 10:02 am


Korg: "time-of-flight" Debounce

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

Korg: "time-of-flight" Debounce

PostWed Feb 06, 2019 1:35 pm

When a friend donated a Korg PA300 keyboard (I think it was) to one of my VPO projects, I happily accepted since, although the synthesizer was dead, the MIDI Out still functioned. It was a fine keyboard, but then the MIDI died. I opened it up and noted that the keys were mounted on a sturdy metal frame and had real contacts; none of this rubber dimple stuff! This was worth salvaging.

I extracted it from its massive metal cocoon and divested it of all electronics. The Korg has two contacts under each key. The first one encountered, as the key is depressed, is normally closed whereas the second is normally open. The Korg of course was programmed to use these to determine the velocity with which the note is struck. I had another idea.

This setup is ideal for "time-of-flight" debouncing. Here is how it works. When the key is depressed and closes the second, NO switch, the note is turned on, unless it is already on. Upon release the NC top switch closes again. This time the note is turned off, unless it is already off. Simple; and the response feels right (and no bounce).

The contacts are arranged in a 12 x (5 + 5) matrix. Although usually top C is treated as the odd man out, in the Korg it is bottom C. On page four of my website you will find the code (an elided version) that does the scanning. You'll see that it is quite different from the code for my Galanti project (pages 2 and 3)

https://sites.google.com/site/casavantopus400/home

In Praise of Linear Code:
When you look at the code, you'll see that it is the code for one note repeated five times and that block of code, in turn, is repeated twelve times. Professional programmers will denounce this as inelegant and insist that I restructure this as two tightly nested loops.

But let me make my case. The pin order for the notes and octave lines was a bit screwy and with "cut and paste" it was easy enough to replicate the code and then edit in the correct parameters. The result is easy to read and understand. Debugging is a breeze. Beginning programmers should not hesitate to use linear code if that helps them understand what is going on. There is nothing wrong with linear code! Yes it takes up more memory, but with a dedicated Arduino, who cares. And, because the program is not managing loop counters and doing comparisons, linear code should run slightly faster. But again, who cares. It's your VPO, program it as you wish.

Someday soon, I hope to use the Korg as part of a MIDI front end for a small pipe organ.

John
Offline
User avatar

RichardW

Member

  • Posts: 899
  • Joined: Sun Oct 28, 2007 9:16 am
  • Location: UK

Re: Korg: "time-of-flight" Debounce

PostWed Feb 06, 2019 2:49 pm

Good idea.

There is a hardware version of the same idea in part 2 of this report that uses a simple flop-flop circuit.

http://www.ganssle.com/debouncing.pdf

Image
Richard
Offline

jkinkennon

Member

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

Re: Korg: "time-of-flight" Debounce

PostSun Feb 10, 2019 3:04 pm

It's quite neat to have that combination of NO and NC switches. I know it is hard to follow why that works so well but of course it is just like the flip-flop circuit. Normally we don't have that switch combination but it is possible, with the usual normally open contacts, to abbreviate the NoteOn debouncing. I shudder when I see code examples with 10 and 20ms debounce times, sometimes even in commercial products.

I don't think I included that fast attack debounce in my Teensy code I posted but it is in all my PIC examples on my web site. When a key contact makes its first possible glitch of an electrical connection it is safe to assume that the key was pressed. On the other hand when a NO key contact opens we cannot assume that the key is being released. We have to debounce it (perhaps 2ms) in case it was just an issue with an intermittent contact. Debouncing should never occur inline and delay other code from executing -- that should go without saying.
Offline
User avatar

RichardW

Member

  • Posts: 899
  • Joined: Sun Oct 28, 2007 9:16 am
  • Location: UK

Re: Korg: "time-of-flight" Debounce

PostMon Feb 11, 2019 1:24 pm

In the circuit I posted the use of two NO switches is also possible. The circuit just needs a trigger pulse to select which gate is "on". It will remain that way until the other gate is triggered.

Regards,
Richard

Return to DIY organ consoles / MIDI

Who is online

Users browsing this forum: No registered users and 5 guests