Scilab/C4/Simulating-a-PID-controller-using-XCOS/English
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.
|
Show Slide | As a pre-requisite, watch the tutorial Xcos Introduction.
|
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. | |
Point to
|
By doing this, two windows will open.
|
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. Click on Ok. | |
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, the Initial value is 0 and the Final value is 2.
Click on OK | |
Simulation tab >> choose Start | Click on Simulation on the menu bar 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.
|
Click on Signal Routing >> drag-drop Mux block inside Xcos | Click on the Signal Routing category.
|
Click on Mathematical Operations >> drag-drop Summation block inside Xcos | Click on Mathematical Operations category.
|
Note that this block, by default, subtracts the second input from the first input.
| |
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.
|
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.
|
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 the 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.
|
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.
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.
|
Click on Cancel |
We will 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.
|
Click on Start simulation button | Click on the Start simulation button available on the menu bar. |
Plot window
|
Expect a graphic window to open.
It will have two variables plotted in a single plot.
|
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
|
Show Slide
|
The video at the following link, summarizes the Spoken Tutorial project.
Please download and watch it. |
Show Slide
|
The Spoken Tutorial Project Team conducts workshops and gives certificates.
For more details, please write to us. |
Show Slide 1
FORUMS |
|
Show Slide 2
FORUMS |
|
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. |