Eight bit robot dance


The short pulses are zeroes, and the long pulses are ones. We call these ones and zeros bits , the smallest unit of information in computers the MP3-file itself is made up of many many bits. The bits in the signal contain the information about how the robot should move and blink. Specifically, the first, red part containing , tells the robot at what speed and in which direction the left motor should turn. Then the same for the right motor in blue, and at the end the command for the eight LEDs in orange.

So what does mean for the left motor? The last 1 is easy: It tells the motor to turn forward. If the last bit is a zero, the motor should turn backwards. The first bits encode how fast the motor should turn in the given direction. These bits are the digits of a binary number. Let us figure out how to read the number. Before we read the binary number, we briefly review the decimal system that we are used to.

Dissecting the number by digits, each digit has a different meaning based on its location in the number. So the 5 is a multiplier for the 1s added to the number, the 3 is the multiplier for the 10s, and the 2 is the multiplier for the s.

The 1, 10, , etc. One way to think about the powers is as follows: The use of 10 is why we call it the decimal-, or base system.

The binary numbers work the same way, but instead of 10 as the base, they use 2. We are ready to read the number in the motor command above, then. First, we need to reverse the sequence , since the signal sends the lowest digit, or bit, first. The actual number we need to read is therefore As mentioned above, we analyzed wave data every 2s and separated it into 10 sections.

At the beginning we tried to get frequency directly by using numpy. The frequency values we got starting from 1kHz to hundreds of kHz, which is impossible as what Nyquist points out, the maximum frequency could only be a half of sampling frequency, where the sampling frequency of our wave data is well defined to be Then we realized that we have made a mistake that what the numpy. Therefore, we compared the numpy. In this time, the frequency range was strictly less than 6kHz and generally less than 1kHz.

As I listened to the music and compared my personal feeling with sampling 1kHz frequency sound as well as Hz sound, I felt the result from that FFT analysis is reasonable. As the result, guided by the same high level design idea, we have 10 dominating frequency every 2s which representing the frequency of every 0. After we got the dominating frequency from Fourier Transform, we found the maximum and minimum dominating frequency in that 2 seconds duration. Then, we divided the frequency difference between maximum and minimum frequency to seven ranges.

For each range, we assigned a unique color for the frequency in that range. The following is the rule between frequency and color: As for the number behind each label, we used these numbered labels in our wave information cube to help our strip library to set the color of each column LEDs.

Therefore, our new wave information cube is as following:. Finally, as the table provided above, each column of LEDs will have their own color and amplitude shown on LED strip panel. We want the robot to move depending on low frequency signal more because generally low frequency sound such as drum beating works more important in rhythm control.

Therefore, from the given dominating frequency and corresponding amplitude, we splitted it into two parts first: As the result, I realized that when people hearing sound and trying to tell which one is high and which one is low, people generally convert unit in Hz to dB first and then compare, and it sounds like nature. In low frequency part, the movement direction is determined by frequency. From the lowest to 60dB, the movement directions are in order: The movement speed is controlled by the WAVE amplitude.

The higher amplitude, the higher moving speed. In addition, there is an upper limit for moving speed in low frequency region because I want to tell difference between low frequency region and high frequency region resolution. The limit is slightly less than half of the full speed of servo motor. In high frequency part, the directions are left, right and forward.

The speed level is set directly to full speed. In practice, the classification follows the rule: Although there were some problems happened during project so often, finally we successfully solved these problems. Generally, we make the robot work as expected. It delivers a good visual and audio performance. Multiple processing improve the cores efficiency and robot performance and the processor distribution is still reasonable because totally Rpi has 4 cores and we only call 3 multiple processes.

Here is two videos to give you an impression about what our music robot looks like. During this project, we explored how to use external library on Raspberry Pi, how allocate tasks to different CPU cores and so on. The most important is that all our planned work and proposed functions has been finished at the end of the project and all the function has been proved to be functional.

We really enjoy the process of the project. On the other hand, we still have potential to enhance the performance of the robot.

We could quantitatively get how these three processes cost in execution time, and balancing it by adjust refresh time. We'd like to thank our professor Joseph Skovira for his advice and help not only for project and lab but also teach us how to logically plan and design the project.