signal processing master class...matlab streaming signal processing with matlab deployed signal...

31
1 Β© 2015 The MathWorks, Inc. Signal Processing Master Class Graham Reith

Upload: others

Post on 08-May-2020

131 views

Category:

Documents


17 download

TRANSCRIPT

Page 1: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

1Β© 2015 The MathWorks, Inc.

Signal Processing Master Class

Graham Reith

Page 2: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

2

Session Outline

Offline

signal

processing with

MATLAB

Streaming

signal

processing with

MATLAB

Deployed

signal

processing from

MATLAB

Functions,

Capabilities

Structure,

Performance

Prototyping,

Implementation

C

Page 3: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

3

Session Outline

Offline

signal

processing with

MATLAB

Streaming

signal

processing with

MATLAB

Deployed

signal

processing from

MATLAB

Functions,

Capabilities

Structure,

Performance

Prototyping,

Implementation

C

Page 4: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

4

Spectral Analysis

Determining the Frequency Content of a Signal

– Usually analysis based on the Fast Fourier Transform (FFT)

– Trade-offs to manage: frequency resolution vs sidelobe attenuation

Page 5: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

5

Introducing the Signal Analyzer App

Spectral analysis of signals

Time domain panning

Enhanced command line interface

allows specifying input signals and

sample rates

Analyze signals in time and

frequency and navigate through

the signals using a panner.

Page 6: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

6

Spectrum Controls

Control spectral leakage (Kaiser window shape factor)

Read resolution bandwidth values for the current

spectral estimates

Page 7: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

7

Spectrum Scope

dsp.SpectrumAnalyzer

Page 8: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

8

Scope Improvements

Spectral Mask in Spectrum Analyzer

– Compare a spectrum to a mask, e.g. to verify

compliance with communication standards

or design requirements

– Use in MATLAB or Simulink

Now supported by MATLAB Compiler: – dsp.TimeScope

– dsp.SpectrumAnalyzer

– dsp.ArrayPlot

Array Plot: Custom X-axis data

– Visualize arbitrarily-spaced data

Time Scope: Programmatic legend strings and autoscaling

Page 9: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

9

Channelizer and Filter-bank Spectral Analysis

Analyze and synthesize narrow subbands of a

broadband signal using a polyphase FFT filter bank

Analysis: dsp.Channelizer

Synthesis: dsp.ChannelSynthesizer

Efficient filter banks based on FFT

and a polyphase structure for filtering

Used for high-resolution spectral analysis:

– Achieve arbitrary inter-channel separation

Applications in 5G communications – beyond OFDM

Use as method of dsp.SpectrumEstimator

Page 10: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

10

Comparison: Channelizer for Spectral Analysis

Page 11: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

11

Analysing Vibration Data

Data from rotational machinery, captured using accelerometers

Typically fundamental frequencies and harmonics vary with RPM

Page 12: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

12

Order Spectrum and Order Tracking

Compute and display an order amplitude profile vs. RPM using ordertrack

Compute and display an average spectrum using orderspectrum

Analyze the amplitude and spectrum of vibration signal orders

>> ordertrack(x,Fs,rpm,orderlist)

>> ordertrack(map,order,rpm,…)

>> orderspectrum(x,Fs,rpm)

>> orderspectrum(map,order)

Page 13: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

13

Order Waveforms

Extract decoupled time-domain waveforms

for crossing (and non-crossing) orders

Vold-Kalman Filter

– Specify bandwidth and order

Compute waveforms by segments to

improve computation speed

Extract time-domain orders waveforms

>> orderlist=[0.052 0.066 0.264])

>> orderwaveform(x,fs,rpm,orderlist)

Page 14: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

14

Synchrosqueezing Transforms

>> sst = fsst(x,…)

Compute and display a compact time-frequency representation of modes using fsst

Extract time-frequency ridges (e.g. instantaneous frequency of each mode) using tfridge

Reconstruct the entire plane, a band of frequencies, or a time-frequency ridge using ifsst

High resolution time-frequency spectral analysis and waveform extraction

>> [f,idx] = tfridge(sst,…) >> y = ifsst(sst,[],idx)

Page 15: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

15

Finding a Signal via Similarity Search: findsignal

Compare real/complex vectors of arbitrary

dimensions

Popular distance metrics (Euclidean,

Squared Euclidean, Symmetric Kullback-

Liebler)

Convenient normalizations (Zero-mean, Unit

norm, average power) over an arbitrary

sample length for both data and signal

Time warping

Outlier robustness

Locate the best matching data to your signal

Β» data = exp(-((1:300)/100).^2).*cos(2*pi*(1:300)/100);

Β» signal = sin(2*pi*(1:100)/100);

Β» findsignal(data,signal)

Page 16: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

16

Session Outline

Offline

signal

processing with

MATLAB

Streaming

signal

processing with

MATLAB

Deployed

signal

processing from

MATLAB

Functions,

Capabilities

Structure,

Performance

Prototyping,

Implementation

C

Page 17: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

17

Offline Processing vs Streaming Processing

2 Entry Points for describing Signal Processing operations in MATLAB:

Data analysis

Algorithm exploration

System simulation

Efficient implementation

Function

Initialize

Process

Page 18: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

18

fs

fRF

fs Sampling frequency (up to ~2.8MHz)

fRF RF Centre Frequency (20MHz to ~1.8GHz)

+ Tuner gain parameters

Frequency correction parameters

Example: RTL-SDR USB RF Receiver

Page 19: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

19

ADS-B Receiver

Page 20: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

20

Execution Engine from R2015b

Efficient Coding Constructs

Parallel Computing– Desktop

– Computer Clusters

– GPU Acceleration

MATLAB to C– MATLAB Coder

Accelerating your Simulations

C

