You are on page 1of 13
EECE 301 Signals & Systems Prof. Mark Fowler Note Set #9a • Example: Using D-T Convolution

EECE 301 Signals & Systems

Prof. Mark Fowler

Note Set #9a

• Example: Using D-T Convolution in an Application of Measuring the Speed of a Motor

Course Flow Diagram

The arrows here show conceptual flow between ideas. Note the parallel structure between the pink blocks (C-T Freq. Analysis) and the blue blocks (D-T Freq. Analysis).

Ch. 6 & 8: Laplace Models for CT

Signals & Systems

Transfer Function

New System Model
New System Model

Ch. 3: CT Fourier Signal Models

Fourier Series

Periodic Signals

Fourier Transform (CTFT)

Non-Periodic Signals

Ch. 5: CT Fourier System Models

Frequency Response

Based on Fourier Transform

Course Flow Diagram The arrows here show conceptual flow betwee n ideas. Note the parallel structure
New System Model
New System Model

Ch. 2 Convolution

C-T System Model

Convolution Integral

D-T System Model

Convolution Sum

Ch. 5: DT Fourier System Models

Freq. Response for DT

New Signal Models Ch. 1 Intro C-T Signal Model Functions on Real Line
New Signal
Models
Ch. 1 Intro
C-T Signal Model
Functions on Real Line
Course Flow Diagram The arrows here show conceptual flow betwee n ideas. Note the parallel structure
Course Flow Diagram The arrows here show conceptual flow betwee n ideas. Note the parallel structure

Ch. 2 Diff Eqs

C-T System Model

Differential Equations

D-T Signal Model

Difference Equations

Zero-State Response
Zero-State Response
Zero-Input Response Characteristic Eq.
Zero-Input Response
Characteristic Eq.
System Properties LTI Causal Etc
System Properties
LTI
Causal
Etc

New System Model

Course Flow Diagram The arrows here show conceptual flow betwee n ideas. Note the parallel structure
D-T Signal Model Functions on Integers New Signal Model
D-T Signal Model
Functions on Integers
New Signal
Model

Ch. 7: Z Trans. Models for DT Signals & Systems

Transfer Function

New System

Model

2/13

Ch. 4: DT Fourier Signal Models

DTFT

(for “Hand” Analysis)

DFT & FFT

(for Computer Analysis)

Course Flow Diagram The arrows here show conceptual flow betwee n ideas. Note the parallel structure
Course Flow Diagram The arrows here show conceptual flow betwee n ideas. Note the parallel structure
Powerful Analysis Tool
Powerful
Analysis Tool
Based on DTFT New System Model
Based on DTFT
New System Model

Example: D-T Processing for Motor Speed

The m-file motor_speed.m is available for download from the course website.

To run it all you need to do is:

1. Download it to a folder on your computer

a. Make sure Matlab’s current directory is the folder where you have put the m-file (change it if needed)

  • 2. At the Matlab command line type: motor_speed

  • 3. The m-file will run and create several figures

Physical Set-Up of Motor and Sensor

Suppose you have a motor whose shaft is connected to a sensor that can measure the angular position of the shaft… its values will range between -π and π.

Output of Sensor when Motor spins at constant angular rate of 5π rad/sec

Physical Set-Up of Motor and Sensor Suppose you have a motor whose shaft is connected to
Motor Assume that the sensor generates 1 volt/radian
Motor
Assume that the
sensor generates
1 volt/radian

Motor and D-T System for Processing

First we could sample the sensor’s signal at a fast enough rate to get a D-T signal that accurately conveys the C-T signal coming from the sensor:

θ m (t)

Motor

Motor and D-T System for Processing First we could sample the sensor’s sign al at a
C-T Signal Representing Angular Position
C-T Signal Representing
Angular Position

θ m [n]

Analog-to-Digital Converter (ADC)

Computer-Based D-T System

D-T Signal Representing Angular Position
D-T Signal Representing
Angular Position

The resulting samples could be put into a computer (as binary numbers) and processed using D-T convolution.

Now… the trick is to determine how to design the D-T system (i.e., choose the system’s impulse response h[n]) to get a measure of the angular rate r m [n] !!!

Computer
Computer
θ m [n] Some h 1 [n] h 2 [n] Tricks
θ m [n]
Some
h 1 [n]
h 2 [n]
Tricks

r m [n]

Simulate the Angular Position’s D-T Signal in Matlab

% Create time samples spaced 1 ms apart

del_t=0.001;

t=0:del_t:3;

theta=5*pi*t; %% simulates angular position of motor shaft spinning at a constant rate

%% use some matlab "tricks" to simulate the fact that measured angle lies in –pi to pi theta_m=angle(exp(j*theta));

θ m [n]
θ m [n]
Some h 1 [n] h 2 [n] Tricks
Some
h 1 [n]
h 2 [n]
Tricks
Motor
Motor
ADC
ADC

r m [n]

Simulate the Angular Positi on’s D-T Signal in Matlab % Create time samples spaced 1 ms
Simulate the Angular Positi on’s D-T Signal in Matlab % Create time samples spaced 1 ms
Note: Discontinuities
Note: Discontinuities

Figure 1 from motor_speed.m

6/13

1

