discrete systems - telemark university...

33
Discrete Systems Hans-Petter Halvorsen Control Engineering

Upload: truongnhu

Post on 19-Aug-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscreteSystems

Hans-PetterHalvorsen

ControlEngineering

Page 2: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

Transfer-funksjoner

Differensial-likninger

1.orden

2.orden

Laplace

Blokk-diagrammer

Tilstandsrom-modeller

Stabilitets-analyse

MathScript

LabVIEW

Dataverktøy

1.Systemetspoler Bodediagram

Analyse/Design

Realisering/Implementering

2.Frekvensrespons

DiskretiseringReguleringssystem

Detkomplekseplan

Detkomplekseplan

AsymptotiskstabiltsystemMarginaltstabiltsystem

Ustabiltsystem

Asymptotiskstabiltsystem

Marginaltstabiltsystem

Ustabiltsystem

TidsplanetAirHeater

1.ordenmedtidsforsinkelse

Tidsplanet S-planet

Reguleringsteknikk

K=ForsterkningT=Tidskonstant

Sprang-respons

Serie,Parallel,Feedback

Diskretisering

Page 3: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

TableofContents1. WhatisDiscreteSignalsandDiscretization?2. WhyDiscretization?3. DiscretizationMethods

– Euler,Tustin,ZOH,etc.

4. DiscretizationExamples– DifferentialEquations->DifferenceEquations– Continous State-spacemodels->DiscreteState-spacemodels

5. DiscretizationinMathScript withExamples6. DiscretizationinLabVIEW withExamples7. DiscreteLowpass Filter

– DiscreteAlgorithm– LabVIEWImplementation(Example)

8. DiscretePI Controller– DiscreteAlgorith– LabVIEWImplementation(Example)

9. PC-basedControlSystem– LabVIEWExample

Page 4: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DigitalSignals&Values

1 0 1 00

E.g.8bit:00000000 ->0………11111111 ->255

Resolution:

E.g.8bitresolution

Resolution:5V/256=0.0195V

8bitshave256differentcombinationsorlevels

BinaryValues:“0”and“1”

Page 5: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

ADConverter

DAConverter

MeasurementSignal

ControlSignal

AD&DAConverters

AD – AnalogtoDigitalDA – DigitaltoAnalog

Page 6: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

ContinuousSignal

DiscretSignal Acomputercanonlydealwithdiscretesignals

Page 7: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DifferentDiscreteSymbolsandmeanings

Present Value:

Previous Value:

Next (Future)Value:

Note!DifferentNotationisusedindifferentlitterature!

Page 8: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

SamplingandAliasingOriginalSignal

Aliasing(“Nedfolding”)->TheSamplingRateistolow!

SamplingTimeSamplingFrequency

Page 9: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscreteApproximationofthetimederivativeEulerbackwardmethod:

Eulerforwardmethod:

Page 10: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscretizationMethods

Eulerforwardmethod:

Eulerbackwardmethod:

OthermethodsareZeroOrderHold(ZOH),Tustin’smethod,etc.

Simplertouse!

MoreAccurate!

Page 11: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscretizationExampleGiventhefollowingcontinuoussystem:

WewillusetheEulerforwardmethod:

Students:Penandpaper:Findthedifferenceequation(discretedifferenitialequation)forthissystem.

Page 12: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscretizationExample- SolutionsGiventhefollowingcontinuoussystem:

WewillusetheEulerforwardmethod:

Page 13: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscretizationinMathScript- Alt.1

% Simulation of discrete modelclear, clc

% Model Parametersa = 0.25;b = 2;

% Simulation ParametersTs = 0.1; %sTstop = 20; %suk = 1; % Step in ux(1) = 0; % Initial value

% Simulationfor k=1:(Tstop/Ts)

x(k+1) = (1-a*Ts).*x(k) + Ts*b*uk;end

% Plot the Simulation Resultsk=0:Ts:Tstop;plot (k, x)grid on

Students:ImplementandSimulatethissysteminMathScript

Page 14: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscretizationinMathScript- Alt.2

% Find Discrete modelclearclc

% Model Parametersa = 0.25;b = 2;Ts = 0.1; %s

% State-space modelA = [-a];B = [b];C = [1];D = [0];

model = ss(A,B,C,D)model_discrete = c2d(model, Ts, 'forward')step(model_discrete)

Students:ImplementandSimulatethissysteminMathScript

Wegetthesameanswerasinpreviousexample!

Page 15: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscretizationinLabVIEW usingtheFormulaNode

Example (bacteriapopulation):

ImplementingdicreteequationsinLabVIEWusingCsyntax

