0% found this document useful (0 votes)
65 views14 pages

Experiment #6 ECE 44

The document discusses using Scilab XCOS to control an Arduino for data acquisition and system control applications. It describes how to install the necessary toolboxes and configure the connection between Scilab and Arduino. Details are provided about using XCOS to design control systems and implement them on Arduino to monitor sensors and control actuators in real-time.

Uploaded by

cpoloy2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views14 pages

Experiment #6 ECE 44

The document discusses using Scilab XCOS to control an Arduino for data acquisition and system control applications. It describes how to install the necessary toolboxes and configure the connection between Scilab and Arduino. Details are provided about using XCOS to design control systems and implement them on Arduino to monitor sensors and control actuators in real-time.

Uploaded by

cpoloy2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Republic of the Philippines

State College and Universities


ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

SCILAB XCOS Arduino Controller

ECE 44
Experiment # 6

Laboratory Experiment Submitted to


Ramon A. Alguidano, Jr.,
DT, BSECE, MEngr., D.I.T., RECE, PECE, ANZSCO PE
Iloilo Science and Technology University

Paul Sherwin Cala-or


Niels Gzenric Po
BSECE 3-A1

April 19, 2024


Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

I. Introduction and Basic Theory

Scilab is open-source software for numerical computation, providing a powerful


computing environment for engineering and scientific applications (“Scilab & Arduino
for low-cost data acquisition | Scilab,” n.d.). It has been used in various scientific and
engineering fields for data analysis, algorithm development, modeling, and simulation.
Scilab includes hundreds of mathematical functions, high-level programming languages,
and easy-to-use data structures.

Figure 1.0: Scilab console

Xcos is a graphical editor within Scilab that allows you to design hybrid
dynamical systems models (“Xcos for beginners – tutorial | Scilab,” n.d.). Models can be
designed, loaded, saved, compiled, and simulated. It is a tool for modeling and simulating
explicit and implicit dynamical systems, including continuous and discrete sub-systems.
Xcos is packaged with a rich set of predefined blocks that can be used to construct
models of complex systems.

Figure 1.1: Scilab XCOS tab Figure 1.2: XCOS palette browser
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

Arduino is a popular platform for creating interactive electronic objects. It is a


hardware and software ecosystem that enables reading from and writing to various
sensors and actuators. Arduino boards feature digital and analog input/output (I/O) pins
that can interface with different expansion boards (shields) and circuits. The Arduino IDE
(Integrated Development Environment) is a crucial tool for programming Arduino
boards. It provides a feature-rich code editor, compiler, programmer, serial console, and
serial plotter, making it simple and easy to use for developing projects with Arduino. The
IDE allows users to write sketches (programs) in a language derived from C/C++,
compile the code into machine code, and upload it to the Arduino board for execution.

Figure 1.3: Arduino board and Arduino IDE

Additionally, the IDE supports various versions like Arduino IDE 1.x and
Arduino IDE 2.x, offering different GUIs and additional features such as auto code
completion. Installing the Arduino IDE is straightforward, involving downloading the
installer for the specific operating system, agreeing to the license agreement, selecting the
installation location, and connecting the Arduino board to the computer for automatic
driver installation. By selecting the correct board and serial port in the IDE, users can
effectively program and interact with Arduino boards to create a wide range of electronic
projects.

The Scilab Xcos Arduino Controller is a way to use the Arduino platform for data
acquisition and control tasks. It is particularly useful in a laboratory setting where you
might need to collect data from various sensors and control different experiment elements
(“Scilab & Arduino for low-cost data acquisition | Scilab,” n.d.).
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

To configure the Arduino Uno with Scilab Xcos, you first need to download and
install the Arduino toolbox and the Serial communication toolbox from ATOMS (“Scilab
& Arduino for low-cost data acquisition | Scilab,” n.d.). ATOMS (AuTomatic mOdules
Management for Scilab) is the repository for packaged extension modules (“Tool
Boxes”). Once installed, you can establish a connection between Scilab and Arduino. It is
done through the serial port (“Scilab & Arduino for low-cost data acquisition | Scilab,”
n.d.).

Figure 1.4: ATOMS tab Figure 1.5: ATOMS modules

Regarding Hardware, you can easily link your sensors to the Arduino’s analogue
and digital I/Os. For instance, if you are setting up a temperature acquisition system, you
might connect a temperature sensor to one of Arduino’s analogue inputs. The sensor will
signal the Arduino and then relay that information to Scilab (“Temperature monitoring
Tutorial with Scilab/Xcos and Arduino,” n.d.).

