ee 1130 freshman eng. design for electrical and computer eng. · matlab and simulink. ee 1130...

25
10/3/2013 EE 1130 1 Class 4 Signal Processing Module (DSP). Matlab and Simulink. 1 EE 1130 Freshman Eng. Design for Electrical and Computer Eng.

Upload: others

Post on 12-Mar-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 1

Class 4

Signal Processing Module (DSP).

Matlab and Simulink.

1

EE 1130 Freshman Eng. Design for Electrical and Computer Eng.

Page 2: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 2

Simulink: Signal Processing.

2

Last lecture we ended up with a noisy signal as next figure

shows:

)602sin(2.0)12sin()( tttx

Page 3: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 3

Simulink: Signal Processing.

3

We will insert a system that will filter out the ripple.

First option is to insert from the continuous library group a

Transfer Function block.

We also add a Mux from Signal Routing library group.

Page 4: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 4

Simulink: Signal Processing.

4

We insert the Transfer Function after the summator and before

the Mux.

The Mux will allow the Scope to show two traces:

Now, hit play and see:

Page 5: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 5

Simulink: Signal Processing.

5

Now, hit play and see:

Somehow we cleaned the signal, but we need to amplify its

gain by a factor of 4. We open the transfer function and set 4

the numerator to do this.

Page 6: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 6

Simulink: Signal Processing.

6

Somehow we cleaned the signal, but we need to amplify its

gain by a factor of 4. We open the transfer function and set 4

the numerator to do this.

Page 7: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 7

Simulink: Signal Processing.

7

We have cleaned the signal, but introduced a time delay (time

shift). This is common in any kind of filters.

Page 8: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 8

Simulink: Signal Processing.

8

Now, lets design a filter that particularly eliminates the signal

of 60Hz. We do that using the Zero-Pole Transfer function

Page 9: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 9

Simulink: Signal Processing.

9

When studying Filter Theory you will learn that the roots of the

numerator (called zeros) must be s=260j where 60 is the

frequency to eliminate at the output.

Page 10: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 10

Simulink: Signal Processing.

10

But the coefficients of the numerator are some of the values of

the Electrical Components.

Remember, for the RC circuit we had:

/1

1)(

ssH

)(/1

1)( sX

ssY

)()(1

)( sXsYRC

ssY

)()(1

txtyRCdt

dy

Page 11: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 11

Simulink: Signal Processing.

11

But the coefficients of the numerator are some of the values of

the Electrical Components or amplifier gains.

Therefore we can not have imaginary coefficients, that in fact

are component values or amplifier gains.

We need to do a mathematical trick to convert imaginary

numbers into real numbers!!

COMPLEX CONJUGATE

(a +jb) (a -jb)=a2+b2 eso es debido a que -j2=1

Page 12: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 12

Simulink: Signal Processing.

12

When studying Filter Theory you will learn that the roots of the

numerator must be (s-260j) and (s+260j). The use of

complex conjugated roots is to have real coefficients because:

At the denominator we just set roots to.

If you set smaller roots, the output becomes too large. Please

try other values to check out by yourself

604)602)(602( 22 sjsjs

)360)(340( ss

Page 13: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 13

Simulink: Signal Processing.

13

The final Transfer Function that solve our problem is:

Now, we simulate this in Simulink

360)340(

604)(

22

ss

ssH

(s+2*pi*60*j)(s-2*pi*60*j)

(s+340)(s+360)

Zero-Pole

Spectrum

Analyzer

Sine Wave1

Sine Wave

Scope

Add1

Page 14: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 14

Simulink: Signal Processing.

14

Now we hit play and compare input and output in the Scope

Page 15: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 15

Simulink: Signal Processing.

15

The simulation shows we did the job

Spectrum before the filter

0 1 2 3 4 5 6 7 8 9 10

-1

0

1

Time in seconds

Am

plit

ude

Signal

0 10 20 30 40 50 60 700

100

200

300

400

Frequency in Hertz

Spectr

al D

ensity

Spectral Density Plot

Page 16: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 16

Simulink: Signal Processing.

16

The simulation shows we did the job:

Spectrum after the filter

0 1 2 3 4 5 6 7 8 9 10

-1

0

1

Time in seconds

Am

plit

ude

Signal

0 10 20 30 40 50 60 700

200

400

600

Frequency in Hertz

Spectr

al D

ensity

Spectral Density Plot

Page 17: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 17

Simulink: Signal Processing.

17

We notice the dark trace is completely clean of noise. We could

add another trace to the scope and see both signals separated:

Page 18: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 18

Simulink: Signal Processing.

18

Once the simulation shows we solved the problem, we need to

implement the Electrical Circuit.

In order to do that, we need to modify the Transfer Function in

a sum of simpler Transfer Functions of the type:

This is done with Partial Fraction Expansion:

Matlab calculate the residues very fast:

360340)360)(340(

604)( 21

22

s

R

s

R

ss

ssH

)1()(

s

GsH simple

Page 19: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 19

Simulink: Signal Processing.

19

Matlab calculate the residues very fast:

340

10*1.2886

360

10*1 1.3586-

)360)(340(

604)(

4422

ssss

ssH

Page 20: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 20

Simulink: Signal Processing.

20

One more modification yields:

Each term correspond to a RC circuit:

)1()1(

)(22

2

11

1

sCR

G

sCR

GsH simple

1340

1

37.9

1360

1

37.7-)(

ss

sH

Page 21: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 21

Simulink: Signal Processing.

21

Implementation:

1

340

1

37.9

1360

1

37.7-)(

ss

sH

Page 22: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 22

Simulink: Signal Processing.

22

From the Electrical Schematics we build the

physical layout:

We obtain something like:

Page 23: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 23

Simulink: Signal Processing.

23

From the physical layout:

we build the

PCB (Printed Circuit Board)

We solder the components.

Solder the cables.

Then we test!!!

Page 24: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 24

Simulink: Signal Processing.

24

We generate the final report with our findings, to assess that the

circuit does what we intended it to do.

Page 25: EE 1130 Freshman Eng. Design for Electrical and Computer Eng. · Matlab and Simulink. EE 1130 Freshman Eng. Design for Electrical and Computer Eng. ... Sine Wave1 Sine Wave Scope

10/3/2013 EE 1130 25 25

End of Class