47
Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Embed Size (px)

Citation preview

Page 1: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Software Defined RadioPhD Program on Electrical Engineering

Sampling Theory and QuantizationJosé Vieira

Page 2: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Sumary

• The USRP kits in the Lab• Sampling of low-pass signals• Sampling of band-pass signals• Second order sampling• Quantization

Page 3: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

USRP 1

Page 4: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

USRP

• Four 12bit 64Ms/s ADCs

• Four 14bit 128Ms/s DACs

• USB 2.0 with 32MB/s

Page 5: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

USRP – FPGA pre-programmed front-end

• The FPGA has a digital down converter

• The frequency of the Numerical Controlled Oscillator and the decimation factor can be changed

• The output is transmitted via USB to the PC

• The remaining processing is performed on the PC.

Page 6: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

USRP – Architecture general overview

Page 7: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

USRP 2

Page 8: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

USRP 2

• Use with GNU Radio, LabVIEWTM and SimulinkTM

• Modular Architecture: DC-6 GHz• Dual 100 MS/s, 14-bit ADC• Dual 400 MS/s, 16-bit DAC• DDC/DUC with 25 mHz Resolution• Up to 50 MS/s Gigabit Ethernet Streaming• Fully-Coherent MIMO Capability• Gigabit Ethernet Interface to Host• Spartan 3A-DSP 3400 FPGA (N210)

Page 9: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

USRP 2

Page 10: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Sampling of low-pass signals

• The Sampling Theorem

• We can describe the sampling process as a multiplying the signal x(t) by a pulse train of Dirac pulses

Consider a low-pass signal x(t) with bandwidth B. Then, if we sample this signal at a rate greater than 2B is possible to reconstruct the original signal from the samples.

Page 11: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Sampling of low-pass signals

• In the Fourier transform domain

• Fourier transform of the signal p(t)

Page 12: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Aliasing

• When the sampling frequency is not enough, aliasing occurs due to the overlap of the spectrum components

Page 13: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Sampling a Low-pass SignalLow pass filter

Page 14: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Uniform sampling of band-pass signals

• Consider a band-pass signal x(t) with carrier frequency fc and bandwidth B.

• The maximum frequency of this signal is

• Using the Nyquist sampling theorem for low-pass signals the sampling frequency fs for the signal x(t) should be

Page 15: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Uniform sampling of band-pass signals

• For modulated signals x(t) where the frequency of the carrier fc is much larger than the signal bandwidth, this form of sampling is impracticable.

• However, there is a version of the Nyquist theorem for band-pass signals

If a signal as bandwidth B, then the sampling frequency fs should be greater than 2B in order to be possible to recover the original signal from the samples.

Page 16: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Sub-Sampling Using a Band-pass Filter

Fs=2B

2B

2B

Page 17: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Sub-Sampling

• The sampling frequency fs should be properly chosen in order to match the carrier frequency, we could have fc=kfs, with k an integer.

• In certain systems we can use oversampling and perform the band-pass filtering in the digital domain.

• As the resultant signal is oversampled it can decimated. Using polyphase decomposition of the anti-aliasing filters an efficient implementation is possible.

Page 18: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Sampling of band-pass signals

• The Nyquist zones

Page 19: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Second Order Sampling

• The second order sampling is a form of sub-sampling with down conversion that gives the in-phase and quadrature components directly.

Page 20: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Second Order Sampling

Page 21: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Oversampling and Digital Decimation

Fs>2B

2B

>2B

Page 22: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Quantization

Page 23: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

23

Fixed Point Multiplication with the Q15 Format

×Q30s s

Q15s

Q15s

Q15s

Shift 15

Page 24: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

24

Integer Multiplication

×Inteiro 32 bitss s

Inteiro 16 bitss

Inteiro 16 bitss

Inteiro 16 bitss

Page 25: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

25

Example

0.6796875*0.9296875 =0.63189697265625119 *87 =103530.1110111 *0.1010111 =00.10100001110001 =0.625

Page 26: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

26

Fixed Point Arithmetic

• Avoiding the Overflow– Scaling– Saturated arithmetic

• Truncation• Rounding

– Rounding to the nearest– Convergent rounding

Page 27: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

27

Scaling

• Consider a system with a frequency response having a absolute value maximum given by

