Difference between revisions of "Arduino/C4/Arduino-Programming-with-Scilab-and-Xcos/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "{| border="1" |- || '''VISUAL CUE''' || '''NARRATION''' |- || '''Slide 1:''' ||Welcome to the Spoken tutorial on '''Arduino Programming with Scilab and Xcos.''' |- || '''Slide...")
 
Line 11: Line 11:
 
'''Learning Objectives'''
 
'''Learning Objectives'''
 
|| In this tutorial, we will learn about
 
|| In this tutorial, we will learn about
*'''Arduino - Scilab '''toolbox
+
*'''Arduino - Scilab toolbox'''
 
*Interfacing '''Arduino''' with '''Scilab'''
 
*Interfacing '''Arduino''' with '''Scilab'''
 
*Interfacing''' Arduino '''with '''Xcos'''
 
*Interfacing''' Arduino '''with '''Xcos'''
Line 21: Line 21:
 
|| To record this tutorial, I’m using
 
|| To record this tutorial, I’m using
 
*'''Ubuntu Linux '''OS version 18.04  
 
*'''Ubuntu Linux '''OS version 18.04  
*Arduino Shield and
+
*'''Arduino Shield''' and
*Arduino Uno Board
+
*'''Arduino Uno Board'''
  
 
|-
 
|-
Line 37: Line 37:
  
 
|| In the above tutorial, you will learn
 
|| In the above tutorial, you will learn
*How to download the e-book and code files required for the experiments.
+
*How to download the '''e-book''' and code files required for the experiments.
*How to upload and compile '''Arduino''' programs in '''Arduino IDE.'''
+
*How to upload and '''compile Arduino programs''' in '''Arduino IDE.'''
 
*About '''FLOSS Firmware'''
 
*About '''FLOSS Firmware'''
 
|-
 
|-
Line 46: Line 46:
 
|| If you are not familiar with '''Scilab''', go through the''' Scilab spoken tutorials''' on this website.
 
|| If you are not familiar with '''Scilab''', go through the''' Scilab spoken tutorials''' on this website.
  
 +
You will learn about:
 
*Introduction to '''Scilab'''
 
*Introduction to '''Scilab'''
 
*Introduction to '''Xcos'''
 
*Introduction to '''Xcos'''
 
*'''Scilab''' and '''Xcos''' interface and
 
*'''Scilab''' and '''Xcos''' interface and
*Simulation  
+
*'''Simulation'''
 
|-
 
|-
 
|| '''Point to the book in the desktop'''
 
|| '''Point to the book in the desktop'''
 
'''and open the book'''
 
'''and open the book'''
|| I have downloaded '''Microcontroller Programming with Arduino, Scilab and Xcos '''ebook.
+
|| I have downloaded '''Microcontroller Programming with Arduino, Scilab and Xcos ebook'''.
 
|-
 
|-
 
|| Show the relevant pages in the book.
 
|| Show the relevant pages in the book.
Line 59: Line 60:
 
||
 
||
 
* Refer to chapter 3 in the book.
 
* Refer to chapter 3 in the book.
*Follow the steps given for the installation of '''Arduino IDE '''and''' Scilab'''
+
*Follow the steps given for the '''installation''' of '''Arduino IDE '''and''' Scilab'''
*Installation steps are given for '''Windows''' and '''Linux OS.'''
+
*'''Installation''' steps are given for '''Windows''' and '''Linux OS.'''
 
*'''Xcos''' comes pre-installed with '''Scilab'''. Hence a separate installation of '''Xcos''' is not required.
 
*'''Xcos''' comes pre-installed with '''Scilab'''. Hence a separate installation of '''Xcos''' is not required.
 
* The experiments that are covered in the book are tested in '''Ubuntu Linux 18.04 '''and '''Windows 10 OS.'''
 
* The experiments that are covered in the book are tested in '''Ubuntu Linux 18.04 '''and '''Windows 10 OS.'''
 
|-
 
|-
 
|| Arduino shield_USB.jpg
 
|| Arduino shield_USB.jpg
|| Connect the '''Arduino uno board''' with '''Arduino shield''' to the '''USB''' port of the computer
+
|| Connect the '''Arduino uno board''' with '''Arduino shield''' to the '''USB port''' of the computer
 
|-
 
|-
 
|| '''Slide:'''
 
|| '''Slide:'''
Line 71: Line 72:
 
|| Note the below points:
 
|| Note the below points:
  
1. Launch Arduino IDE
+
1. Launch '''Arduino IDE'''
  
2. Check the port
+
2. Check the '''port'''
  
3. Upload the FLOSS firmware
+
3. Upload the '''FLOSS firmware'''
  
 
That is, in the '''Arduino IDE''', upload the file available at '''Origin/tools/floss-firmware/floss-firmware.ino'''
 
That is, in the '''Arduino IDE''', upload the file available at '''Origin/tools/floss-firmware/floss-firmware.ino'''
Line 85: Line 86:
 
'''About -Scilab''' '''- ArduinoToolbox'''
 
'''About -Scilab''' '''- ArduinoToolbox'''
 
|| By default, '''Scilab '''does not have the capability to communicate with '''Arduino'''.
 
|| By default, '''Scilab '''does not have the capability to communicate with '''Arduino'''.
* All such add-on functionalities are added to '''Scilab''' using the toolbox.
+
* All such '''add-on functionalities''' are added to '''Scilab''' using the '''toolbox'''.
* These functions are required to run various experiments on the Arduino''' Uno board.'''
+
* These '''functions''' are required to run various experiments on the '''Arduino Uno board.'''
* It also establishes a serial communication with '''Arduino'''.
+
* It also establishes a '''serial communication''' with '''Arduino'''.
* We have created different toolboxes for '''Windows''' and '''Linux''' '''OS.'''
+
* We have created different '''toolboxes''' for '''Windows''' and '''Linux OS.'''
 
|-
 
|-
 
|| Show the directory in the book
 
|| Show the directory in the book
  
|| The '''Scilab Arduino '''toolbox can be found inside the '''Origin/tools/scilab/windows''' or '''Origin/tools/scilab/linux'''
+
|| The '''Scilab Arduino toolbox''' can be found inside the '''Origin/tools/scilab/windows''' or '''Origin/tools/scilab/linux'''
 
directory.
 
directory.
 
|-
 
|-
 
||  
 
||  
|| First we have to load the toolbox depending upon your OS.
+
|| First we have to load the '''toolbox''' depending upon your '''OS'''.
  
I’ll show you how to load the toolbox in '''Linux'''.
+
I’ll show you how to load the '''toolbox''' in '''Linux'''.
 
|-
 
|-
||  
+
|| Open the '''terminal'''
 +
 
 +
Go to the folder where '''Scilab''' is installed
  
|| Open the terminal by pressing '''Ctrl+Alt+T''' keys.
+
|| Open the '''terminal''' by pressing '''Ctrl+Alt+T''' keys.
 
I have already installed '''Arduino IDE''' and '''Scilab 5.5.2''' in my '''Linux''' system as specified in the book.
 
I have already installed '''Arduino IDE''' and '''Scilab 5.5.2''' in my '''Linux''' system as specified in the book.
  
Line 108: Line 111:
 
|-
 
|-
 
||  
 
||  
||Next we have to change the working directory.
+
||Next we have to change the '''working directory'''.
In the''' File Browser,''' Select the toolbox folder available at '''Desktop/Origin/tools/scilab/linux'''
+
In the''' File Browser,''' select the '''toolbox''' folder available at '''Desktop/Origin/tools/scilab/linux'''
  
Click on the ok button.
+
Click on the '''OK''' button.
  
Now the '''Scilab''' working directory becomes the toolbox folder.
+
Now the '''Scilab working directory''' becomes the '''toolbox''' folder.
 
|-
 
|-
 
||  
 
||  
|| In the file browser panel, we can see the '''builder.sce '''file gets loaded.
+
|| In the '''file browser panel''', we can see the '''builder.sce '''file gets loaded.
  
This shows that we are in the right directory.
+
This shows that we are in the right '''directory'''.
 
|-
 
|-
 
|| > '''exec builder.sce'''
 
|| > '''exec builder.sce'''
  
||Type the command '''exec builder.sce''' on the '''Scilab''' console
+
||Type the '''command exec builder.sce''' on the '''Scilab console'''.
  
Next, type the command, '''exec loader.sce'''. This will load the toolbox.
+
Next, type the '''command exec loader.sce'''. This will load the '''toolbox'''.
  
'''Note''': If you clear the workspace for any reason, you will have to execute this command once again.
+
'''Note''': If you clear the '''workspace''' for any reason, you will have to '''execute''' this '''command''' once again.
 
|-
 
|-
 
||
 
||
||We have to run the scilab script to check whether the firmware is properly installed or not.
+
||We have to run the '''Scilab script''' to check whether the '''firmware''' is properly installed or not.
  
 +
It is available at:
 
'''Origin/tools/scilab/test_firmware.sce'''
 
'''Origin/tools/scilab/test_firmware.sce'''
 
|-
 
|-
Line 136: Line 140:
 
Select '''Origin/tools/scilab'''/ '''test_firmware.sce.'''
 
Select '''Origin/tools/scilab'''/ '''test_firmware.sce.'''
  
|| In the '''Scilab''' console, type '''editor''' and press the enter key.
+
|| In the '''Scilab console''', type '''editor''' and press the '''Enter''' key.
  
 
Click on the “'''File'''” menu and choose “'''Open'''”.  
 
Click on the “'''File'''” menu and choose “'''Open'''”.  
  
Browse to the directory '''Origin/tools/scilab.'''
+
Browse to the '''directory Origin/tools/scilab.'''
  
 
Choose the file '''test_firmware.sce.'''
 
Choose the file '''test_firmware.sce.'''
  
It will open a '''Scilab''' Code.
+
It will open a '''Scilab''' code.
 
|-
 
|-
|| click on the '''Execute '''
+
|| Click on the '''Execute '''
select''' File''' with '''no echo'''.
+
 
 +
Select''' File''' with '''no echo'''.
  
|| In the menu bar, click on the '''Execute '''option, to execute the code.
+
|| In the '''menu bar''', click on the '''Execute '''option, to '''execute''' the code.
  
Then choose '''File''' with '''no echo'''.
+
Then choose '''File with no echo'''.
  
We see the response of this code as “ans = ”“ok” three times.
+
We see the '''response''' of this code as '''“ans = ”“ok”''' three times.
  
This confirms the working of the '''Arduino-Scilab''' toolbox.
+
This confirms the working of the '''Arduino-Scilab toolbox'''.
 
|-
 
|-
 
|| Show chapters 5 program '''push-button-status.sce'''
 
|| Show chapters 5 program '''push-button-status.sce'''
  
|| Next let us run the '''Scilab''' program in chapter 5. That is, '''Interfacing a Pushbutton.'''
+
|| Next let us run the '''Scilab program''' in chapter 5. That is, '''Interfacing a Pushbutton.'''
  
This program will read the status of the '''pushbutton''' and display it on the GUI.
+
This '''program''' will read the '''status''' of the '''pushbutton''' and display it on the '''GUI'''.
 
|-
 
|-
 
|| Open the file '''Origin/user-code/push/scilab/push-button-status.sce'''
 
|| Open the file '''Origin/user-code/push/scilab/push-button-status.sce'''
 
|| Open the file available at '''Origin/user-code/push/scilab/push-button-status.sce'''
 
|| Open the file available at '''Origin/user-code/push/scilab/push-button-status.sce'''
 
|-
 
|-
|| Click on '''execute'''  
+
|| Click on '''Execute'''  
|| Click on the '''execute''' button.
+
|| Click on the '''Execute''' button.
  
Press the pushbutton in the shield.
+
Press the '''pushbutton''' in the '''shield'''.
  
The GUI in Scilab shows the status of the pushbutton as 1 when it is pressed
+
The '''GUI''' in '''Scilab''' shows the status of the '''pushbutton''' as '''1''' when it is pressed.
  
It shows 0 when it is released.
+
It shows '''0''' when it is released.
 
|-
 
|-
 
|| narration only
 
|| narration only
Line 179: Line 184:
 
|-
 
|-
 
||  
 
||  
|| Next we will see how to run the arduino program in '''Xcos'''.
+
|| Next we will see how to run the '''Arduino program''' in '''Xcos'''.
 
|-
 
|-
 
||  
 
||  
|| Type '''Xcos''' in the editor to launch the Xcos.
+
|| Type '''Xcos''' in the '''editor''' to launch the '''Xcos'''.
 
|-
 
|-
 
||  
 
||  
||Next we will run the code to turn the LED on or off, depending on the pushbutton.
+
||Next we will run the code to turn the '''LED on''' or '''off''', depending on the '''pushbutton'''.
  
 
The code is available in the '''Origin/user-code/push/scilab/led-push-button.zcos'''
 
The code is available in the '''Origin/user-code/push/scilab/led-push-button.zcos'''
Line 191: Line 196:
 
Click on the '''File''' menu and Open the file '''led-push-button.zcos''' as shown.
 
Click on the '''File''' menu and Open the file '''led-push-button.zcos''' as shown.
  
When the user presses the pushbutton, the LED on digital pin 9 of the shield is switched on.
+
When the '''user''' presses the '''pushbutton''', the '''LED''' on '''digital pin 9''' of the '''shield''' is switched '''on'''.
  
When the pushbutton is released, the LED is switched off.
+
When the '''pushbutton''' is released, the '''LED''' is switched '''off'''.
 
|-
 
|-
 
||  
 
||  
Line 200: Line 205:
 
|| '''Points to remember:'''
 
|| '''Points to remember:'''
 
|| Points to remember:
 
|| Points to remember:
* Whenever you plug the '''Arduino Uno board''' into the computer, check for the port.
+
* Whenever you plug the '''Arduino Uno board''' into the computer, check for the '''port'''.
*Then execute the commands required for read-write permission
+
*Then '''execute''' the '''commands''' required for '''read-write permission'''.
*Don’t upload any '''Arduino''' program after uploading the '''FLOSS''' firmware to '''Arduino Uno board.'''
+
*Don’t upload any '''Arduino program''' after uploading the '''FLOSS firmware''' to '''Arduino Uno board.'''
*This would overwrite the '''FLOSS '''firmware.
+
*This would overwrite the '''FLOSS firmware'''.
*Check if the '''Arduino-Scilab '''toolbox is properly running or not.
+
*Check if the '''Arduino-Scilab toolbox''' is properly '''running''' or not.
 
*You have to load the '''Arduino Scilab toolbox '''each time when you launch the '''Scilab'''.
 
*You have to load the '''Arduino Scilab toolbox '''each time when you launch the '''Scilab'''.
 
|-
 
|-
Line 216: Line 221:
 
Summary
 
Summary
 
|| In this tutorial, we learnt about  
 
|| In this tutorial, we learnt about  
*'''Arduino'''-'''Scilab''' toolbox
+
*'''Arduino - Scilab toolbox'''
 
* Interfacing '''Arduino''' with '''Scilab'''
 
* Interfacing '''Arduino''' with '''Scilab'''
 
* Interfacing''' Arduino '''with '''Xcos'''
 
* Interfacing''' Arduino '''with '''Xcos'''

Revision as of 17:55, 22 October 2021

VISUAL CUE NARRATION
Slide 1: Welcome to the Spoken tutorial on Arduino Programming with Scilab and Xcos.
Slide 2:

Learning Objectives

In this tutorial, we will learn about
  • Arduino - Scilab toolbox
  • Interfacing Arduino with Scilab
  • Interfacing Arduino with Xcos
Slide 3:

System requirements

To record this tutorial, I’m using
  • Ubuntu Linux OS version 18.04
  • Arduino Shield and
  • Arduino Uno Board
Slide 4:

Prerequisites

To follow this tutorial, you should go through the below Arduino spoken tutorial.
  • Getting ready for Arduino FLOSS.
Slide 5:

Getting ready for Arduino Floss

In the above tutorial, you will learn
  • How to download the e-book and code files required for the experiments.
  • How to upload and compile Arduino programs in Arduino IDE.
  • About FLOSS Firmware
Slide 6:

About Scilab and Xcos

If you are not familiar with Scilab, go through the Scilab spoken tutorials on this website.

You will learn about:

  • Introduction to Scilab
  • Introduction to Xcos
  • Scilab and Xcos interface and
  • Simulation
Point to the book in the desktop

and open the book

I have downloaded Microcontroller Programming with Arduino, Scilab and Xcos ebook.
Show the relevant pages in the book.
  • Refer to chapter 3 in the book.
  • Follow the steps given for the installation of Arduino IDE and Scilab
  • Installation steps are given for Windows and Linux OS.
  • Xcos comes pre-installed with Scilab. Hence a separate installation of Xcos is not required.
  • The experiments that are covered in the book are tested in Ubuntu Linux 18.04 and Windows 10 OS.
Arduino shield_USB.jpg Connect the Arduino uno board with Arduino shield to the USB port of the computer
Slide:

Points to be noted:

Note the below points:

1. Launch Arduino IDE

2. Check the port

3. Upload the FLOSS firmware

That is, in the Arduino IDE, upload the file available at Origin/tools/floss-firmware/floss-firmware.ino

As discussed in the earlier tutorial the above steps have to be done before proceeding further.

Slide 7:

About -Scilab - ArduinoToolbox

By default, Scilab does not have the capability to communicate with Arduino.
  • All such add-on functionalities are added to Scilab using the toolbox.
  • These functions are required to run various experiments on the Arduino Uno board.
  • It also establishes a serial communication with Arduino.
  • We have created different toolboxes for Windows and Linux OS.
Show the directory in the book The Scilab Arduino toolbox can be found inside the Origin/tools/scilab/windows or Origin/tools/scilab/linux

directory.

First we have to load the toolbox depending upon your OS.

I’ll show you how to load the toolbox in Linux.

Open the terminal

Go to the folder where Scilab is installed

Open the terminal by pressing Ctrl+Alt+T keys.

I have already installed Arduino IDE and Scilab 5.5.2 in my Linux system as specified in the book.

Go to the folder where Scilab is installed as shown and launch the Scilab.

Next we have to change the working directory.

In the File Browser, select the toolbox folder available at Desktop/Origin/tools/scilab/linux

Click on the OK button.

Now the Scilab working directory becomes the toolbox folder.

In the file browser panel, we can see the builder.sce file gets loaded.

This shows that we are in the right directory.

> exec builder.sce Type the command exec builder.sce on the Scilab console.

Next, type the command exec loader.sce. This will load the toolbox.

Note: If you clear the workspace for any reason, you will have to execute this command once again.

We have to run the Scilab script to check whether the firmware is properly installed or not.

It is available at: Origin/tools/scilab/test_firmware.sce

Select Origin/tools/scilab/ test_firmware.sce.

In the Scilab console, type editor and press the Enter key.

Click on the “File” menu and choose “Open”.

Browse to the directory Origin/tools/scilab.

Choose the file test_firmware.sce.

It will open a Scilab code.

Click on the Execute

Select File with no echo.

In the menu bar, click on the Execute option, to execute the code.

Then choose File with no echo.

We see the response of this code as “ans = ”“ok” three times.

This confirms the working of the Arduino-Scilab toolbox.

Show chapters 5 program push-button-status.sce Next let us run the Scilab program in chapter 5. That is, Interfacing a Pushbutton.

This program will read the status of the pushbutton and display it on the GUI.

Open the file Origin/user-code/push/scilab/push-button-status.sce Open the file available at Origin/user-code/push/scilab/push-button-status.sce
Click on Execute Click on the Execute button.

Press the pushbutton in the shield.

The GUI in Scilab shows the status of the pushbutton as 1 when it is pressed.

It shows 0 when it is released.

narration only Likewise practice the experiments in Scilab with other components as specified in the book.
Next we will see how to run the Arduino program in Xcos.
Type Xcos in the editor to launch the Xcos.
Next we will run the code to turn the LED on or off, depending on the pushbutton.

The code is available in the Origin/user-code/push/scilab/led-push-button.zcos

Click on the File menu and Open the file led-push-button.zcos as shown.

When the user presses the pushbutton, the LED on digital pin 9 of the shield is switched on.

When the pushbutton is released, the LED is switched off.

Do the otherXcos experiments as specified in the book.
Points to remember: Points to remember:
  • Whenever you plug the Arduino Uno board into the computer, check for the port.
  • Then execute the commands required for read-write permission.
  • Don’t upload any Arduino program after uploading the FLOSS firmware to Arduino Uno board.
  • This would overwrite the FLOSS firmware.
  • Check if the Arduino-Scilab toolbox is properly running or not.
  • You have to load the Arduino Scilab toolbox each time when you launch the Scilab.
With this we come to the end of this tutorial. Let us summarize.

Slide 8:

Summary

In this tutorial, we learnt about
  • Arduino - Scilab toolbox
  • Interfacing Arduino with Scilab
  • Interfacing Arduino with Xcos
Slide 10:

(About Spoken Tutorial Project)

The video at the following link,summarizes the Spoken Tutorial project.

Please download and watch it.

Slide 11:

(About Spoken Tutorial Project)

The Spoken Tutorial Project Team conducts workshops and gives certificates.

For more details, please write to us.

Slide

Forum questions:

Please post your timed queries on this forum.
Slide: Acknowledgement Spoken Tutorial project is funded by the Ministry of Education (MoE), Govt. of India.
This is Nirmala venkat from Spoken Tutorial Project, IIT Bombay signing off.

Thanks for joining.

Contributors and Content Editors

Nancyvarkey, Nirmala Venkat