Enhance Your Signal Processing Toolbox with Complex...

11

Click here to load reader

Transcript of Enhance Your Signal Processing Toolbox with Complex...

Page 1: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Enhance Your Signal Processing Toolbox with Complex Notation

At first glance this notation seems like an unnecessary complication rather than an aid, and has caused many a good engineer to walk away from valuable signal processing information.

Barry L. Dorr, P.E. Dorr Engineering, Inc. As the speed of DSP's and digital hardware keeps increasing, software and digital hardware are replacing traditional analog hardware, making today's gizmos and gadgets smarter, more reliable, less expensive, and more power efficient than ever before. As an embedded systems engineer, you may have found yourself doing more signal processing than you originally bargained for! This article about complex notation is a survival guide to some of the most important basics of signal processing. Begin reading nearly any article on signal processing and you will quickly encounter complex notation. Signals that could be easily represented as sine’s or cosines become Re(e⋅j(∆ωt-Φ)) and we’re often reminded that j is the square root of -1. It gets worse – a simple sinusoid actually contains both positive and negative frequencies, but frequently “only positive frequencies are used.” We also see modulated signals referred to as "complex envelopes." At first glance this notation seems like an unnecessary complication rather than an aid, and has caused many a good engineer to walk away from valuable signal processing information. Most signal processing textbooks provide an excellent review of complex notation, but these descriptions are sometimes more general and involved than the working engineer wants. This article presents the basics of complex numbers as used in signal processing, and will provide you with the tools for using them. Through the examples used in this article you will gain a clear understanding of AC circuit analysis using phasors, and also get introduced to some of the key components of a QPSK receiver. THE BASICS OF COMPLEX NUMBERS Figure 1 shows a complex number. The “real” part of the number, Re(C), is represented by the horizontal component and the “imaginary” part of the number, Im(C), is represented by the vertical component. The complex number appears immediately useful because, like a sine wave, it has both a magnitude and an angle. If we change the sign of the imaginary part we obtain the complex conjugate of the number, and we designate the complex conjugate with the overbar symbol.

Page 2: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 2 of 11 www.dorrengineering.com

re

im

b

a

C

|C|2 = a2 +b

2

Φ

Figure 1- Complex number

The complex number can be represented various ways:

bjaC ⋅+= Equation 1

