Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan...

11
Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski

Transcript of Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan...

Page 1: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

Audio Led Bargraph Equalizer

Final Project for ECE-355105/02/09

Instructor: Dr Kepuska

By; Anushan Weerasooriya & Chris Guzowski

Page 2: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

Outline

• Summary:

1) Objective: – 6 Band Led Bargraph Equalizer

2) Design: - Overview

3) C Code: - Filters\Timers\Display

4) Difficulties: - Audio Addition

5) Outcome: - Functionality

Page 3: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

6 Band Led Bargraph Equalizer

• Synopsis:

• a) Using 6 leds and 4 switches create an led bargraph equalizer using C code and the Analog Devices

BF533 Evaluation board. This project contains modest functionality so that it could be used for the job that it

was intended. Each switch along with each led of the Bf533 will be utilized. Intended functions will include

audio gain and hold adjustments for each individual bandpass filter, varying led intensity displaying audio

output levels (alterd vs. unaltered), audio switchability for channel comparison and sample/hold led display.

• b) The led display will recreate audio levels (across all 6 bandpass filters) by illumination intensity, the

brightest being the most and the weakest being the least.

• c) All 6 filters will be recombined into a composite audio output of the original audio input incorporating our

desired gain adjustments.

Page 4: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

Overview• Implementation

• Switches/Leds:

a) Switch #1 selects each bandpass of filters one at a time which will be displayed by its appropriate led and corresponding

illumination intensity.

b) Switch #2 controls 3 levels of gain adjustments for each filter one at a time.

c) Switch #3 locks in gain for each channel adjusted.

d) Switch #4 selects altered (all bandpass filters) audio with full led bargraph display or the full led bargraph display by itself.

FIR Filters:

a) Six bandpass filters will make up the original audio input spectrum. Low frequencies will be pass by the 200hz-

750hz filter, the highest frequencies will be passed by the 7khz-10khz filter and the midband frequencies will be

pass by the 5khz-7khz, the 3khz-5khz, the 1.5khz-3khz , the 750hz-1.2khz filters respectively.

Diagram of Typical FIR Filter

Page 5: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

Overview - SwitchingCode snippets for audio switching control:

*pDMA1_IRQ_STATUS = 0x0001; // Confirm Interrupt Handling

if(LED1 == 0x00 && LED4 == 0x00) // Checking LED Status{

// Copy Input Data from Dma Input Buffer into VariablesiChannel0LeftIn = iRxBuffer1[INTERNAL_ADC_L0];iChannel0RightIn = iRxBuffer1[INTERNAL_ADC_R0];

Process_Data();// Call Function that Contains user Code

// Copy Processed Data from Variables into Dma Output BufferiTxBuffer1[INTERNAL_DAC_L0] = iChannel0LeftOut;iTxBuffer1[INTERNAL_DAC_R0] = iChannel0RightOut;Status1 = 0x00; // Controls Led's Illumination Time

}if(LED1 == 0x01 && LED4 == 0x00) // Checking LED Status

{// Copy Input Data from Dma Input Buffer into Variables

iChannel0LeftIn = iRxBuffer1[INTERNAL_ADC_L0];iChannel0RightIn = iRxBuffer1[INTERNAL_ADC_R0];

// Copy Processed Data from Variables into Dma Output BufferStatus1 = 0x01; // Controls Led's Illumination Timeabandpass();iTxBuffer1[INTERNAL_DAC_L0] = aChannel0LeftOut;iTxBuffer1[INTERNAL_DAC_R0] = aChannel0RightOut;

}// One Bandpass Filter at a Time

if(*pFIO_FLAG_C == 0x0100 && pf8count == 0) // Switch P8 Flag & Count at 0{

FIO_ANOM_0311_FLAG_W(0x0100,pFIO_FLAG_C);// Confirm Interrupt HandlingLED1 = 0x01; // Sets LED1 Control Variablepf8count++;

}if(*pFIO_FLAG_C == 0x0100 && pf8count == 1) // Switch P8 Flag & Count at 1

{FIO_ANOM_0311_FLAG_W(0x0100,pFIO_FLAG_C);// Confirm Interrupt HandlingLED1 = 0x02; // Sets LED1 Control Variablepf8count++;

}

Page 6: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

FIR Filters - Code in Process_data.c file– Filter Coefficients (101) for the 100th Order – Impulse response of a Nth order FIR filter lasts N+1 samples & dies to 0– Filter Equation Implementation

for (m=fBL - 1; m >= 0; m--)

{

xl[m]=xl[m-1]; // moving the array data from the end to the beginning (leftwards)

xr[m]=xr[m-1];

}

xl[0]=(float)(iChannel0LeftIn<<8); // Shift Left 8 bits to make 16 bit arrays since ADC gives 24 bit arrays

xr[0]=(float)(iChannel0RightIn<<8);

 

for(counter=0;counter < fBL;counter++)

{

yl += fB[counter] * xl[counter];

yr += fB[counter] * xr[counter];

}

fChannel0LeftOut=(((int)yl)>>8)*gainbp6; // Shift Right 8 bits to create the original 24 bit array

fChannel0RightOut=(((int)yr)>>8)*gainbp6;

N

k

knxkwny0

][*][][

FIR Filter Algorithm

Page 7: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

Timers - Code in ISR.c file

• Timer Setup:• a) A two timer operation will be enabled to run the led brightness display by gauging the fastest running timer against

the slowest running timer ultimately providing varying intensities with each corresponding led frequency band.

