PLL Implementation with Simlink and Matlab - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

PLL Implementation with Simlink and Matlab

Description:

sizes.NumSampleTimes = ; % at least one sample time is needed. sys = simsizes(sizes); x0 ... (continuous and discrete-time) Number of inputs. Number of outputs ... – PowerPoint PPT presentation

Number of Views:327
Avg rating:3.0/5.0
Slides: 19
Provided by: daei
Category:

less

Transcript and Presenter's Notes

Title: PLL Implementation with Simlink and Matlab


1
PLL Implementation with Simlink and Matlab
  • Project 2
  • ECE283
  • Fall 2004

2
Simulink in MATLAB
  • Graphic user interface
  • Continuous, discrete, and mixed mode
  • Integration with MATLAB
  • Fast prototyping
  • User-defined functions
  • How to run it
  • gtgtsimulink
  • Or click simulink icon

Simulink main screen
3
Graphic User Interface
  • Make a new model window
  • Expand library
  • Drag and drop
  • Connect blocks
  • Simulate
  • Visualize
  • Tuning

Simulink built-in library
4
Make a model
  • New model
  • Open library
  • Drag blocks
  • Connect
  • Source and sink
  • ExampleAmModEx.mdl

Amplitude modulation
5
Simulation
  • Tune
  • Simulation time
  • Relative tolerance
  • Refine factor
  • Etc
  • Simulate
  • ExampleAmModEx.mdl

Simulation parameters
6
Visualization
  • Double click scope
  • Options on signal source and sink
  • External files
  • Workspace variables
  • ExampleAmModEx.mdl

Simulation output scope
7
Subsystem
  • Subsystem for modular programming
  • How to make it
  • Subsystem library
  • Subsystem conversion
  • ExampleAmModEx.mdl

Ports and subsystem library
Triggered subsystem
8
Getting Help
  • Need help?
  • MATLAB and Simulink help
  • Mathworks user community
  • Mathwork technical support

Simulink help screen
9
PLL Implementation
  • Sampler
  • Voltage controlled clock
  • Voltage controlled oscillator
  • Feedback loop

Decision-directed phase-locked loop
10
Sampler
  • Options
  • Triggered subsystem
  • User-defined function
  • Others
  • Latched and unlatched
  • Matters with discrete-time signals
  • Almost same with continuous-time signals except
    for feedback
  • ExampleTriggerEx1.mdl
  • Subsystem examples

Latched and unlatched trigger example
11
Integration
  • Initiailization
  • Matched filter
  • Correlator
  • External triggering
  • ExampleIntegratorEx.mdl

Integration block parameters
12
S-function
  • User-defined function written in MATLAB, etc.
  • One input and one output
  • scalar, vector, matrix, etc.
  • Static parameters
  • R14 provides more options for user-defined
    function

User-defined functions library
13
S-function Operation
  • Initialization
  • Calculate outputs
  • Update discrete states
  • Calculate derivatives
  • Integration
  • Calculate outputs
  • Calculate derivatives
  • MATLAB example code sfuntmpl.m is in
    matlabroot/toolbox/simulink/blocks

S-function operation diagram
14
Example Code
  • function sys,x0,str,ts VCO(t,x,u,flag,FreqCntr
    )
  • VCO
  • switch flag,
  • case 0, Initialization
  • sys,x0,str,tsVCOInit
  • case 1, Derivatives
  • sysVCODeriv(t,x,u)
  • case 2, Update
  • sysVCOUpdate(t,x,u)
  • case 3, Outputs
  • sysVCOOutput(t,x,u,FreqCntr)
  • case 4, GetTimeOfNextVarHit
  • sysVCPNextHit(t,x,u)
  • case 9, Terminate
  • sysVCOExit(t,x,u)
  • otherwise Unexpected flags
  • End
  • Flag 0 Initialization
  • Flag 1 Calculation of derivatives
  • Flag 2 Update of discrete states
  • Flag 3 Calculation of output
  • Flag 4 Calculation of next sample hit
  • Flag 9 End of simulation tasks

15
S-function Initialization
  • function sys,x0,str,tsVCOInit
  • sizes simsizes
  • sizes.NumContStates
  • sizes.NumDiscStates
  • sizes.NumOutputs
  • sizes.NumInputs
  • sizes.DirFeedthrough
  • sizes.NumSampleTimes
  • at least one sample time is needed
  • sys simsizes(sizes)
  • x0
  • initialize the initial conditions
  • str
  • str is always an empty matrix
  • ts 0 0
  • initialize the array of sample times
  • Define necessary
  • Internal states (continuous and discrete-time)
  • Number of inputs
  • Number of outputs
  • Initial conditions

16
S-function Output
  • function sys,x0,str,ts VCO(t,x,u,flag,FreqCntr
    ,Phase,Gain)
  • switch flag,
  • case 3, Outputs
  • sysVCOOutput(t,x,u,FreqCntr,Phase,Gain)
  • End
  • function sysVCOOutput(t,x,u,FreqCntr,Phase,Gain)
  • sys Gaincos(2pi(FreqCntru)tPhase)
  • T time
  • X state
  • U input
  • Flag computation mode
  • Static parameters

17
S-function Instantiation
  • Drag and drop S-function system block to a model
  • Double click the block to specify the script name
    and static parameters
  • Example VCOSfuncEx.mdl

S-function instance
S-function block parameters
18
Discussions on PLL
  • Modulation frequency
  • Number of waves per symbol
  • Low-pass filter
  • Simulation length
  • Symbol feedback delay
  • Evaluation
  • Timing error
  • Capture range
  • Loop lock range
  • Effect of symbol error
  • Effect of signal noise

Decision-directed PLL diagram
Write a Comment
User Comments (0)
About PowerShow.com