[ ])sin()cos( φφ ⋅+⋅= jCC Equation 2

⎟⎠⎞

⎜⎝⎛=+= −

abbaC 122 tan and :where φ

The Euler identity shown below forms the basis of complex notation.

φjeCC ⋅= Equation 3

Note that the rectangular forms of equations 1 and 2 allow convenient addition and subtraction of complex numbers. The polar form of equation 3 allows convenient multiplication and division. If Φ is a phase angle which increases linearly with time then the complex number in Figure 1 rotates in a counter-clockwise circle. Letting the magnitude of the complex number be unity, equation 2 becomes

)sin()cos( tjtC ωω ⋅+= Equation 4

and it’s evident that the real part of this expression is a simple cosine wave. Furthermore, equations 1 through 4 can be easily manipulated to yield other useful forms

Page 3: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 3 of 11 www.dorrengineering.com

)sin()cos( tjte tj ωωω ⋅+= Equation 5

)sin()cos( tjte tj ωωω ⋅−=− Equation 6

2)cos(

tjtj eetωω

ω−+

= Equation 7

jeet

tjtj

2)sin(

ωω

ω−−

= Equation 8

Several things are readily apparent from equations 5 through 8. First they are related - equation 7 is the result of adding equations 5 and 6, and equation 8 is the result of subtracting equation 6 from equation 5. Equations 5 and 6 can also be viewed as two counter-rotating vectors in which the complex parts always cancel thereby accounting for the real result. Equation 6 can be viewed as two counter-rotating vectors where the real parts cancel. Equations 1 through 8 can also be used to derive useful identities such as:

2)Re( xxx += Equation 9

yxyx ⋅=⋅ Equation 10

But the most significant observation is that if we wish to take advantage of complex exponentials, we must either use the abstraction of complex numbers (equations 5 and 6) or the abstraction of negative frequencies (equations 7 and 8). LINEAR FILTERING AND PHASORS The problem of determining the steady state response of a linear network to a sinusoidal input is an excellent application of complex notation. However, working the problem once will show that steady-state analysis can be done virtually by inspection using the phasor technique. This section will reinforce what we’ve covered so far by showing why the phasor technique works. Digital and analog filters can be described by complex frequency domain transfer functions. For example the lowpass RC filter shown in Figure 2 has the transfer function:

( )( ) ( )RCjV

VH

in

Out

ωωω

ω+

==1

1)( Equation 11

This transfer function can be evaluated at different frequencies. At DC (ω=0) the result is 1 + j0. At ω=1/RC the result is 0.707 - j0.707, at ω=∞ the result is 0.

Page 4: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 4 of 11 www.dorrengineering.com

Figure 2 - RC filter

A property of this filter is that its transfer function has conjugate odd symmetry. This means that

( ) ( )H Hω ω− = Equations 7 and 8 show that the sinusoidal excitation also has odd symmetry. We will use the superposition property of linear networks to determine the output of the filter. Stated mathematically:

)()()( bfafbaf +=+ Equation 12 In other words, the output due to the sum of two input signals is equal to the sum of the outputs due to the individual inputs. A quick glance at equations 5 through 8 suggests that this property should come in handy. The input to the network is the cosine from equation 7. Using superposition, the output signal is simply the sum of the outputs due to the two components in equation 7.

)(2

)(2

),( ωωωωω

HeHetVtjtj

o ⋅+⋅=− Equation 13

Applying the identity in equation 10 yields:

)(2

)(2

),( ωωωωω

HeHetVtjtj

o ⋅+⋅= Equation 14

Then apply the identity from equation 9:

{ })(Re),( ωω ω HetV tjo ⋅= Equation 15

{ })()(Re),( ωφω ωω jtjo eHetV ⋅⋅= Equation 16

{ }))(()(Re),( ωφωωω +⋅⋅= tj

o eHtV Equation 17

))(cos()(),( ωφωωω +⋅= tHtVo

Equation 18

Page 5: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 5 of 11 www.dorrengineering.com

Because of the conjugate symmetry of both the input signal and the transfer function, the operations in equations 13 through 18 are identical for any network. As a result, to find the response of a network due to a sine wave, you simply need to know the magnitude and phase response of the network at the desired frequency. In circuit analysis complex numbers are represented using shorthand called phasor notation as shown below.

( ) φφω ∠=⋅= + CeCC tj Equation 19

Setting the angular frequency to 1/RC, the steady state problem above is solved quickly using phasors as follows:

°−∠=°−∠×°∠ 45707.045707.001 Equation 20

)45cos(707.0)( °−⋅= ttVo ω Equation 21

NARROWBAND SIGNALS AND COMPLEX NOTATION In signal processing we frequently work with narrowband signals as shown in Figure 3. A narrowband signal has its energy concentrated around a frequency usually near the center of the signal's bandwidth called the carrier. Channelized signals can usually be treated as narrowband signals. Complex notation allows us to focus only on the bandwidth containing the signal rather than the bandwidth containing both the signal and the carrier. It also suggests hardware and software structures that aid processing of lowpass signals.

Figure 3 - Narrowband signal

To illustrate, consider the signal processing used for QPSK data transmission shown in Figure 4.

Page 6: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 6 of 11 www.dorrengineering.com

X

X

+ Bandpass Filter

X

X

G=2

Lowpass Filter

G=2

X Complex Equalizer

Local Oscillator

(TX)

cos(ωct)

-sin(ωct)

sik

sqk

Local Oscillator

(RX)

cos(ωct)

-sin(ωct)

Lowpass Filter

e-j(ω

ctΦ

)

From carrier recovery

From adaptive equalizer

sik

sqk

m(t)

Figure 4 - QPSK transmission system

QPSK, or Quadrature Phase Shift Keying is a data transmission technique where groups of two bits of data are encoded into one of four phase shifts of a sinusoidal carrier. The phase shift is held for the symbol time, and then it is updated based on the next pair of bits in the input bit stream. Since the symbol rate is usually much lower than the carrier frequency, the result is a narrowband signal.

It is natural to use complex notation to represent the two bits comprising each symbol. The index k is used to indicate that the signal represents a pair of bits in a serial bit stream. Signals sik and sqk are the kth in phase and quadrature signal components that take values of ±1, and sk denotes the complex signal sik + j sqk. The complex baseband signal could also be represented as ej⋅φk where φk is 45, 135, 225, or 315 degrees. Mapping these signals on the complex plane results in the constellation shown in Figure 5.

i=1q=1

i=1q=-1

i=-1q=1

i=-1q=-1

i

q

Figure 5 - QPSK constellation

The two multipliers at the left of Figure 4 up-convert the complex baseband signal to the carrier frequency. This is shown graphically in Figure 6 where multiplication by ej⋅ω⋅t shifts the complex baseband spectrum to the right, and taking the real part adds the negative frequency component.

Page 7: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 7 of 11 www.dorrengineering.com

ωc-ωc DC

Step 1 - Multiplying the complex baseband signal by ejωct shifts the complex baseband spectrum to the carrier frequency ωc

Step 2 - Retaining only the real part adds the negative frequency component. The result is a real signal.

Figure 6 - Up-converter operations

Equations 22 to 25 describe the operation of the up-converter. The output is the real modulated signal m(t)1.

( ){ }tcjqkik esjstm ω⋅⋅+= Re)( Equation 22

( ) ( ){ })sin(cos(Re)( tjtsjstm ccqkik ωω ⋅+⋅⋅+= Equation 23

{ })sin()cos(())sin()cos(Re)( tstsjtststm cikcqkcqkcik ωωωω +⋅+−= Eq. 24

)sin()cos()( tststm cqkcik ωω −= Equation 25

At the receiver the signal encounters a bandpass filter used for rejecting out-of-band signals. The bandpass filter response is not symmetric about the carrier frequency and it distorts the signal slightly. The two multipliers and lowpass filters after the bandpass filter are used to down convert the signal to its lowpass representation. We'll elaborate on the down converter since it is a commonly encountered signal processing operation. One way to explain the operation of the down converter is to begin with the signal as described by equation 25, multiply the sines and cosines and note that the lowpass filter removes the double frequency terms resulting from the multiplications. But instead of using sines and cosines, we'll use our newfound skills with complex notation. For the top arm we have:

{ } ( )φωω +⋅⋅ tes ctcj

k)cosRe Equation 26

The identities in equations 9 and 10 and the Euler identities allow us to write this as:

1 This expression for m(t) is valid for the kth symbol only. Refer to the references for an accurate description of a modulated data signal.

Page 8: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 8 of 11 www.dorrengineering.com

⎟⎠⎞

⎜⎝⎛ +⋅⎟⎟⎠

⎞⎜⎜⎝

⎛ ⋅+⋅ +⋅−+⋅−

22

)()( φωφωωω tcjtcjtcjk

tcjk eeeses

)) Equation 28

