Difference between revisions of "Scilab/C4/Interactive-Simulation-in-Xcos-using-slider/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 21: Line 21:
  
 
* Use '''Slider''' in '''Xcos'''
 
* Use '''Slider''' in '''Xcos'''
* Use '''TKSCALE''' block for simulation and
+
* Use '''TKSCALE block''' for '''simulation''' and
* Run '''Xcos''' simulations in real-time
+
* Run '''Xcos simulations''' in real-time
 
|-
 
|-
 
|
 
|
Line 45: Line 45:
 
To follow this tutorial, you should have
 
To follow this tutorial, you should have
  
* Basic knowledge of '''Scilab and Xcos.'''
+
* Basic knowledge of '''Scilab''' and '''Xcos.'''
 
* If not, for relevant tutorials please visit this website.
 
* If not, for relevant tutorials please visit this website.
 
|-
 
|-
Line 53: Line 53:
 
'''Interactive Simulation'''
 
'''Interactive Simulation'''
 
|
 
|
* Interactive simulation gives a way to change the parameters during simulation.
+
* '''Interactive simulation''' gives a way to change the '''parameters''' during '''simulation'''.
* The parameters can be changed by using the '''Slider.'''
+
* 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 .
+
* In this tutorial we will see how to change values using the '''TKSCALE block''' as a '''slider''' .
 
|-
 
|-
 
|
 
|
Line 64: Line 64:
 
Open the '''Scilab console'''.
 
Open the '''Scilab console'''.
  
In the menu bar click on '''Applications''' and select '''Xcos.'''
+
In the '''menu bar''' click on '''Applications''' and select '''Xcos.'''
 
|-
 
|-
 
| Cursor on the '''Palette browser window''' and '''Untitled-Xcos window'''.
 
| Cursor on the '''Palette browser window''' and '''Untitled-Xcos window'''.
Line 70: Line 70:
 
Notice the '''Palette browser window''' is located on the left side.
 
Notice the '''Palette browser window''' is located on the left side.
  
The '''Untitled''' - '''Xcos window''' is on the right side.
+
The '''Untitled - Xcos window''' is on the right side.
 
|-
 
|-
 
|
 
|
Line 77: Line 77:
 
'''Sources>>TKSCALE''' .
 
'''Sources>>TKSCALE''' .
 
|
 
|
In the '''Palette browser-Xcos''' window, Click on '''Sources''' '''palette.'''
+
In the '''Palette browser-Xcos''' window, click on '''Sources palette.'''
  
In the right panel, scroll down and click on the '''TKSCALE''' block'''.'''
+
In the right panel, scroll down and click on the '''TKSCALE block'''.
 
|-
 
|-
 
| Cursor on '''TKSCALE''' and '''Untitled-Xcos window'''.
 
| Cursor on '''TKSCALE''' and '''Untitled-Xcos window'''.
| Let us drag and drop this block in the '''Untitled-Xcos window'''.
+
| Let us drag and drop this '''block''' in the '''Untitled-Xcos window'''.
 
|-
 
|-
 
|
 
|
Line 91: Line 91:
 
Next, go to the '''Palette browser-Xcos window'''.
 
Next, go to the '''Palette browser-Xcos window'''.
  
Click on the '''sinks palette'''.
+
Click on the '''Sinks palette'''.
  
In the right panel, scroll down and select the '''CSCOPE''' block.
+
In the right panel, scroll down and select the '''CSCOPE block'''.
  
Now, drag and drop it after the '''TKSCALE''' block.
+
Now, drag and drop it after the '''TKSCALE block'''.
 
|-
 
|-
 
|
 
|
Line 102: Line 102:
 
Double-click on '''TKSCALE'''.
 
Double-click on '''TKSCALE'''.
 
|
 
|
Next we will see the parameters for the '''TKSCALE''' block.
+
Next we will see the '''parameters''' for the '''TKSCALE block'''.
  
Double click on the '''TKSCALE''' block.
+
Double-click on the '''TKSCALE block'''.
 
|-
 
|-
 
| On '''Scilab Multiple Values Request''',
 
| On '''Scilab Multiple Values Request''',
Line 110: Line 110:
 
A window named '''Scilab Multiple Values Request''' appears.
 
A window named '''Scilab Multiple Values Request''' appears.
  
It displays the '''TKSCALE''' block parameters.
+
It displays the '''TKSCALE block parameters'''.
 
|-
 
|-
 +
