Difference between revisions of "Scilab/C4/User-defined-variables-in-Xcos/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Title of script: User-defined variables in Xcos''' '''Author:Rupak Rokade and Anandajith TS''' {| class= "wikitable" ! '''Visual Cue''' ! '''Narration''' |- | Show Slide:...")
 
Line 17: Line 17:
  
 
'''Learning Objectives'''
 
'''Learning Objectives'''
 +
 +
 +
 +
 
|
 
|
 
In this tutorial, we will learn how to:
 
In this tutorial, we will learn how to:
Line 28: Line 32:
  
 
'''System Requirements'''
 
'''System Requirements'''
 +
 +
 +
 +
 +
 +
 
|
 
|
 
To record this tutorial, I am using
 
To record this tutorial, I am using
Line 57: Line 67:
  
 
'''Variables'''
 
'''Variables'''
 +
 +
 +
 +
 
|
 
|
 
There are two ways to define '''variables''' in '''Xcos''':
 
There are two ways to define '''variables''' in '''Xcos''':
Line 69: Line 83:
 
|-
 
|-
 
|
 
|
Show slide
+
Show slide:
 +
 
 +
'''Simulation - Blocks used'''
 +
 
 +
 
 +
 
 +
 
 +
 
  
Simulation - Blocks used
 
 
|
 
|
 
For this we used the below blocks
 
For this we used the below blocks
Line 81: Line 101:
 
|-
 
|-
 
| Show '''Scilab workspace window'''
 
| Show '''Scilab workspace window'''
 +
 +
 +
 +
 +
 +
 +
 +
 
|
 
|
 
Open '''Scilab.'''
 
Open '''Scilab.'''
Line 96: Line 124:
  
 
'''Sources palette>>RAMP block'''
 
'''Sources palette>>RAMP block'''
 +
 +
 +
 +
 +
 +
 
|
 
|
 
To create the '''simulation''' we will have to import the necessary '''blocks.'''
 
To create the '''simulation''' we will have to import the necessary '''blocks.'''
Line 105: Line 139:
 
|-
 
|-
 
| '''Sinks palette>>CSCOPE block'''
 
| '''Sinks palette>>CSCOPE block'''
 +
 +
 +
 +
 
|
 
|
 
<ul>
 
<ul>
Line 113: Line 151:
 
|-
 
|-
 
| '''Event handling&gt;&gt;Clock_c block'''
 
| '''Event handling&gt;&gt;Clock_c block'''
 +
 +
 +
 +
 
|
 
|
 
<ul>
 
<ul>
Line 119: Line 161:
 
|-
 
|-
 
| Show '''Xcos window'''
 
| Show '''Xcos window'''
 +
 +
 +
 +
 
|
 
|
 
Next we will interconnect all the '''blocks.'''
 
Next we will interconnect all the '''blocks.'''
Line 294: Line 340:
 
'''Thank you'''
 
'''Thank you'''
 
|
 
|
This is Iswariya Sasikumar from FOSSEE intern 2021, IIT Bombay signing off.
+
This is Iswariya Sasikumar, a FOSSEE intern 2021, IIT Bombay signing off.
  
 
Thanks for joining.
 
Thanks for joining.
 
|}
 
|}

Revision as of 18:15, 30 August 2021

Title of script: User-defined variables in Xcos

Author:Rupak Rokade and Anandajith TS

Visual Cue Narration

Show Slide:

Title Slide

Hello and welcome to the Spoken Tutorial on “ User-defined Variables in Xcos

Show Slide:

Learning Objectives



In this tutorial, we will learn how to:

  • Pass variables from Scilab Console to Xcos.

  • Pass variables from context menu to Xcos.

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:

Prerequisite

https://www.spoken-tutorial.org

Before practising this tutorial, a learner should have :

  • Basic knowledge of Scilab and Xcos.

If not, then go through the Scilab spoken tutorials on this website.

Show Slide:

Variables



There are two ways to define variables in Xcos:

  • Defining variables from the Scilab Console.

  • Defining variables from the context menu.

First we will create a simple simulation.

Show slide:

Simulation - Blocks used




For this we used the below blocks

  • RAMP

  • CLOCK underscore c and

  • CSCOPE

Show Scilab workspace window





Open Scilab.

Type in ‘xcos’ in the Scilab console and press enter.

Two windows will open :

  • Palette browser and the

  • Untitled-Xcos window.

Show Xcos window

Sources palette>>RAMP block




To create the simulation we will have to import the necessary blocks.

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

  • In the right panel, select the RAMP block.

  • Now, drag and drop this block in the Untitled-Xcos window.

Sinks palette>>CSCOPE block



  • Go to the Palette browser-Xcos window.

  • Click on the sinks palette.

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

  • Drag and drop it next to the RAMP block in the Untitled-Xcos window

Event handling>>Clock_c block



  • Again go to the event handling palette, select the CLOCK underscore c block.

  • Then drag and drop it above the CSCOPE block in the untitled -Xcos window

Show Xcos window



Next we will interconnect all the blocks.

  • Connect black output port of RAMP to black input port of CSCOPE.

  • Connect the red output port of CLOCK underscore c to the red input port of CSCOPE.

  • Our simulation is ready.

Show Xcos window
  • Then right click on the RAMP block and select the block parameters.

  • Here we set the slope parameter to ‘a’ and click OK .

  • It shows an error as ‘a’ is not defined.

  • This is correct because we never defined the variable ‘a’ before.

Show Scilab workspace window

Our first way to define a variable is using the Scilab console.

For this, go to the Scilab console .

Type ‘a=1’ and press enter

Show Xcos window

Now come back to the Untitled-Xcos window .

  • Right click on the RAMP block and select the block parameter option in the menu.

  • Again we set the slope parameter to ‘a’ and click ok.

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.

We will see a warning message saying that there is no continuous time state.

This can be ignored in this example. So click on OK.

Show graphic window Now, we can see that the slope of the output RAMP signal changes to a in the graphic window.

Next we will see how to define variables

using the context menu in the Xcos toolbar.

Show workspace window
First we will have to clear the previous value of a. For this :
  • Go to the scilab console window

  • Type in ‘clear a’ in the console and press enter .

  • Now type ‘a’ and press Enter

  • We can see that the console shows ‘a’ as undefined.

Show Xcos window and context menu

a=1

  • Next, in the menu bar of the Untitled-Xcos window, click on Simulation.

  • In the drop down menu select the set context option.

  • set context popup window appears.

  • Type a=1 in the window and click ok.

Show Xcos window

Now we execute the simulation again:

  • Go to the toolbar and click start.

  • Click ok in the warning window.

  • Then switch to the graphic window

  • We can see that the slope of output RAMP changed to ‘a’.

Show Slide :

Advantages of Context menu

  • Using the set context menu we can include the variables in the simulation itself.

  • We need not carry an additional sci file just to initialize the variable.

Show Slide:

Summary

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

In this tutorial, we have learnt to:

  • Pass variables from Scilab Console to Xcos.

  • Pass variables from context menu to Xcos.

Show slide ;

Assignment

As an assignment, please do the following

  • Change the value of variable ‘a’ to 5 using the Console window and context menu.

  • Check the output in the graphic window.

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:

Acknowledgement

Spoken Tutorial and FOSSEE projects are funded by MoE, Government of India.

Show Slide :

Thank you

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

Thanks for joining.

Contributors and Content Editors

Iswariyas