AUTOMATIC VOLUME CONTROL Team 37 Marius Berner and Muhammed Azam TA: Justine Fortier ECE 445: Senior...

Preview:

Citation preview

AUTOMATIC VOLUME CONTROL

Team 37

Marius Berner and Muhammed Azam

TA: Justine Fortier

ECE 445: Senior Design Project

December 4, 2013

INTRODUCTION

• Purpose of the project: to create a small sound system capable of adjusting the volume of a remote controlled device (i.e. a TV or stereo) based on what its current volume is in comparison to the background noise in the room

• Project ideally would eliminate need to toggle volume manually (via operation of a remote) for fluctuations of background noise in an environment (such as dogs barking, someone vacuuming, etc).

FEATURES

• Electret microphone with breakout board to detect and measure the background noise levels

• Noise cancellation circuitry to correct the microphone measurements for the TV contribution

• Arduino Uno R3 microcontroller coded to compare TV sound level to the rest of the room and control infrared transmissions based on the differential

• IR LED to transmit volume control signals

• User controllable audio thresholds via USB connections

• Transmits remote signals when device is placed from a 4 ft. distance from the television with detection capability of approximately 0.5 ft. from the television’s IR receiver

• Currently compatible with four major remote code protocols (NEC, Sony, RC5, RC6)

Phase Inverting Circuit

Noise Limiter andComparator

Microcontroller Processing Unit

Power Signal  Noise Signal  Volume Control Signal

Tv Noise Signal

mic

Background + TV noise

RemoteTransmission Circuit

Automatic Volume Control Block Diagram

Speaker

+ 9V+9V+9V

Changes from original design

• Original plan: design an exponential circuit to correct the microphone signal for the noise of the TV before comparison of the two

• Problem: too unreliable and prone to delay

• Alternate plan: use active noise cancellation to cancel the noise of the TV at the microphone

Phase Inverting Noise Cancellation Circuit

• Purpose: to phase invert an AC voltage signal as well as eliminate any dc offset in the output

• Parts used: 1 - 20kohm resistor, 1- 4700uF capacitor, 1- LM 386N-1 (20 x gain) audio amplifier, and 1- 9V battery for the amplifier.

• Functionality: the signal goes through the 20 kOhm and the 4700uF capacitor works as an high pass filter. Its output is then send to the LM 386N-1 to be inverted.

Phase Inverter Circuit

High Pass Filter Verification

Top green plot corresponds to the output after the high pass filter

Bottom yellow plot corresponds to the input leading to the high pass filter

Input on the function generator was .200Vpp with a 1Vdc offset.

Phase Inverter Verification

Noise Cancellation

• Plan was to use a speaker powered by 9V battery to output the inverted signal

• Speaker output would be added with the background noise (also containing TV noise) at the electret microphone to cancel out the TV noise from the background

Electret Microphone for Noise Detection

• Adafruit electret microphone with built in breakout board for amplification ($4.95)

• Outputs voltage signal of the audio level measurement

Requirement: must be able to detect sound levels and output the corresponding audio voltage signals

• Verification procedure: connect output voltage of the microphone to a voltage probe and display signal; create various noises and check that the microphone responds accordingly

(Test results here are for 5 ft from the microphone and averaged over

5 trials per test case with 10 seconds per trial)

Test Sound

Max Voltage (V)

Min Voltage (V)

Quiet room (a lightly filled senior design lab)

1.20 0.60

Hammer (about half strength)

4.81 1.97

Clapping (half strength)

4.16 1.89

TV (40% max) 1.70 0.95TV(80% max) 2.45 1.55

Comparator

• Purpose: to compare the TV noise signal with the background noise signal

• Parts used: 1 – 500 ohm resistor, 1- 9V battery, 1- 47 kOhm resistor, and 1- 24 kOhm resistor, 1- LM 386N-1

Comparator Circuit Diagram

Comparator Output Range

• Works best if inputs are in DC form and supply is 9 V.

• low (~ 700mVdc) when TV (- input) >background(+ input)

• mid (~3Vdc) when TV ~= background

