Anda di halaman 1dari 13

DSP for Dummies

aka

How to turn this (actual raw sonar trace)

2590

2580

2570

2560

2550

2540

2530
1

14 27 40 53 66 79 92 105 118 131 144 157 170 183 196 209 222 235 248 261 274 287 300 313 326 339 352 365 378 391 404 417 430 443 456

1
2552
2554
2556
2558
2560
2562
2564
2566
2568
2570
2572
2574

14

27

40

53

66

79

Into this .. (filtered sonar data)


92 105 118 131 144 157 170 183 196 209 222 235 248 261 274 287 300 313 326 339 352 365 378 391 404 417 430 443 456

Fundamental property of all analog


signals

properties

complex signals

amplitude

i.e. audio

Decompose

into summation

of sinusoids

phase

frequency

i.e. digital bitstream


Fourier Transform

How do we analyze the frequency components of a complex signal

Time space x(t)



single frequency signal 0

Frequency space X()


Some properties

X() is complex -- complex conjugate encodes phase

Fourier transform is invertable


Digital Signals

Sample amplitude at discrete time intervals

1,0

.55

.46

-,6

Nyquist limit

-1.0

(http://www.medcyclopaedia.com)

(Harry Nyquist, 18891976, Swedish - American physicist), the maximum frequency of a signal that
can be measured with a method that employs sampling of the signal with a specific frequency, the
sampling frequency. According to Shannons sampling theorem, a signal must be sampled with a
frequency at least twice the frequency of the signal itself. The maximum measurable frequency the
Nyquist limit or frequency is thus half the sampling frequency. If the signal frequency is higher than
the Nyquist limit, aliasing occurs.

Discrete Fourier Transform



Given a signal represented as a time sequence of samples, the DFT
gives us a seqence of frequency/phase amplitudes

1,0

.55

.46

-,6

-1.0

Signals and noise



What is noise?

Any signal other than the one you are interested in!



Sources of Noise (the usual suspects)

statistical signals from active electronic components

crosstalk from other channels or other signals in the same channel

signals sensed from external sources (power supply, EM radiation)


Trival Example

1.5

1.5

1.5

0.5

0.5

0.5

0
1

9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81

7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82

-0.5

-0.5

-0.5

-1

-1

-1

-1.5

-1.5

-1.5

Signal of interest
+

Signal to Noise ratio


Noise signal

7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82

Noisey Signal

The relative amplitude of


the signal of interest o the
noise signal

Filtering out the Noise



Finite Impulse response (FIR) filter

Ideal Pulse (time domain)

Zero rise/fall time

Ideal Pulse (frequency domain)




to inifinity

to inifinity

t

Ideal Pulse (time domain)

actual rise/fall time

finite band of component frequencies

The number and values of the component freqencies is related to the rise/fall time of the pulse

http://www.chem.uoa.gr/Applets/AppletFourAnal/Appl_FourAnal2.html

FIR filter
A special type of weighted average designed to enhance signal
components at some frequencies while attenuating others

i=(taps1)

xt =

Ci * Sti

i=0

St

C1

St-1

C2

St-2

C3

St-3

C4

C5

Selecting the coefficients tunes



the filter to pass or attenuated specific

frequency bands

St-4

St-5

C5

*
+

Xt

Selecting the coefficients


a.k.a designing the filter

Matlab demo

How a filter works (theoretically)



1.5

0.5

FFT

0
1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82

signal

-0.5

noise

-1

-1.5

1.5

minus

0.5

0
1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82

noise

-0.5

-1

-1.5

1.5

0.5

0
1

-0.5

-1

-1.5

9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81

FFT-1

signal

/*

fir.h

simple fir filter code

* dmc - 03-04-08

* for cs 1567 note this code does not set up coefficents



*/



#define TAPS 4 // how many filter taps



typedef struct

{

float coefficients[TAPS];

unsigned next_sample;

float samples[TAPS];

} filter;



/* firFilterCreate()

* creates, allocates, and iniitializes a new firFilter

*/

filter *firFilterCreate()

{

int i;

filter *f = malloc(sizeof(filter));

for (i=0; i<TAPS; i++) {

f->samples[i] = 0;

f->coefficients[i] = 1. /(float) TAPS; // user must set coef's

}

f->next_sample = 0;

}

Sample Code



/* firFilter

* inputs take a filter (f) and the next sample (val)

* returns the next filtered sample

* incorporates new sample into filter data array

*/



float firFilter(filter *f, float val)

{

float sum =0;

int i,j;



/* assign new value to "next" slot */

f->samples[f->next_sample] = val;



/* calculate a weighted sum

i tracks the next coeficeint

j tracks the samples w/wrap-around */

for( i=0,j=f->next_sample; i<TAPS; i++) {

sum += f->coefficients[i]*f->samples[j++];

if(j==TAPS) j=0;

}

if(++(f->next_sample) == TAPS) f->next_sample = 0;

return(sum);

}


Filtered Wheel Encoder Data



Left Wheel

Right Wheel

Filtered NorthStar data



X Position

Y Position

Theta

Anda mungkin juga menyukai