Velocity-sensitive, contactless MIDI keyboard with polyphonic aftertouch for Teensy synth

Yes, the purpose of those transistors is to allow to implement power saving. Since there are lots of Hall sensors their total power consumption might be >300mA. The idea for those was to enter power-saving mode when keyboard is not used for extended periods of time. There is also 0.5V voltage drop on those transistors that is actually good so I limit output voltage of Hall sensors.
 
Last edited:
Yes I thought I needed extra protection, but then I checked 4067 analog multiplexer data sheet. https://www.ti.com/lit/ds/symlink/cd4067b.pdf
Every input is protected internally (see below) and since I am using Vdd=3.3V supply for the analog multiplexer, I seem to have that covered, especially considering the fact that I am supplying SS49E with something like 4.5V only (note bipolar transistor keys in the schematics) and at full swing SS49E outputs not more than 3.8V, so I am within 4067 specs.

View attachment 35192
That only protects the digital signal inputs, not the analogue signals. Note the asterisk that is on each of the digital control pins.
 
As I wrote: spec say max voltage on any pin Vdd + 0.5V. I am within specs even under most extreme situation (wrong assembly, reverse orientation of magnets, keys with wrong orientation pressed to max).
Under normal operation I am always below 2.5V.

I guess that if I ever made this "commercially" I would put those extra diodes just for the "peace of mind", but with my prototype build, I am not worried.
 
Last edited:
As I wrote: spec say max voltage on any pin Vdd + 0.5V. I am within specs even under most extreme situation (wrong assembly, reverse orientation of magnets, keys with wrong orientation pressed to max).
Under normal operation I am always below 2.5V.

I guess that if I ever made this "commercially" I would put those extra diodes just for the "peace of mind", but with my prototype build, I am not worried.
You want to protect the Teensy from over voltage. It didn't want more than 3.3V on its ADC pins. The AH49E can send +5V and the CD4067 can pass it through without the clamping that you had previously assumed so you can get 5V at the Teensy. You can test this by disconnecting from the Teensy then applying a reverse magnetic field to a sensor then measuring the voltage at the output of the CD4067.

Of course you may remain lucky that the sensors don't come near to a reverse polarity magnet but someone may put a loudspeaker near the keyboard at sometime and kill the microprocessor.

I considered some ideas to mitigate this risk, including:

- Driving the AH49E from 3.3V. This reduces the range and hence resolution. I am testing this now.
- Controlling the CD4067 enable pin from it's output. This may cause it to oscillate.
- Clamping the output of the CD4067. Probably the _right_ thing to do.
- Adding 5V to 3.3V converter at output of CD4067. Probably not linear.

Anyway, I have some magnets and sensors so will play with them to see what works. Thanks for the ideas and inspiration.
 
Apparently you did not notice what I wrote before.
Teensy never sees voltage above 2.5V in real life at the analog input.
I would need to get the assembly completely wrong to get anything above 2.5V.
Typically you don't protect circuits against wrong assembly.

And you are overestimating those "loudspeaker fields" as they fall off with at least (distance)^3 factor.
To get anything above 3V I would need to put Hall sensor INSIDE loudspeaker.
That would never happen.

The schematic I have sent in the first post did not show the microcontroller part. In fact I do have Schottky diodes
between analog input of microcontroller and +3.3V, but even then, Schottky diodes have still something like 0.3-0.4V dropoff voltage
and would only clamp voltages above 3.3V+0.4V = 3.7V.
In the circuit I have shown such voltages simply don't exist, since SS49E output swing is Vdd-1V and Vdd for Hall sensors in my circuit is NOT 5V. It is 4.5V due to collector-emiter drop on Q1/Q2 transistors used in power circuit. So in practice, even in worst case the output at SS49E would be 3.5V. Which is below what those protection diodes would even react.

Anyway my project works fine already, I have fully working keyboard, playability is excellent, much much better than mechanical solution.
 
Last edited:
Apparently you did not notice what I wrote before.
Teensy never sees voltage above 2.5V in real life at the analog input.
I would need to get the assembly completely wrong to get anything above 2.5V.
Typically you don't protect circuits against wrong assembly.

And you are overestimating those "loudspeaker fields" as they fall off with at least (distance)^3 factor.
To get anything above 3V I would need to put Hall sensor INSIDE loudspeaker.
That would never happen.

The schematic I have sent in the first post did not show the microcontroller part. In fact I do have Schottky diodes
between analog input of microcontroller and +3.3V, but even then, Schottky diodes have still something like 0.3-0.4V dropoff voltage
and would only clamp voltages above 3.3V+0.4V = 3.7V.
In the circuit I have shown such voltages simply don't exist, since SS49E output swing is Vdd-1V and Vdd for Hall sensors in my circuit is NOT 5V. It is 4.5V due to collector-emiter drop on Q1/Q2 transistors used in power circuit. So in practice, even in worst case the output at SS49E would be 3.5V. Which is below what those protection diodes would even react.

Anyway my project works fine already, I have fully working keyboard, playability is excellent, much much better than mechanical solution.
Very happy to read about the outcome and steps here. Curious if you have any sort of full write-up that would let people follow in your footsteps? Also curious of any video or audio of its use. Cheers!
 
I am sorry, I wish I had more time to publish more stuff and work more on hobby side but life is busy and you gotta do the things you don't like first and fun things need to wait :-(
Anyway, I am now trying to build some real enclosure and add some extra controls (lots of pots and ribbon controller :)) to get that CS-80 vibe (ribbon + aftertouch). I am not really good with mechanical stuff so the progress is sloooow.

