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

From Script | Spoken-Tutorial
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
  2. Modify step test code to design a proportional controller
  3. Implement this proportional controller on SBHS
Show Slide

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

Show Slide As a pre-requisite, watch the tutorial on 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.

Browse to the folder, as per narration

Point to the file.

In my machine, the data file is within the 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 LHS. On the left hand side, click on Downloads.
Click on SBHS Analysis Code link >> save on Desktop. 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 >> 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 fileinside Kp tau order1 folder. 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.

Click on File >> Open a file>> click on firstorder >> Open. 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 filename 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
  • and 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 is 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.

click on the File>>choose Export to>> type sbhsplot>>click on Files of type and choose PNG>> choose Desktop>> click on Save. 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.

Go to 'Desktop >> point to file. Let us open and see if the image file is created on the Desktop


Here it is.

Close window Close the image window.
Switch to the slides 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 with figure. This is illustrated in this figure.


This is the tangent line drawn at the point of inflection .


  • K is the gain of the system
  • L is the dead time
  • T is the time constant
Replicate this on the SBHS output figure we just saved on the Desktop.
Open image I have already done this.


Let me open this file.

I have used paint brush which is a default image editing tool on Windows.
Point to relevant info on the figure. I have got the values of
  • gain equal to 2.78
  • dead time equal to 1 second
  • and time constant equal to 50 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 proportional gain.
Switch to the slides 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 18.

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


We would modify the step test code for this.

Switch to step test code folder>> make a copy >> rename as proportional and open it Switch to the folder where you have the step test code.


Here it is. Make a copy of this folder.


Rename this folder as proportional and open it.


Rename stepc as proportional >> steptest.sci as proportional >> steptest.xcos as proportional Rename the stepc file to proportional.


Rename the steptest dot sci file to proportional.


Rename the steptest dot xcos file to proportional.

Demo as per narration >> Double-click on proportional.sce Close Scilab if already running.


Double-click on the proportional dot sce file.


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

Click on File >> Open a file

>> Choose proportional.sce >> Open

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


Choose the file proportional dot sce and click on Open.

Change exec command>> steptest.sci as proportional.sci Change the exec command to execute proportional.sci file instead of steptest.sci file.
Change xcos command>> steptest.xcos as proportional.sci >> Save file. Change the xcos command to execute proportional.xcos file instead of steptest.xcos file.


Save this file.

Click on File >> Open

>> Choose proportional.sci >> Open>> Change steptest to proportional.

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.

Change heat as setpoint'>>type global space temp>> press Enter 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.

Demo as per narration In the next line type err equal to setpoint minus temp.


Add semicolon at the end and press Enter.

Demo as per narration In the next line type heat equal to 18 multiplied by err


Add semicolon at the end.


Here 18 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 a space after temp and type setpoint 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.

Save this file. Save this file.
Switch to Scilab console>> Type xcos> press Enter>> Close palette. Switch to the Scilab console.


Type xcos and press Enter.


xcos window will open.


Close the palette window.

click on File>> Open>> proportional directory >>Select proportional.xcos >> click on Open. 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.

Demo as per narration 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 Properties 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.

Demo as per narration 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 from step test to proportional.


Click on Ok.

Demo as per narration 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.

Click on Virtual labs>> Login >> Book a slot. Switch to the web browser.


On the left hand side, click on Virtual labs.


Login with your registered username and password.


Book a slot.

Switch to proportional folder >> run Switch to the proportional folder.


Double click on the file run.

Login >> Point to message 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.

On Scilab console >> type as per narration Switch to the Scilab console.


Type get d space dot dot slash common files


Press Enter

Execute proportional.sce on Scilab editor >> execute xcos diagram. 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.
Demo as per narration Run this experiment long enough to observe what happens after a step change in setpoint occurs.
Demo as per narration 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