Skip to content

DIY piano sensors

Frédéric L

Yes, not exactly, but any time measurement have the same issue. (Any measure has some limited accuracy too).

Even if you hardlink an input to a CPU IRQ, the CPU can memorize the Time Stamp Counter (TSC) when it receives the IRQ, but it won’t know how much time are spent between the last TSC increment and the IRQ. Then it won’t be an exact measure. (With GHz CPU clock you will however have some magnitude more accuracy).


xooorx

RIP [@CyberGene...] if my understanding is correct, you are "sampling" the on/off condition of that sensor with a 9us period, which is roughly 3 orders of magnitude faster than what the chip/sensors I got fixated with can do. And that is more or less the "sweet spot" for enough MIDI v1 resolution, so "mine" are too slow -- 'nuff said.

The Cybrid, the VPC1, any of the 2/3 squidgy switch based systems, anything with a light gate waiting for a slot to pass through it... none of these systems are measuring velocity (distance/unit-time) directly. They are all measuring colevity (time/unit-distance) and then calculating a velocity by taking the reciprocal of the measured colevity.

(Yes, OK, "colevity" is a word I just made up, but it's still the thing that all these systems are measuring).

7 bits worth of directly measured velocity would give you 128 measurable velocities like this:

But 7 bits of directly measured colevity gives you 128 measurable colevities like this:

And when you calculate 128 velocities from these 128 colevities you get this:

As you can see this gives plenty of velocity resolution down there in the tiny highlighted area at bottom-left, but there's not so much resolution in the middle and there's barely any at the top, and this is why those systems need scan rates so very much faster than you might expect.

With a 9us scan time the Cybrid can "see" ridiculously high velocities: The last value, top-right of the third graph above, represents a hammer speed of many hundreds of miles per hour in the Cybrid. The hammer never goes anything like that fast of course, but it means that the speeds it does go are all clustered down in that bottom-left corner of the graph where the distinguishable velocities are packed close enough together to get the job done.

Your sensors are way too slow to take this approach. But to measure velocity directly instead? To measure the distance moved in a known unit of time, to obtain the first graph above instead of the third? The ones (of "yours") that I looked at were only a bit too slow for doing it that way.


RIP

xooorx They are all measuring colevity (time/unit-distance) and then calculating a velocity by taking the reciprocal of the measured colevity.

(Yes, OK, "colevity" is a word I just made up, but it's still the thing that all these systems are measuring).

Very nicely said, thanks. May I nudge you to make a PR with a markdown version of your text and the plots to incorporate in either or both https://github.com/ekumanov/cybrid/ and https://github.com/jkominek/piano-conversion/ ? I think it'll be extremely useful for others, and there is an easier to find place than here. I am sure @CyberGene will agree.

Besides, you could have said in the "traditional" approach the sensors are measuring time (since the distance unit is fixed for all of them) rather than colevity, but that sounds cool 😀

xooorx Your sensors are way too slow to take this approach.

Yes, I finally concluded that on my own, thanks for confirming.

xooorx But to measure velocity directly instead? To measure the distance moved in a known unit of time, to obtain the first graph above instead of the third? The ones (of "yours") that I looked at were only a bit too slow for doing it that way.

Assuming that the hammers could move that distance, which may not be the case: a properly regulated let off could be as close as just 2mm before the "string" strike, so at the highest speed there is simply not enough room for it to travel the fixed amount of time, no? One could (and I definitely will) measure the hammer before let off, but being still attached to the key its speed is "not authoritative" yet, and to infer the final velocity one should integrate the momentum transfer rather than just measuring speed. I'd need to do some math to confirm, but I suspect the error propagation will not make it worth it.

FWIW, I ordered several specimens of those 3 kind of sensors and the boards to control them. I'm now designing some test fixtures and I hope to gather some data during the holidays.


vagfilm

Or you could put accelerometers, and calculate position and velocity from instantaneous acceleration. Nothing other than Newton (I believe) but will drive you crazy 😊 no effect of coletivity (whatever that means).


xooorx

RIP Assuming that the hammers could move that distance, which may not be the case: a properly regulated let off could be as close as just 2mm before the "string" strike, so at the highest speed there is simply not enough room for it to travel the fixed amount of time, no?

Hang on, yes, sorry... I was looking at "your" sensors in the context of key sensing and thought they were "a bit" too slow for that. Hammer sensing is complicated by higher speed, shorter distance, and trying to take measurements really close to the place where they bounce off something and start going in the opposite direction. Probably an order of magnitude, and then some, too slow for that. (With the other two orders of magnitude between them and the Cybrid then being the "colevity" thing).


vagfilm

xooorx Hammer sensing is complicated by higher speed

From the measurements I know of, key velocity is actually faster than hammer velocities. ff struck keys (not pressed with fingee contact throughout) are faster then hammers.


xooorx

vagfilm I'm working from papers with diagrams like this and similar:


(Touch and temporal behaviour of grand piano actions)

which shows hammer velocities at generally around 5 x key velocities, as would be expected from the leverage in the action. (Which of course means the hammer travels further too... except we only want to look at the final 2mm of free flight hence me saying it's complicated by higher speed and shorter distance).

There are certainly moments in these plots where the key is travelling faster than the hammer, but the overall range of speeds to be measured is more for the hammer.


vagfilm

Oops... Embarrassing mistake: overlooked the different scale between hammer and key (force of habit... For easy comparison between conditions, in biomedicine we tend to prefer comparison over absolute values, and usually stick to using the same x and y scales in all panels if the same figure, whenever appropriate). You are absolutely right (and yes, this is the paper I usually refer to).

My error was also caused because to me the important thing in this figure is how fast the key moves from min to max in ff struck, because that determines the needed time resolution of the sensor.


RIP

I was good enough, so I got my Christmas gifts in the mail.

I assembled them as follow. Not super neat (I too like cables out of the way, and that's a painstaking activity to get right), but much better than air cabling. On the breadboard, I also like cables of the right color, which was a pain because the ones I had were colored by the length:

Here are some details of the connections on the Pico side:

Here are some details of the connections on the sensor side:

And of the sensors themselves. That is a Everligth EAITRCA6 on the left, a QRE1113 preassembled by sparkfun in the center (https://www.sparkfun.com/products/9453), and a well-known CNY70 by VISHAY on the right. All the LED have a 100Ohm resistor to limit the current, and all the phototransistors are wired in the same way with a 10kOhm resistor before Vcc

I adjusted their location on the breadboard such that they lay approximately at the same height:

And then I did some trivial programming on the Pico to turn them on and see if they show anything in the output. Not sure yet about the last part (too tired to try all three of them at the same time, but one at the time they worked).

When the LEDs are off, this is what it looks like:

When it's on, it's cute to see that the LED illuminates. Human eyes do not see it (pretty much I saw the same as previous image), but most cameras are sensitive to IR and they show it! As follows:

In the coming days I will run some tests and decide if there is a sensor that I like most from an electrical or optical point of view. I strongly prefer the smaller ones (both EAITRCA6 and QRE1113 are exactly the same package, but pins are different), and the surface mount (the EAITRCA6 can be gotten with short leads). Moreover, the EAITRCA6 is slightly cheaper than the QRE1113 and both are about 1/3 the price of the CNY70. Not a huge deal, but noticeable saving when multiplied by 88 (notes) x2 (hammer and key) + 3 (pedals). Most importantly, they fit my mechanical design much better.

So stay tuned!


CyberGene

One particular consideration I have for the CNY70 is the rim it has with the phototransistor and the LED being on the inside and lower than the rim. I haven’t made any measurements though but intuitively I believe it helps in preventing cross-talk from neighboring elements.


RIP

CyberGene One particular consideration I have for the CNY70 is the rim it has with the phototransistor and the LED being on the inside and lower than the rim. I haven’t made any measurements though but intuitively I believe it helps in preventing cross-talk from neighboring elements.

Yes, that's a good point. Also, that rim prevents the possibility that the object to be sensed gets too close to the sensor, reducing the signal, because the fototransistor is looking at an area which is outside of the illuminated region (this can be seen in all the datasheets, and one of them had the simple geometry explanation of why it is and can't be easily solved).

In fact I have some aces in my sleeves for exactly this thing, and how it applies to the smaller sensors. I'll play them in due time 😀


RIP

Preliminary result. The object for now is a hand-held aluminum bar. Next it'll be the piano keys (under the back action). I suspect the differences from one sensor to another are due to the different location of the sensors wrt the bar, which cannot be perfectly at the same distance and angle from all of them.

When nothing is present, this is what I get:

When the bar is held close to the sensors, this is what I get (too short of a time series to compute coherence in this case):

When I move the bar back and forth in front of the sensor (close/far) this is what I get:

From the last plot one might conclude that the QRE1113 is the worse performer, but that would be a rushed conclusion. Other attempts showed it performing better than the other sensors, e.g.

and

In these last two plots the CNY70 was loose from the breadboard because the length of its terminals is too short for such an arrangement, so please ignore that.

In all top graphs, y axis is the raw data out of the RPi pico, which is 12 bits, however only about 9 bits are usable (obviously does not matter for the plot). The x axis is time in second.
The bottom graphs are coherence between each pair, vs frequency of the signal in Hz. I'm moving the bar very slowly, hence plotting only up to a couple of Hz. For curiosity, I will check if I could see the 60Hz of the power line.

Raw data and software utilized for capture on github


RIP

I posted the followup to this in its own thread here (with link to more detailed data and plots on github)


RIP

xooorx The Cybrid, the VPC1, any of the 2/3 squidgy switch based systems, anything with a light gate waiting for a slot to pass through it... none of these systems are measuring velocity (distance/unit-time) directly. They are all measuring colevity (time/unit-distance) and then calculating a velocity by taking the reciprocal of the measured colevity.

(Yes, OK, "colevity" is a word I just made up, but it's still the thing that all these systems are measuring).

@xooorx you are not the same person as @Gruust on PTQ's site, are you? Reason is, somewhat I thought you were, but if you aren't I should ping that other person to come at least lurk (if not contribute) here. See e.g. https://forum.modartt.com/viewtopic.php?id=8956


xooorx

RIP @xooorx you are not the same person as @Gruust on PTQ's site, are you?

No, I'm "xooorx" on here, on PTQ, and on PW.



« Previous Page Next Page »