I have really crazy idea to use this keyboard with a "monster" synth project that I am working on that would have eight Teensy 4 as synth engines, plus ESP32-driven 1024x600 IPS display for user interface and couple of STM32F103/RP Pico for pot/encoder handling. I am working on multiple things at once, so unfortunately everything is work-in-progress and nothing is complete (yet).

Thank you for showing interest! I truly do hope to work more on this.
 
Last edited:
Hello there I actually had imagined a keyboard like this in my dream with a million dollar idea with Hall effect sensors to zero the latency of any midi device in any given moment. Then while searching if it already existed I have stumbled upon this forum. If you manage to create this keyboard . You could create a software to trigger midi messages as soon as the magnetic field change before you actually reaching the end of the keys where you hit the electronic 0-1 trigger which would create negative latency to compensate for whatever latency you might have on your system. So even on a bluetooth midi keyboard you would actually have an actual zero latency. Then I have realized yes it is possible to create this but only problem then would be what happens to the unstable latency which is created by the analog sensors in different velocities. Because if you hit the keys slower the travel time will be longer and you would hear the sound before you even press the keys the whole way. 🤣 If someone can crack this problem they would be as rich as Bill Gates. But this system can be used for a non velocity keyboard the create zero latency effect.
 
I will post some videos soon of working keyboard. So yes I have done it already and it works perfectly fine.
Currently position of each key is measured 1000 times per second and temporal velocity can be measured as difference between positions in this small delta time.

As for MIDI triggering you are free to choose any position as the trigger, you don't need to touch keyboard bed but practically the only sensible solution is to have different areas for key-on and key-off events (hysteresis) as it prevents false repeated triggering. These areas can be anywhere. I find it comfortable for those areas to be in 1/3..2/3 zone of whole key travel.
 
OK, after many days of work, I have finally achieved the point where I have my keyboard with polyphonic aftertouch connected with fancy LED lights, ribbon controller, Teensy based synth and 800x480 LCD display all working together. And I am having lots of fun playing it :)

Synth1.jpg


Synth2.jpg


I promised you a video, so here it comes very short test of Polyphonic Aftertouch


As you can see in the video each key has totally independent polyphonic aftertouch.

It was very tricky to get the amount of precision and control I have now because the distance that key travels in the "aftertouch zone" was very small (like 1-2 mm) and the readings from Hall sensor where quite noisy and inprecise, but thanks to DSP I managed to solve all issues :)
The readings from Hall sensor using 12 bit ADC in the "touch zone" represented only 64 discrete levels and they were super noisy. At one point I thought that I would not be able to use it at all, but then I realized that noise can be useful too, because when I oversample readings 16x, with filtering and decimation I can get 4 bits extra resolution and noise doesn't hurt because it provides natural "dithering". As it turned out oversampling and filtering provided quite stable readings. Now I only had to address nonlinearity (as magnetic field is not linear vs distance / pressure). But with a little bit of math (polynomial approximation) I managed to linearize the output.

I am very satisfied with the result, the polyphonic aftertouch offers absolutely great smooth control and playability. Now I understand why Vangelis loved Yamaha CS-80. It is so cool and fun to play with such expressiveness.
 
Here it comes more demonstration of my Polyphonic Aftertouch sensitive keyboard and Teensy-based synth. This time recreating opening sequence of Chariots of Fire by Vangelis. Except for the piano, all sounds are coming from my DIY Teensy-based synth (multitracked). Appologies for my sloppy playing :) Most funny thing is that sounds are so close to original that Universal Music immediately claimed copyright on that :) , even though this music was recreated from scratch not using original instruments or sounds/samples. Pure mathematics + Teensy computational power.
Thanks to PJRC for creating such a powerful board.

 
Last edited:
I am still looking for perfect material for the keyboard's key bed. The felt that I have now is a bit too hard (tough) I bought another piece and it is hard too. I ordered some "EVA foam" seal tape and it is softer (good) but is not "springy" ("dead") so it does not return to the original shape quickly. I need something in between.
I am curious if anyone of you can offer any suggestions regarding key bed material?
 
Last edited:
At a hardware store, in garden department, look for hose washers. They're available in different rubber hardness as well as a foam sponge. You'd need to experiment.

Piano key guide-pin felt? It's used to control key-down stop height. Looks like a little donut.

How about a blob of silicon caulking?
Or, lay down a bead for consistent diameter.

And then there's all sorts of weather stripping: foam, rubber.

I used a piece of rubber stripping for my truck-bed box cap. Look in auto-motive department.

Bicycle inner tube rubber? Car inner tube might be thicker. Rubber floor mat?

I think the contact area under the key (usually pretty thin) will play a major roll in the material you use.
 
Thanks for all the ideas. I will certainly try some of them. I am also thinking about going "two layer" (bottom layer using hard felt and upper layer with something on the softer side (like EVA, but maybe more springy).
 
I thought about the 2-layer approach too. You could try the soft/hard layers top/bottom as well as bottom/top. Should get different dynamic feel for both configurations.

I also just noticed my rectangular-soft-white-rubbery pencil eraser as a possibility. Difficult to know if it would break down over time from repeated strikes. Maybe a layer of felt over top of it to protect it?

Sponge mouse pad with cloth top?
 
Last edited:
Since my goal is to be able to play live as much music as I can, I implemented advanced arpeggiator and split keyboard feature and multi-timbrality.
I also worked on some recreation of famous Solina String Ensemble sound.

A little demo is here.

 
Back
Top