# Using electromagnetism to simulate an arbitrary force-displacement curve

I've been thinking about piano actions -- the way piano keys are linked to the hammers that strike the strings. Different pianos have different actions, and thus their keys travel different distances, they require different amounts of force, and the resistance changes in different ways while the key travels as it activates different mechanisms and lands on the cushion (which may be of different materials and thus feel different). Specifically I was thinking about whether a digital piano could be constructed to replicate not just one acoustic piano action, but any acoustic piano action by modifying settings.

Ultimately a piano key is a lever that the player presses, and the counterforce it exerts against the finger changes as it is depressed. It is mostly a smooth transition, except there are often a couple of "bumps" where mechanisms are activated, and then a hard stop at the end when it hits the bottom.

My idea was to use electromagnetism to provide the resistance with feedback and active control to make it simulate a particular piano action (or rather, simulate a force-displacement curve). I'd use a hall effect sensor or rotary encoder or LVDT or something (not concerned specifically with that right now) to measure displacement and a microcontroller to control it all. For providing the resistance, I had a couple of ideas in mind:

• Magnet on the underside of the key, electromagnet on the key-bed below, vary the current to the electromagnet based on the displacement of the key and the chosen force-displacement curve.
• Iron rod mounted perpendicular to the bottom of the key that passes through a solenoid coil, again varying the current based on the displacement.
• Linear motor mounted vertically, either under the key or at the back end of the key. Rather than being used to create motion, letting the player "overpower" the motor and have the motor exert counterpressure. This could actually be several different ideas depending on the particular technology employed.

For the design parameters I'm working with a maximum travel distance of 25mm, a maximum key velocity of 5m/s, a maximum key force of 50N, and an ideal "resolution" of 0.5 mm, or 50 steps over the full travel distance.

One of my big concerns is whether it's feasible to simulate a hard "wall" sensation this way, so I could make it feel like the key hits the cushions at the bottom after 10 or 12 mm or whatever, variable based on preferences.

Another concern with using either the electromagnet or solenoid solution is changing the magnetic field rapidly enough as the key moves. I'm guessing it might require a pretty big voltage spike to change the current that quickly.

With the linear motor solution I might be able to use several different coils to exert different forces as the key passes through, so maybe I could get the force-displacement curve without having to change the current / field in real time. The flipside to that though is that it might be hard to get the 0.5mm resolution I am looking for.

So now I come to my actual questions:

• Is there prior work using EM for this sort of thing? I've tried Googling, but most of what I get is about using magnets to hold something in a fixed place (levitation, locks), or using linear motors for a fixed speed or fixed force.
• Do you think this is even feasible? I'm sure it's physically possible, but the fact that I haven't found anything similar makes me wonder if there are big practical considerations like heat or power draw that will make this nonviable for a consumer product.
• You appear to be asking questions that are likely beyond the scope of an EE site.; Is there prior work is like asking for product recommendations (off-topic) and, Do you think this is even feasible requires a lot of knowledge about piano mechanisms and I don't think that is generally on-topic here. Oct 12, 2022 at 17:11
• Re prior work: I don't mean anything to do with piano keys -- I mean has anyone used magnets in a way that controls the force exerted on an object based on its distance from the magnet. Oct 12, 2022 at 17:19
• Thank you @Neil_UK! Is there a general term for this technique that I could search for? I thought about a controllable end stop, as that definitely would get rid of some of the hardest parts of the design, seems like that is a good idea then. Oct 12, 2022 at 17:22
• Look up "haptic feedback". There are a lot of DIY projects which use a BLDC motor to give haptic feedback to a knob on the motor shaft. Oct 12, 2022 at 19:10
• Apple patent US7166795B2 Method and apparatus for simulating a mechanical keyboard action in an electronic keyboard Abstract An electronic keyboard simulates the keyboard action of one or more acoustic pianos and/or organs. Sensors associated with each key capture the force exerted on the key, the speed of the key and the position of the key to compute an amount of force to apply in feedback to the depressed key. An actuator associated with each key provides the computed feedback value as a counter-force to the player's finger pressure. Oct 13, 2022 at 0:21