Difference between revisions of "Scilab/C4/Loading-and-saving-data-in-Xcos/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Title of script''': Loading and saving data in Xcos '''Author: Rupak Rokade and Utkarsh''' '''Keywords: Xcos,TOWS_c, C_binary, workspace, read, write, data file, scilab''...")
 
 
(7 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
'''Keywords: Xcos,TOWS_c, C_binary, workspace, read, write, data file, scilab'''
 
'''Keywords: Xcos,TOWS_c, C_binary, workspace, read, write, data file, scilab'''
  
 +
{|border=1
 +
! '''Visual Cue'''
 +
! '''Narration'''
 +
|-
 +
|Show Slide:
  
 +
'''Title Slide'''
 +
| Hello and welcome to the Spoken Tutorial on “ '''Loading and saving data in Xcos'''”.
 +
|-
 +
|Show Slide:
  
{|
+
'''Learning Objectives'''
 +
|In this tutorial, we will learn how to:
 +
 
 +
*Save '''Xcos simulation data values''' to the '''workspace'''
 +
*Read and write '''data''' in '''Xcos simulation''' using a '''C binary''' file
 
|-
 
|-
 +
|Show Slide:
 +
 +
'''System Requirements'''
 +
|To record this tutorial, I am using
 +
 +
*'''Ubuntu 18.04 OS''' and
 +
*'''Scilab 6.1.0 version'''
 
|-
 
|-
 +
|Show Slide:
 +
 +
'''Pre-requisites'''
 +
|To follow this tutorial, you should have
 +
 +
*Basic knowledge of '''Scilab''' and '''Xcos.'''
 +
*If not, for relevant tutorials please visit this website.
 
|-
 
|-
 +
|Show Slide:
 +
 +
'''Code Files'''
 +
|
 +
*The files used in this tutorial are provided in the '''Code files''' link.
 +
*Please download and extract the files.
 +
*Make a copy and then use them while practising.
 
|-
 
|-
 +
|Cursor on the '''Untitled Xcos editing''' window.
 +
|I have already opened the '''Xcos''' windows.
 +
 +
We can see two windows named '''Untitled Xcos''' and the '''Palette browser''' are opened.
 
|-
 
|-
 +
|On the '''Untitled Xcos''' window,
 +
 +
Cursor on '''Toolbar''' >> Click on '''Open file''' option >> Click on '''SaveData.xcos''' >> Click on '''OK.'''
 +
|Go to the '''Untitled Xcos''' window.
 +
 +
Click on the '''Open File''' icon on the '''Toolbar'''.
 +
 +
A window will appear.
 +
 +
Go to the '''Downloads''' folder and select the file '''SaveData.xcos'''.
 +
 +
Then click on the '''OK''' button.
 
|-
 
|-
 +
|Adjust the Window accordingly.
 +
|Let me adjust the window.
 +
 +
I have already created this file for demonstration.
 
|-
 
|-
 +
|On the '''SaveData.xcos''' window,
 +
 +
cursor on the '''SaveData.xcos''' window.
 +
|This file has a simple '''Xcos simulation''' diagram.
 
|-
 
|-
 +
|On the '''SaveData.xcos''' window,
 +
 +
Hover cursor on '''RAMP block'''.
 +
|It uses the '''RAMP block''' to generate a '''Ramp signal'''.
 
|-
 
|-
 +
|On the '''SaveData.xcos''' window,
 +
 +
Hover cursor on '''CSCOPE block'''.
 +
|And the '''CSCOPE block''' to plot it.
 +
 +
Let us see how to record the generated '''Ramp signal'''.
 
|-
 
|-
 +
|On the '''SaveData.xcos''' window,
 +
 +
cursor on the '''SaveData.xcos window'''
 +
|First we will see how to push the values generated by the '''RAMP block''' to '''workspace.'''
 
|-
 
|-
 +
|On '''palette browser''',
 +
 +
click on '''Sinks''' >> scroll down >> click on '''TOWS_c.'''
 +
|Go to the '''Palette browser''' window.
 +
 +
Click on the '''Sinks palette'''.
 +
 +
In the right panel, select the '''TOWS_c block'''. This is the '''To Workspace block'''.
 
|-
 
|-
 +
|As per narration
 +
|'''Drag and Drop''' the '''To Workspace block''' to the '''SaveData.xcos''' window.
 
|-
 
|-
 +
|On the '''editing''' window,
 +
 +
Double-click on the '''TOWS_c''' block.
 +
|Double-click on the '''To Workspace block''' to '''configure''' its properties.
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' Window of '''TOWS_c block'''
 +
 +
Double click on the '''Size of Buffer.''' Text field to highlight it.
 +
|The size of '''buffer''' is by default set to '''128.'''
 +
 +
This means that 128 values will be saved in the '''block'''.
 +
 +
If any more values are '''passed''', the '''block''' will overwrite the previous values.
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' Window of '''TOWS_c block'''
 +
 +
Double-click on the '''Variable Name''' text field to highlight it.
 +
|The '''Variable Name''' is the name of the '''variable''' to which the values are saved.
 +
 +
By default it is '''set''' to '''A.'''
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' Window of '''TOWS_c block'''
 +
 +
Double click on the '''Inherit''' Text field to highlight it.
 +
 +
Click on the '''OK''' button at the bottom.
 +
|'''Inherit''' is used to decide whether to take the '''event input''' or not.
 +
 +
By default '''Inherit''' is '''set''' to '''0''' which means it has to take '''event input'''.
 +
 +
Click on the '''OK''' button to close this window.
 
|-
 
|-
 +
|On '''SaveData.xcos Window''',
 +
 +
Connect as per narration.
 +
|Let us make the connections.
 +
 +
Select the '''black input port''' of the '''To workspace block'''.
 +
 +
Connect it to the line joining the '''RAMP''' and the '''CSCOPE block'''.
 
|-
 
|-
 +
|On '''SaveData.xcos Window''',
 +
 +
Connect as per narration'''.'''
 +
|Next, select the '''red input port''' of the '''To workspace block'''.
 +
 +
Connect it to the line joining the '''CLOCK_c''' and the '''CSCOPE block'''.
 +
 +
Our file is ready for '''simulation'''.
 
|-
 
|-
 +
|On the '''SaveData.xcos''' window,
 +
 +
Click on '''Start''' button on the toolbar >> click on '''OK''' button on the '''Warning message.'''
 +
|Let us run this '''simulation''' by clicking on the '''Start''' button on the '''toolbar'''.
 +
 +
A '''Warning message''' will appear.
 +
 +
Ignore the message and click on the '''OK''' button.
 
|-
 
|-
 +
|On the '''Graphic''' window,
 +
 +
Hover cursor on the '''graph.'''
 +
 +
Close the '''Graphic''' window.
 +
|We can see a straight line with '''slope 2'''.
 +
 +
Let’s close the graphic window.
 
|-
 
|-
 +
|Switch to '''workspace.'''
 +
|Now let us look at the '''values'''.
 +
 +
Switch to the '''workspace'''.
 
|-
 
|-
 +
|On the '''workspace''',
 +
 +
Type '''''A''''' >> press '''Enter.'''
 +
|Let us '''execute''' the '''variable A'''.
 +
 +
Type '''A''' on the '''workspace''' and press '''Enter'''.
 
|-
 
|-
 +
|On the '''workspace''' window,
 +
 +
Highlight '''variable A.'''
 +
 +
Highlight '''values.'''
 +
 +
Highlight '''time.'''
 +
|'''A''' is a special '''variable'''.
 +
 +
We can either extract '''values''' from '''A''' or we can extract '''times''' from '''A.'''
 +
 +
Let us look at the '''values'''.
 
|-
 
|-
 +
|On the '''workspace''' window,
 +
 +
Type '''''A.values''''' >> Press '''Enter.'''
 +
|Type '''A.values''' on the '''workspace'''.
 +
 +
Press '''Enter.'''
 
|-
 
|-
 +
|On the '''workspace''',
 +
 +
Scroll up to show all the values and Highlight them.
 +
|These are all the values from the graph and are now saved in the '''workspace'''.
 
|-
 
|-
 +
|On the '''workspace''',
 +
 +
hover cursor on a new line on the workspace.
 +
|Now we need to save these '''values''' in a file so that we can share them.
 
|-
 
|-
 +
|Switch to '''SaveData.xcos''' window.
 +
|Switch back to the '''SaveData.xcos''' window.
 
|-
 
|-
 +
|On the '''palette browser''',
 +
 +
Click on '''Sinkss''' >> Click on '''WRITEC_f block'''.
 +
|To save these '''values''', we will use the '''WRITEC_f block'''.
 +
 +
Go to the '''Palette browser''' window.
 +
 +
Click on the '''Sinks palette'''.
 +
 +
Click on the '''WRITEC_f block''' in the right panel.
 +
 +
This is the '''Write to C binary file block'''.
 
|-
 
|-
 +
|As per narration
 +
|Drag and drop the '''block''' on the '''SaveData.xcos''' window.
 
|-
 
|-
 +
|On the '''SaveData.xcos''' window,
 +
 +
Double-click on '''WRITEC_f block'''.
 +
|Double-click on the '''WRITEC_f block''' to '''configure''' its properties.
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' Window of '''WRITEC_f block''',
 +
 +
Double click on the '''Input Size''' Text field to highlight it.
 +
|'''Input Size''' is the size of our input '''values'''.
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' Window of '''WRITEC_f block'''
 +
 +
Double click on the '''Output File Name''' Text field to highlight it >> Change it to '''''‘data’'''''
 +
|'''Output File''' is the name of our output file.
 +
 +
I will name the output file as '''‘data ‘'''.
 +
 +
If no '''file path''' is entered, the file will be saved in the '''Current working directory.'''
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' window of '''WRITEC_f block'''
 +
 +
Double-click on the '''Output Format''' Text field to highlight it >> Change it to ‘ '''d''' ’
 +
|'''Output Format''' is the format of the output file.
 +
 +
By default it is '''‘ c ‘.''' That is, by default, '''values''' are saved as '''integers'''.
 +
 +
But, I want to save the '''values''' as '''double.''' So, I will change it to '''‘d’.'''
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' Window of '''WRITEC_f block''',
 +
 +
Double-click on the '''Buffer Size''' Text field to highlight it.
 +
|'''Buffer Size''' is the size of the '''buffer'''.
 
|-
 
|-
 +
|On '''SaveData.xcos Window''',
 +
 +
Connect as per narration'''.'''
 +
|Let us make the connections.
 +
 +
Select the '''black input port''' of the '''WRITEC_f block'''.
 +
 +
Connect it to the line joining the '''RAMP''' and the '''CSCOPE block'''.
 
|-
 
|-
 +
|On '''SaveData.xcos Window''',
 +
 +
Connect as per narration'''.'''
 +
|Next, select the '''red input port''' of the '''WRITEC_f block'''.
 +
 +
Connect it to the line joining the '''CLOCK_c''' and the '''CSCOPE block'''.
 +
 +
Our file is ready for '''simulation'''.
 
|-
 
|-
 +
|On the '''SaveData.xcos''' window,
 +
 +
Click on '''Start''' button on the toolbar >> click on '''OK''' button on the Warning message.
 +
|Let's '''run''' the '''simulation''' again by clicking on the '''Start''' Button on the '''toolbar.'''
 +
 +
A '''Warning message''' will appear. Ignore the message and click on the '''OK''' button.
 
|-
 
|-
 +
|On the '''Graphic''' window,
 +
 +
Hover cursor on the '''graph.'''
 +
 +
'''Close''' the Graphic window.
 +
|We can see the graph.
 +
 +
Let’s close the graphic window.
 
|-
 
|-
 +
|As per narration.
 +
|Let's go to the location where we have saved the '''data''' file.
 
|-
 
|-
 +
|On '''file manager window''',
 +
 +
Click on the '''data''' file once.
 +
|We can see a file named '''‘data‘''' .
 +
 +
Since it is a '''binary encoded''' file we cannot simply read it.
 +
 +
We would need a special '''block''' to read this file.
 
|-
 
|-
 +
|Switch back to '''SaveData.xcos''' file
 +
|Switch back to the '''SaveData.xcos''' window.
 
|-
 
|-
 +
|On the '''SaveData.xcos''' window,
 +
 +
Cursor on '''Toolbar''' >> Click on '''Open file''' option >> Click on '''LoadData.xcos''' >> Click on '''OK'''
 +
|Let us open the file '''LoadData.xcos'''
 +
 +
Click on the '''Open File''' icon on the '''Toolbar'''.
 +
 +
A window will appear.
 +
 +
Go to '''Downloads''' folder and select the file '''LoadData.xcos'''.
 +
 +
Then click on the '''OK''' button.
 +
 +
We will use this file to read our '''data''' file.
 
|-
 
|-
 +
|Adjust the Window accordingly.
 +
|Let me adjust the window.
 
|-
 
|-
 +
|On the '''palette browser,'''
 +
 +
Click on '''Sources''' >> Click on '''READC_f block'''.
 +
|We will use the '''READC_f block''' to read our '''values'''.
 +
 +
Go to the '''Palette browser''' window.
 +
 +
Click on the '''Sources palette'''.
 +
 +
Click on '''READC_f block''' in the right panel.
 +
 +
This is the '''Read from C Binary block'''.
 
|-
 
|-
 +
| As per narration
 +
| '''Drag and Drop''' the '''block''' on the '''LoadData.xcos''' window.
 
|-
 
|-
 +
|
 +
On the '''LoadData.xcos''' window,
 +
 +
Double-click on '''READC_f block'''
 +
| Double-click on the '''READC_f block''' to '''configure''' its properties.
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' Window of '''READC_f block'''
 +
 +
Double-click on the '''Input File Name''' Text field to highlight it. >> Change it to '''''data'''''
 +
|'''Input File Name''' is the name and the '''path''' of your '''data''' file.
 +
 +
Since my '''data''' file was named '''data''' I will change it to '''data'''.
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' Window of '''READC_f block'''
 +
 +
Double-click on the '''Input Format''' Text field to highlight it >> Change it to '''''d.'''''
 +
|'''Input format''' is the format of the '''data''' file.
 +
 +
Since the format for my '''data''' file is '''double''', I will change it to '''d'''.
 
|-
 
|-
 +
|On the '''Scilab Multiple Values Request''' Window of '''READC_f''' block,
 +
 +
Double-click on the '''Buffer Size''' Text field to highlight it.
 +
 +
Click the '''OK''' button .
 +
|This is the '''buffer''' size.
 +
 +
Let’s close this window by clicking on the '''OK''' button.
 
|-
 
|-
 +
|On '''LoadData.xcos Window''',
 +
 +
Connect as per narration'''.'''
 +
|Let us make the connections.
 +
 +
Select the '''black output port''' of the '''READC_f block'''.
 +
 +
Connect it to the '''black input port''' of the '''CSCOPE block'''.
 
|-
 
|-
 +
|On '''LoadData.xcos Window''',
 +
 +
Connect as per narration.
 +
|Lastly, select the '''red input port''' of the '''READC_f block'''.
 +
 +
Connect it to the line joining the '''CLOCK_C''' & the '''CSCOPE block'''.
 
|-
 
|-
 +
|On the '''LoadData.xcos''' window,
 +
 +
Click on '''Start''' button on the '''toolbar'''
 +
|Let’s '''run''' this '''simulation''' again by clicking on the '''Start''' button on the '''toolbar'''.
 
|-
 
|-
 +
|On the '''Graphic''' Window,
 +
 +
Hover Cursor on the '''Graph.'''
 +
|We have a similar graph to the one we had earlier without using the '''RAMP block'''.
 +
 +
This is because we have loaded the '''values''' from the '''data''' file.
 
|-
 
|-
 +
|Show Slide:
 +
 +
'''Summary'''
 +
|This brings us to the end of this tutorial. Let us summarise.
 +
 +
In this tutorial, we have learnt to:
 +
 +
*Save '''Xcos simulation data values''' to the '''workspace'''.
 +
*Read and write '''data''' in '''Xcos Simulation''' using a '''C binary''' file
 
|-
 
|-
 +
|Show Slide:
 +
 +
'''Assignment'''
 +
|As an assignment,
 +
 +
Create two '''Xcos simulation''' files:
 +
 +
*Use the first for plotting a straight line with '''slope 3'''.
 +
*Push the '''values''' to the '''workspace''' and save them as a '''binary encoded''' file.
 +
*Create another '''Xcos simulation''' to plot a new graph of a straight line with '''slope 3'''.
 +
*Use only the saved '''data values'''.
 
|-
 
|-
 +
| 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 website.
 
|-
 
|-
 +
|Show Slide: '''Lab Migration'''
 +
|The FOSSEE team coordinates the Lab Migration project.
 +
 +
For more details, please visit this website.
 
|-
 
|-
 +
|Show Slide: '''Acknowledgement'''
 +
|Spoken Tutorial and FOSSEE projects are funded by the Ministry of Education, Government of India.
 
|-
 
|-
|-
+
|Show Slide: '''Thank you'''
|-
+
|This is Utkarsh Anand, FOSSEE intern 2021, IIT Bombay signing off.
|-
+
|}
+
  
''' '''
+
Thanks for joining.
 +
|}

Latest revision as of 17:01, 21 September 2021

Title of script: Loading and saving data in Xcos

Author: Rupak Rokade and Utkarsh

Keywords: Xcos,TOWS_c, C_binary, workspace, read, write, data file, scilab

Visual Cue Narration
Show Slide:

Title Slide

Hello and welcome to the Spoken Tutorial on “ Loading and saving data in Xcos”.
Show Slide:

Learning Objectives

In this tutorial, we will learn how to:
  • Save Xcos simulation data values to the workspace
  • Read and write data in Xcos simulation using a C binary file
Show Slide:

System Requirements

To record this tutorial, I am using
  • Ubuntu 18.04 OS and
  • Scilab 6.1.0 version
Show Slide:

Pre-requisites

To follow this tutorial, you should have
  • Basic knowledge of Scilab and Xcos.
  • If not, for relevant tutorials please visit this website.
Show Slide:

Code Files

  • The files used in this tutorial are provided in the Code files link.
  • Please download and extract the files.
  • Make a copy and then use them while practising.
Cursor on the Untitled Xcos editing window. I have already opened the Xcos windows.

We can see two windows named Untitled Xcos and the Palette browser are opened.

On the Untitled Xcos window,

Cursor on Toolbar >> Click on Open file option >> Click on SaveData.xcos >> Click on OK.

Go to the Untitled Xcos window.

Click on the Open File icon on the Toolbar.

A window will appear.

Go to the Downloads folder and select the file SaveData.xcos.

Then click on the OK button.

Adjust the Window accordingly. Let me adjust the window.

I have already created this file for demonstration.

On the SaveData.xcos window,

cursor on the SaveData.xcos window.

This file has a simple Xcos simulation diagram.
On the SaveData.xcos window,

Hover cursor on RAMP block.

It uses the RAMP block to generate a Ramp signal.
On the SaveData.xcos window,

Hover cursor on CSCOPE block.

And the CSCOPE block to plot it.

Let us see how to record the generated Ramp signal.

On the SaveData.xcos window,

cursor on the SaveData.xcos window

First we will see how to push the values generated by the RAMP block to workspace.
On palette browser,

click on Sinks >> scroll down >> click on TOWS_c.

Go to the Palette browser window.

Click on the Sinks palette.

In the right panel, select the TOWS_c block. This is the To Workspace block.

As per narration Drag and Drop the To Workspace block to the SaveData.xcos window.
On the editing window,

Double-click on the TOWS_c block.

Double-click on the To Workspace block to configure its properties.
On the Scilab Multiple Values Request Window of TOWS_c block

Double click on the Size of Buffer. Text field to highlight it.

The size of buffer is by default set to 128.

This means that 128 values will be saved in the block.

If any more values are passed, the block will overwrite the previous values.

On the Scilab Multiple Values Request Window of TOWS_c block

Double-click on the Variable Name text field to highlight it.

The Variable Name is the name of the variable to which the values are saved.

By default it is set to A.

On the Scilab Multiple Values Request Window of TOWS_c block

Double click on the Inherit Text field to highlight it.

Click on the OK button at the bottom.

Inherit is used to decide whether to take the event input or not.

By default Inherit is set to 0 which means it has to take event input.

Click on the OK button to close this window.

On SaveData.xcos Window,

Connect as per narration.

Let us make the connections.

Select the black input port of the To workspace block.

Connect it to the line joining the RAMP and the CSCOPE block.

On SaveData.xcos Window,

Connect as per narration.

Next, select the red input port of the To workspace block.

Connect it to the line joining the CLOCK_c and the CSCOPE block.

Our file is ready for simulation.

On the SaveData.xcos window,

Click on Start button on the toolbar >> click on OK button on the Warning message.

Let us run this simulation by clicking on the Start button on the toolbar.

A Warning message will appear.

Ignore the message and click on the OK button.

On the Graphic window,

Hover cursor on the graph.

Close the Graphic window.

We can see a straight line with slope 2.

Let’s close the graphic window.

Switch to workspace. Now let us look at the values.

Switch to the workspace.

On the workspace,

Type A >> press Enter.

Let us execute the variable A.

Type A on the workspace and press Enter.

On the workspace window,

Highlight variable A.

Highlight values.

Highlight time.

A is a special variable.

We can either extract values from A or we can extract times from A.

Let us look at the values.

On the workspace window,

Type A.values >> Press Enter.

Type A.values on the workspace.

Press Enter.

On the workspace,

Scroll up to show all the values and Highlight them.

These are all the values from the graph and are now saved in the workspace.
On the workspace,

hover cursor on a new line on the workspace.

Now we need to save these values in a file so that we can share them.
Switch to SaveData.xcos window. Switch back to the SaveData.xcos window.
On the palette browser,

Click on Sinkss >> Click on WRITEC_f block.

To save these values, we will use the WRITEC_f block.

Go to the Palette browser window.

Click on the Sinks palette.

Click on the WRITEC_f block in the right panel.

This is the Write to C binary file block.

As per narration Drag and drop the block on the SaveData.xcos window.
On the SaveData.xcos window,

Double-click on WRITEC_f block.

Double-click on the WRITEC_f block to configure its properties.
On the Scilab Multiple Values Request Window of WRITEC_f block,

Double click on the Input Size Text field to highlight it.

Input Size is the size of our input values.
On the Scilab Multiple Values Request Window of WRITEC_f block

Double click on the Output File Name Text field to highlight it >> Change it to ‘data’

Output File is the name of our output file.

I will name the output file as ‘data ‘.

If no file path is entered, the file will be saved in the Current working directory.

On the Scilab Multiple Values Request window of WRITEC_f block

Double-click on the Output Format Text field to highlight it >> Change it to ‘ d

Output Format is the format of the output file.

By default it is ‘ c ‘. That is, by default, values are saved as integers.

But, I want to save the values as double. So, I will change it to ‘d’.

On the Scilab Multiple Values Request Window of WRITEC_f block,

Double-click on the Buffer Size Text field to highlight it.

Buffer Size is the size of the buffer.
On SaveData.xcos Window,

Connect as per narration.

Let us make the connections.

Select the black input port of the WRITEC_f block.

Connect it to the line joining the RAMP and the CSCOPE block.

On SaveData.xcos Window,

Connect as per narration.

Next, select the red input port of the WRITEC_f block.

Connect it to the line joining the CLOCK_c and the CSCOPE block.

Our file is ready for simulation.

On the SaveData.xcos window,

Click on Start button on the toolbar >> click on OK button on the Warning message.

Let's run the simulation again by clicking on the Start Button on the toolbar.

A Warning message will appear. Ignore the message and click on the OK button.

On the Graphic window,

Hover cursor on the graph.

Close the Graphic window.

We can see the graph.

Let’s close the graphic window.

As per narration. Let's go to the location where we have saved the data file.
On file manager window,

Click on the data file once.

We can see a file named ‘data‘ .

Since it is a binary encoded file we cannot simply read it.

We would need a special block to read this file.

Switch back to SaveData.xcos file Switch back to the SaveData.xcos window.
On the SaveData.xcos window,

Cursor on Toolbar >> Click on Open file option >> Click on LoadData.xcos >> Click on OK

Let us open the file LoadData.xcos

Click on the Open File icon on the Toolbar.

A window will appear.

Go to Downloads folder and select the file LoadData.xcos.

Then click on the OK button.

We will use this file to read our data file.

Adjust the Window accordingly. Let me adjust the window.
On the palette browser,

Click on Sources >> Click on READC_f block.

We will use the READC_f block to read our values.

Go to the Palette browser window.

Click on the Sources palette.

Click on READC_f block in the right panel.

This is the Read from C Binary block.

As per narration Drag and Drop the block on the LoadData.xcos window.

On the LoadData.xcos window,

Double-click on READC_f block

Double-click on the READC_f block to configure its properties.
On the Scilab Multiple Values Request Window of READC_f block

Double-click on the Input File Name Text field to highlight it. >> Change it to data

Input File Name is the name and the path of your data file.

Since my data file was named data I will change it to data.

On the Scilab Multiple Values Request Window of READC_f block

Double-click on the Input Format Text field to highlight it >> Change it to d.

Input format is the format of the data file.

Since the format for my data file is double, I will change it to d.

On the Scilab Multiple Values Request Window of READC_f block,

Double-click on the Buffer Size Text field to highlight it.

Click the OK button .

This is the buffer size.

Let’s close this window by clicking on the OK button.

On LoadData.xcos Window,

Connect as per narration.

Let us make the connections.

Select the black output port of the READC_f block.

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

On LoadData.xcos Window,

Connect as per narration.

Lastly, select the red input port of the READC_f block.

Connect it to the line joining the CLOCK_C & the CSCOPE block.

On the LoadData.xcos window,

Click on Start button on the toolbar

Let’s run this simulation again by clicking on the Start button on the toolbar.
On the Graphic Window,

Hover Cursor on the Graph.

We have a similar graph to the one we had earlier without using the RAMP block.

This is because we have loaded the values from the data file.

Show Slide:

Summary

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

In this tutorial, we have learnt to:

  • Save Xcos simulation data values to the workspace.
  • Read and write data in Xcos Simulation using a C binary file
Show Slide:

Assignment

As an assignment,

Create two Xcos simulation files:

  • Use the first for plotting a straight line with slope 3.
  • Push the values to the workspace and save them as a binary encoded file.
  • Create another Xcos simulation to plot a new graph of a straight line with slope 3.
  • Use only the saved data values.
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 website.

Show Slide: Lab Migration The FOSSEE team coordinates the Lab Migration project.

For more details, please visit this website.

Show Slide: Acknowledgement Spoken Tutorial and FOSSEE projects are funded by the Ministry of Education, Government of India.
Show Slide: Thank you This is Utkarsh Anand, FOSSEE intern 2021, IIT Bombay signing off.

Thanks for joining.

Contributors and Content Editors

Nancyvarkey, PoojaMoolya, Utkarsha