Students:ImplementandSimulatethissysteminLabVIEWusingaFormulaNodeandaForLoop.ASubVIcouldbeusedtoimplementthemodel.

Wewillsimulatethenumberofbacteriainthejarafter1hour(simulationperiod),assumingthatinitiallythereare100bacteriapresent(x(0)).Setb=1,p=0.5.SetTs=0.01s.

SubVI

Page 16: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscretizationinLabVIEWusingtheFormulaNode- Solutions

Note!ASubVIisusedtoimplementthemodel.Recommended!!

SimulationResults:SubVI:

Note!Right-ClickandselectProperties.SetMultiplier=0.01(=Ts)intheScalesTab.

Page 17: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscreteState-spaceModels

Orusinganothernotation:

Page 18: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscreteState-spaceModels- Example

Giventhefollowingcontinuoussystem:

WewillusetheEulerforwardmethod:

Students:Students:Findthediscretestate-spacemodel(usingpenandpaper)

Page 19: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscreteState-spaceModels- Example(Solutions)

Giventhefollowingcontinuoussystem:

WewillusetheEulerforwardmethod:

Page 20: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscreteState-spaceModelsExampleinMathScript

Giventhefollowingcontinuoussystem:

% PropertiesTs = 0.1;

% Continuous System:A = [0, -Ts; 0, 0];B = [2*Ts, 0]';C = [1 0];D = [0];ssmodel = ss(A, B, C, D);figure(1)step(ssmodel)

% Discrete System:ssmodel_discete = c2d(ssmodel, Ts, 'forward’)figure(2)step(ssmodel_discete)

MathScript

Students:ImplementthesystemaboveandfindthestepresponseusingMathScript.

TrywithdifferentvaluesforTs!

Page 21: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

ImplementingaControlSystemWhiletherealprocessiscontinuous,normallytheControllerandtheFilterisimplementedinacomputer.

WearegoingtofinddiscretealgorithmsfortheLowpassFilterandthePIControllerandimplementtheminLabVIEW

Page 22: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

PC-basedControlSystem–LabVIEWExample(HMI/GUI)

Page 23: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

LowpassFilterLowpassFilterTransferfunction:

Students:PenandPaper:Findthediscretealgorithmforthisfilter,whichcanbeimplmentedinaprogramminglanguagelikeCorLabVIEWFormulaNode

UsetheEulerBackwardmethod:

Page 24: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscreteLowpassFilter

WeusetheEulerBackwardmethod:

InverseLaplacegivesthedifferentialEquation:

Thisgives:

LowpassFilterTransferfunction:

Wedefine:

Thisgives:

ThisalgorithmcanbeeaslyimplementedinaProgramminglanguage

Filteroutput Noisyinputsignal

Page 25: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscreteLowpassFilter- LabVIEW

Students:ImplementaDiscreteLowpassFilterandmakesuretotestitproperly

ExampleofImplementation

Page 26: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

TestingtheDiscreteLowpassFilter

Page 27: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

PIControllerContinuousPIController:

Students:PenandPaper:FindthediscretealgorithmforthisPIcontroller,whichcanbeimplmentedinaprogramminglanguagelikeCorLabVIEWFormulaNode

UsetheEulerBackwardmethod:

Page 28: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscretePIControllerContinuousPIController:

WeusetheEulerBackwardmethod:

Wemayset:

ThisgivesthefollowingdiscretePIalgorithm:

ThisalgorithmcanbeeaslyimplementedinaProgramminglanguage

Page 29: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

DiscretePIController- LabVIEW

Students:ImplementaDiscretePIControllerandmakesuretotestitproperly

ExampleofImplementation

Page 30: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

MathematicalModeloftheProcess

FeedbackNode

TestofDiscretePIControllerinLabVIEWNote!MakesuretocompareyourPIControllerwiththebuilt-inPIDController!

Page 31: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

PC-basedControlSystem–LabVIEWExample(Realprocess)

SubVIthathandlestheI/ObetweenLabVIEWandtheRealProcess

SubVI:

Scaling:1-5V->20-50degreesCelsius

Ts

Tf

Page 32: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

PC-basedControlSystem–LabVIEWExample(HMI/GUI)

Page 33: Discrete Systems - Telemark University Collegehome.hit.no/~hansha/documents/control/lectures/Discrete Systems.pdf · Discrete Systems Hans-Petter ... What is Discrete Signals and

Hans-PetterHalvorsen,M.Sc.

UniversityCollegeofSoutheastNorwaywww.usn.no

E-mail:[email protected]:http://home.hit.no/~hansha/