Page 21: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

21

Multithreaded Acceleration via Unfolding

Generate a multi-threaded MEX file from a MATLAB function that operates on streamed signals with dspunfold

Acceleration workflow based on code generation

– Requires MATLAB Coder

Application to DSP

– Distribute subsequent frames to different cores at the

expense of latency

Support for custom processing algorithms

Page 22: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

22

Creating Parallelism by Unfolding

CPU1

CPU2

CPU3

Alg Instance 1

Frame T-2

Alg Instance 2

Frame T-1

Alg Instance 3

Frame T-0

One long time series…

Normal: Execute one instance of one algorithm on the dataset

Unfolded: Replicate the algorithm to run multiple instances (copies)

Each instance operates on a different frame of the dataset

Each instance executes on a different thread (core)

Frame

T-2

Frame

T-1

Frame

T-0……

Page 23: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

23

Stateless Algorithms

F = 50, U=4

U1

U2

U3

U4

time

...

1 50

Frame1

51 100

Frame2

101 150

Frame3

151 200

Frame4

201 250

Frame5

251 300

Frame6

301 350

Frame7

351 400

Frame8

1 50

Frame1

51 100

Frame2

101 150

Frame3

151 200

Frame4

201 250

Frame5

251 300

Frame6

301 350

Frame7

351 400

Frame8

CPU1

CPU2

CPU3

CPU4

Speed improvement = π‘’π‘›π‘–π‘žπ‘’π‘’ π‘ π‘Žπ‘šπ‘π‘™π‘’π‘  π‘π‘Ÿπ‘œπ‘π‘’π‘ π‘ π‘’π‘‘

π‘ π‘Žπ‘šπ‘π‘™π‘’π‘  π‘π‘Ÿπ‘œπ‘π‘’π‘ π‘ π‘’π‘‘ π‘π‘’π‘Ÿ π‘‘β„Žπ‘Ÿπ‘’π‘Žπ‘‘=

400

100= 4π‘₯

Step 1 Step 2

F = Frame size – minimum number of samples given to algorithm at once

U = Threads – assume each thread maps to a core

Page 24: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

24

U1

U2

U3

U4

1 50

Frame1

51 100

Frame2

101 150

Frame3

151 200

Frame4

201 250

Frame5

251 300

Frame6

301 350

Frame7

351 400

Frame8

201 250

Frame5

200191

51 100

Frame2

5041

101 150

Frame3

10091

151 200

Frame4

150141

251 300

Frame6

250241

301 350

Frame7

300291

351 400

Frame8

350341

F=50, S=10, U=4

time

Step 2

Efficiency =π‘’π‘›π‘–π‘žπ‘’π‘’ π‘ π‘Žπ‘šπ‘π‘™π‘’π‘  π‘π‘Ÿπ‘œπ‘π‘’π‘ π‘ π‘’π‘‘

π‘‘π‘œπ‘‘π‘Žπ‘™ π‘ π‘Žπ‘šπ‘π‘™π‘’π‘  π‘π‘Ÿπ‘œπ‘π‘’π‘ π‘ π‘’π‘‘=

400

480= 83%

Speedup = π‘’π‘›π‘–π‘žπ‘’π‘’ π‘ π‘Žπ‘šπ‘π‘™π‘’π‘  π‘π‘Ÿπ‘œπ‘π‘’π‘ π‘ π‘’π‘‘

π‘ π‘Žπ‘šπ‘π‘™π‘’π‘  π‘π‘Ÿπ‘œπ‘π‘’π‘ π‘ π‘’π‘‘ π‘π‘’π‘Ÿ π‘‘β„Žπ‘Ÿπ‘’π‘Žπ‘‘=

400

120= 3.3π‘₯

501

Frame10CPU1

CPU2

CPU3

CPU4

Step 1

...

Algorithms with State

Page 25: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

25

Session Outline

Offline

signal

processing with

MATLAB

Streaming

signal

processing with

MATLAB

Deployed

signal

processing from

MATLAB

Functions,

Capabilities

Structure,

Performance

Prototyping,

Implementation

C

Page 26: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

26

From MATLAB algorithms to real-time code

Experiment with algorithm in MATLAB

Architect/review/optimize MATLAB code

Generate real-time source C/C++ code

Verify/validate generated code

Optimize generated code

C

Page 27: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

27

Raspberry Pi with RTL-SDR

From R2015b: Using the Raspberry Pi with the RTL-SDR receiver

Deploy signal processing algorithms directly to the ARM processor on the

Raspberry Pi, and stream in data from the RTL-SDR receiver

Output audio, or send data to ThingSpeak, etc

Page 28: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

28

Session Outline

Offline

signal

processing with

MATLAB

Streaming

signal

processing with

MATLAB

Deployed

signal

processing from

MATLAB

Functions,

Capabilities

Structure,

Performance

Prototyping,

Implementation

C

Page 29: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

29

Tools used in this Presentation

MATLAB

Signal Processing Toolbox

DSP System Toolbox

Communications System Toolbox

– Support Package for RTL-SDR

Simulink

– Support Package for Raspberry Pi

MATLAB Coder

Page 30: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

30

Other Sessions at MATLAB EXPO Today

Application Track 1:

15:45-16:15

16:15-17:00

Page 31: Signal Processing Master Class...MATLAB Streaming signal processing with MATLAB Deployed signal processing from MATLAB Functions, Capabilities Structure, Performance Prototyping, Implementation

31

Demo Stations at MATLAB EXPO Today

Real-Time Audio Processing with MATLAB:

Automatic VST Plugin Generation

Designing, Prototyping, and Testing

Video Algorithms for FPGA and SoC

Using MATLAB to Explore the

Internet of Things

Wireless Communication System Design

Using MATLAB and Simulink