Scilab/C4/Interactive-Simulation-in-Xcos-using-slider/English

From Script | Spoken-Tutorial
Revision as of 17:53, 30 August 2021 by Iswariyas (Talk | contribs)

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

Title of script: Interactive Simulation in Xcos Using Slider

Author: Rupak Rokade and Iswariya Sasikumar

Visual Cue Narration

Show Slide:

Title Slide

Hello and welcome to the Spoken Tutorial on “Interactive Simulation in Xcos Using Slider”.

Show Slide:

Learning Objectives



In this tutorial, we will learn how to:

  • Use Slider in Xcos
  • Use TKSCALE block for simulation and
  • Run Xcos simulations in real-time

Show Slide:

System Requirements



To record this tutorial, I am using

  • Windows 10 OS
  • Scilab 6.1.0

The process demonstrated in this tutorial is identical in Linux OS also.

Show Slide:

Pre-requisites

https://www.spoken-tutorial.org

To follow this tutorial, you should have

  • Basic knowledge of Scilab and Xcos.
  • If not, for relevant tutorials please visit this website.

Show Slide:

Interactive Simulation

  • Interactive simulation gives a way to change the parameters during simulation.
  • The parameters can be changed by using the Slider.
  • In this tutorial we will see how to change values using the TKSCALE block as a slider .

On the Scilab console,

Applications>>Xcos.

Open the Scilab console.

In the menu bar click on Applications and select Xcos.

Cursor on the Palette browser window and Untitled-Xcos window.


Notice the Palette browser window is located on the left side.

The Untitled - Xcos window is on the right side.

Cursor on the Palette browser window,

Sources>>TKSCALE .

In the Palette browser-Xcos window, click on Sources palette.

In the right panel, scroll down and click on the TKSCALE block.

Cursor on TKSCALE and Untitled-Xcos window. Let us drag and drop this block in the Untitled-Xcos window.

On the Palette browser window,

Sinks>>CSCOPE.



Next, go to the Palette browser-Xcos window.

Click on the Sinks palette.

In the right panel, scroll down and select the CSCOPE block.

Now, drag and drop it after the TKSCALE block.

On Untitled-Xcos window,

Double-click on TKSCALE.

Next we will see the parameters for the TKSCALE block.

Double-click on the TKSCALE block.

On Scilab Multiple Values Request,


A window named Scilab Multiple Values Request appears.

It displays the TKSCALE block parameters.

Point to the Min value.

Here, “Min value” -10 represents the minimum value in the range of the slider scale.

Point to the Max value. “Max value” 10 represents the maximum value in the range of the slider scale.
Point to the Normalization.

Click on OK.

And “Normalization” 1 represents the interval value of the slider scale.

Click on OK.

Point to the black input of CSCOPE. The black input port in the CSCOPE carries the data values.
Point to the red input of CSCOPE.


The red input port in the CSCOPE represents the events.

The red input can connect only to a block that generates the events.

Cursor on the Palette browser window,

Sources>>CLOCK _c.

As per narration.


To generate the events, go to the Palette browser-Xcos window.

Click on the Sources palette.

Then click on the CLOCK underscore c block.

Drag and drop the CLOCK underscore c block above the CSCOPE block.

Hover cursor on Untitled-Xcos window.


We have collected all the required blocks in the Untitled-Xcos window to do the simulation.

Let us now connect the blocks together.

On Untitled-Xcos window,

Connect as per narration.

Select the black output port of the TKSCALE block.

Connect it to the black input port of the CSCOPE block.

On Untitled-Xcos window,

Connect as per narration.

Next select the red output port of the CLOCK underscore c block.

Connect it to the red input port of the CSCOPE block.

On Untitled-Xcos window,

Connect as per narration.

Next select the red input port of the TKSCALE block.

Connect it to the line connecting CLOCK underscore c and CSCOPE block.

On Untitled-Xcos window,

Connect as per narration.

Use the left mouse click to create line bends and then connect it to the line.

Now let us simulate this file with the default values.

On Untitled-Xcos window,

Click on start.

To start the simulation, go to the toolbar of the Untitled-Xcos window.

Then click on the Start button that is of the shape of the play button.

Cursor on the Slider and the Graphic window.



Two windows get opened.

The left window will display the slider.

The right Graphic window will display the output of the system.

Hover cursor over slider



Notice that the slider opens and closes quickly.

It doesn’t give a chance to make use of this slider.

This is happening because Xcos is trying to simulate this file at computer time.

Close Graphic window To handle this problem, first close the Graphic window.

On Untitled-Xcos window,

Simulation>>Setup

Then go to the menu bar of the Untitled-Xcos window and click on Simulation.

Then click on Setup.

On Set parameters window,

Cursor on Real time scaling

A pop up window named Set parameters appears.

We will change the default value of the real time scaling to 1.

Hover cursor over Set parameters window.

Click on OK.

Keep the other parameters unchanged.

Then click on OK.

On Untitled-Xcos window, click on Start.

To start the simulation, go to the toolbar of the Untitled-Xcos window.

Click on the Start button.

Cursor on Graphic window and slider A Graphic window and the slider will open.

Hover cursor over the slider.


Hover cursor over slider and Graphic window.


Now I’ll change the value of a parameter using the slider.

Notice that I am changing the value while the simulation is running.

Observe the changes on the Graphic window as I change the slider value.

So this is how we can make the Xcos simulation interactive using a slider.

This brings us to the end of this tutorial. Let us summarise.

Show Slide:

Summary


In this tutorial, we have learnt to:

  • Use Slider in Xcos
  • Use TKSCALE block for simulation and
  • Run Xcos simulations in real-time

Show Slide:

Assignment


As an assignment, please do the following.

  • Modify the Xcos diagram to have an autoscale feature (scale graph at runtime) in the graph.
  • Hint: Explore the use of SCALE underscore CSCOPE to have the autoscale feature.

Show Slide:

About Spoken Tutorial Project

The video at the following link summarises the Spoken Tutorial project.

Please download and watch it.

Show Slide:

Spoken Tutorial Workshops

The Spoken Tutorial Project Team conducts workshops and gives certificates.

For more details, please write to us.

Show Slide:

Answers for THIS Spoken Tutorial

Please post your timed queries in this forum.
Show Slide: FOSSEE Forum Please post your general and technical queries on Scilab in this forum.

Show Slide:

Textbook Companion project.


The FOSSEE team coordinates the Textbook Companion project.

We give Certificates and Honorarium to the contributors.

For more details, please visit this site.

Show Slide: Lab Migration

The FOSSEE team coordinates the Lab Migration project.

For more details, please visit this site.

Show Slide: Acknowledgements Spoken Tutorial and FOSSEE projects are funded by MoE, Government of India.

This is Iswariya Sasikumar, a FOSSEE intern 2021, IIT Bombay signing off.

Thanks for joining.

Contributors and Content Editors

Iswariyas, Nancyvarkey