On the software side, you can design your motor controller in Xcos. It allows for
real-time Hardware in the Loop (HIL) simulations (“Scilab & Arduino for low-cost data
acquisition | Scilab,” n.d.). A tutorial explains how to apply a PID Controller with Xcos
and Arduino. This powerful feature allows you to design complex control systems within
the Xcos environment and then implement them on the Arduino platform.

Figure 1.6: Arduino block diagram in Xcos


Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

With everything set up, you can now run your experiment. Data can be sent to and
received from the Arduino in real time, allowing for dynamic control of your system
(“Scilab & Arduino for low-cost data acquisition | Scilab,” n.d.). It makes the Scilab Xcos
Arduino Controller a powerful tool for conducting laboratory experiments.

Remember, the key to using the Scilab Xcos Arduino Controller effectively is
understanding how each component — Scilab, Xcos, and Arduino — works and how
they can work together. With this understanding, you can design and run various
experiments.

II. Objectives

The purpose of this laboratory experiment is to:

1. Research and understand SCILAB XCOS integration with Arduino.


2. Execute physical modifications to add feedback terminal in the servo motor
3. Model creation using SCILAB XCOS.
4. Configure servo motor control and position mapping.
5. Simulate and observe the resulting graph produced by the servo motor’s arm
shifting.
6. Explore the Real-World by thinking of one real application.

III. Equipment/Tools/Materials/Components Needed

a. Software Requirements:
● Scilab on Windows 32 or 64 bits (Version 6.1.1 - latest)
● Arduino IDE (Version 1.8.19 - latest)
- toolbox_arduino_v5.ino
https://atoms.scilab.org/toolboxes/arduino/1.8
- I2Cdevlib
https://github.com/jrowberg/i2cdevlib

b. Hardware Requirements:
● Desktop Computer/Laptop
● SG90 Servo motor (180 degrees)
● Connecting Wires
● Arduino Uno w/ usb cable
● Extra tools for modification (e.g. soldering iron & lead)
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

IV. Diagram

Figure 2.0: Parts of the Servo


Motor

V. Procedure

A. Integration of Scilab and Arduino:

1. Research and comprehend the configuration of Arduino Uno using SCILAB XCOS to
control an actual system.
- Refer to the Scilab-Arduino manual for setup and configuration details​​.
https://drive.google.com/file/d/1-8a18Fk6QvxppSb2BXlA_2xzcG7L29ch/view?u
sp=sharing
2. Develop a block diagram model in SCILAB XCOS for controlling the digital and
analog pin inputs and outputs of the Arduino Uno.
- Use the SCILAB XCOS interface to drag and drop blocks from the Arduino
folder in the palette window. Configure these blocks to control the digital and
analog pins of the Arduino Uno​​.
3. Create a block diagram model in SCILAB XCOS to control a servo motor connected
to the Arduino Uno using PWM mode.
- Integrate the appropriate blocks to generate PWM signals for controlling the servo
motor.
4. Connect the servo motor position encoder to the analog input of the Arduino Uno.
- Ensure the servo motor’s position encoder output is connected to one of the
analog input pins on the Arduino Uno.
5. Map the servo motor position from 0 to 180 degrees based on the analog read values
ranging from 0 to 1023.
- Implement a mapping function in SCILAB XCOS to convert the analog input
values (0-1023) to servo positions (0-180 degrees).
6. Modify the servo motor to add a fourth terminal for position feedback.
- Physically alter the servo motor if necessary, to include a feedback terminal for
position data.
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

7. Connect this terminal to the Arduino Uno’s analog input.


- Connect the newly added feedback terminal to one of the Arduino Uno’s analog
input pins.
8. Simulate the block diagram model and set a predetermined position for the servo
motor.
- Use SCILAB XCOS to simulate the block diagram and control the servo motor to
move to a specified position.
9. Compare the predetermined position with the actual position of the servo motor arm
and analyze any discrepancies.
- Utilize feedback from the position encoder to compare the target position with the
actual position and adjust the control algorithm as needed.
10. Design and simulate a block diagram model for a real-world application using the
SCILAB XCOS and Arduino setup.
- Develop and test a comprehensive model that integrates the SCILAB XCOS and
Arduino for a practical application, such as a robotic arm or an automated system.

B. Configuration and Setup:

1. Install Scilab and Required Modules:


- Download and install Scilab.
- Use the ATOMS module manager in Scilab to install the Arduino, Fuzzy Logic
Toolbox, and Serial Communication modules​​.
2. Set Up Arduino IDE:
- Install the Arduino IDE and connect the Arduino Uno board to your PC.
- Check the port used in the Arduino IDE.
- Copy the I2Cdev and MPU5060 folders from the downloaded i2cdevlib file to the
libraries folder in the Arduino directory​​.

