Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
68
Добавлен:
06.06.2017
Размер:
3.31 Mб
Скачать

Chapter 24 Fourier Analysis and Digital Signal Processing

What's in this chapter

This chapter describes how to use the Digital Signal Processing operators to do Fourier analysis on circuit waveforms. It includes these topics:

How digital signal processing functions work

Digital Signal Processing functions

A DSP example

The DSP dialog box

597

How digital signal processing functions work

The Digital Signal Processing (DSP) functions are a group of math functions for extracting frequency and time information from transient analysis waveforms and AC analysis curves. All of the functions employ the same internal Fast Fourier Transform (FFT) routine. That routine requires two basic parameters to do its work; N, the number of data points, and DF, the sampling frequency.

N: Number of data points

N is determined in one of two ways:

N = The Number of Points field in the DSP dialog box if its Status is On.

N = The binary number nearest the actual number of data points computed during the analysis run if Status is Off.

N must always be a power of two and is also constrained to the following range:

Minimum = 64 or 26

Maximum = 262144 or 218

DF: Sampling frequency

The sampling frequency, DF, is calculated as follows:

Transient analysis:

If the DSP dialog box Status flag is Off:

DF = sampling frequency = 1'st harmonic = 1 / <tmax> <tmax> is from the Time Range field of the analysis dialog box.

If the DSP dialog box Status flag is On:

DF = 1'st harmonic = 1 / (<Upper Time Limit> - <Lower Time Limit>) where <Upper Time Limit> and <Lower Time Limit> are from the DSP dialog box.

AC analysis:

If the DSP dialog box Status flag is Off:

1'st harmonic = DF = sampling frequency = <fmax> / N

598 Chapter 24: Fourier Analysis and Digital Signal Processing

<fmax> is from the Frequency Range field of the analysis dialog box.

If the DSP dialog box Status flag is On:

DT = Time Step = 1 / DF = N / <Upper Freq Limit> where <Upper Freq Limit> is from the DSP dialog box.

DF is the interval between sample points in the output FFT and is also referred to as the first harmonic. The frequency range sampled is:

Data Point

Contents

1

0 Hz or DC value

2

H1 = 1'st harmonic at F = DF

3

H2 = 2'nd harmonic at F = 2*DF

...

...

N

HN = N-1'th harmonic at F = (N-1)*DF

The DSP functions can be used in both AC and transient analysis.

In transient analysis, time domain waveforms (curves of real voltage vs. time) are sampled and fed to the FFT routines which employ N samples of DF frequency steps to calculate, typically, an FFT or a HARM function.

In AC analysis, frequency spectra (curves of complex voltage vs. frequency) are sampled and fed to the FFT routines which employ N samples of the time step, DT, to calculate, typically, an IFT function.

Resolution, range, and accuracy are controlled by the FFT parameters N and DF.

In transient analysis:

If the DSP dialog box Status flag is Off, increasing <tmax> in transient analysis decreases DF, resulting in finer frequency resolution and a lower maximum frequency, since fmax = (N-1)*DF.

Increasing N increases the upper frequency range.

In AC analysis:

If the DSP dialog box Status flag is Off, increasing <fmax> in AC analysis decreases the time step, DT, resulting in a finer time step resolution and a lower tmax, since tmax = (N-1)*DT. Increasing N increases the maximum time range.

599

Digital Signal Processing functions

The Digital Signal Processing (DSP) functions include the following:

HARM(u)

This function returns the amplitude of the harmonics of waveform u. Amplitude means the multiplier of the sine or cosine function. For example, for this function,

V(T) = 3.0*SIN(2*PI*1E6*T)

HARM would return 3.0 for the harmonic associated with 1E6.

HARM is the closest thing to the original SPICE .FOUR command. It returns the following values:

Data Point

Contents

1

H0 = DC value

2

H1 = Amplitude of 1'st harmonic

3

H2 = Amplitude of 2'nd harmonic

...

...

N

HN = Amplitude of N-1'th harmonic

Examples:

 

HARM(V(OUT))

Harmonic amplitude of the voltage waveform V(OUT).

HARM(IC(Q1))

Harmonic amplitude of the current waveform IC(Q1).

Note that, in transient analysis, the first harmonic occurs at DF = 1 / <tmax>.

THD(S[,FR])

This function returns a running sum of the total harmonic distortion of the spectrum S as a percent of the harmonic magnitude at the reference frequency FR. It returns the following values:

Data Point

Contents

1

0

2

0

3

Distortion of 2'nd harmonic as % of first harmonic

4

Distortion of 2'nd and 3'rd harmonic as % of first

...

...

