Musical Robot

by lakshay garg in Circuits > Robots

8066 Views, 81 Favorites, 0 Comments

Musical Robot

IMG_3598.JPG
Musical robot Demo:1
Musical robot Alternative Demo

The first video is a demo of my first approach which gives a more versatile motion and the second video corresponds to the demo for the second approach. Go through both videos and there respective explanations in the last couple of steps.

The idea for this project is inspired from various musical robots around the world. In fact musical robots are very popular among robotics enthusiasts.

I have been working on this project since a couple of months and wish to share the results I have got so far. The project is a musical robot which takes any sound track preferably non-vocal as input and estimates its tempo(beats). It then accordingly plans its motion to be performed in sync with the song being played. You can learn about arduino, Matlab and beat tracking from this project. In the future I will extract more features from the audio file and make robot motion more versatile. Beat tracking itself is a very complex process and there is a truckload of material on it available on net.

Mechanical structure was designed to sort of give a feeling of a person who is head banging on EDM tracks, which kind of looks cool.

Electronics is fairly simple and similar to my previous project Drawing Robot


So go through the complete 'ible and comment if a better explanation for something is required.

P.S. Do vote if you liked the project.

Material Required

FIFXJ43I1EU1H4H.LARGE.jpg
51WAhVfjIPL.jpg
FT0A9OYI1EU1H5H.LARGE.jpg

1. Mechanical

  • Nut bolt
  • 3d print of the model given on the next step

2. Electronics

3. Servo Motors(2)

4. Software

Above links are for India, so you can find this stuff with your local retailer easily.
You can take any servos with torque greater than 15 Kg.cm and for bread board users soldering iron and wire are not required.

Mechanical Design

IMG_3606.JPG
IMG_3607.JPG
IMG_3605.JPG

Designing is flexible process and you can change it according to your preferences.

Lets quickly go through the mechanical design.

Firstly you have to get the 3d model printed given in the fourth figure.

Then fix one of the servo brackets on the table as in the second image using screws, nails or nut bolt(preferable).

Attach one end of the printed model to the other bracket of the servo.

Attach your servo to both the brackets and its pin number is 8.

For the second servo attach the second end of the printed model to another bracket.

Now attach your servo to it as in the 3rd picture.

Drill 4 holes in the speakers so that they can be attached to the second bracket of the second servo and the attach them as shown in 3rd image. pin number of this servo is 9.

Where ever I have said attach do it using nut-bolt.

Electronics

circuit.jpg

The picture above is self explanatory you can either make a shield for
the arduino as I have done or a bread board for the circuit.

Here you can see what I meant by pin numbers in the previous step.

Coding...............

cosine.png

In this step I'll explain the first approach along with the setup.

SETUP: Download ArduinoIO from the link given on the materials page and install it on your Matlab as given in the installation steps which comes along with the package. If there is still some problem comment below.

Now download and save all the files given on this step to your Matlab directory except adioes.ino . Uplaod adioes.ino to your arduino

Attach your arduino to your PC swich on the power supply, connect the speakers to your PC.

First calibrate your servos as follows:-

Type a=arduino('COM#'); in place of # type the comport number of your arduino which you can find from the arduino IDE or device manager.

servoAttach(a,9);

servoAttach(a,8);

servoWrite(a,9,90);

servoWrite(a,8,90);

Now make sure that the speakers are facing up and everything is straight.

Add your audio file in the matlab directory

Type the following in the command line of your matlab to start your musical robot.

trialnew('filename',a); filename is your audio file for example booyah.wav.

And you are done!

Explanation of the code: trialnew function takes in the audio file and arduino object as input then extracts its beat timings (which cannot be explained here) then estimate its tempo for the first second of the song.

It then constructs an angle trajectory which is a cosine wave such that the bot bangs at the beat time and intensity corresponding to the beat time length. Then it adds the beat time to the timer and estimates the tempo of the next second. Thus constructing the motion of both the servos.

Alternative Coding.................

Musical robot Demo:2

For this process type:-

Download and save the file given in this step along with all the files in the previous step

trial4('filename',a);

Explanation: Everything is same as in the previous step but there is no continuous updating of tempo instead on constant tempo is calculated at the beginning and the motion becomes repetitive.

Downloads