• To avoid the saturation of the signal numerical representation at the output of the system (overflow), we have to scale the input signal by multiplying with the scaling factor 1/A.

)(max jeHA

Page 28: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

28

Scaling

1/A H(z)

)cos( no )cos(1

nA o )cos( no

AeH oj )(

Page 29: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Scaling on the inner points

• Consider a second order IIR notch filter.

• Also consider that the maximum absolute value of the frequency response is 0dB.

• What would be the maximum absolute value of the frequency response of

Z-1

a1 b1

Z-1

a2 b2

Z-1

aN bN

b0

x(n) y(n)s(n)

)(

)(

zX

zS

Page 30: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

30

Pole-zero Map

-1 -0.5 0 0.5 1-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

Real Part

Imag

inar

y P

art

Y(z)/X(z)

-1 -0.5 0 0.5 1-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

Real Part

Imag

inar

y P

art

S(z)/X(z)

2

Page 31: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

31

Frequency Response

0 100 200 300 400 500 600-40

-30

-20

-10

0Y(z)/X(z)

rad

dB

0 100 200 300 400 500 600-20

-10

0

10

20

30S(z)/X(z)

rad

dB

Page 32: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

32

Scaling in the Inner Points

• To avoid the overflow on the inner point of the IIR filter we have to reduce the amplitude of the input signal by the maximum absolute value of the transfer function between the input and the inner point.

• Then, in order to replace the unitary in/out gain on the pass-band we have to set an inverse gain on the output

• Result: Signal to Noise ratio degradation

Page 33: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

33

Quantization

Qb bitsm bits

m>b

x(n) xq(n)

b bitsm bits

x(n) xq(n)

e(n)

0 50 100 150 200 250 300-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

n

x(n)xq(n)

e(n)

Page 34: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

34

Quantization

1/6 1/2 2/3-1/6x(n)

xq(n)

1/3

2/3

1

-1/3

1 - 001

2 - 010

3 - 011

-1 - 111

1

• |x|≤1• q = nº of quantization

steps• 2/q , quantization

step• b = nº of quantization

bits• q = 2b

Page 35: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

35

• |x|≤1• q = nº of quantization

steps• 2/q , quantization

step• b = nº of quantization

bits• q = 2b

Quantization

D/2 3D/2 5D/2-D/2x(n)

xq(n)

D

2D

1

-D

1 - 001

2 - 010

3 - 011

-1 - 111

1

Page 36: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

36

Quantization Noise

)()()( nxnxne q

2

22/

2/

222

3

1

12

1)(

qdeeneq

D

D

D

D

D/2e

D/2

D

pE(e)

1/D

2)(

Dne

Page 37: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

37

Signal to Quantization Noise Ratio

xq

x SqS

N

S 22

3

dBbN

S

SN

Sx

b

68.4

23log10 210

•The signal to quantization noise ratio is a function of the number of bits.

•Each extra bit reduces the signal to noise ratio by 6dBs

•With 16 bits we get around 100dB of signal to noise ratio

Page 38: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

38

Scaling and Quantization Noise

1/A A1

D

A

1

D

1

DA

If in a 16 bit system the scaling factor is set to A=256, then the signal to noise ratio will be 52dB instead of 100dB

Note that if we have used a floating point arithmetic the scaling of the inner point was not necessery. The signal to noise ratio would be 100dB.

Page 39: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

39

Rounding Error on FIR Filters

Z-1

b0 b1

Z-1

bN

Q Q Q

16bits

16bits

32bits

16bits

16bits Accumulator

12)1(

22 D

Nq

Page 40: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

40

Rounding Error in FIR Filters

Z-1

b0 b1

Z-1

b2

16bits

16bits

32bits

16bits

Q

32bits32bits Accumulator

12

22 Dq

The quantization noise doesnot increase with thenumber of coeficients

Page 41: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

41

Rounding Error on IIR Filters

Z-1a1

16bits

16bits

32bits

16bits

Q

32bits

For the IIR filters, due to the feedback, an accumulator with extra bits does not solve the quantization error problem.

•Stability issues when the poles are near the unitary circle. Due to the quantization problems the poles could be moved to out of the unitary circle.

•Limit cycles, which are small output periodic signals when no input is applied.

Page 42: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

42

Effects of the Filter Coefficients Quantization

• FIR filters– The frequency response of the filter with the quantized

coefficients can be quite different of the designed one– This can be a difficult problem to solve for filters with a

large number of coefficients.• IIR filters

– Stability problems due to the placement of the poles near the unit circle

– The frequency response of the quantized version can be quite different due to the high precision needed for the pole-zero placement

Page 43: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Non-uniform Quantization

• If the Probability Density Function (pdf) of the input signal is known we can take advantage of this knowledge using non-uniform quantization.

• The uniform quantizer is optimal only for signals with a constant pdf.

• Example: The voice signal has a Laplacian pdf. The small amplitudes are more probable than the larger ones.

Page 44: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Signal with a Laplacian PDF

Page 45: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Dithering

• When the amplitude of the signal is too small when compared with the minimum quantization step, is possible to obtain a digital representation of this signal by using dithering

Dithering example with 5 levels of quantization {-1,0.5,0,0.5, 1} and thresholds on {-0.5,-0.25,0.25,0.5}

Page 46: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

Dithering

• A dithering signal with an uniform distribution with a maximum amplitude equal to half the quantization step has the effect of flatting the quantization noise spectrum.

Page 47: Software Defined Radio PhD Program on Electrical Engineering Sampling Theory and Quantization José Vieira

47

Bibliography

• John G. Proakis and Dimitris G. Manolakis, “Digital Signal Processing, Prentice Hall, 2007. (Chapter 9)

• Jeffrey H. Reed, “Software Radio”, Prentice Hall, 2002. (Chapter 5)