• high (> ~ 4.76Vdc) when TV < background

Comparator Verification Procedure

• 0Vpp with a 0Vdc bias on negative input while grounding positive input• Check output with oscilloscope and record value

• 0Vpp with a .1Vdc bias …• Check output with oscilloscope and record value

• 0Vpp with a -.1Vdc bias …• Check output with oscilloscope and record value

Remote Signal Transmission

• Remote signals transmitted via a 940nm wavelenghth infrared transmitter LED ($0.95)

• Microcontroller controls when to transmit the signals

• Smartphone camera can be used to determine whether the LED is emitting (since IR signals are typically non-visible to naked eye)

Requirement: correctly transmit remote code protocols for device (Sony TV)

• Using the public Arduino IRremote library (https://github.com/shirriff/Arduino-), infrared remote signals were obtained for various televisions using the IRrecvDump sketch and connecting a 38 kHz, 3-pin IR receiver to the Arduino.

• Most of the testing for the remote signal transmissions were done on the Sony TV we used for our demo (which uses Sony remote protocol) and an LG TV (which transmits NEC protocol signals)

• Button codes sent to receiver via Comcast universal remote

Remote Protocol

Button Decoded IR code (in HEX)

Number of bits

Sony POWER 0xA90 12

NEC POWER 0x20DF40EF 32

Sony VOLUME UP 0x490 12

NEC VOLUME UP 0x20DF40BF 32

Sony VOLUME DOWN 0xC90 12

NEC VOLUME DOWN 0x20DFC03F 32

• Once IR signals for necessary buttons were decoded, IR LED was hooked up to Arduino

• Tested transmission by using various conditionals to command an IRsend function of the desired button from the transmitter:

#include <IRremote.h>

IRsend irsend;

• Through trial and error it was determined that the transmitter was able to send code from about 4 ft. from the TV and could be placed about 0.5 ft. to the left or right of the TV IR receiver at that distance

Sound Level Processing Unit

• The output of the comparison circuit is inputted into an Arduino Uno R3 microcontroller ($29.61)

• Used to control the IR transmitter LED

• Coded to send the appropriate remote button signals based on various voltage thresholds

• Power requirements: any battery that can source 7-12 V and over 500 mA of current (USB power can also be used)

Algorithm for Arduino code:• Receives input from differential comparison

circuit output (4.76 V for microphone > TV, 3.0 for approximate equality, and 0.7 V for microphone < TV) into analog input pin

• Scales voltages and computes a running average based on the squares of the inputs (to avoid opposite signed sound signals from negating each other before taking the average sound level)

• Creates constant voltage thresholds based on the comparison circuit to compare the inputs to:

1. If running average > 4.20-V, send “volume up” signal

2. If 2.85-V<running average < 4.20-V, do nothing

3. Otherwise send “volume down” signal

Requirements: command the IR LED to transmit distinct remote signals based on the voltage received as analog input

• Once the code was written testing was fairly straightforward: simply modify the voltage thresholds in the code and checked to ensure that the volume signals were or weren’t being sent accordingly

• Problem 1: originally code saw issues due to the large nature of the running average of squared values (i.e. the analog pin was reading significantly different values for voltage values very close to each other, making it difficult to set thresholds

• Solution: subtract an central offset (2.5-V) from each sample before squaring

• This temporarily caused an issue of negative values being introduced to the microcontroller for V < 2.5-V, which it processed as looping back around and caused certain low signals to be read as high

• Solution: change to a variable offset

Problems/Future Improvements

• Comparator cannot take in AC inputs (output seem to be the sum of both inputs) so AC inputs should be converted to DC.

• Although we used a battery, a constant power supply of 7V is needed for the output of the comparator circuit.

• TV noise input and Speaker couldn’t be fully implemented in our circuit

Solution might be to use a mono audio jack rather than a stereo audio jack (for our TV)

• Design not fully transferred to a PCB/vector board

Acknowledgements

• Professor Makela

• Justine Fortier

• 445 TA’s/course staff

• Parts’ Shop Personnel

Recommended