Figure 3.0: Arduino IDE version 1.8.19 Figure 3.1: Installed Arduino libraries folder
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

3. Prepare Arduino Sketch:


- Open the “toolbox_arduino_v5.ino” file in the Arduino IDE.
- Verify and upload the program to the Arduino Uno​​.

Figure 3.2: Arduino IDE sketchbook

4. Create and Simulate System in SCILAB XCOS:


- Open Xcos in Scilab and create a system model by dragging and connecting
blocks.
- Include the Arduino board block diagram from the palette window and configure
it according to the correct port settings​​.
- Execute the model by clicking the start button in the Xcos window. Ensure the
Arduino board is connected properly and check for a blinking onboard LED to
confirm successful configuration​​.

Figure 3.3: Configured Arduino controller block diagram


Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

VI. Results and Discussions

Figure 4.0: XCOS diagram arduino uno’s analog and PWM pin control

The block diagram shows that the servo motor is connected to an Arduino Uno
board. The signal pin of the servo is tied to the Arduino's PWM pin, allowing for precise
control of the servo motor's position. The positive power pin of the servo is connected to
the Arduino's 5V supply, and its ground pin is connected to the Arduino's ground. This
setup ensures that the servo motor receives the necessary power for operation.

Additionally, a potentiometer is connected to one of the Arduino Uno's analog


pins. It allows for manual control of the servo motor's position, essentially testing its
responsiveness.

Figure 4.1: Manual arm shifting graph of the servo motor until reaching its peak

The graph represents the output waveform of the servo motor arm's movement
over time. The highest peak in the graph is at the point (8.409, 683.99), which indicates
the maximum extension or rotation of the servo motor arm, possibly around 180 degrees.
This peak is higher than any other point on the graph, indicating the maximum
displacement achieved in this experimental setup.
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

Other notable but lower peaks occur at (1.797, 682.876) and (4.5, 681.525). These
peaks represent significant shifts in the servo motor arm's position, but they do not reach
the height of 683.99, seen at 8.409 on the X-axis, which is the maximum movement
achieved by the servo motor arm.

Figure 4.2: XCOS diagram arduino uno’s analog and PWM pin control at 90°

The XCOS diagram provides a detailed view of the control system used to operate
the servo motor connected to an Arduino Uno. The system is designed to move the servo
motor to a 90-degree position using both direct input and feedback from the actual
position of the servo.

In this setup, the servo motor is connected to the Arduino Uno's PWM pin for
precise control of the motor's position. A constant signal block with a value of "90"
represents the target position for the servo motor. This signal is sent directly to a
summing junction and also through a feedback loop involving an H-bridge symbol before
reaching the same summing junction. This feedback loop allows the system to adjust the
motor's movement based on its actual position, which is read through an "Analog READ"
block connected to one of the Arduino Uno's analog pins.
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

Figure 4.3: Response of the arm shifting of the servo motor at 90°

The graph shows the servo motor's response to this control system. It reveals an
initial oscillation in the output before it stabilizes around the target position. This initial
movement suggests an overshoot or undershoot as the servo adjusts to match the desired
angle. The gradual stabilization towards the target position highlights the role of the
feedback mechanism in correcting the motor's movement and achieving accuracy.

Figure 4.4: Response of the manual arm shifting of the servo motor at 90°

The graph represents the response of a servo motor that was manually distorted
and then commanded to return to a constant position of 90 degrees. The waveforms,
labeled as ‘Curve1’, ‘Curve2’, and ‘Curve3’, show the servo motor’s response to this
control system.

Each curve shows an initial oscillation, indicating the servo motor’s adjustment to
match the desired angle after being manually distorted. After these initial oscillations, all
curves stabilize around the target position of 90 degrees. This behavior is typical for
control systems like servos, where precision positioning is required, even after a manual
disturbance.
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

VII. Observations
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

VIII. Conclusion
IX. Recommendations
X. Simulations
XI. Design
Republic of the Philippines
State College and Universities
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
Burgos Street, La Paz, Iloilo City
College of Engineering and Architecture

References

Scilab & Arduino for low-cost data acquisition | Scilab (n.d.). Scilab. Retrieved from
https://www.scilab.org/tutorials/scilab-arduino-for-low-cost-data-acquisition
Temperature monitoring Tutorial with Scilab/Xcos and Arduino (n.d.). Scilab. Retrieved
from
https://www.scilab.org/sites/default/files/Scilab%20Arduino%20Temperature%20
monitoring%20Tutorial.pdf
Xcos for beginners – tutorial | Scilab (n.d.). Scilab. Retrieved from
https://www.scilab.org/sites/default/files/Xcos_beginners.pdf

You might also like