Experiment #6 ECE 44
Experiment #6 ECE 44
ECE 44
Experiment # 6
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
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.).
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.
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
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
V. Procedure
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
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
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.
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