st D-T Convolution Approximates Computing a Derivative

% specify impulse response of D-T system that computes %% the time derivative of the input h_1=[-3 16 -36 48 -25]/(12*del_t);

%%% Compute D-T system's output using convolution

x=theta_m;

% just rename position measurements to "typical" input symbol

y=conv(x, h_1); % Matlab has a command for convolving two signals

Comes from Branch of Math known as “Numerical Methods”
Comes from Branch of Math
known as “Numerical Methods”
1 D-T Convolution Approximates Computing a Derivative % specify impulse response of D-T system that computes
θ m [n] r m [n] Some Motor ADC h 1 [n] h 2 [n] Tricks
θ m [n]
r m [n]
Some
Motor
ADC
h 1 [n]
h 2 [n]
Tricks

Figure 2 from motor_speed.m

1 D-T Convolution Approximates Computing a Derivative % specify impulse response of D-T system that computes

Correct Values For Rate

Large Spurious Values due to Discontinuities

7/13

D-T Tricks to Fix the Effects of the Discontinuities

%% we can do some computer-based "exception processing" to get rid of those %% by throwing away output values whose absolute value is bigger than we would expect %% the rotational rate to be

I=find(abs(y)>500); % find the indices of such large values

y(I)=0;

% replace the values with zeros at those locations

D-T Tricks to Fix the Effects of the Discontinuities %% we can do some computer-based "exc
θ m [n] r m [n] Some Motor ADC h 1 [n] h 2 [n] Tricks
θ m [n]
r m [n]
Some
Motor
ADC
h 1 [n]
h 2 [n]
Tricks
≈ Correct Values
For Rate

Figure 3 from motor_speed.m

Zeros Inserted to

Replace Spurious

Values from

Discontinuities “Transient” values “Ramp-Up values due to convolution due to convolution
Discontinuities
“Transient” values
“Ramp-Up values
due to convolution
due to convolution

8/13

D-T Convolution to Further Fix the Discontinuities

In the previous stage we inserted zeros at the discontinuity points… so what we end up with (ignoring the transient) is many correct values with a few zero values included.

So… imagine taking a small block of N such data points and taking the data average (add them up and divide by N)… the small number of zero values will have a small effect and we should end up with the average being close to the true value.

If we imagine “sliding the block” used for averaging ahead by one sample each time… then we would get an average for each block that should be a good estimate of the angular rate

Figure 3 from motor_speed.m

These indicate the Etc. sliding blocks
These indicate the
Etc.
sliding blocks
D-T Convolution to Further Fix the Discontinuities In the previous stage we inserted zeros at the

9/13

With a little thought we can convince ourselves that this sliding average is nothing more that convolving the “zero-corrected” signal with a D-T signal that has N ones and zeros elsewhere and then dividing by N:

y2a=conv(y,ones(1,100)) /100;

% do sliding average of 100 pts to reduce effect of inserted zeros

y2b=conv(y,ones(1,1000))/1000;

% do sliding average of 1000 pts to explore effect of N value

θ m [n]
θ m [n]
Some h 1 [n] h 2 [n] Tricks
Some
h 1 [n]
h 2 [n]
Tricks
Motor
Motor
ADC
ADC

r m [n]

Blue: N = 100 Red: N = 1000 Figure 4 from motor_speed.m
Blue: N = 100
Red: N = 1000
Figure 4 from
motor_speed.m
This indicates the following trade-off for the size of the averaging block:
This indicates the following trade-off
for the size of the averaging block:
 

Small N

Large N

 

Pro

Rapid

Small

Response

Fluctuation in

Time

Values

Con

Large

Slow

Fluctuation

Response

in Values

Time

10/13

Admission: The way we did it (replace anomalies with zeros, smooth with convolution) is probably not the best way to do this:

A better “Trick” would be to replace each anomaly with the non-anomaly value that precedes it. This would reduce the jumps due to the inserted zeros and reduce the need for the second convolution.

Exploring Impact of Abrupt Rate Change

Motor

Exploring Impact of Abrupt Rate Change Motor θ m [n] r m [n] Some ADC h
θ m [n] r m [n] Some ADC h 1 [n] h 2 [n] Tricks
θ m [n]
r m [n]
Some
ADC
h 1 [n]
h 2 [n]
Tricks
Rate Change
Rate Change

Figures 5&6 from motor_speed.m

Blue: N = 100 Red: N = 1000

Bigger N gives: • More accurate measure… • But… slower response to changes
Bigger N gives:
• More accurate measure…
• But… slower response to changes

12/13

Things We’ve Seen Here

Using Matlab to simulate D-T signals that will be obtained from an ADC

Use D-T convolution to approximately compute the derivative of a signal

– The D-T signal represents samples of some “underlying” C-T signal

Use tricks to correct anomalies and spurious results

– In practice this kind of thing is pretty common

Use D-T convolution to “smooth out” jumps

– Here the jumps were due to physical characteristics of angle measurement

We have seen a fundamental trade-off that often arises in linear systems:

A system that provides more “smo othing” capability typically responds slowly to signal changes

– So… if we have a noisy signal, we can remove a lot of the noise but only at the expense of smoothing out some of the signal’s rapid changes

13/13