I'll talk more about the circuit in the electronic section.
I did this project with an existant librairy (MIDI) but my
goal is to include AI in a way to recognize music notes and send a JSON-like or 2D-array
with (notes, timing...) to arduino and have it play directly.
The main idea of the electric part is the solenoids, buying 24 Solenoids is quite expensive so I decided to make my own also its more fun and will help me better understand electromagnets. The math behind Electromagnet is quit tricky so I used the trial and error approach until I arrived to a result that Im satisfied with.
Afer trying many desings and nail sizes, I was satisfied with sounds made by a 2 ohm solenoid 28mm length , 26 AWG.
Once decided on the paramters of my custom solenoid I was thinking about 3D printing the body of the solenoid and its support but unfortuanly the printing failed and I just moved to an other solution but eventually the initial desing was just right and with the help of a MechEng. friend Malak he fixed some printing settings and it works fine. But was late :/
SolidWords
Failed printing.
After some adjustement.
Tube + Washers.
Cutting the tube.
one done 24 to go.
I used hair straightener to melt the glue, it is better than glue gun as it offers an entire surface of glue so it makes the process easier and faster.
I did a hole on the wood and Im using it as a support of the solenoids, it holds very good! and finally its more straightforward than the 3d printing desing.
drawing the Xylophone body.
Putting all solenoids.
Adjustable height.
Adding a permanent magnet in the top can drasticly increase the force with the same electric power but I didn't used it because:
Arduino's current output at its digitals pins is ~40mA (I need ~1.2A to power one solenoid) and Im looking to power 4 solenoids at the same time so I need a 5A external power and therefore I had to use switches: I ruled out Relays as they are mechanics and the click noise is audible additionally they aren't designed for lot of ON/OFFs.
I went with TIP-120 NPN transistors, many reditors advised me to go with MOSFETS instead to reduce the voltage loss & the heat, but MOSFETS are also 3 times expensive than BJTs + didn't want to wait for shipping.
Comming from a software background I used to work by "if it works don't touch it" so I decided to ignore the Back-EMF generated by Soelenoids and to not use Diods to block it becauses it worked just fine without it.
What happened is I was using a relatively small current in the beginning but when I got the PSU (5A / 3~12V) and tried the full load some transistors got burned :).
I run into some difficulties on that part. Luckely I had a roommate David Deng from McGill with good electronic background, he was in Vancouver for his Amazon internship and we worked together on the circuit.
That's a simplified illustration of wiring made with TinkerCad.
We connected one end of solenoids to that cable.
-Idea: (+) end is always connected and
(-) end will be
closed once the transistors got the Arduino signal.
Putting electronic components in the bredbords.
We connected the other end of each solenoid to the breadboard, for the solenoids on the back row I put their coils in the front row to ease cabling.
Simple code to loop trough all the Solenoids.
Without the Xylophone.
Put a foam to to absorb the nail strike and cancel its noize.
Looking good :)
My goal is recognize notes on musical sheets (.jpeg) and send Indexes of notes & timing to Arduino but for now im just using the MIDI library and thats its idea:
You can use this website it contains a lot of MIDI files alternatvely you can google:[nameOfMusic.mid].
LMMS is a digital audio software I used to:
We need to "trick" LMMS and create a virtual MIDI device so it can output into it, I believe creating a virtual media is not required for macOS, but please do some googling, for Windows loopMIDI is working fine!
I used Hairless MIDI to transfer MIDI inputs to the Arduio, the numbers shown as "Note: XX" are indexes of the notes assinged by the MIDI library C4=60.
We Wish You a Merry Christmas
Fur Elise
Alla Turca
The Star and Stripes for Ever