Programming Robotic Finger to Strike Piano Keys at a Predetermined Speed?

Hi guys!

I hope the topic title isn't too long. I am trying to be as specific as possible, as is recommended in one of the sticky's.

For a current university project, I am modifying a Thumbs Up robotic arm so that I can determine the precise velocity in which a piano key is being played. To do this, I will be designing a human finger using either a DC motor or a servo with some kind of flesh-like material attached to it for natural feel.

For the programming side of the project, I am seeking advice on how to determine the speed in which the finger strikes the piano keys before mapping various different speeds to different keys on my computer keyboard.

Is this even possible?

Arduino Uno
Arduino 1.6.9
AdaFruit Motor Shield V2
Thumbs Up Robotic Arm

For the programming side of the project, I am seeking advice on how to determine the speed in which the finger strikes the piano keys

Usually, "determine" means "measure". However, the way that you use the word makes me think that you mean "command" or "control". What is your intent?

A DC motor's speed is controlled by the amount of current through it. By using PWM, you could control its speed. Varying the voltage would be another way to control the speed.

A servo's speed is controlled by timing the position commands sent to it. That is, different PWM commands are sent at various times to control the position versus time - and thus the speed.

We can't help much until you settle on what your hardware is and show us some code.

Right okay. Thank you for your reply, and your patience. This is my first project using Arduino.

Yes you are right, I am wanting to control the speed and will most probably go down the servo route.

Judging by your response, I may have to do more research into this before I ask for input from the forum. At present, I have no idea how to program my board. I was thinking that I could maybe modify one of the example sketches that came with the AdaFruit motor shield.

Thanks again

I was thinking that I could maybe modify one of the example sketches that came with the AdaFruit motor shield.

You may be able to but only if you know what you are doing and if you know what you are doing you will probably start from scratch. Chicken/egg !

What exact kind of piano keys do you have in mind? Electronic or string-based?

How do you think that pressure speed will affect the sound?

DC motors IMO are not well suited for such a project. A given motor current means a constant force/torque, the speed is determined by the counterforce. First the finger must move down until the key, with no counterforce, then start moving the key until its trigger point, and finally press the key with even more force. It's not really easy to steer a DC motor against such varying counterforces, at a given speed. Even geared DC motors tend to stall on slightly increasing counterforce, unless driven by high current (meaning high speed), and then they must be stopped before they damage the key. And motor current can be varied only slowly, due to the EMF and rotational energy of the motor.

If you think that you want something like a hammer, to press a key (old electric pianos), you may be better off with a somewhat powerful solenoid. Then you can vary the solenoid current, to find out which current produces which sound shape on attack, and the same for decay with decreased current.

Unless you want to do some scientific research, with a force sensor on the finger tip, start experimenting with the various actuator types (linear/solenoid, geared DC motor, servo, stepper), to find out which one will allow for the intended sound effect, with what effort in hard- and software.

DrDiettrich:
What exact kind of piano keys do you have in mind? Electronic or string-based?

How do you think that pressure speed will affect the sound

I will be sampling an upright acoustic piano and the idea is to sample each note at 3 different velocities.

The reason for this is that the natural envelope of a struck key will differ depending on the force applied. I am trying to illustrate that a key played with great force would not sound the same as a key played with less force if their volumes were equal.

So what you want are sound files of each note played in 3 different ways? Why do you need a machine to strike the keys for you?

lg, couka

I will be recording the sound files myself myself and then loading them into a sampler.

So the robotic arm will be striking the keys of the piano at 3 different velocities (not the actual strings of the piano, just replacing what a human finger would do) > I will record each note through my audio interface into my computer > I will then process each recorded note through a sampler.

So your electric finger shall press every key of the piano in the same way (speed, timing).

Again I suggest a solenoid for that purpose, which can be programmed for repeatable force and time on attack, hold time with probably reduced force, and decay. The code could look like this, using PWM to control the solenoid:

analogWrite(pin, attack_forceX);
delay(attack_timeX);
analogWrite(pin, hold_forceX);
delay(hold_timeX);
analogWrite(pin, 0);

with the ...X parameters determined by you, for every strike type.

Avocado232:
Hi guys!

I hope the topic title isn't too long. I am trying to be as specific as possible, as is recommended in one of the sticky's.

For a current university project, I am modifying a Thumbs Up robotic arm so that I can determine the precise velocity in which a piano key is being played. To do this, I will be designing a human finger using either a DC motor or a servo with some kind of flesh-like material attached to it for natural feel.

For the programming side of the project, I am seeking advice on how to determine the speed in which the finger strikes the piano keys before mapping various different speeds to different keys on my computer keyboard.

Is this even possible?

Arduino Uno
Arduino 1.6.9
AdaFruit Motor Shield V2
Thumbs Up Robotic Arm

I assume it is of importance not only to hit the piano key at a certain speed, but also at a pretty exact time? If say, multiple such fingers were to play a melody?

For something like this, that is, executing an accelerated motion at spesific time, you need a stepper motor. Servos move to the indicated position "as fast as they can".

A cheap and dirty solution that requires little precision, is letting a servo tension a rubber band to varying degrees, while the "finger" is locked. Then the finger is released, perhaps by switching off a solenoid, and then all you need to do is determine experimentally how fast the finger moves and with what delay, for different tension levels of the rubber band.

:slight_smile:

Don't know how this fits with the "hand" that this "finger" is to be mounted on.

Avocado232:
I will be recording the sound files myself myself and then loading them into a sampler.

Still, why do you need a machine to hit the keys? By now, you could have been done sampling, if you had used a real hand to do it.
I don't really play piano, but hitting keys with a certain amount of force is something even I can do.

lg, couka

couka:
Still, why do you need a machine to hit the keys? By now, you could have been done sampling, if you had used a real hand to do it.
I don't really play piano, but hitting keys with a certain amount of force is something even I can do.

lg, couka

The reason is that when putting together a full piano sample library, it is important to be able to identify exact velocity values. If I am able to program precise velocities during the recording stage, I will be able to accurately manipulate the recorded sounds into the sampler at a later stage. If I used real hands to record the samples, I would only know whether they were played soft, medium, or hard, as apposed to knowing the exact values.

DrDiettrich:
So your electric finger shall press every key of the piano in the same way (speed, timing).

Again I suggest a solenoid for that purpose, which can be programmed for repeatable force and time on attack, hold time with probably reduced force, and decay. The code could look like this, using PWM to control the solenoid:

analogWrite(pin, attack_forceX);

delay(attack_timeX);
analogWrite(pin, hold_forceX);
delay(hold_timeX);
analogWrite(pin, 0);



with the ...X parameters determined by you, for every strike type.

Could this only be used for with a solenoid? or could I use this code to experiment with the components I already have?

Thanks for all your help so far guys!

Avocado232:
The reason is that when putting together a full piano sample library, it is important to be able to identify exact velocity values. If I am able to program precise velocities during the recording stage, I will be able to accurately manipulate the recorded sounds into the sampler at a later stage. If I used real hands to record the samples, I would only know whether they were played soft, medium, or hard, as apposed to knowing the exact values.

Could this only be used for with a solenoid? or could I use this code to experiment with the components I already have?

Thanks for all your help so far guys!

My rubber band technology seems more and more relevant. You need a mechanical device that you set to a particular tension, then release.

Rupert909:
My rubber band technology seems more and more relevant. You need a mechanical device that you set to a particular tension, then release.

Thanks for the advice.

Could you explain this further? In layman's terms if possible.

Avocado232:
Thanks for the advice.

Could you explain this further? In layman's terms if possible.

Not really, no. :slight_smile: