# Scilab/C4/Discrete-systems/English

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Title of script: Discrete Time System

Keywords: State space, Discrete time

Visual Cue
Narration
Slide 1 Dear Friends,

Welcome to the Spoken Tutorial on “Discrete Time System

Slide 2-Learning Objectives At the end of this tutorial, we will learn how to:
• Convert between state space and transfer function descriptions
• Define a discrete time system and plot its step response
• Discretize a continuous time system

Slide 3- System Requirement slide * I am using Ubuntu 12.04 operating system with Scilab 5.3.3 for demonstation

Slide 4- Prerequisite slide * To practise this tutorial, you should have basic knowledge of Scilab.
• If not, please refer to the Scilab tutorials available on the Spoken Tutorial website.

Slide 5- State Space Model

* The state space model
• x dot is equal to A x plus B u
• y is equal to c x plus D u
• is specified by sys three is equal to syslin into bracket into quotes c comma A comma B comma C comma D close bracket
• for prespecified matrices A, B, C and D of suitable sizes.

Switch to Scilab and type this on your Scilab Console

sys3=syslin(’c’,4,3,6,9) Press Enter

Press Enter again

clc

* Start Scilab on your computer
• Type
• sys three is equal to syslin into bracket into quotes c comma four comma three comma six comma nine close bracket and press Enter. Press enter to continue the display.
• This is an example for single state, Single Input Single Output
• The output will have matrices A, B, C and D and initial state x zero
• Type clc to clear the console

Slide 6- State Space Model

* Define for example matrices A, B, C, D on Scilab console as you see

Switch to Scilab and type this on your Scilab Console

A = [2 3;4 5]

Press enter

B = [1;2]

Press enter

C = [-3 -6]

Press enter

D = 2

Press Enter

sys4=syslin('c',A,B,C,D)

Press enter

Press enter again

* Type this on your Scilab Console
• A is equal to open square bracket two space three semicolon four space five close square bracket
• Press enter
• B is equal to open square bracket one semicolon two close square bracket
• Press enter
• C is equal to open square bracket minus three space minus six close square bracket
• Press enter
• D is equal to two
• Press enter
• Let us substitute these matrices in the previous command
• sys four is equal to sys lin into brackets into quotes c comma A comma B comma C comma D close the bracket and press enter
• You will get the following output.
• Press enter to continue display.
• The output will have matrices A B C D and initial state x zero

Slide 7- State Space Model * Check whether poles of sys4 are same as eigenvalues of A .
• For this you can use the function p l z r function and the spec function

Slide 8- State Space Model

* The s s two t f command can be used to obtain a transfer function of a state-space system sys S S.

Switch to Scilab and type on your Scilab Console

clc

sysTF = ss2tf(sys4)

Press Enter

* Type on your Scilab Console
• clc to clear it
• Type sys capital T capital F is equal to s s two t f open bracket sys four close bracket
• Press enter
• You see this output

Slide 8- State Space Model * It is in the form sys TF equal to ss two tf into bracket sys of SS

Slide 9- State Space Model * Use ss two tf function for sys three defined earlier
• sys T F is a new variable for which 'denom' command is applicable and not applicable to sys four as it is in state space form

Slide 10, 11, 12- Exercise * Solve the following exercise
• Find a state space realization of the second order transfer function defined below
• Use t f two s s command
• For the new system in state space form, say sys S S, check if the eigenvalues of the matrix A and the poles of the transfer function G of s are the same.
• Use the A, B, C, D matrices of the system sys S S to obtain the transfer function and check if the answer is the original one.

Slide 13, 14- Discrete Time System

* We now define a discrete time system.
• It is customary to use ’z’ for the variable in the numerator and denominator polynomials.
• Recall that the variable ’z’ has a shortcut
• Instead of z is equal to poly into bracket zero comma inside quotes z : use z is equal to percentage z

clc

z=%z

Press Enter

* Go to Scilab console.
• Type clc to clear
• Type z is equal to percentage z.
• Press enter

Slide 15- Discrete Time System * We now define a first order discrete time system

DTSystem = syslin(’d’, z/(z – 0.5))

Press Enter

* Type on your Scilab Console
• D T System is equal to syslin into bracket into quotes small d comma z divided by inside bracket z minus zero point five close the bracket close outer bracket .
• Press enter

Slide 15- Discrete Time System * We use the same ’syslin’ function as before.
• This time, we specify the domain to be discrete time, instead of continuous time.

Slide 16- Discrete Time System

* For checking the step response, we have to define the input explicitly as ones, for example, for 50 points.

Type this on your Scilab Console

u = ones(1, 50);

Press Enter

* Type on your Scilab Console
• u is equal to ones open bracket one comma fifty close bracket semicolon
• Press enter

Slide 16- Discrete Time System

* Instead of csim, the function we have to use the ’flts’ function to simulate this system.

Type this on your Scilab Console

clc

y = flts(u, DTSystem);

Press Enter

* Type this on your Scilab Console
• clc to clear console
• y is equal to f l t s open bracket u comma D T System close bracket semi colon
• Press enter

plot(y)

Press Enter

* Type on your Scilab Console
• plot of y and then press Enter

Display output * The output will be plotted.
• Close the graphic window

Slide 17- Discrete Time System

* It is helpful to discretize a given continuous time system.
• This is done using the dscr function.

Type on Scilab Console

s=%s

sysG=syslin('c', 2/(s^2+2*s+9))

Press enter

* Let us define a continuous system s is equal to percent s
• sys G is equal to syslin into bracket into quotes c comma two divided by into bracket s square plus two multiplied by s plus nine close bracket close outer bracket and press enter

Slide 18- Discrete Time System * Let us discretize the system sys G with a sampling period of zero point one.

clc

sys5=dscr(sysG, 0.1)

Press Enter

* Type on your Scilab Console
• clc to clear
• sys five is equal to d s c r into bracket capital sys G comma zero point one close bracket and then press Enter
• Press enter to continue display
• As you see system is discretized as A B C D matrices and inital state x zero

Slide 19- Discrete Time System

* Notice that we obtain the discretized system in state space representation.
• We can convert this to a transfer function representation in discrete time using the s s to t f function

clc

sys6 = ss2tf(sys5, 0.1)

Press Enter

* Type on your Scilab Console
• clc and clear it
• sys six is equal to s s two t f into bracket sys five comma zero point one close the brackets and press enter

Display output * The output gives the transfer function.

Slide 20- Summary In this tutorial we have learnt to:
• Convert between state space and transfer function descriptions
• Define a discrete time system and plot its step response
• Discretize a continuous time system.

Show Slide 21

Title: About the Spoken Tutorial Project

• It summarises the Spoken Tutorial project
• If you do not have good bandwidth, you can download and watch it

* Watch the video available at the following link
• It summarises the Spoken Tutorial project
• If you do not have good bandwidth, you can download and watch it

Show Slide 22

Title: Spoken Tutorial Workshops

The Spoken Tutorial Project Team

• Conducts workshops using spoken tutorials
• Gives certificates for those who pass an online test
• For more details, please write to contact@spoken-tutorial.org

The Spoken Tutorial Project Team
• Conducts workshops using spoken tutorials
• Gives certificates for those who pass an online test
• For more details, please write to contact at spoken hyphen tutorial dot org

Show Slide 23

Title: Acknowledgement

• Spoken Tutorial Project is a part of the Talk to a Teacher project
• It is supported by the National Mission on Education through ICT, MHRD, Government of India