|Point to the '''Min value'''.
 +
 
|
 
|
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 '''Max value'''.
+
|-
 
+
|Point to the '''Normalization.'''
Point to the '''Normalization.'''
+
  
 
Click on '''OK.'''
 
Click on '''OK.'''
|
+
|And '''“Normalization” 1''' represents the '''interval''' value of the '''slider scale'''.
Here, '''“Min value” -10''' represents the minimum value in the range of the slider scale.
+
 
+
'''“Max value” 10''' represents the maximum value in the range of the slider scale.
+
 
+
And '''“Normalization” 1''' represents the interval value of the slider scale.
+
  
 
Click on '''OK'''.
 
Click on '''OK'''.
 
|-
 
|-
|
+
|Point to the '''black input''' of '''CSCOPE.'''
Point to the '''black input''' of '''CSCOPE.'''
+
  
Point to the '''red input''' of '''CSCOPE.'''
+
|The black '''input port''' in the '''CSCOPE''' carries the '''data''' values.
|
+
The black '''input port''' in the '''CSCOPE''' carries the data values.
+
  
The red '''input port''' in the '''CSCOPE''' represents the events.
+
|-
 +
|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.
+
The '''red input''' can connect only to a '''block''' that generates the '''events'''.
 
|-
 
|-
 
|
 
|
Line 147: Line 145:
 
As per narration.
 
As per narration.
 
|
 
|
To generate the events, go to the '''Palette browser-Xcos window'''.
+
To generate the '''events''', go to the '''Palette browser-Xcos window'''.
  
Click on the '''Sources''' Palette.
+
Click on the '''Sources palette'''.
  
Then click on the '''CLOCK underscore c''' block.
+
Then click on the '''CLOCK underscore c block'''.
  
Drag and drop the '''CLOCK underscore c''' block above the '''CSCOPE''' block.
+
Drag and drop the '''CLOCK underscore c block''' above the '''CSCOPE block'''.
 
|-
 
|-
 
| Hover cursor on '''Untitled-Xcos window'''.
 
| Hover cursor on '''Untitled-Xcos window'''.
 
|
 
|
We have collected all the required blocks in the '''Untitled-Xcos window''' to do the simulation.
+
We have collected all the required '''blocks''' in the '''Untitled-Xcos window''' to do the '''simulation'''.
  
Let us now connect the blocks together.
+
Let us now connect the '''blocks''' together.
 
|-
 
|-
 
|
 
|
 
On '''Untitled-Xcos window''',
 
On '''Untitled-Xcos window''',
  
Connect as per narration'''.'''
+
Connect as per narration.
 
|
 
|
Select the '''black output port''' of the '''TKSCALE''' block.
+
Select the '''black output port''' of the '''TKSCALE block'''.
  
Connect it to the '''black input port''' of the '''CSCOPE''' block.
+
Connect it to the '''black input port''' of the '''CSCOPE block'''.
 
|-
 
|-
 
|
 
|
 
On '''Untitled-Xcos window''',
 
On '''Untitled-Xcos window''',
  
Connect as per narration'''.'''
+
Connect as per narration.
 
|
 
|
Next select the red '''output port''' of the '''CLOCK underscore c''' block.
+
Next select the red '''output port''' of the '''CLOCK underscore c block'''.
  
Connect it to the red '''input port''' of the '''CSCOPE''' block.
+
Connect it to the red '''input port''' of the '''CSCOPE block'''.
 
|-
 
|-
 
|
 
|
 
On '''Untitled-Xcos window,'''
 
On '''Untitled-Xcos window,'''
  
Connect as per narration
+
Connect as per narration.
 
|
 
|
Next select the '''red input port''' of the '''TKSCALE''' block.
+
Next select the '''red input port''' of the '''TKSCALE block'''.
  
Connect it to the '''line''' connecting '''CLOCK underscore c''' and '''CSCOPE''' block.
+
Connect it to the '''line''' connecting '''CLOCK underscore c''' and '''CSCOPE block'''.
 
|-
 
|-
 
|
 
|
 
On '''Untitled-Xcos window,'''
 
On '''Untitled-Xcos window,'''
  
Connect as per narration
+
Connect as per narration.
 
|
 
|
Use the left mouse click to create line bends and then connect it to the line.
+
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.
+
Now let us '''simulate''' this file with the default values.
 
|-
 
|-
 
|
 
|
Line 202: Line 200:
 
Click on '''start'''.
 
