Robotic Piano Playing Fingers: Feasibility and Guidance Questions

Hey there,

First of all, I want to say that although I finished Computer Science and have the general gist of how to write code, I have no background in engineering or low-level/hardware coding. This is also going to be my first arduino and DIY project. On paper it might appear pretty straight-forward, but I'm sure it's going to be more complex than it looks.

What I want to do is, basically, a series of fingers that can be fitted on any piano with standard sized keys, each hovering above it's respecting key until it's activated, then pressing it's respective finger for a variable duration, and then letting it go until it's reactivated. The system will, ideally, be able to read MIDI files and replay them on an actual piano or keyboard/synth, as long as all the notes of the MIDI are included in the octaves that the system will cover, and disregarding all else notes that are out of range.I guess I can put it on table with adjustable size, or just on the floor with my keyboard piano.

The components of the system will be installed on a foam surface (unless you suggest something else).
A Raspberry Pi will load a midi file from the SD card and then check, perhaps let's say once every 1/36th of a second, which notes are pressed down and send the necessary instructions via pins to a series of Arduino Uno slaves. I could research on writing boot-up Raspberry Pi python boot-up scripts of some sort and how they can communicate with arduinos via pins. The number of the arduinos will be variable, but I thought that one Arduino can control each octave, 12 fingers (7 fat ones on white keys and 5 lifted thinner ones on the black keys). The Raspberry Pi can assign which octave each arduino represents automatically, by the series on which the Arduinos are connected to the Pi, therefore defining which notes each Arduino is responsible for. Each Arduino will be connected, via breadboard I imagine, to 12 servos which will either pull back or let loose a string. Each string will activate and deactivate its respective finger (which is basically 3 pieces of foam with angles, glued with elastic band together), so when tension is applied to the string, the finger will become curved, thus hitting the note.
The fingers will have to somehow be sturdied on the foam surface as well as the servos, I can think hot glue but something more elegant will be a bonus.

The keyboard I currently own covers 5 octaves, so I'll make 5 sets which will need 5 arduinos and 60 servos and fingers in total. I know creating two hands with 5 fingers that slide above the piano keys would be more practical, but a real hand can stretch its fingers to play notes out of reach as well as overlap the other hand to play on different octaves, higher or lower, so I thought this would make the project less complex. I'll start with a finger, then programming one servo for that finger, then one octave and see how it goes.

Before I start buying and researching, I'd like to ask if the project is feasible and if I am missing anything? Can you point me to any useful resources on how to control servos with arduino and how to make a raspberry pi communicate with them? Power supply is also a concern, what do you think will be needed exactly to power such a system? Also, can servos move with variable intensity and is it possible to increment variable power to the press of each button?

I tried doing some google search, found robotic hands playing piano but not my exact implementation, which I imagine would be simpler. If you can point me to any similar projects, it'll be wonderful.

Sorry for the long post,
Thanks in advance!

There exist many ways for constructing such fingers. Did you consider the servo size, so that that these line up with the fingers and piano key wiidth?

Eventually you are better off with solenoids for pressing the keys.

A single Arduino can do all that, with a SD card and port extenders added, for the required number of keys. Some port extenders (TPIC6B595...) will drive solenoids directly, or a Servo board can drive up to 16 servos at the same time.

Thanks for your input. Much appreciated.
No, I haven't measured the servo width, I ordered 4 of them just to experiment.
If they don't, I'll definitely consider solenoids.

Are you saying that a single Arduino can drive more than 60 servos and power the entire system (it might be expanded if I get a bigger piano/keyboards).

Another functionality I'd love would be to be able to upload MIDIs to the system over the network.
A small screen and a few buttons for selecting which MIDI to play next or which mode (aka play the library in random order) would also be cool.

Do you think a single Arduino Uno can support all these?

An Arduino doesn't power servos you power then from a separate supply, you will need a big one to power so many. An Arduino Uno can only drive 12 servos a Mega can drive a lot more. But with so many you are best to use an external servo pulse generator board.

A servo pulse board combined with one Arduino Uno?
How many servos can it drive?

Also, how about a Mega?

I have found that servos generally cost less than solenoids. Since it's my first project, I'm trying to keep the costs down and I don't have much of a budget.

Do solenoids or servos allow you to hit/spin with variable force, thus simulating different ways of playing?

Is there a good place to buy a bulk order if I find either one suits my needs?

Thanks again

The PCA9685 chip can generate 16 channels of 12-bit PWM. Each channel can drive a servo OR a solenoid! Solenoids could be used to get faster response than a hobby servo AND provide for variable velocity.

The interface to the chip is I2C so it only needs two signal wires to the Arduino. The breakout boards can be set for any of 64 addresses so you can use multiple boards. Six boards would control over 88 keys. One board would get you 1-1/3 octaves for testing.

Do solenoids or servos allow you to hit/spin with variable force, thus simulating different ways of playing?

No.

Also repeated bashing of an object with a servo will cause it to stall and have a strain on the gears. The cheapest have plastic gears which are not so strong. While you can use them for this purpose be prepared to replace them when they burn out. The cheaper the servo the quicker they burn out. Don't expect to bash something all day for several days.

Here is a video of something I made. Note the use of a mouse ball, in a spiral binding "spring" to reduce the impact on the servo when something is hit. You will get a much longer life from these.