University of Portland School of Engineering 5000 N. Willamette Blvd. Portland, OR 97203-5798 Phone 503 943 7314 Fax 503 943 7316 Final Report Frequency Response Audio Visualizer Team Members: Jake Nylund (Fall Team Lead) Kevin Ratuiste (Spring Team Lead) Alex Arlint (Treasurer) Robert Rodriguez (Secretary) Industry Representatives: John Turner – Impinj, Inc. Faculty Advisors: Dr. Joseph Hoffbeck Clients: Will Taylor – Student FINAL REPORT TEAM COUCH STREET REV. 0.95 PAGE 2 REVISION HISTORY Rev. Date Author Reason For Changes 0.9 21 Mar 2014 Team First draft submitted to advisor 0.95 28 Mar 2014 Team Second draft submitted to advisor FINAL REPORT TEAM COUCH STREET REV. 0.95 PAGE 3 Table of Contents REVISION HISTORY ...................................................................................................................................................... 2 INTRODUCTION ............................................................................................................................................................. 4 HIGH LEVEL ARCHITECTURE............................................................................................................................. 5 HARDWARE AND SOFTWARE DESIGN ......................................................................................................... 6 User Interface ............................................................................................................................................................. 7 Arduino Due Microcontroller .............................................................................................................................. 7 Software ........................................................................................................................................................................ 9 Electromagnet .......................................................................................................................................................... 10 Mechanical Components ...................................................................................................................................... 12 Assumptions ............................................................................................................................................................. 12 Changes ....................................................................................................................................................................... 13 Risks ............................................................................................................................................................................. 13 MILESTONES ............................................................................................................................................................ 14 CONCLUSION .............................................................................................................................................................. 15 GLOSSARY.................................................................................................................................................................... 15 FINAL REPORT TEAM COUCH STREET REV. 0.95 PAGE 4 INTRODUCTION Frequency Beats, the name given to this project, is a frequency response audio visualizer. The overall goal of the device was to visualize the spectrum of an audio signal. The input is an analog line level audio signal connected via a standard 3.5mm headphone jack. This signal enters the microcontroller where it is processed and filtered to separate the various frequencies in the audio signal. Implementing the filters digitally allowed more flexibility in how the microprocessor processed the signal as well as the resulting action or response. Once the frequencies of the audio signal were separated, they were output to the electromagnets, which, in turn, manipulated the ferromagnetic fluid creating a visual representation of the audio signal. A front view of the final product is shown below in Figure 1, illustrating the front of the apparatus, consisting of three glass chambers partially filled with ferrofluid. Each glass chamber has a handmade electromagnet fixed to the top of it. << figure deleted >> Some highlights of the implementation phase were building electromagnets, building electromagnets that worked, constructing circuitry that accurately and reliably limits and amplifies the amount of current and voltage going into the arduino’s input pins and coming out of the PWM output pins, implementing a working program for the microcontroller that does the processing required and seeing that the project works in parts. The team has been unable to get the project working as a whole up to this point. FINAL REPORT TEAM COUCH STREET REV. 0.95 PAGE 5 The biggest challenge the team faced was getting the Fast Fourier Transform (FFT) algorithm to work on the Arduino Due. This led to many hours of frustration and debugging that ultimately ended in a major change to the project. Another challenge was trying to produce three, mostly identical electromagnets that would generate a strong enough electromagnetic field to actuate the ferrofluid. The first attempts produced depressingly subpar results and extra assistance was requested for the next trial. Throughout this design and construction process, the team faced several challenges related to the software implementation and display construction. Each of these challenges was addressed according to the team’s list of anticipated challenges in the design document and was ultimately overcome. The team noticed early in the Spring Semester that their milestones were, perhaps, overly ambitious and were not necessarily in the ideal order for completion. Overall, the team did well sticking to their original design, communicating with each other to anticipate, and plan for, any potential future challenges, and solving problems quickly as they arose in order to stay on schedule. The team could have done better in regards to testing individual components on a smaller scale as they were assembled, rather than testing larger sets of components towards the end and final assembly. The following sections of this document will detail the technical and process outcomes including the differences between the team’s original designs and the final product, how the implementation was different than intended, and a discussion of assumptions, changes, milestones, and risks the team faced. Additionally, there is a glossary at the end of this document. HIGH LEVEL ARCHITECTURE The figure below shows the high level architecture of Frequency Beats. The key component of this project is the MSGEQ7 (not pictured), which is an IC that takes the audio signal as its input, analyzes seven frequency bands of the signal, and then outputs a DC representation of each frequency band. The seven frequencies are then passed into the Arduino Due where they are consolidated into three frequency bands, low, mid, and high, scaled for interaction with the electromagnets, then sent out as three DC frequency representations of the audio signal. The outputs of the Arduino are smoothed out by a low pass filter and then used to control the electromagnets by a Darlington Pair. Frequency Beats utilizes a 12V power supply for the electromagnets and Arduino. As you can see, there are only a couple differences between the schematic below and the team’s original plan. This includes the addition of a 2N3904 transistor to help the Arduino drive the TIP102 power transistor, elimination of the biasing circuit, and the addition of a flyback diode to protect the circuitry from voltage spikes. FINAL REPORT TEAM COUCH STREET REV. 0.95 PAGE 6 12V Power Supply Electromagnet (Low-Range) LPF Electromagnet (Low-Range) Electromagnet (Low-Range) TIP102 Darlington Pair 2N3904 Transistor Low-Range Out Audio Inpu t Arduino MSGEQ7 Mid-Range Out TIP102 Darlington Pair 2N3904 Transistor LPF High-Range Out TIP102 Darlington Pair 2N3904 Transistor LPF Powered Speaker Figure 2. High Level Architecture HARDWARE AND SOFTWARE DESIGN This section will go into the multiple components that make up the project. Both hardware and software designs will be discussed. Figure 3 below shows the overall final schematic of Frequency Beats. BAT42 12V Electromagnet (Low-Range) BAT42 Electromagnet (Mid-Range) BAT42 Electromagnet (High-Range) GPB554B05BB 100 O.1uF TIP102 3 LPF 2 2 2N3904 1 1 100 SUBJECT TO CHANGE 5K GPB554B05BB 150 5V O.1uF MSGEQ7 O.1uF Audio Input 33pF 11 Low-Range Out Mid-Range Out Arduino5112 High-Range Out 13 3 2 53 51 LPF 100 0.1uF 3 2 2 TIP102 2N3904 1 1 100 O.1uF 5K 100 GPB554B05BB 150 Powered Speaker SUBJECT TO CHANGE LPF 100 0.1uF 3 3 2 TIP102 2 2N3904 1 100 1 5K 150 3 Figure 3. Circuit Schematic FINAL REPORT TEAM COUCH STREET REV. 0.95 PAGE 7 User Interface The user can plug in their audio signal via a 3.5mm standard line level audio cable on the back side of the project device. Once connected, the user presses play on the audio device (Ipod, Iphone, etc.) and watches the audio visualization of his or her music choice on the front side of the device. Additionally, the user will be able to hear the music, via external powered speakers, while viewing the ferrofluid displays with the aid of a 3.5mm headphone splitter; the user will not have to interact with this component as it is a passive piece on the back side of the device. Originally, the team had planned on using buttons on the face of the apparatus to manipulate the ferrofluid without music, but toggle switches were easier to incorporate. Additionally, the user is able to hear the music, via external powered speakers. The following figure shows the three switches and audio cable that the user will be able to interact with. [need a picture of finished displays and the toggle switches] Figure 4. Toggle Switches Arduino Due Microcontroller The first primary digital component utilized in the project is the MSGEQ7 integrated circuit. This little IC can accept a single audio source, analyze seven frequency bands of the audio, and output a DC representation to represent the average amplitude of each frequency band. This isn’t super accurate or calibrated in any way, but it works. The second primary digital component is the Arduino Due, which is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU. It is the first Arduino board based on a 32-bit ARM core microcontroller. It has 54 digital input/output pins, 12 analog inputs with 12 bits of resolution each, and 12 PWM output pins. The audio signal enters the MSGEQ7 where the signal is broken into seven frequency bands (as seen in Figure 5) to be further processed by the Arduino Due. When the signal reaches the Due, the Due combines bands 0-2, 2-4, and 4-6, separating the signal into low-range (630 - 400 Hz), mid-range (400 - 2.5 kHz), and high-range (2.5 - 16 kHz) groupings, averages the DC representation to produce three frequency bands, then scales the amplitudes to correctly reflect the presence of each frequency range, and finally outputs those three signals to individual power transistor current amplifiers. FINAL REPORT TEAM COUCH STREET REV. 0.95 PAGE 8 Figure 5. Frequency Response of MSGEQ7 Originally, the team had hoped to utilize Fast Fourier Transform (FFT) on the Arduino Due to separate the frequency bands, but problems within the Arduino integrated development environment (IDE) caused so many setbacks that a work-around IC was used instead. << figure deleted>> << figure deleted >> FINAL REPORT TEAM COUCH STREET REV. 0.95 PAGE 9 Software The key software utilized in the design will be the Arduino integrated development environment (IDE), which is a cross-platform application written in java. The team will use this software to write the code necessary for filtering the input audio signal. An overview of the process to be implemented via code is shown below. Figure 8. Software Flowchart Figure 8 shows the general process that the signal will undergo as it is sampled by the Arduino. Simply stated the Arduino will continually sample the input of the MSGEQ7. The following is a list of the functions the Arduino will be performing. Init Initialize I/O pins and variables for the sampling and output process sampleLoop FINAL REPORT 10 TEAM COUCH STREET REV. 0.95 PAGE Samples input from MSGEQ7 in the form of a seven element long array. The Arduino then combines elements 0, 1, and 2, for low frequencies, 2, 3, and 4, for mid frequencies, and 4, 5, 6, for high frequencies. Each of the 3 bands is added together and divided by 3 to get an average value for the low frequencies. That number is then scaled to a value between 0 and 255 for the PWM analogWrite function on the Arduino. As of now to get a better LED visual we are subtracting 200 from the value of each of the seven frequencies. This is purely aesthetic and will be changed in its final form; there may be a refining of that method. The output is on pins 13, 12, and 11 for high, middle and low respectively. //Final with FFT (SUBJECT TO CHANGE) This loop will continually sample the audio input in Analog format. Using FFT it will split the signal and output onto three separate pins for high, low, and band pass frequencies. Sample code for the FFT algorithm can be found here: http://www.drdobbs.com/cpp/a-simple-and-efficient-fft-implementatio/199500857 FFT will output several complex numbers, or rather a real and complex part of each number in the form of doubles. Each of the outputs will be sent to each of their corresponding output pins as a combine value, putting the real and complex portions into one value. The values will be continually recalculated in the loop to continually send to their respective pins, for example pins 22, 23, and 24 on the Arduino. The signal will then pass throw a low pass filter in order to create the proper DC current output for the circuit. Electromagnet Power Supply The signal from the Arduino was not strong enough to drive the electromagnet. Thus, the electromagnets were powered by a 6.5A, 12V power supply. Control The signal from the Arduino’s PWM output pins was passed through a LPF ,which acts as a simple DAC, allowing the electromagnets to be powered to any level within a certain range. TIP102 Darlington Pair, which acts as the “on/off” switch for the electromagnet, is controlled by the signal from the Arduino that is boosted by a 2N3904 NPN transistor. The team had to diverge slightly from the original plan since the maximum current from the Arduino is approximately 8mA, less than the originally anticipated 40mA. As a result, a 2N3904 NPN transistor had to be used in order to boost the current high enough to trigger the TIP102. In other words, a 2N3904 was needed provided the additional current needed to turn on the TIP102. When there is current seen at the base of the TIP102, current from the 12V power supply is able to flow through the electromagnet, thus turning the electromagnet on. FINAL REPORT 11 TEAM COUCH STREET REV. 0.95 PAGE A small change that was also made was the addition of a flyback diode. This protected the circuitry from the voltage spikes that occur when the electromagnet is suddenly turned off. 12V BAT42 From Arduino 3 2 TIP102 2N3904 1 Electromagnet 2 1 100 5K 150 3 Figure 9. Electromagnet Control Circuit Build Each electromagnet was made with of approximately 500 feet of 26 gauge magnet wire and wrapped around a 1/4” diameter iron core that is 5 inches in length. The internal resistance of the wire was approximately 13Ω (greater than the originally anticipated 5.7 Ω). The electromagnets were mounted above the ferrofluid display. After many unsuccessful attempts at hand wrapping electromagnets, the team finally found success using a lathe to slowly wrap each individual electromagnet. Each magnet took approximately 3 hours to manufacture. Figure 10 below illustrates a hand wrapped electromagnet (on the right) and one wrapped carefully using a lathe (on the left) FINAL REPORT 12 TEAM COUCH STREET REV. 0.95 PAGE << figure deleted >> Mechanical Components The team’s project incorporates several simple mechanical devices. One of which was the casing that houses the Ferro fluid. For this, the team originally planned to use plexiglass cylinders, each with a diameter of approximately 2 inches and height of 5 inches. However, the plexiglass allowed the ferrofluid to stick to the sides thus blacking the display out and making it unusable. To correct this, the team decided to use glass cylinders instead, since glass didn’t allow the ferrofluid to stick to the sides. The electromagnets were mounted above the cylinder. Additionally, we constructed a wood base to mount the three Ferro-fluid displays as well as the Arduino and support circuitry. Assumptions The team originally made several assumptions (listed below) that all proved to be true throughout the construction, testing, and assembly process. No issues arose in regards to these assumptions, which are listed below. FINAL REPORT 13 TEAM COUCH STREET REV. 0.95 PAGE Alan Hansen will be available to help with the construction of the base and container for the ferrofluid All hardware will be available and function properly Some hardware components, such as resistors and capacitors, will be available from the University and are not necessary to purchase. There was, however, an assumption that was not listed in the team’s functional specifications that should have been, which was the assumption that the Arduino would output a sufficient current to switch the TIP102. This was not the case, and as a result, the team needed to debug, and then correct the issue by adding a 2N3904 to add enough current to switch the TIP102. Changes There were several changes that the team made during the implementation phase of the project: An MSGEQ7 IC was used to analyze seven frequency bands outside of the Arduino Due, rather than inside as originally planned. This change was necessary because problems in the Arduino IDE prevented proper operation and even compilation when trying to implement the FFT on the Arduino Due. This happened as a direct result of the fourth assumption in the previous section. The team had researched if it was possible to, and how to implement, an FFT algorithm on an Arduino, but the overlooked fact was that each implementation was done on an Arduino Uno. The Arduino Due’s IDE is in beta and has very little support to help debug such implementation problems. Additionally, the team could not revert to the Arduino Uno because that board lacks the processing speed to analyze audio signals in real time. The addition of the MSGEQ7 IC drastically changes the difficulty of the project because the FFT implementation was the core EE concept of the project; with a chip doing that part on auto-pilot, the project is complete, but far easier. This oversight could have been prevented if the team had understood that there was virtually no support for the Arduino Due IDE and that it was still in beta before the projected was started. Risks The risks for the project have been stated previously in the Functional Specifications Document and the Design Document. Please refer to that as there have been no changes in the risks. Documentation can be found at: http://wordpress.up.edu/egr13couchstreet/visualizer-status/. The only risk that became a reality was the potential for issues with the plexiglass containers, as discussed previously. The team’s contingency proved helpful. The team was FINAL REPORT 14 TEAM COUCH STREET REV. 0.95 PAGE able to effectively utilize their resources to find an alternative material (glass) to house the ferrofluid. There were not any risks that were not identified in the Functional Specifications. MILESTONES Task Order all parts Build base and get audio input Finish building one display Finish digital signal processing Test signal with one display Testing and debugging of first display Build other displays and add processing Final assembly and testing Final report Founder’s Day presentation Date Due 12/1/13 1/17/14 1/24/14 1/31/14 2/3/14 2/7/14 2/28/14 3/14/14 4/4/14 4/8/14 Date Complete 12/1/13 3/17/14 3/13/14 3/12/14 3/17/14 3/20/14 3/13/14 - Several milestones were achieved late for two primary reasons. First, the milestone due dates were set back during the Fall Semester and ended up not being in the most efficient order. For example, the milestones called for the base to be built first and early in the semester. However, the base ended up being one of the last parts to be constructed because it made a lot more sense to build the displays first to ensure the base is built appropriately. Second reason was due to the team’s overly ambitious goal setting at the beginning of the year coupled with the fact that despite a team’s best attempts to anticipate any and all potential problems, no team can foresee all issues that will occur. This was precisely the case with team Couch Street. The team encountered problems with manufacturing the ferrofluid displays that put them behind schedule. These problems included difficulty developing a method of accurately manufacturing the electromagnets, the unexpected problem of the ferrofluid sticking to the plexiglass, and the team trying to create their own ferrofluid from the start rather than purchasing it. These issues were all ultimately corrected, but resulted in the team falling behind schedule. FINAL REPORT 15 TEAM COUCH STREET REV. 0.95 PAGE CONCLUSION The ferromagnetic fluid audio visualizer is a different way of seeing different frequencies used in different types of music. It visually represents the low, middle and high frequency ranges by processing the sound from a standard 3.5mm headphone jack, and using the processed signal to drive electromagnets, which will manipulate ferrofluid. Overall, the team’s final prototype was almost identical to their original design as outlined in the Design Document. The only significant changes were that of adding a 2N3904 NPN transistor before the TIP102, eliminating the biasing circuit, eliminating the FFT, and adding a flyback diode to eliminate any potential voltage spikes. The team did a great job of communicating with each other, planning and adapting as issues arose, and keeping focused on the end goal. The team’s primary mistake was not anticipating more potential problems throughout the assembly and testing phases. GLOSSARY IC: (Integrated Circuit) is a microelectronic circuit manufactured on a thin substrate of a semiconductor material such as silicon. Microcontroller: is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Arduino: is a single-board microcontroller to make using electronics in multidisciplinary projects more accessible. Electromagnet: is a type of magnet in which the magnetic field is produced by electric current. Ferrofluid: is a liquid which becomes strongly magnetized in the presence of a magnetic field. LED: (Light Emitting Diode) A semiconductor diode that emits light when a voltage is applied to it and that is used especially in electronic devices (as for an indicator light).