Single-Board-Heater-System/C2/Implementing-Proportional-Controller-on-SBHS-remotely/English

From Script | Spoken-Tutorial
Revision as of 16:57, 30 January 2015 by Rupakrokade (Talk | contribs)

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

Title of script: Implementing proportional controller on SBHS Remotely

Author: Rupak Rokade

Keywords: SBHS, Virtual labs, tutorial


Narration
Show Slide Welcome to the spoken tutorial on Implementing proportional controller on SBHS remotely.
Show Slide In this tutorial we will learn to:


  1. Use Ziegler-Nichols tuning method to calculate proportional controller gain
  1. Modify step test code to design a proportional controller
  1. Implement this proportional controller on SBHS


Ensure that Scilab is installed on your computer.


Also, ensure that you have internet connectivity before you begin with this tutorial.


I am recording this tutorial on a Windows 7 32-bit OS

As a pre-requisite, watch the tutorial on <!--StartFragment-->Using SBHS Virtual labs on Windows OS


This tutorial is available on the spoken tutorial website.


It will teach you how to do a basic step test experiment on SBHS, remotely


You also need to have basic knowledge of PID tuning

Show Slide You should have the step test experiment code folder available with you.


You should also have the step test experiment data file with you.


If not, then it is recommended that you re-do the step test experiment and generate a new data file.

In my machine, the data file is within Scilab codes windows folder >> step test folder >> logs folder.


Here is a folder with my username and here is my data file.

Open web browser and browse to sbhs.os-hardware.in Let us now download the Analysis code from the website.


Open a web browser and go to the web site sbhs.os-hardware.in

Click on Downloads On the left hand side, click on Downloads
Click on SBHS Analysis Code link Download the file SBHS Analysis Code and save it on the Desktop.


Here it is.


The file downloaded will be in zip format.

Right click on the zip file and choose extract here Right-click and extract the contents of the zip file.


A folder named Scilab codes analysis will be created.

Paste the data file inside Kp tau order1 folder Open this folder.


Locate and open the folder Step Analysis.


The Step Analysis folder will have few more folders

Copy-paste the data file generated earlier inside Kp tau order1 folder.
Double click on the file firstorder.sce Double click on the Scilab file firstorder


This will launch Scilab automatically and will also open the file in Scilab editor.

If it doesn't open the file, click on File menu then on Open a file.


Choose the file firstorder and click on Open.

Change the filename argument with data file name Locate the variable filename and change its value to the filename of your data file.


I will copy paste the file name to avoid spelling mistakes


Keep the .txt extension.

Click on exeute button Save and execute this Scilab code.


If the data file is not corrupted and there are no errors, a plot window will open.

Point at respective information available on the plot This plot window will show two graphs,
  • the SBHS temperature plot which has noise
  • output of SBHS first order model which is a smooth curve

This code basically does the job of fitting a first order transfer function using the data file.


The value of time constant tau and gain Kp will be displayed on the top.


In this tutorial we will not use the first order transfer function.


We will only use the plot of the SBHS output.

Switch to editor and comment the line plot2d(t,prediction) Switch to the Scilab editor.


Locate the line plot2d of t comma y underscore prediction.


We don't want the prediction output to appear on the plot


Comment out this line by putting two forward slashes at the beginning of the line



Execute the code and show the plot Save and execute the Scilab code.


Switch to the plot window


Notice that the plot window now has only the SBHS temperature plot

Demo as per narration To save this image click on the File menu.


Then choose Export to option.


Give a name to the image file.


I will type sbhsplot.


Click on the drop down menu for Files of type and choose PNG.


Choose a directory where you want to save the file.


I will choose Desktop and click on Save.


Let us open and see if the image file is created on the Desktop


Here it is


Close the image window


Let me now switch to the slides


Let us calculate the value of proportional gain using Ziegler-Nichols tuning method.

Show slide There are two tuning rules given by Ziegler-Nichols to calculate the PID parameters. These are


  • Reaction curve method and
  • Instability method

We will see the Reaction curve method

Show slide In this method a step input is given to the system and its output is observed over a period of time.


Any practical system would respond exponentially to a step input.


A tangent is drawn at the point of inflection, that is when the curve changes from convex to concave.


The dead time and time constant is calculated from the time axis.

Show slide This is illustrated in this figure


This is the tangent line drawn at the inflection point


  • K is the gain of the system
  • L is the dead time
  • T is the time constant


Open image Replicate this on the SBHS output figure we just saved on the Desktop.


I have already done this.


Let me open this file


I have used paint brush which is a default image editing tool on Windows