N

Distortion of all harmonics as % of first harmonic

600 Chapter 24: Fourier Analysis and Digital Signal Processing

In general, the m'th value of the THD is given by:

THD

m

= 100*( (H 2

+ H 2 + H 2

+... H

2 ) / H 2

) 0.5

 

 

 

2

3

4

m

1

 

where H

m

= (REAL(H

)2 + IMAG(H )2)0.5

 

 

 

 

 

m

 

m

 

 

If FR is unspecified, or if the FR value specified does not match one of the harmonic frequencies, n*DF, to within 1%, FR is set to the first harmonic.

Examples:

 

THD(HARM(V(1)))

THD of the harmonics of the waveform V(1).

THD(HARM(I(D1)))

THD of the harmonics of the waveform I(D1).

IHD(S[,FR])

This function behaves the same as the THD function but returns individual harmonic distortion as a percent of the harmonic magnitude at the reference frequency FR. It returns the following values:

Data Point

Contents

1

0

2

0

3

Distortion of 2'nd harmonic as % of first harmonic

4

Individual distortion through 3'nd harmonic

...

...

N

Individual distortion through N-1'th harmonic

In general, the m'th value of the IHD is given by:

IHDm = 100*( mag(Hm ) / mag(H1)

If FR is unspecified, or if the FR value specified does not match one of the harmonic frequencies, n*DF, to within 1%, FR is set to the first harmonic.

Examples:

 

IHD(HARM(V(A)))

IHD of the harmonics of the waveform V(A).

IHD(HARM(IB(Q1)))

IHD of the harmonics of the waveform IB(Q1).

FFT(u)

This function returns a classical Fourier transform of waveform u. It does not return the harmonics as HARM does. The FFT calculates a set of Fourier coefficients scaled by N/2 (DC scaled by N). Recall that the Fourier series approximates a waveform x(t) as follows:

601

x(t) = a0/2 + (aNcos(2π Nf1t) + bNsin(2π Nf1t))

where f1 is the fundamental frequency.

The FFT function returns a complex quantity whose real part contains the scaled Fourier series aN coefficients and the imaginary part contains the scaled Fourier series bN coefficients:

Data Point

REAL(FFT())

IMAG(FFT())

1

a0N

0

2

a1N/2

b1N/2

3

a2N/2

b2N/2

...

...

...

N

aN-1N/2

bN-1N/2

The FFT and its inverse are defined such that IFT(FFT(x(t))) = x(t). That is, the inverse of the transform of a waveform is equal to the original waveform.

Examples:

 

FFT(V(A))

FFT of the voltage waveform V(A).

FFT(IB(Q1))

FFT of the collector current waveform IB(Q1).

The HARM, THD, and FFT functions transform a time-domain waveform into a frequency-domain spectrum, so when you use one of these in a Y expression, the X expression should be F for frequency. The X range should be initially set to between 5*DF and 10*DF.

IFT(S)

This function returns a classical inverse Fourier transform of a spectrum S. A spectrum is a list of the value of some complex expression vs. frequency. In AC analysis all expressions are of this type, so IFT(V(1)) would produce meaningful results. In transient analysis, IFT(V(1)) would make no sense, since V(1) would be a time domain waveform. However, an expression like IFT(FFT(V(1))) would produce meaningful results in transient analysis.

Example:

 

IFT(V(5)*I(R10))

IFT of the spectrum V(5)*I(R10).

An IFT transforms a frequency-domain spectrum into a time-domain waveform, so when you use an IFT in a Y expression, the X expression should be T for time. The initial time range should be set to between 10*DT and 100*DT.

602 Chapter 24: Fourier Analysis and Digital Signal Processing

CONJ(S)

This function returns the conjugate of a spectrum S. The conjugate of the complex number a + b•j is a - b•j . This function simply negates the imaginary part of the spectrum.

Example:

CONJ(FFT(V(1))) Conjugate of the spectrum FFT(V(1)).

CS(u1,u2)

This function returns the cross spectrum of two waveforms, u1 and u2. The cross spectrum is defined as CONJ(FFT(u2))*FFT(u1)*DT*DT.

Example:

CS(V(1)),V(2)) Cross spectrum of V(1) and V(2)

AS(u)

This function returns the auto spectrum of a waveform u. The auto spectrum is defined as AS(u) = CONJ(FFT(u))*FFT(u)*DT*DT.

Example:

AS(I(RL)) Auto spectrum of waveform I(RL)

AC(u)

This is the auto correlation of waveform u. The definition is:

AC(u) = IFT(CONJ(FFT(u))*FFT(u))*DT