• Timer Configuration:• *pTIMER0_CONFIG = 0x0019;• *pTIMER0_PERIOD = 0x00080000; // Timer0 Period• *pTIMER0_WIDTH = 0x00040000; // Timer0 Width• *pTIMER1_PERIOD = 0x00003900; // Timer1 Period• *pTIMER1_WIDTH = 0x00001950; // Timer0 Width• *pTIMER_ENABLE = 0x0003; // Enable Timers0/1

• Timer Code:

• timerstatus = (*pTIMER_STATUS); // Records TIMER_STATUS before it is Reset• *pTIMER_STATUS = 0x0003; // Confirms Interrupt Handling• if((timerstatus & 0x0001) == 0x0001) // Checks for Timer0 Status Bit• {• tim0++; // Once Timer0 is Detected Keep Enabled until Cycle Complete• }• if((timerstatus & 0x0002) == 0x0002) // Checks for Timer1 Status Bit• {• tim1++; // Auto Increment tim1• tim2++; // Auto Increment tim2• }• if(tim0 < 1 ) // Reset tim0=1 when tim0 does not = 1• {• tim1 = 0;• }•

Page 8: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

Timers - Continued• Timer Code

• // Led1 Section-------------------------------------------------------------------------------------------------------------//• if(ledctr == 1 && tim0 == 1 && tim1 == 1) // Send to amp "level" of Freq #1 when tim0=1• {• if(hold== 0)• {• amp1 = famp1; // Samples and Holds famp1 Before it is Used• }• *pFlashA_PortB_Data = 0x01&Status1; // Illuminate Led #1• }• if(ledctr == 1 && tim0 == 1 && tim1 > amp1) // Checks to Turnoff all Led's• {• *pFlashA_PortB_Data = 0x00; // De-illuminate all Led's• tim0 = 0; // reset tim0=0• tim1 = 0; // reset tim1=0• }

Timer1

Timer0 -32 Possible Illumination Levels-pTIMER0_PERIOD = 0x00080000

pTIMER1_PERIOD = 0x00003900

Timing Diagram

Initialize.c file Changes:// Set Sport0 RX (DMA1) interrupt priority to 2 = IVG9

*pSIC_IAR0 = 0xffffffff;*pSIC_IAR1 = 0xffffff2f; // Sport0->ID2*pSIC_IAR2 = 0xffff5f44; // FlagA->ID5/Timer0->ID4/Timer1->ID4

// assign ISRs to interrupt vectorsregister_handler(ik_ivg9, Sport0_RX_ISR); // Sport0 RX ISR -> IVG 9register_handler(ik_ivg11, Timerz_ISR); // Timer0/1 ISR -> IVG 11register_handler(ik_ivg12, FlagA_ISR); // FlagA ISR -> IVG 12

// enable Sport0 RX and FlagA interrupt*pSIC_IMASK = 0x000b0200;

Page 9: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

Display - Code in ISR.c Process_data.c files

Led Values are set here after each filter algorithm which converts audio output words into integers:

// Led Value Set Here

if(aChannel0LeftOut<0xffff0000 && aChannel0LeftOut>0xf0000000){

famp1 = 32;}if(aChannel0LeftOut<0xf0000000 && aChannel0LeftOut>0x0f000000){

famp1 = 24;}if(aChannel0LeftOut<0x0f000000 && aChannel0LeftOut>0x00f00000){

famp1 = 16;}if(aChannel0LeftOut<0x00f00000 && aChannel0LeftOut>0x000f0000){

famp1 = 8;}if(aChannel0LeftOut<0x000f0000 && aChannel0LeftOut>0x0000f000){

famp1 = 4;}if(aChannel0LeftOut<0x0000f000 && aChannel0LeftOut>0x00000f00){

famp1 = 0;}

Page 10: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

Audio Addition• Recombining Audio Bands:

• a) An unorthodox audio addition scheme was utilized to allow for complete board functionality. All bandpass audio filters are added using

time division multiplexing. This seemed to be the only way to recombine six altered audio channel into one composite stream and

overcome Bf533 board slowdowns or halts. • if(LED4 == 0x01 && LED1 == 0x00) // Checking LED status• {• // Copy Processed Data from Variables into Dma Output Buffer• if(tim2 == 1)• {• abandpass();• }• if(tim2 == 2)• {• bbandpass();• }• if(tim2 == 3)• {• cbandpass();• }• if(tim2 == 4)• {• dbandpass();• }• if(tim2 == 5)• {• ebandpass();• }• if(tim2 == 6)• {• fbandpass();• }

• iTxBuffer1[INTERNAL_DAC_L0] = aChannel0LeftOut+bChannel0LeftOut+cChannel0LeftOut+dChannel0LeftOut+eChannel0LeftOut+fChannel0LeftOut;• iTxBuffer1[INTERNAL_DAC_R0] = aChannel0RightOut+bChannel0RightOut+cChannel0RightOut+dChannel0RightOut+eChannel0RightOut+fChannel0RightOut;

Page 11: Audio Led Bargraph Equalizer Final Project for ECE-3551 05/02/09 Instructor: Dr Kepuska By; Anushan Weerasooriya & Chris Guzowski.

Functionality

• Discussion:

• a) All the desired led/switch and audio pass functions of the project operated nominally; however, final added bandpass filters produced unwanted

frequencies in each band producing an undesirable filtered audio output. Total functional operation was realized; however, there were unwanted

sympathic (outside of bandpass filter) frequencies and Bf533 board slowdowns/halts.

• b) Also, because of time constraints and audio addition (switching noise) problems, other functions such as adjustable led rise/decay rates and

decibel signal referencing would have been a nice touch but could not be realized.

• c) Although we had a few difficulties, overall we learned a lot about controlling the Bf533 board and using it to digitally manage signals.