Click on '''start'''.
 
|
 
|
To start the '''simulation''', go to the toolbar of the '''Untitled-Xcos window'''.
+
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.
+
Then click on the '''Start''' button that is of the shape of the '''play''' button.
 
|-
 
|-
 
| Cursor on the '''Slider''' and the '''Graphic window'''.
 
| Cursor on the '''Slider''' and the '''Graphic window'''.
Line 212: Line 210:
 
The left window will display the '''slider'''.
 
The left window will display the '''slider'''.
  
The right '''Graphic window''' will display the output of the system.
+
The right '''Graphic''' window will display the output of the '''system'''.
 
|-
 
|-
 
| Hover cursor over '''slider'''
 
| Hover cursor over '''slider'''
Line 220: Line 218:
 
It doesn’t give a chance to make use of this '''slider'''.
 
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.
+
This is happening because '''Xcos''' is trying to '''simulate''' this file at computer time.
 
|-
 
|-
 
| Close '''Graphic window'''
 
| Close '''Graphic window'''
| To handle this problem, first close the '''Graphic window'''.
+
| To handle this problem, first close the '''Graphic''' window.
 
|-
 
|-
 
|
 
|
Line 230: Line 228:
 
'''Simulation>>Setup'''
 
'''Simulation>>Setup'''
 
|
 
|
Then go to the menu bar of the '''Untitled-Xcos window''' and click on '''Simulation'''.
+
Then go to the '''menu bar''' of the '''Untitled-Xcos''' window and click on '''Simulation'''.
  
 
Then click on '''Setup'''.
 
Then click on '''Setup'''.
Line 248: Line 246:
 
Click on '''OK'''.
 
Click on '''OK'''.
 
|
 
|
Keep the other parameters unchanged.
+
Keep the other '''parameters''' unchanged.
  
 
Then click on '''OK.'''
 
Then click on '''OK.'''
 
|-
 
|-
 
|
 
|
On '''Untitled-Xcos window''',
+
On '''Untitled-Xcos''' window, click on '''Start'''.
 
+
Click on '''Start'''.
+
 
|
 
|
To start the '''simulation,''' go to the toolbar of the '''Untitled-Xcos window'''.
+
To start the '''simulation,''' go to the '''toolbar''' of the '''Untitled-Xcos window'''.
  
Click on the '''Start''' button.
+
Click on the '''Start button'''.
 
|-
 
|-
 
| Cursor on '''Graphic window''' and '''slider'''
 
| Cursor on '''Graphic window''' and '''slider'''
| A '''graphic window''' and the '''slider''' will open.
+
| A '''Graphic''' window and the '''slider''' will open.
 
|-
 
|-
 
|
 
|
 
Hover cursor over the '''slider'''.
 
Hover cursor over the '''slider'''.
  
Hover cursor over '''slider''' and '''Graphic window.'''
+
Hover cursor over '''slider''' and '''Graphic''' window.
 
|
 
|
Now I’ll change the value of a parameter using a '''slider'''.
+
Now I’ll change the value of a '''parameter''' using the '''slider'''.
  
Notice that I am changing the value while the simulation is running.
+
Notice that I am changing the value while the '''simulation''' is '''running'''.
  
Observe the changes on a '''Graphic window''' as I change the '''slider''' value.
+
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'''.
+
So this is how we can make the '''Xcos simulation interactive''' using a '''slider'''.
 
|-
 
|-
 
|
 
|
Line 289: Line 285:
  
 
* Use '''Slider''' in '''Xcos'''
 
* Use '''Slider''' in '''Xcos'''
* Use '''TKSCALE''' block for simulation and
+
* Use '''TKSCALE block''' for '''simulation''' and
* Run '''Xcos''' simulations in real-time
+
* Run '''Xcos simulations''' in real-time
 
|-
 
|-
 
|
 
|
Line 299: Line 295:
 
As an assignment, please do the following.
 
As an assignment, please do the following.
  
* Modify the '''Xcos''' diagram to have an autoscale feature (scale graph at runtime) in the graph.
+
* 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.
+
* Hint: Explore the use of '''SCALE underscore CSCOPE''' to have the '''autoscale''' feature.
 
|-
 
|-
 
|
 
|

Revision as of 19:28, 8 August 2021

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 from FOSSEE intern 2021, IIT Bombay signing off.

Thanks for joining.

Contributors and Content Editors

Iswariyas, Nancyvarkey