This function is useful for finding periodic signals buried in noisy waveforms.

Example:

 

RE(AC(V(10)))

Auto correlation of waveform V(10)

See the sample circuit FFT5.CIR for an example of this type of function.

CC(u,v)

This is the cross correlation of waveforms u and v. The definition is:

CC(u,v) = IFT(CONJ(FFT(v))*FFT(u))*DT

This function is useful for finding the time delay betwen two periodic signals.

603

Example:

 

CC(V(1),V(2))

Cross correlation of waveform V(1) with V(2).

See the sample circuit FFT3.CIR for an example of this type of function.

COH(u,v)

This is the coherence function of waveforms u and v. The definition is:

COH(u,v) = CC(u,v)/sqr(AC(u(0))*AC(v(0)))

Example:

COH(V(1),V(2)) Coherence of waveform V(1) with V(2).

DSP operators

The math functions available to manipulate the output of DSP functions are:

Short form

Long form

Function

RE(S)

REAL(S)

Real part of spectrum S

IM(S)

IMAG(S)

Imaginary part of spectrum S

MAG(S)

MAG(S)

Magnitude of spectrum S

PH(S)

PHASE(S)

Phase of spectrum S

Either the long form or the short form may be used. Note that the MAG function is redundant. Plotting V(1) is the same as plotting MAG(V(1)), since the plotting routines always plot the magnitude of the final result.

DSP Accuracy

Accuracy of the lower harmonics is affected mainly by the size of the time or frequency step in the analysis run. If there are many high frequency components, then accuracy will be affected by N, since N determines fmax.

The table below summarizes how accuracy is affected by the time step in the circuit FFT1.CIR. This circuit contains a single source generating a pure mixture of DC, 1Mhz, 2Mhz, and 3Mhz sine waves. The result below is for the HARM function applied to the soure node, HARM(V(1)). Ideally, the HARM function should return 1.5, 1.0, 2.0, and 3.0 exactly. The extent to which the results differ from these exact values determines the accuracy.

604 Chapter 24: Fourier Analysis and Digital Signal Processing

The error in parts per billion (1E9) with N=1024 is as follows:

Max Time Step and %

1'st

2'nd

3'rd

of 1'st harmonic period

harmonic

harmonic

harmonic

1ns (.1%)

3300

13000

30000

.1ns (0.01%)

33

130

300

.01ns (0.001%)

0.3

1.3

3.0

The error in decibels DB(ERROR) with N=1024 is as follows:

Max Time Step and %

1'st

2'nd

3'rd

of 1'st harmonic period

harmonic

harmonic

harmonic

.001U (.1%)

-109

-97

-91

.0001U (0.01%)

-149

-137

-131

.00001U (0.001%)

-191

-177

-170

N has virtually no effect on the accuracy of the lower harmonics.

DSP Speed

The speed of the FFT routine is approximately a linear function of N. Always use a value of N that is as small as possible. A value of 1024 is nearly always a good choice. Remember, N affects only fmax, because fmax = N*DF. Sometimes you may want to increase the tmax to decrease DF to get finer frequency resolution. This has the side effect of lowering fmax, so you may need to increase N to maintain the desired fmax.

605

A DSP example

To illustrate how DSP functions are used load the file FFT1. It looks like this:

Figure 24-1 The FFT1 circuit

This circuit contains a node to which is attached a function source with an output expression of:

1.5+1.0*SIN(2*PI*T*1E6)+2.0*COS(2*PI*T*2E6)+3.0*SIN(2*PI*T*3E6)

This source generates a waveform that is a mix of the following pure sinusoids:

F

Amplitude

0

1.5

1E6

1.0

2E6

2.0

3E6

3.0

There are no capacitors or inductors in the circuit, so there is no initial transient to obscure the steady state output we're interested in.

Select Transient from the Analysis menu. This dialog box illustrates several important steps in getting good results with DSP functions.

606 Chapter 24: Fourier Analysis and Digital Signal Processing

Соседние файлы в папке Micro-Cap v7.1.6
  • #
    06.06.20171.32 Кб60model.CNT
  • #
    06.06.201776.72 Кб62MODEL.HLP
  • #
    06.06.20173.72 Кб60NETHASP.INI
  • #
    06.06.2017450 б59os.dat
  • #
    06.06.2017545 б63READ.ME
  • #
    06.06.20173.31 Mб68RM.PDF
  • #
    06.06.2017226.69 Кб61setup.bmp
  • #
    06.06.201795 б59SETUP.INI
  • #
  • #
    06.06.201749 б60setup.lid
  • #
    06.06.20172.04 Mб60Standard.cmp