( ) ( ) ( ) ( )

⎟⎟⎠

⎞⎜⎜⎝

⎛ ⋅+⋅+⎟⎟

⎞⎜⎜⎝

⎛ ⋅+⋅ ++∆−++−∆−−∆

221

221 φωωφωωφωφω tctj

ktctcj

ktj

ktj

k eseseses)) Equation 29

Where:

cc ωωω )−=∆

( ){ } ( )( ){ }φωωφω ++−∆ ⋅+⋅ tccj

ktj

k eses)

Re21Re

21 Equation 30

The lowpass filter removes the double frequency term on the right. Multiplying by 2 yields the final result:

( ){ }φω −∆⋅⋅ tjk esRe Equation 31

Similarly the result for the bottom arm is:

( ){ }φω −∆⋅⋅ tjk esIm Equation 32

The I and Q branches at the output of the down-converter are lowpass signals and can be sampled at a much lower rate than the modulated signal, which reduces both power consumption and hardware cost. Figure 4 shows the I and Q branches combined into a single heavy line indicating that the signal is complex. A clear advantage of complex notation is that the frequency and phase differences between the transmit and receive oscillators are maintained by equations 31 and 32. The next step for the QPSK receiver to recover the transmitted data bits si and sq is to correct for the frequency offset (∆ω) and phase offset (∆φ) between transmitter and receiver. The process of removing these offsets is called carrier recovery, and the receiver has the means to detect them and internally generate the signal e⋅j(∆ωt-Φ) The process of applying the correction is often referred to as de-rotation because the frequency offset causes the baseband phasor to rotate at the difference frequency. However this is simply complex multiplication as shown by equation 33 and implemented in Figure 7. Though the structure appears formidable, it can be done in just a few lines of DSP code. ( ) ( ) ( )reimimreimimrereimreimre yxyxjyxyxyyxx ++−=+⋅+ Equation 33