I have got the values of

  • gain equal to 2.78
  • dead time equal to x seconds
  • and time constant equal to y seconds

Note that these are all approximate values.


The values depend on the accuracy with which you draw the tangent line at the inflection point.

Show slide After you get the required values, refer to the table given by Ziegler-Nichols to calculate the value of PID.


Let me switch to the slides


For a proportional controller, we need to calculate only the value of proportional gain


In my case the value of proportional gain comes out to be X


But a unity gain will have no noticeable effect.


Hence I approximate the value to 2


Now let us see how to implement the proportional controller on SBHS


We would modify the step test code for this

Demo as per narration Switch to the folder where you have the step test code.


Make a copy of this folder


Rename this folder as proportional and open it.


Rename the stepc.sce file to proportional


Rename the steptest.sci file to proportional


Rename the steptest.xcos file to proportional

Demo as per narration Close Scilab if already running


Double click on the proportional.sce file


This should launch Scilab automatically and also open the file in Scilab editor


If it doesn't open the file, click on File menu then on Open a file.


Choose the file proportional.sce and click on Open.



Demo as per narration Change the exec command to execute proportional.sci file instead of steptest.sci file


Change the xcos command to execute proportional.xcos file instead of steptest.xcos file


Save this file

Demo as per narration Click on File menu and choose Open.


Select the file proportional.sci file and click on Open


Change the function name from steptest to proportional


Delete the input variable heat from the proportional function input and type setpoint


In the next line type global, leave a space and then type temp and press Enter


In the next line type err equal to setpoint minus temp


Add semicolon at the end and press Enter


In the next line type heat equal to 2 multiplied by err


Add semicolon at the end


Here 2 is the value of the proportional gain for my SBHS.


You may change it according to what you would have calculated for your SBHS


Add setpoint in the input variable of the plotting function inside its function call.


To do so, add a space after temp and type setpoint.


Then save this file

Demo as per narration Switch to the Scilab console, type xcos and press Enter


xcos window will open


Close the palette window


On the xcos untitled window, click on File menu and choose Open


Browse to the proportional directory


Select proportional.xcos and click on open


Xcos file will open


Double click on the label Heat input in percentage

Delete it and type setpoint


Click once anywhere on the xcos window to save the label

Demo as per narration Double click on the step input block to open its property window


Change the initial value to 30 and final value to 40


Keep step time as 300


click on Ok

Demo as per narration Double click on the function block


A window will appear. click on OK


Another window will appear.


Here there is an option to enter the function name to be called by this xcos block


Change the function name step test to proportional


Click on ok


Another window will open. Keep clicking on ok three times to finish configuring the function block


Save the xcos diagram and close it.


Close the xcos untitled window as well



Demo as per narration Switch to the web browser


On the left hand side, click on Virtual labs


Login with your registered username and password


Book a slot


I have already booked the slot. Here it is.

Demo as per narration Switch to the proportional folder


Double click on the file run


This will open the SBHS client application


Login with your username and password


Make sure you are logging in at the booked slot time


Expect the message Ready to execute Scilab code

Demo as per narration Switch to the Scilab console


Type getd space dot dot slash common underscore files


Press enter


Switch to the Scilab editor


execute the file proportional.sce


If the network is fine then it will automatically open the xcos window with

proportional controller xcos diagram


Execute the xcos diagram and expect a plot window

Point on various plots on graph The plot window will have three plots heat fan temperature


Setpoint will also be plotted in the temperature graph


Observe that the proportional controller computes the value of heat in order to achieve the setpoint value of temperature


Run this experiment long enough to observe what happens after a step change in setpoint occurs.


I will now pause this recording until the experiment is executed for sufficient time

You can see that the proportional controller has responded to the change in setpoint


You can observe that the proportional controller inherently has the property of offset


A proportional controller will always have an offset between the setpoint value and the actual value

Now let us summarize, In this tutorial we learnt to
  1. Use Ziegler-Nichols tuning method to calculate proportional controller gain for SBHS
  2. Modify step test code to design a proportional controller
  3. Implement the designed proportional controller on SBHS


Show slide 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 The Spoken Tutorial Project Team


Conducts workshops using spoken tutorials.


Gives certificates to those who pass an online test


For more details, please write to contact at spoken-tutorial.org

Show slide 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

More information on this Mission is available at: http://spoken-tutorial.org/NMEICT-Intro

Thanks for joining, This is Rupak Rokade from IIT Bombay signing off.

Thank You

Contributors and Content Editors

Nancyvarkey, Rupakrokade