Scilab/C4/Simulating-a-PID-controller-using-XCOS/English

From Script | Spoken-Tutorial
Revision as of 12:49, 4 October 2017 by Rupakrokade (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of script: Simulating a PID controller using Xcos

Author: Rupak Rokade

Keywords: Xcos, PID, Simulation, Closed loop


Narration
Show Slide Welcome to the spoken tutorial on Simulating a PID controller using Xcos.
Show Slide In this tutorial we will learn how to implement a PID controller in Xcos.
Show Slide Ensure that Scilab is installed on your computer.


I am recording this tutorial on This is just a declaration. The tutorial output will not change.In the tutorial "Xcos introduction", these are not same.Ubuntu 16.04 64-bit Operating System and using Scilab 6.0.0

Show Slide As a pre-requisite, watch the tutorial Xcos Introduction.


This tutorial will make you comfortable with the Xcos environment.


Also, we will use the firstorder.xcos file created in that tutorial.


Hence, it is important that you practice the tutorial before continuing so that you have the file with you.


Some basic knowledge of PID controller is necessary.


Assuming that you have satisfied the pre-requisites, let us begin with the tutorial.
Launch Scilab First of all, we will launch Scilab.
Applications >> Xcos Then go to Applications and select Xcos.
Or in your Scilab console window, type Xcos and press Enter.
This is just a narrationPoint to #
Palette Browser and
  1. An Untitled-Xcos window


By doing this, two windows will open.


  1. Palette Browser and
  2. An Untitled-Xcos window


Untitled-Xcos window>> click on File >> Open On the Untitled-Xcos window, click on File and then click on Open.
Go to the saved folder>> click on the file >> OK Browse to the directory where the file firstorder.xcos is saved. Choose that file and click on Ok.
Double-click transfer function block. Double-click on the transfer function block.
Highlight the transfer function parameters Check that you are using the same transfer function as I am using.
For me, the numerator is 1 and denominator is 2 asteric s plus 1

Which is 2 multiplied by s plus one

Highlight the step input parameters Double-click on the Step block.

Check that you are using the same step input parameters as I am using.

For me the Step time is 1, Initial value is 0 and Final value is 2.

Click on OK

Simulation tab >> choose Start Click on Simulation tab and choose Start to simulate the file.
Expect a similar plot which ensures that the file has no mistakes.
Switch to the Palette Browser. Switch to the Palette Browser.
Click on Continuous time systems >> drag-drop PID block inside Xcos Click on Continuous time systems category.


Drag and drop the PID block, which is here, inside the Xcos window

Click on Signal Routing >> drag-drop Mux block inside Xcos Click on the Signal Routing category.


Drag and drop the Mux block, which is here, inside the Xcos window

Click on Mathematical Operations >> drag-drop Summation block inside Xcos Click on Mathematical Operations category.


Drag and drop the Summation block, which is here, inside the Xcos window.


Note that this block, by default, subtracts the second input from the first input.


We will use this default configuration of the summation block.

Click on the line joining the step input block + transfer function block >> press Delete Click on the line joining the step input block and transfer function block.


Then press the Delete button to delete it.

Drag away Drag the step input block away from the transfer function block
Click on the line joining the transfer function block and the cscope block >> press Delete Click on the line joining the transfer function block and the cscope block.


Then press the Delete button to delete it.

Drag away Drag the cscope and clock input block away from the transfer function block
Do as narrated Place the PID block before the transfer function block.
Do as narrated Place the summation block before the PID block.
Do as narrated Place the Mux block between the transfer function block and cscope block.
Do as narrated Adjust the blocks, if required, so that they all come in a line.
Do as narrated Connect the step input block to theAdded new statement for clarificationIt refers to '+' terminal of summation block. We might need to mention this. first input port of the summation block.

Note that this is the positive input port of the summation block

Do as narrated Connect the output port of summation block to the input port of PID block
Do as narrated Connect the output port of PID block to the input port of transfer function block
Do as narrated Connect the output port of transfer function block to the lower input port of Mux block
Do as narrated Connect the output port of Mux block to the input port of the cscope block
Do as narrated Locate the line connecting the step input block and the summation block


Connect the inputCorrectedIt should be input port of Mux. port of Mux to that line.

Use the left mouse click to create line bends while making the connection.
Do as narrated Locate the line joining the transfer function block and the Mux block.


Connect the second input port of summation block to that line.

Use line bends wherever necessary

Do as narrated Double-click on the PID block to open its parameter setting dialog box.
Point to the respective gains. Here you can set the Proportional, Integral and Derivative gains.


Please note that the Integral gain should be considered as 1 by tau I, where tau I is the integral time.


Click on Cancel

We will use the default settings.


Click on Cancel to use the default settings.

We are now ready to run the simulation.
Highlight step input block Notice that we are using the step input block as a setpoint variable.
Highlight PID controller The PID controller will generate an input to the Transfer Function block.


It will be such that the output of the transfer function block matches the setpoint.

Click on Start simulation button Click on the Start simulation button available on the menu bar.
Plot window



Highlight setpoint


Highlight transfer function

Expect a graphic window to open.
It will have two variables plotted in a single plot.


The step plot is the setpoint which has a final value of 2.


The curved plot which is green in color, is the output of the transfer function which tries to meet the setpoint value of 2.

You can now change the PID settings and learn how they affect the output.

Pause the video here and solve the given exercises.

Exercise slide Implement a Proportional Controller only

That is, only P and not PID

Change the proportional gain such that the setpoint matches the output but without overshoots.

Exercise slide


Include the output of the summation block in the plot.

You may use CMSCOPE to keep it separate.

Compare it visually with the output of the PID block

This brings us to the end of this tutorial.

Let us summarize.

Summary slide In this tutorial we learnt-#
To modify the firstorder.xcos file to implement a PID controller
  1. Configure each block as per the simulation requirements
  2. Setup the simulation parameters


Show Slide


(About Spoken Tutorial Project)

The video at the following link, summarizes the Spoken Tutorial project.
Please download and watch it.
Show Slide


(About Spoken Tutorial Forum)

The Spoken Tutorial Project Team conducts workshops and gives certificates.
For more details, please write to us.
Show Slide 1

FORUMS

*
Do you have questions in THIS Spoken Tutorial?
  • Choose the minute and second where you have the question
  • Explain your question briefly
  • Someone from our team will answer them


Show Slide 2

FORUMS

*
The Spoken Tutorial forum is for specific questions on this tutorial
  • Please do not post unrelated and general questions on them
  • This will help reduce the clutter
  • With less clutter, we can use these discussions as instructional material


Show slide Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.. More information on this mission is available at the link shown.
This is Rupak Rokade signing off.
Thanks for joining.

Contributors and Content Editors

Nancyvarkey, Rupakrokade