Page 9: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 9 of 11 www.dorrengineering.com

X

X

X

X

+

+

Xre

Xim

yre

yim

-

xyre

xyim

Figure 7 - Complex multiplier

The final step for recovering the transmitted data bits is to remove the distorting effects of the bandpass filter at the receiver input. The modem has the means for identifying the distortion based on statistical characteristics of the distorted input or corrected output. This process is called adaptive equalization,2 and the result of the equalization process is the complex filter shown in Figure 4 at the right of the de-rotator. Before describing the complex filter, observe the signal spectrum shown in Figure 8. The operation of the down converter can be viewed as shifting the positive portion of the spectrum left by ω̂ and discarding the negative frequency term. The de-rotator further shifts the signal so that the overall shift precisely matches the frequency (and phase) of the up-converter. However the shifted signal is not symmetrical about DC. The i and q signals from the de-rotator are real signals. But when viewed as i + j*q, the result is complex and the asymmetrical spectrum is perfectly acceptable.

ωc-ωc DC

The positive frequency component is shifted left by ωc

The negative frequency component is discarded.

Figure 8 - Bandpass and lowpass spectrums

2 The oversimplification is for the sake of clarity. In this example, the output from the carrier recovery would have a slight phase error because its input has been distorted by the bandpass filter. Modern demodulators frequently perform carrier recovery and equalization jointly.

Page 10: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 10 of 11 www.dorrengineering.com

Equalization of the asymmetrical signal spectrum requires an asymmetrical filter for the equalizer. To see how this works note that when a signal is passed through a linear filter, the resulting signal spectrum is equal to the spectrum of the input signal multiplied by the frequency response of the filter. If both the spectrum and the filter are complex we have:

( ) ( ))()()()()()( fHjfHfSjfSfHfS imreimre ⋅+⋅⋅+=⋅ Equation 34

[ ])()()()()()()()( fHfSfHfSjfHfSfHfS imrereimimimrere ⋅+⋅+⋅−⋅= Equation 35

Figure 9 shows an implementation of the complex equalizer. The i and q signals from the equalizer precisely match those at the transmitter.

Figure 9 - Complex filter

ANOTHER TOOL IN THE TOOLBOX! As engineers, we strive to avoid unnecessary complexity, and abstractions such as imaginary numbers and negative frequencies sometimes fall into this category and end up on the chopping block. In reality, complex notation is a valuable tool for any engineer working with signal processing because:

• Working with exponentials is much less tedious than working with sines and cosines.

• Signal processing articles and technical papers use complex notation extensively.

• Complex notation suggests hardware and software structures for implementing signal processing functions.

The intent of this article has been to provide a set of tools for understanding and working with complex notation. Most signal processing textbooks (see references below) include a chapter or section dedicated to narrowband signals. These are excellent references, and most include much of the mathematical rigor not included here. The information in this article should allow you to breeze through the basics and get the most out of that next signal processing article.

Page 11: Enhance Your Signal Processing Toolbox with Complex …embedded-computing.com/articles/white_papers/dorr/Complex Number...Setting the angular frequency to 1/RC, the steady state problem

Page 11 of 11 www.dorrengineering.com

REFERENCES [1] J. Proakis, Digital Communications, McGraw Hill, 1983, Chapter 3 [2] H. Meyr, M. Moeneclaey, A. Fechtel, Digital Communication Receivers, Wiley Interscience, 1998. Chapter 1. [3] M. Schwartz, W. Bennett, S. Stein, Communication Systems and Techniques, McGraw Hill, 1966, Chapter 1. About the author: Barry Dorr is the owner/president of Dorr Engineering Services, Inc., a consulting firm located in San Marcos, CA. DESI specializes in signal processing, modem development, and embedded servos. He holds a BSEE from California Polytechnic State University and an MSEE degree from San Diego State University, and is a registered Professional Engineer in the state of California. Outside of work he enjoys his children and playing the trombone. Mr. Dorr has also teaches a course in Embedded Servo Systems: http://www.dorrengineering.com/downloads.htm. He can be reached at [email protected].