Preview only show first 10 pages with watermark. For full document please download

Enhanced Wireless Audio Amplifier

   EMBED


Share

Transcript

5/4/2012 RUTGERS UNIVERSITY, SCHOOL OF ENHANCED WIRELESS AUDIO AMPLIFIER ENGINEERING | Evan Foxman, Chihwei Ching, Bryan Garofalo, Matthew Moccaro , Xiang Lin Contents Abstract ......................................................................................................................................................... 3 Background information on our design ........................................................................................................ 5 Overall Design ............................................................................................................................................... 5 The Amplifier Circuit ..................................................................................................................................... 7 Class B & AB amplifier ............................................................................................................................... 8 Short-Circuit Protection .......................................................................................................................... 10 Output ..................................................................................................................................................... 11 The Coding Algorithms ................................................................................................................................ 15 Conclusion ................................................................................................................................................... 17 Presentation – May 2, 2012 ........................................................................................................................ 18 Poster ...................................................................................................................................................... 20 Group Shot .............................................................................................................................................. 21 Bibliography ................................................................................................................................................ 21 Appendix ..................................................................................................................................................... 22 Bluetooth Bee – master code ................................................................................................................ 22 Bluetooth Bee – slave code ................................................................................................................... 23 Abstract Amplifiers are devices used to generate a greater output signal when compared to its input signal. In equation form: Vo=AVin, where Vo is the output voltage, Vin is the input voltage and “A” is the gain. “A” is dimensionless and is a multiple of the input voltage and/or signal. While amplifiers are commonly linked to voltage gain, they are not limited to strictly voltage applications, as some amplifiers can be used to amplify current. Amplifiers are used in countless circuits, but are well-known for being applied to audio signaling applications. A typical amplifier configuration is shown in the figure below: (Stutz) In the figure, the amplifier is represented by the triangular symbol. The +V and -V terminals determine the maximum voltage swing that the amplifier can achieve at its output terminal when amplifying the input signal; hence, the amplified output signal will clip off below -V or above +V. An input signal, Vinput, is sent to the positive or negative input terminals and the output signal is seen across resistor Rload. The output signal will ideally be a linear multiple of the input signal and can be either positive or negative. (Jaegar and Blalock) p. 554 For many applications, the amplifier will be configured to operate in an inverting mode, which means Vinput is input to the inverting terminal via a resistor (R1). The positive terminal is typically tied to either a voltage supply or a ground. The output is connected to the inverting terminal through a resistor (R2), resulting in negative feedback. In this configuration, the amplifier gain is given by: -(R2/R1).Thus the output of the amplifier is a linear multiple of the input and is also inverted, or phase-shifted by 180⁰. (Jaegar and Blalock) p. 558 In many cases, the amplifier may also be configured in a non-inverting mode. A setup similar to the inverting mode is applied, with the exception that the feedback loop and Vinput are physically decoupled and are only connected via the virtual short at the input of the amplifier. Using the same notation as the inverting mode, the gain of the non-inverting amplifier is given by: 1+(R2/R1). The concept behind our design of a wireless amplifier was to couple an amplifier and a speaker with a wireless link to send audio signals from a central base station to many speakers around either a room or a small building. We chose to use Bluetooth rather than Wi-Fi; although Bluetooth suffers from lower bit rates than Wi-Fi, our application does not necessitate high bit rates, and uses less power than Wi-Fi, making it a better choice for our application. Our experimental setup consists of an audio player and a master Bluetooth module on the source end, which transmits the audio signal to a slave Bluetooth module on the receiving end. The slave outputs a digital signal at the receiving end, which is converted to an analog signal, amplified and then output to a speaker. The amplifier has variable volume control via a potentiometer. This design will allow a user to place a speaker anywhere within a 10-meter radius of the base station without the hassle of running wires between the speaker(s) and the base station. Background information on our design There are many different topologies and designs for an audio amplifier, each one having its benefits over the other. The amplifier we designed started as a class B but we had trouble with distortion, background noise, and clipping. By switching to a class AB amplifier, when the crossover occurred, no background noise was heard and the amplifier was more efficient. To briefly summarize the different classes of amplifiers:     Class A - has low efficiency of less than 40% but good signal reproduction and linearity. Class B - is twice as efficient as class A amplifiers with a maximum theoretical efficiency of about 70% because the amplifying device only conducts (and uses power) for half of the input signal. Class AB - has an efficiency rating between that of Class A and Class B but poorer signal reproduction than class A amplifiers. Class C - is the most efficient amplifier class as only a very small portion of the input signal is amplified therefore the output signal bears very little resemblance to the input signal. Class C amplifiers have the worst signal reproduction. (Storr) Overall Design Our final design consists of about five distinct stages. A synopsis of these stages is presented below: 1.) The MP3 Player The MP3 player starts the process. It simply provides a song to the Arduino where it will soon be processed and transmitted via Bluetooth. 2.) The Transmission - Arduino Uno The Arduino Uno is a very versatile platform that is intuitive to code for. As such, it was a perfect platform for our design. We were going to need two of these boards: one for the processing and transmission of the audio file and one for the reception and playback of the audio file. For now, only the transmission board is of note. From the previous step, the Arduino Uno has an on-board Analog-toDigital Converter (ADC) which takes the analog output from the MP3 player and then processes it through the Digital I/O pins of the Bluetooth Bee. 3.) The Bluetooth Bees The Bluetooth Bee is a standard Bluetooth module that can be attached to the Arduino Uno. For our design, two Bluetooth Bees were necessary: one to send the audio file and one to receive the audio file for playback. The Bluetooth Bee acts as a slave device to the Arduino Uno it is attached to, however, the two Bees also exhibit a hierarchical relationship between each other, with the source Bee being the master device of that pair. The receiving Bluetooth Bee receives the data from the source Bluetooth Bee and sends it into a Digital I/O pin on the receiving Arduino. 4.) The Off-Board Digital-to-Analog Converter The receiving Arduino Uno takes in the output of the Bluetooth Bee and sends it to an off-board resistive ladder network (called an R-2R ladder). The song’s bits are spread into a parallel arrangement and fed to the network from 10 of the Digital I/O pins on the Arduino board in the form of discrete HIGH (5V) and LOW (0V) voltage values. The HIGHs and LOWs generated at these pin sites are voltage divided within the resistive network and the analog signal is produced from variation in voltage divisions as separate pins pulse HIGH or LOW. The output conversion is seen at the top of the ladder network and is then sent to the amplifying circuit. 5.) The Amplifier Circuit The final step of our overall process is the amplifier circuit. It is composed of three distinct stages, which will be examined more thoroughly in the following sections. On a basic level, the amplifier acts to boost and modulate the gain of our audio file before it reaches the speaker through two separate operational amplifier (op-amp) stages and a buffer stage. While the op-amps control the gain, the buffer stage is needed to properly drive the speaker. The following sections will explain these stages in more detail. The Amplifier Circuit VDD 5V VDD LME49720HA C2 8 1 3 1 V1 0.5 Vpk 1kHz 0° VDD R2 Key = A 3 10kΩ 5V VDD 8 0 10uF 2 U1A 3 1 50% 2 2 4 5 U1B R11 1kΩ 4 4 R10 270 Ω LME49720HA 14 V4 5V U2 6 U5 R12 2kΩ D1 1N4148 TIP41c 16 2N3904 0 R4 1Ω 0 11 8 R3 10 Ω D2 1N4148 R5 1Ω Q2 2N3906 17 U3 9 R9 270 Ω TIP42c VSS VSS -5V As previously mentioned, the amplifier circuit is broken into three separate stages before the final output is sent to the speaker. The first stage consists of an op-amp in positive feedback with a gain of 1.5 that acts as a pre-amp. The output of this op-amp flows to an AC-coupling capacitor and a variable resistor, called a potentiometer. The potentiometer can be manually modulated by turning the screw on its top. In doing so, it will vary the gain of the second stage op-amp, which is in negative feedback connected to the output of the third stage with the potentiometer. The potentiometer can be adjusted to create about a gain of three on the second op-amp (75% turn) before clipping occurs on the output of the second stage. From the second stage, there is a final output stage using two high-powered BJTs: the NPN-TIP41 and the PNP-TIP42. Since the output from the second op-amp will be a varying sine wave, generally one of these transistors will be on at any given time, though a small crossover distortion where both are on also exists. To reduce crossover distortion, two diodes were placed on the bases of each of these transistors to properly bias them. As a final measure, short circuit protection was also placed on the emitters of these transistors in the form of two very smaller resistors in parallel with two general purpose transistors: the NPN-2N23904 and the PNP-2N3906. If the current flowing through the TIP series BJTs becomes too great, the voltage drop across the resistors will be equal to or greater than the necessary voltage to turn either of the general purpose transistors on. In doing so, they will steal current from the TIP series transistors to prevent them from burning out. Finally, the output signal will flow in feedback to the potentiometer and to the speaker itself, which will play the audio file. 0 Class B & AB amplifier As mentioned before, our original amplifier design was a class B. A simplified version of the class B amplifier can be seen in the adjacent circuit schematic: (Jaegar and Blalock) p.1008 (Jaegar and Blalock) p.1008 (Jaegar and Blalock) p.1009 As the sinusoidal wave is in the “positive” phase or the first half of 180 , the top transistor is on. When the sinusoidal wave passes 180 , the signal is in the negative region and the bottom transistor is on. During this switch from the top to the bottom transistor, there is a point where a “dead zone” is formed. This is where the distortion occurs. As seen from the plots of the output from the class B amplifier, distortion and other unpleasant sounds can be heard when the audio signal is passed to the speaker during the crossover region. To eliminate this problem, we changed our design to a class AB amplifier, which adds two diodes to the base of our transistors. Similar to the class B design, the top transistor will be on for the first half of the 180 and the bottom transistor will be on after. Unlike the class B amplifier, which simply took the input from the second amplifier to the base of the transistor, the diodes allow both transistors turn on in the crossover period, reducing crossover distortion. In our design seen above, the output from the second amplifier at node 11 is where the class AB amplifier begins. A simplified class AB amplifier: (Jaegar and Blalock) p. 1010 Although the example shows MOSFETs, the same setup and output occurs when BJT’s are use. Short-Circuit Protection In the event there was a surge from the op-amp, or some outside factor causing a dramatic increase of current, some sort of protection was going to be needed to prevent the high-powered BJTs from overheating and breaking down. Hence, we decided to implement short-circuit protection as an extra measure. As seen in our design above, when the current enters the base of the transistor at node 6, it crosses over to the emitter region at node 16, then through a 1Ω resistor and lastly, the speaker, which is represented by a load resistance of 10 . Very little voltage will be lost to the 1Ω resistor during normal operation and the general purpose transistors will remain off. However, if there is a surge, when the current passes through the emitter and then node 16, it will be large enough to turn on the BJT that is also connected to node 16 because the voltage drop across that resistor will be greater than or equal to the transistor turn-on voltage. During the surge, the 3904 BJT takes the increased current and shunts it through its collector, limiting the current through the high-powered TIPs and saving them from destruction. Although, we have discussed our circuit design for short circuit protection, a simplified circuit shows how this process works: (Jaegar and Blalock) p. 1012 Output The final output of this design is when the signal passed through the speaker. We compared the output of the signal under two conditions. The first condition was when the MP3 player was attached to the speaker. Next, we took the MP3 player and hooked it up to our circuit and adjusted the potentiometer until the gains were substantial. Even when the speaker was simply hooked up to the MP3 player and the volume was at max, our circuit was still louder and clearer. The simulated outputs can be seen on the following pages. Note that the image description appears below the respective image in bolded text: Unity gain (potentiometer set to 50%) Potentiometer set to 65% - gain equals 1.86 Potentiometer set to 75% - gain equals 3 Potentiometer set at 80% - gain equals 4 As seen above in the image above, clipping occurs when the potentiometer ratio reaches about 80% and a lot of background noise and distortion can also be noticed; however, the greatest gains occur when the potentiometer is between 75% and 80%. Actual constructed circuit with MP3 player and speaker Close up of the breadboard The Coding Algorithms The algorithms for this project were involved within the coding of the Bluetooth modules. Each Bluetooth module had to follow several algorithms in order to perform the tasks needed. The process involved connecting the two pieces together, sending the appropriate data, and then receiving the data, all in a timely manner so that the music would play through clearly and without significant delay. All code associated with these algorithms can be seen in the Appendix at the end of the report. To make a connection between each Bluetooth module, we needed to send a series of commands in order to set up each side for its respective purpose. To send commands directly to the modules, the command “Serial.print();” was used to initialize the Bluetooth modules, i.e., set them up. Furthermore, the first command that needed to be sent was the one to set up one module as a slave and then the other as a master. To do this, the first few line of code were “+STDMOD =0” and “STDMOD=1”, respectively. Next, we sent several other less important commands to the modules which make our experience with them more convenient such as an auto-connect feature and a name command to name each module. Finally, the next vital part of our connection algorithm uses the command “+INQ=1”. This command allows each module to “inquire” for Bluetooth-compatible devices in the surrounding area to look for the other module. The master module is loaded with another command that connects the two devices. It takes on the form “+CONNECT=01,01,01,01,A;”. In our code, the “01”s were replaced with the address of the slave Bluetooth module. This makes sure that the master module connects to the slave module only and not to some other device. Finally, after these steps are completed, the connection is established between the modules and they are ready for communication. MASTER MODULE SLAVE MODULE +STWMOD=1 +STWMOD=0 +INQ=1 +INQ=1 +CONNECT=01,01,A To send the data, another algorithm was used. This algorithm was written in the master Bluetooth module and is used to send data. It is a very simple algorithm and simply reads in digital information from one source pin in a continuous loop and uses the “Serial.print();” command to send the data from one Bluetooth module to another after the connection is made. Read in Data From Source Send Data From Master Bluetooth Module to Slave Module Finally, the last algorithm which was used helped us to receive the data on the slave module. The algorithm was slightly more involved as it needed to sort through the data it received so that it would only pass on good data and not any interference or irregularities picked up from the signal it received. The first problem which we needed to overcome was that the data was received as a character data type. This value then needed to be transformed into an integer so that it could be used by the DAC (Digital to Analog Converter). To solve this problem, we used the “atoi” function which helped us to convert from a character data type to an integer data type. After this, the data was checked to make sure that we were getting the only the data we desired. This was done with simple “if” statements, which stated that if an input was not a number, do not send it on to the DAC. The code then determines what range the number is between, and then sends the correct pin HIGH at the correct time, thus allowing the DAC to take over and convert this digital signal into an analog one. This algorithm is the backbone of our project and helps to transport data efficiently. Read In Data From Serial Convert Data To Integer Sort Out Unneeded Data Send Correct Data To Pins Conclusion As with any project, there is always room for improvement, and this project was no exception. Noise cancellation and distortion reduction are still areas of design that we should seek to improve upon for future projects, as these two issues plagued our project. On another hand, this project could also be expanded to fulfill the initial goal of a surround sound audio system with more than one speaker through the use of longer-range Bluetooth apparatuses and more speaker amplifier systems, as well as a GUI interface for a more established base of operation. Technical and time challenges limited our ability to achieve this original vision, in no small part thanks to the several problems we encountered, from hardware malfunctions, software errors, unforeseen noise issues and last-minute changes. Fortunately, we managed to get all of the pieces working together to achieve a large portion of the goal we set for ourselves when it mattered and our project could still be regarded as an immense success, despite the odds. We managed to properly transmit audio data from one Arduino to another, amplify it and output it relatively clearly through a speaker. Although not everything went as expected or planned, this project served a very vital role in our education. Through this experience, not only did we develop a new set of skills in terms of hardware and software design, but we refined old skills in circuit analysis and design, time management and how to succeed as a team, all of which are essential for success in the real world as electrical engineers. We took our failures and made them into successes by learning from our mistakes and applying new ways of thinking to solve old problems, outside help notwithstanding. In the end, the Capstone project managed to be exactly what it should have been: an educational tool to help get us our feet wet through application combined with theory and to prepare us for the future. Presentation – May 2, 2012 Input yellow & Output blue Poster Group Shot Bibliography Jaegar, Richard C. and Travis N. Blalock. Microelectronic Circuit Design. 4th edition. New York: McGrawHill , 2011. Storr, Wayne. Introduction to the Amplifier. April 2012. 11 April 2012 . Stutz, Michael. Single-ended and differential amplifiers. 2000. 9 April 2012 . Appendix Bluetooth Bee – master code // serial port long DATARATE = 38400; // maximum data rate for BT Bee int LED = 13; // Pin 13 is connected to a LED on many Arduinos const int analogInPin = A0; //pin A0 designated as audio input int sensorValue = 0; //voltage value of audio input int outputValue = 0; //value sent to serial monitor void setup() { Serial.begin(DATARATE); // bluetooth bee setup Serial.print("\r\n+STWMOD=1\r\n"); // set to master Bee delay(1000); Serial.print("\r\n+STNA=EVAN\r\n"); // set Bluetooth master module to “evan” name delay(1000); Serial.print("\r\n+STAUTO=1\r\n"); // don't permit auto-connect delay(1000); Serial.print("\r\n+STOAUT=1\r\n"); // existing default delay(1000); Serial.print("\r\n+STPIN=0000\r\n"); // existing default delay(2000); // required // initiate BTBee connection Serial.print("\r\n+INQ=1\r\n"); delay(2000); // wait for pairing Serial.print("\r\n+CONN=0,18,E4,C,68,A\r\n"); pinMode(LED, OUTPUT); } void loop() { sensorValue = analogRead(analogInPin); //read in audio voltage values Serial.println(sensorValue); //print them out to be sent to other Bee } Bluetooth Bee – slave code #include long DATARATE = 38400; // maximum data rate for BT Bee char inChar; char inData[4]; int index = 0; //counter variable int val = 0; //value to come from inData conversion using atoi() int LED = 13; // Pin 13 is connected to a LED on many Arduinos void setup() { Serial.begin(DATARATE); // bluetooth bee setup Serial.print("\r\n+STWMOD=0\r\n"); // set to slave delay(1000); Serial.print("\r\n+STNA=Foxman\r\n"); // set Bluetooth slave module to “foxman” name delay(1000); Serial.print("\r\n+STAUTO=1\r\n"); // don't permit auto-connect delay(1000); Serial.print("\r\n+STOAUT=1\r\n"); // existing default delay(1000); Serial.print("\r\n+STPIN=0000\r\n"); // existing default delay(2000); // required // initiate BTBee connection Serial.print("\r\n+INQ=1\r\n"); delay(2000); // wait for pairing //pinMode(6, OUTPUT); pinMode(12,OUTPUT); //MSB pinMode(11,OUTPUT); pinMode(10,OUTPUT); pinMode(9,OUTPUT); pinMode(8,OUTPUT); pinMode(7,OUTPUT); pinMode(6,OUTPUT); pinMode(5,OUTPUT); pinMode(4,OUTPUT); pinMode(3,OUTPUT); //LBS } void loop() { if (Serial.available()) { inChar= Serial.read(); if(inChar == '0' || inChar == '1' || inChar == '2' || inChar == '3' || inChar == '4' || inChar == '5' || inChar == '6' || inChar == '7' || inChar == '8' || inChar == '9') { inData[index]= inChar; index++; } else { val = atoi(inData); if(val!=0) { Serial.println(val); if ((val&0b00000001)==1) { digitalWrite(3,HIGH); } else { digitalWrite(3,LOW); } if ((val&0b00000010)==2) { digitalWrite(4,HIGH); } else { digitalWrite(4,LOW); } if ((val&0b00000100)==4) { digitalWrite(5,HIGH); } else { digitalWrite(5,LOW); } if ((val&0b00001000)==8) { digitalWrite(6,HIGH); } else { digitalWrite(6,LOW); } if ((val&0b00010000)==16) { digitalWrite(7,HIGH); } else { digitalWrite(7,LOW); } if ((val&0b00100000)==32) { digitalWrite(8,HIGH); } else { digitalWrite(8,LOW); } if ((val&0b01000000)==64) { digitalWrite(9,HIGH); } else { digitalWrite(9,LOW); } if ((val&0b10000000)==128) { digitalWrite(10,HIGH); } else { digitalWrite(10,LOW); } if ((val&0b100000000)==256) { digitalWrite(11,HIGH); } else { digitalWrite(11,LOW); } if ((val&0b1000000000)==512) { digitalWrite(12,HIGH); } else { digitalWrite(12,LOW); } } for(index=0;index<4;index++) { inData[index] = '\0'; } index = 0; } } }