Programming The Attitude Control of A CubeSat
Programming The Attitude Control of A CubeSat
Document:
Report
Author:
Yilmaz, Alev
Director/Co-director:
Degree:
Examination session:
Autumn 2022/23
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Abstract
The project, which is an update of the previous ones, consists of a laboratory prototype for simulations with
hardware in the loop, where the hardware is the CubeSat prototype. This project is developed within the
PLATHON project, directed by Javier Gago, from the Department of Electronics of the UPC ESEIAAT.
The investigation, design, and implementation of an attitude control system for a 1U CubeSat are the main
topics of this thesis. A CubeSat is an orbiting satellite that was developed in response to the need for
ever-smaller spacecraft to be designed, built, and operated. It must be noted that a 1U CubeSat needs three
to five years of labor and costs about 250 000 euros to create and launch into space.
The software used for its implementation was created with the Arduino IDE, the experimental representations
were done in MATLAB, and the new motor driver was programmed in ESCON Studio to collect a portion of
the results.
The final design is geared toward accurately executing three distinct maneuvers: first, accurately measuring
the CubeSat’s orientation; second, assigning current to the motor to enable movement of the reaction wheel
in both directions (CW and CCW); and third, implementing PID controllers, which enable precise orientation
and speed.
This goal has been accomplished through the development of the ADCS hardware, a comprehensive explanation
of the attitude control software, and experimental studies.
The adoption of a new MAXON brand motor in this thesis serves as an enhancement since it offers more
accuracy and stability. The same-brand motor driver being utilized has a current regulator that increases the
results’ precision.
Since the controllers were correctly implemented and a precise orientation was obtained with nearly imper-
ceptible stationary faults, the findings were satisfactory.
I
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Resumen
El proyecto, que es una actualización de los anteriores, consiste en un prototipo de laboratorio para simulaciones
con hardware in the loop, donde el hardware es el prototipo CubeSat. Este proyecto se desarrolla dentro del
proyecto PLATHON, dirigido por Javier Gago, del Departamento de Electrónica de la UPC ESEIAAT.
El software utilizado para su implementación se creó con Arduino IDE, las representaciones experimentales
se realizaron en MATLAB y el nuevo controlador de motor se programó en ESCON Studio para recopilar
una parte de los resultados.
El diseño final está orientado a ejecutar con precisión tres maniobras distintas: primero, medir con precisión
la orientación del CubeSat; segundo, asignar corriente al motor para permitir el movimiento de la rueda de
reacción en ambas direcciones (CW y CCW); y tercero, implementar controladores PID, que permiten una
orientación y velocidad precisas.
Este objetivo se ha logrado mediante el desarrollo del hardware ADCS, una explicación completa del software
de control de actitud y estudios experimentales.
La adopción de un nuevo motor de la marca MAXON en esta tesis sirve como una mejora ya que ofrece más
precisión y estabilidad. El controlador de motor de la misma marca que se está utilizando tiene un regulador
de corriente que aumenta la precisión de los resultados.
Dado que los controladores se implementaron correctamente y se obtuvo una orientación precisa con errores
estacionarias casi imperceptibles, los resultados fueron satisfactorios.
II
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Contents
1 Introduction 1
1.1 Aim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Justification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
III
CONTENTS CONTENTS
5 Experimental Results 41
5.1 Mode 1: Actual Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.2 Mode 2: Assigning current to RW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.2.1 Mode 2: Experiment 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.2.2 Mode 2: Experiment 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2.3 Mode 2: Experiment 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3 Summary of the Experimental Results of Mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.4 Mode 3: Positioning RW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6 Budget summary 48
7 Environmental Analysis 49
8 Conclusions 50
8.1 Further Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
References 52
D Datasheets 73
D.1 Motor Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
D.2 MAXON Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
D.3 Flex-Print Connector to PCB-screw clamps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
IV
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
List of Figures
V
LIST OF FIGURES LIST OF FIGURES
VI
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
List of Tables
3.1 Wiring between motor driver and MAXON motor (Source: Own) . . . . . . . . . . . . . . . . 16
3.2 Wiring between MPU9250 and Arduino, Calibration (Source: Own) . . . . . . . . . . . . . . 19
3.3 Wiring for Bluetooth module configuration (Source: Own) . . . . . . . . . . . . . . . . . . . . 20
3.4 Wiring to test devices (Source: Own) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.5 Wiring between motor driver and MAXON motor (Source: Own) . . . . . . . . . . . . . . . . 28
VII
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
List of abbreviations
PID: Proportional-Integral-Derivative
BAT: Battery
VIII
LIST OF TABLES LIST OF TABLES
I/O: Input/Output
SP: SetPoint
IX
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Chapter 1
Introduction
1.1 Aim
Primarily, this work is part of the PLATHON project, which is an integrated simulation platform with
hardware in the loop of space missions for communications between ground stations and nanosatellites, where
these missions can be designed, analyzed, and evaluated by a constellation of CubeSats in LEO orbits.
This project is centered on the implementation of a 1DoF attitude control of a CubeSat laboratory prototype
based on a reaction wheel from a certain angle transmitted wirelessly to an electronic board based on the
STM32 microcontroller, in particular, a development board known as Blue Pill.
It should be noted that this work is based on Daniel Castillo Bonillo’s [1], Adrià Pérez Fernández’s [2],
Yi Qiang Ji Zhang’s [3], and Joan Serrano’s [4] previous work. This project’s major goal is to add new
innovations, such as a new motor to drive the wheel more steadily, precisely, and with less vibration. This
goal requires a new motor driver as well as the development of new control algorithms.
1
1.2. SCOPE CHAPTER 1. INTRODUCTION
1.2 Scope
In order to adequately justify and document the prototype electronic advancements, the project’s scope is
based on the delivery of the following documents:
• Final Project Report: In this document, the CubeSat mechanism’s structure is discussed, and each step
that was taken is supported. Additionally, the required electronic system documentation, including
the technical files and all the references and sources utilized, may be seen. Along with the precise
requirements, the project’s timetable for completion (schedule), thorough budget, and conclusion drawn
from everything described previously will all be followed.
• Assembly of the new ADCS board with MAXON motor in the perfboard: This document will provide
detailed descriptions of all the electrical connections made as well as diagrams of them. The importance
of this document lies in the prospect of using wired connections in the future if a hardware connection
has to be changed, as well as in making wired connections easier to understand.
• Code implemented for the attitude control system: Because of the new motor driver, the offered code
will be an improvement over previous works and will include new algorithms. This code is implemented
for the attitude control system. The lines of code will be annotated as much as possible for the reader’s
benefit.
• Instructions for setting the Bluetooth module: In order to use the HC06 module’s properties, the HC05
Bluetooth module has to be set up first. Therefore, it will be feasible to comprehend the Bluetooth
connection for configuration as well as the many AT modes in this part.
On the other hand, since the CubeSat’s mechanical components won’t be improved—only its electronics
will—this project won’t include any blueprints for the components and assemblies.
2
1.3. REQUIREMENTS CHAPTER 1. INTRODUCTION
1.3 Requirements
The necessary conditions for the suggested solution to be deemed ideal are listed in the following list:
• The developed code, which includes IMU reading and coarse positioning, is important for future
improvement with the inclusion of fine positioning to achieve improved precision in the attitude control
of the subsystem, which is critical for the CubeSat’s final behavior.
• The final prototype, which must be built with a new MAXON motor, is also required in order to
perform the necessary tests and make the necessary adjustments for continual development.
• The programming language used in this project is Arduino and its various libraries; it should be noted
that it is free software that corresponds to all CubeSat implementations done to date.
• In order to perform significant modifications in this project, it is also necessary to have prior knowledge
of electronics and space, as well as the ability to search for appropriate material in the event of a lack
of knowledge on any subject.
3
1.4. JUSTIFICATION CHAPTER 1. INTRODUCTION
1.4 Justification
As mentioned in the first section, this project, called PLATHON, is part of a hardware simulation project in
the loop of space missions with cube satellites (CubeSats), whose structure is scalable in cubes with a 10 cm
edge and a mass of less than 1.33 kg [5], in which they can design, analyze, and evaluate communication
missions between terrestrial points via a constellation of CubeSats in LEO orbits.
The orbital propagators are available in MATLAB and the NASA OpenSatKit free software package, from
which simulator 42 may be used.
The attitude determination and control subsystem is used in the majority of space missions. Most space
missions have attitude requirements in order to properly operate their payloads; these requirements might
range from a few degrees of pointing precision for low-cost communications missions to a fraction of an
arcsecond for complex research missions [6].
This work seeks to program an attitude control (CubeSat orientation) with a setpoint angle that would
provide an attitude control electronic board based on the STM32 microcontroller to either the MATLAB
simulator or at 42, wirelessly. The plate is a component of the construction of a CubeSat, which will float
and spin freely and without friction on a compressed air platform. As a result, the CubeSat should have to
follow the turns of the setpoint angles suggested by the simulator. Furthermore, the CubeSat must provide
the real orientation data, as measured by an IMU built into the attitude board, to the CPU running the
MATLAB or 42 simulations, so that it may be depicted visually.
However, one of the limitations of this study is that it only considers the azimuthal angle because the project
is in its preliminary phase with a single reaction wheel, but the project is aimed at having three wheels and
three magnetorquers, and for the time being, missions are being simulated in which the elevation angle is
assumed to be perfectly controlled and only azimuthal movements are made.
The angle of inclination will be assumed to always be right relative to the orbit. That is, the CubeSat will
keep the upper and lower faces parallel to the Earth and to the direction of the orbit, while the lateral faces
will be perpendicular to the Earth and to the direction of the orbit, depending on the translation rate of the
CubeSat in orbit. The predicted movements will be in the direction of the azimuth. Because the lower half is
constantly parallel to the Earth, the communication antenna is always correctly aligned. Additionally, the
side faces can vary in such a way that their antennas are confused relative to CubeSats orbiting in the same
orbit and placed directly in front of and behind them.
4
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Chapter 2
2.1 CubeSats
Because of their small size, CubeSats are classified as nanosatellites. These nanosatellites with standard
dimensions of 10cm x 10cm x 10cm are known as CubeSat ”1U”, or CubeSat ”1 Unit”. There have also been
”2U” (20x10x10 cm), ”3U,” and ”6U” CubeSats built and launched. CubeSats have a unit weight of less
than 1.33kg. This nanosatellite is notable for its utility and low cost [7].
CubeSats were created in 1999 by CalPoly (California Polytechnic State University) and Stanford University
to promote and develop the requisite capabilities for the production of small satellites for LEO missions. The
first CubeSats were launched on a Russian Eurockot in June 2003, and by 2008, around 75 CubeSats had
been placed in orbit [5].
Due to their small size and inexpensive cost of launch, CubeSats are frequently utilised in low Earth orbit for
5
2.1. CUBESATS CHAPTER 2. STATE OF THE ART
tasks including data collection of various types, remote sensing, and communications. It orbits the Earth
approximately every 90 minutes in low-Earth orbit, which has a height between 160 km and 2,000 km.
Typically, a Nanoracks CubeSat Deployer (NRCSD) or Poly Picosat Orbital Deployer (P-POD) is used to
launch CubeSats into orbit.
• For small satellites launched from the International Space Station (ISS), NRCSD is a self-contained
CubeSat deployer system. The Japanese Experiment Module (JEM) of the ISS serves as a staging area
for operation of the NRCSD, which launches within the Pressurized Cargo Module (PCM) of ISS cargo
resupply vehicles. Prior to launch, the NRCSD is connected with payloads at a NanoRacks facility and
physically and electrically separates CubeSats from cargo resupply vehicles, the International Space
Station, and its crew [8].
Any combination of 1U, 2U, 3U, 4U, or 5U CubeSats up to a maximum capacity of 6U, or a single 6U
CubeSat in the 1x6x1U configuration, may be accommodated by the NRCSD.
• The Poly Picosatellite Orbital Deployer (P-POD), a standardised deployment tool, ensures that all
CubeSat designers follow the same physical requirements. With its tubular form, the P-POD can hold
deployable gear that is up to 340.5mm by 100mm by 100mm in size.
The P-POD, which also serves as a conduit between the CubeSats and the launch vehicle, can carry
three ordinary 1U CubeSats. The P-POD is a rectangular box with an alodined aluminium door and
spring mechanism. Once the release mechanism of the P-POD door is activated, the CubeSats are
deployed by the main spring, sliding on the rails of the P-POD [9].
6
2.2. ATTITUDE DETERMINATION AND CONTROL SYSTEM CHAPTER 2. STATE OF THE ART
7
2.2. ATTITUDE DETERMINATION AND CONTROL SYSTEM CHAPTER 2. STATE OF THE ART
2.2.1 Sensors
Sensors collect data that may be used to detect orientation. Sensors are getting increasingly precise as
technology improves.
• Solar sensors are light detectors that detect visible or infrared light and measure one or two angles
between their mounting base and incident sunlight. The fundamental issue with these sensors is that
they require clear fields of vision, and most low-Earth orbits contain eclipse periods [11].
• Star sensors can function as scanners or trackers. On rotating spacecraft, for example, scanners are
utilised. Light from various stars passes through numerous slits, and the vehicle’s attitude can be
determined after several star crossings.
Star trackers, on the other hand, are employed on three-axis stabilised spacecraft to watch one or more
stars and obtain two- or three-axis attitude data. Using a star catalogue, internal processing generates
a three-axis attitude.
The star cameras, however, may not function correctly if the spacecraft rotates too rapidly. Another
issue is that star sensors are susceptible to being obscured by the Sun, Moon, planets, and so on.
Furthermore, these sensors are too large for CubeSat missions [11].
• Horizon sensors, also known as Earth sensors, are infrared devices that detect the difference in
temperature between deep space and the Earth’s atmosphere, showing the direction of the Earth’s
centre by measuring the local horizon line. Typical horizon sensor accuracies range from 0.1 to 0.25
degrees, with certain applications nearing 0.03 degrees [11].
• Magnetometers are sensors that detect the magnitude and direction of the Earth’s magnetic field.
The magnetometer can identify the spacecraft’s attitude in relation to the local magnetic field; this
8
2.2. ATTITUDE DETERMINATION AND CONTROL SYSTEM CHAPTER 2. STATE OF THE ART
information is used with magnetic field models and orbit data to estimate the spacecraft’s attitude in
relation to Earth. Its precision, however, is not as strong as that of star or horizon sensors [11].
• Aside from being utilised as high-precision navigation devices, GPS receivers may also be used to
calculate attitude. The differential signals from the several antennas can be used to estimate attitude if
a spacecraft is large enough to position many antennas far enough apart. Unfortunately, the separation
of the antennas limits its development [11].
• Gyroscopes are inertial sensors that measure and maintain angular velocity and orientation. Gyroscopes
are getting more accurate and lower in mass and size as technology develops. Individual gyroscopes
offer one or two axes of information and are frequently combined as an inertial reference unit (IRU) for
a full three axes and, in certain cases, full redundancy. Moreover, IRUs with additional accelerometers
for position and velocity sensing are referred to as inertial measurement units (IMUs) [11].
The control algorithm’s outputs are the commands to the actuators required to attain or maintain the
reference attitude. Following that, the various actuators that have been employed will be explained.
• Reaction Wheels: When the reaction wheels turn, the satellite rotates in the opposite way. This is
because angular momentum is conserved. These may revolve in either direction and each wheel has one
control axis. The reaction wheels’ nominal operating point is close to zero. If the disturbances have a
secular component, the wheels collect angular momentum. In these instances, the wheel’s turning speed
deviates from its nominal value. When this happens, they must be unloaded from the accumulated
momentum. A second magnetic or propulsive actuator is required to compensate for the impulse
discharge without altering the satellite’s dynamics [13].
• Moment Wheels: Moment wheels, on the other hand, constantly rotate at high speeds and act by
raising or lowering that speed. Two axes of gyroscopic stiffness are provided by impulse, and torque
may be regulated to vary orientation around the axis of rotation [13].
• Control Moment Gyros (CMG): CMGs are gimbale wheels that rotate at a constant speed and can
be single or double. We can generate a large output torque by spinning the gimbale shaft, the magnitude
of which depends on the rotor speed and the gimbale rotation speed. To avoid wheel saturation, CMG
requires sophisticated control rules and precise boost management. Furthermore, they have a shorter
life and are more costly than other actuators. They are utilised when fine control is still necessary for
high torque situations [11].
• Magnetic torques: Magnetic torques are magnetic coils, which are electromagnets intended to create
magnetic dipole moments of a particular magnitude. Three orthogonal torquers deployed on a spacecraft
may generate a magnetic dipole of any direction and magnitude up to the torquers’ strength. The
magnetic dipole can be modified. The torque produced, however, is determined by the magnetic field’s
orientation [11].
9
2.2. ATTITUDE DETERMINATION AND CONTROL SYSTEM CHAPTER 2. STATE OF THE ART
• Thrusters: Due to its dual function for altering orbital parameters, thrusters are arguably the most
commonly flown attitude actuators. They are employed by spacecraft that must conduct orbital
manoeuvres. The thrusters are the most adaptable, but they require fuel to operate, commonly
hydrazine, and once depleted, the mission is over. This approach involves releasing gas at high velocity
in an asymmetric manner to generate momentum but not net thrust [13].
The controller’s goals are to take input from sensors and interpret it to identify the orientation, compute the
target’s attitude, and decide the rotations to perform for each axis. The ADCS will then transmit commands
to the actuator to adjust the CubeSat’s attitude if the OBC (On Board Computer) and EPS (Electrical
Power Supply) subsystems allow it [10].
On the one hand, the On Board Computer, or OBC, is the brain of the satellite and performs a variety of
functions, including directing all operations, giving instructions to the various modules, and receiving and
storing data from the CubeSat before sending it to Earth via the TCS (Telecommunications System) error
handling process [10].
On the other hand, the Electrical Power Supply’s or EPS’s, duties include producing, storing, and
distributing the energy that the solar panels generate. The EPS of the CubeSat is composed of three modules:
the PV (photovoltaic panel), the BAT (battery), and the PCC (power control circuit) [10].
The hardware component known as the ADCS interface sends power from the EPS subsystem to the actuators,
as well as the signal received from the sensors to the microcontroller. The purpose of the interface module is
to maintain strong communication with and interact with other satellite systems by sending data [10].
Furthermore, the ADCS interface is the one that sends the required currents to the motors of the reaction
wheels or magnetorquers based on the control signals provided by the microcontroller.
10
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Chapter 3
In this chapter, each part of the system hardware will be detailed, to later present the final prototype achieved.
This includes the explanation of each of the components used, which are the motor driver, the IMU, the
communication device, and the Bluepill microcontroller.
Figure 3.1: Module 24/2, Servo Controller, P/N 466023 (Source: [14])
The servo motor, on the other hand, is a model EC 20 flat 20 mm, brushless, 5 Watt, with Hall sensors, and
has the part number 351006 (Figure 3.2, Appendix D.2). A servo motor is a type of rotary actuator or motor
11
3.1. MAXON MOTOR DRIVER CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
that offers exact control over acceleration, speed, and angular position—features that a regular engine does
not. In essence, it combines a conventional motor with a sensor to provide position information [15].
Figure 3.2: EC 20 flat Ø20 mm, brushless, 5 Watt, with Hall sensors (Source: [16])
The transition from a stepper motor to a different type of motor is an improvement above what has been done
so far. Servo motors are a considerably better controller of positional precision, which explains this change.
In addition, servo motors have higher top speeds and steeper acceleration and braking ramps than stepper
motors. It’s also crucial to know that servo motors have the benefit of allowing torque to be controlled in
an application, whereas stepper motors operate at maximum torque. But the servo motor’s lower economic
efficiency is one of its main drawbacks [17].
Servo motors are used often because they are powerful and effective despite being small. In fact, servo motors
are a set of certain components coupled with an AC or DC motor. The ESCON 24/2 module has three
working modes that fulfil the strictest specifications: speed control (closed loop), speed control (open loop),
and current control. This module offers broad analogue and digital I/O capability and is intended to be
controlled by an analogue value [14]. The work mode utilised in this project is configured using ”ESCON
Studio,” which is the current control, see Figure 3.3.
12
3.1. MAXON MOTOR DRIVER CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
Furthermore, only digital inputs have been setup using the ESCON application (Figure 3.4); the first digital
input is configured to be the setpoint value PWM (Figure 3.5), and the second digital input is set to be the
enable with the logic high level (Figure 3.6).
13
3.1. MAXON MOTOR DRIVER CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
Moreover, a fundamental component of servo motors is the encoder, which serves as a sensor and provides
speed and position data. The controller receives the end position and compares it to the start position input;
if there is a mismatch, the motor runs to the right position [15]. In this project, a Hall effect encoder is
employed as a feedback mechanism in a brushless servo system to provide information for the amplifier to
electrically control the motor. To create switching signals, the device employs a magnetic wheel and Hall
effect sensors. The accessory utilised is the Adapter 11-pole flexprint connection to 8-pole screw terminal
with the Part Number 220300 (Figure 3.7, Appendix D.3) to connect the motor driver to the MAXON motor.
14
3.1. MAXON MOTOR DRIVER CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
Figure 3.7: Adapter 11-pole flexprint connector to 8-pole screw terminal (Source: [18])
To conclude this section, the Figure 3.8 and the Table 3.1 are included below that indicate how the wiring
between the MAXON motor and the motor driver would appear if the technical specifications in the appendix
to each of them were followed.
Figure 3.8: Wiring between motor driver and MAXON motor (Source: Own)
15
3.2. IMU CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
Table 3.1: Wiring between motor driver and MAXON motor (Source: Own)
Accordingly, it is necessary that the battery provide between +10 and +24V, or else the device will not
operate. Figure 3.8, on the other hand, shows a little supplementary circuit constructed by a fuse, a diode,
and a capacitor to safeguard the MAXON components, as specified in its technical sheet.
Consider that this circuit would not function properly since it is merely a representation of how only two of
the required components should be linked. Later on, the remaining components will be detailed, as well as
how they should be connected.
3.2 IMU
3.2.1 MPU9250
This section will discuss the IMU, which is the component that will provide information on the CubeSat’s
orientation, speed, and acceleration. The Inertial Measurement Unit (IMU) is an electrical device that uses
accelerometers and gyroscopes to monitor acceleration and rotation. The sensor that will be utilised for this
purpose in this project is the MPU-9250 3.9. The MPU-9150 and MPU-9250 sensor families are Invensense’s
latest generation 9DOF IMUs [19].
16
3.2. IMU CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
The MPU-9250 9DOF module detects 9-axis motion by combining on the same DMP chip a 3-axis gyroscope
(3DOF), a 3-axis accelerometer (3DOF), and an AK8963 3-axis magnetometer (3DOF) (9DOF). The I2C or
SPI bus may be used for communication, which makes it easier to collect measured data. I2C is used for
communication in this project [21].
According to Daniel Castillo’s work [1], in order to get a totally accurate measurement of the CubeSat’s
orientation, the DMP (Digital Motion Processor) device was utilised to acquire the needed orientation in
the form of mathematical equations of quaternions. Following that, the MPU9250 module’s access to DMP
was utilised to retrieve these quaternions, and the Euler angles were calculated using the Arduino software
library ”MPU6050 6Axis MotionApps20.h” and the subroutines ”IMU()” and ”QuatToEuler()” built by Juan
Palomares Moyano [22]. On the one hand, the ”IMU()” subroutine performs the ”mpu.dmpGetQuaternion”
subroutines needed to access the DMP, while on the other hand, ”QuatToEuler()” calculates the Euler angles
using the quaternion equations acquired from the DMP. According to the multiple benefits mentioned in
Daniel Castillo’s work [1] the data previously processed by the DMP are acquired as attitude quaternion
equations.
One of the new features of this project has been accessing the DMP to obtain the angular velocity value,
which has been obtained using the function ”mpu.dmpGetGyro”. This function returns a vector ”v”, and the
following expression is used to obtain its value in the yaw direction: ”vz = v.z”.
The MPU-9250 has a single integrated IMU, model number MPU-6500, inside that consists of a 3DOF
accelerometer and a 3DOF gyroscope. As was already indicated, both models support communication through
the SPI and I2C buses, making it simple to get the measured data. Low voltage supply, ranging from 2.4 to
3.6V. The majority of modules have a voltage regulator built in that enables 5V to be supplied directly [21].
17
3.2. IMU CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
With all sensors and the DMP turned on, the sensor uses 3.5mA. It contains programmable interrupts, a
high accuracy clock, and an inbuilt temperature sensor. Additionally, connections to additional I2C devices
are available. A new generation IMU, the MPU-9250, outperforms older IMUs like the MPU-6050 in terms of
performance. The MPU-9250 uses a magnetometer to avoid drift, which can occur in conventional IMUs
after a few hours of operation [21].
The MPU-9250 has a built-in CPU (DMP Digital Motion Processor) that uses sophisticated MotionFusion
algorithms to combine data from internal sensors instead of relying on external filters [21].
A calibration to correct the offset values must be done in order for the DMP readings to be entirely accurate.
Since there might be significant differences between different sensors, it is required to run the IMU calibration
code given in the Appendix A for each sensor in order to do this. Note that the DMP need time to begin
functioning. It will first give off rough measures, but as time goes on, it will stabilise. Although it occasionally
can go up to 40 seconds, the typical duration is around 15 seconds [21].
The following diagram (Figure 3.10) shows the wiring process. The Arduino’s SDA and SCL pins are linked
to the equivalent pins on the sensor, and the module is powered by the Arduino through GND and 5V. See
Table 3.2 for a better understanding of the wiring.
18
3.3. COMMUNICATION DEVICE CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
Table 3.2: Wiring between MPU9250 and Arduino, Calibration (Source: Own)
The Arduino has to be connected to the computer by USB before the software can be compiled and uploaded,
see Appendix A. The calibration results may be seen on the serial monitor. The results of the calibration of
the IMU used in this project may be seen in the Figure 3.11.
One of the issues that needed to be addressed before moving further was that the system required the
capabilities of an HC-06 Bluetooth module while only HC-05 Bluetooth modules were available. As a result,
19
3.3. COMMUNICATION DEVICE CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
the HC-05 Bluetooth module was set up to behave similarly to the HC-06 Bluetooth module. It was necessary
to change the baud rate of the module.
The ZS-040 Bluetooth model (Figure 3.12), which operates on two voltage levels, has to be configured. Even
though its data ports run at 3.3V, this module has a 3.6 to 5V power range, allowing it to be powered by a
5V board. The data output (TXD) may be connected directly to an Arduino, such as the UNO, because
3.3 volts is regarded as a high level on an Arduino input, while the data input (RXD) has to be connected
through a resistive divider. The required wiring for the module’s setup is shown in Figure 3.13 and Table 3.3.
The HC-05 has a particular operating mode called configuration mode, which processes incoming input as
20
3.3. COMMUNICATION DEVICE CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
There are two configuration options for the AT module, one of which permits altering any parameter and the
other of which has some limitations. The sole command that differs between the two modes in this context is
the AT+NAME command, which can only be used in the first mode, also known as reduced mode. It is
important to understand that 38400 baud is always the default connection speed in all cases [24].
To set the Bluetooth device in ”reduced” mode, the following steps given below should be followed:
• While connecting the device to the power, keep the Bluetooth button pressed.
The slow LED flash indicates that the module is in programming mode.
To communicate with the HC-05 and analyze the values it returns using the serial terminal of the Arduino
IDE, a software that acts as a bridge between the computer and the Bluetooth module must be uploaded to
the Arduino UNO. The Arduino soft serial connection (pins 10 and 11) will be used to send each terminal
input to the PC, and the same port will be used to send each module output. See the Appendix B for the
code [24].
The serial monitor is set at 38400 baud and ”both NL and CR” are enabled in the line settings once the
software has been uploaded to the Arduino UNO.
If ”OK” is returned in response to the character ”AT” sent over the serial monitor, AT mode is active. As an
alternative, you can transmit the commands ”AT+NAME” and ”AT+NAME=NAME” to show it on the
serial monitor and modify the module name, respectively. Additionally, the speed has been adjusted to 9600
baud using the ”AT+UART” instruction. Consult the bibliography for further instructions [25].
In addition, downloading the ”Serial Bluetooth Terminal” application from the ”Google Play Store” is
required for communication with the Bluetooth module. Optionally, it is possible to store the data provided
or received by the device in ”.txt” format by clicking ”Log” from the ”Data” menu of the same application
when the results are being printed. The mobile device will save the file.
21
3.4. BLUE PILL MICROCONTROLLER CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
It is important to know that in order to programme the Blue Pill using the Arduino IDE, the ’stm32duino’
library must be added to the board manager, and the board must then be configured in the tools as indicated
in the Figure 3.15 [27].
Figure 3.15: Programming the Blue Pill with the Arduino IDE. (Source: [27])
22
3.4. BLUE PILL MICROCONTROLLER CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
The full pinout can be seen in the Figure 3.16. It is key to be aware that the majority of pins serve many
purposes.
As seen in the Figure 3.16, some of the pins are labelled as 5V tolerant, meaning that when used as inputs,
they can withstand a voltage of 5 Volts, while others are marked as Not 5V tolerant, preventing us from using
them with voltages higher than 3.3 Volts despite the fact that they can withstand voltages of up to 4V [27].
The microcontroller uses PinB7 as the System Data (SDA) and PinB6 as the System Clock (SCL) to receive
measurement data from the IMU. Pin A10 (RX) is used to receive data from the Bluetooth module, whereas
Pin A9 (TX) is used to transmit data.
Besides, the Bluetooth module and measurements from the sensor (MPU9250) have undergone testing to
make sure they are operating properly. The sole purpose of this test was to check if the components were
functioning properly without the motor driver. The wiring diagram for this test is illustrated in Figure 3.17
and Table 3.4. References from earlier studies might be consulted for further details [1] [2] [3].
23
3.4. BLUE PILL MICROCONTROLLER CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
According to section 3.1, the ESCON 24/2 module is a 4-quadrant PWM servo controller that can power
brushless EC motors up to 48 watts. The servomotors work by using pulse width modulation (PWM), which
involves creating a square wave and altering the period of the wave while keeping the pulse’s high level
constant in order to change the servo’s location as needed.
PWM allows users utilise digital values to control analogue devices, such as a motor’s speed. PWM simulates
an analogue signal by using brief pulses. The duty cycle is the proportion of time that the PWM signal is
high (Figure 3.18). The duty cycle of a signal is expressed as either 100% or 0% depending on whether it is
always on or off. Figure 3.5 demonstrates that the motor driver’s reference value is already set to PWM. [29]
24
3.4. BLUE PILL MICROCONTROLLER CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
The most popular method for creating a PWM wave in a microcontroller is to utilise a timer and a comparator,
which frees up the microcontroller to handle other jobs and makes signal production more efficient and
automated. The technique entails setting the timer’s interrupts to correspond to the high pulse duration
value and the pulse width, which is the signal’s period. The interrupt subroutine should pull the PWM signal
high in response to a timer overflow interrupt and low in response to a comparator interrupt [29].
The STM32F103C8 features ten ADC pins and fifteen PWM pins (Figure 3.16). Each PWM output is given
via a channel coupled to 4 timers, and there are 7 timers in total. Because to its 16-bit PWM resolution,
counters and variables may have a maximum size of 65535. A PWM output with a 72 MHz clock rate can
have a maximum duration of around one millisecond [29].
PinA8 of the microcontroller is utilised in order to control the motor driver via PWM signals. The function
”pinMode(PA8, PWM);” first defines the pin as PWM before using the function ”pwmWrite(PA8, value);” to
assign any value to the pin. Experimental results show that the range of PWM values is from 1 to 1000,
with 500 representing zero, 1 representing the highest possible negative value, and 1000 representing the
highest possible positive value. The hardware portion of the attitude determination and control system’s
final assembly is shown in the section that follows.
25
3.5. FINAL HARDWARE WIRING CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
Two switches have been added to the wiring, as can be seen in the Figure 3.20. The first one powers the
entire circuit, and the second one is to enable/disable the motor.
Since the power supply for the motor driver can range from +10 to +24V but the remainder of the circuit
should only get a maximum of 5V, a converter (reducer) has also been incorporated. The MP2307 converter
(Figure 3.19) reduces a power supply from 4.75V-23V to 1V-17V, making it a miniature DC to DC voltage
regulator that may be adjusted using the potentiometer it provides.
Supplementarily, it is noteworthy that the modules 466023 and 220300 were developed in Fritzing as new
components from the corresponding Inkscape drawings made for this project.
The Figure 3.20 and Table 3.5 are followed by actual photographs of the prototype 3.21, on the other hand.
26
3.5. FINAL HARDWARE WIRING CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
27
3.5. FINAL HARDWARE WIRING CHAPTER 3. HARDWARE PROTOTYPE OF THE ADCS
Table 3.5: Wiring between motor driver and MAXON motor (Source: Own)
28
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Chapter 4
The software that has been developed to this point will be discussed in this chapter (Appendix C). The
Arduino IDE, which is free software, was used to write the code. Two distinct enhancements have been made
to the original code to simplify and improve user comprehension.
• Firstly, the program has been optimized to function more effectively and with fewer resources in order
to improve performance.
• The second was to structure the software by grouping the code into tabs that each represented a file in
the same directory as the source code. The project became clearer, was easier to comprehend, and
could be expanded thanks to this alteration, which was able to split the enormous file into multiple
smaller ones. Figure 4.1 illustrates the project’s organizational structure.
29
CHAPTER 4. SOFTWARE CONTROL OF THE ADCS
• Control Code Alev Yilmaz : This is the main code, which contains ”setup()” and ”loop()”. The
setup function is the first to be run within the Arduino program. The loop is then entered, and it will
continue endlessly until the microcontroller is turned off or reset. This is also the file that contains
all of the definitions and loaded libraries, as well as where the IMU is setup and calibrated. This tab
always directs the user to the ”mode Select” file.
• mode Select : This section allows the user to choose between three distinct modes based on what they
want to perform. In contrast to other works, the modes used in this project fulfill different features.
The next sections provide detailed explanations of these modes.
• actual orientation : This is mode 1 of the ”mode Select” menu. By entering this mode, the user will
continually get the angle in degrees in the yaw direction through the Bluetooth connection. Section 4.1
goes into greater detail about this mode.
• assign current : This corresponds to the second mode of ”mode Select” and consists of rotating
the motor in both clockwise and anticlockwise directions at the user’s current input. This function is
described in more detail in the Section 4.2.
• positioning RW : Since it deals with the implementation of the fine positioning mode employing the
PID controller, this subprogram is the third and most crucial option of ”mode Select.” When the user
specifies the desired angle, the CubeSat accelerates and decelerates in both directions (CW or CCW)
infinitely to achieve the desired orientation. Section 4.3 provides a comprehensive explanation of this
mode.
• IMU : DMP data from the IMU is retrieved in this tab thanks to the ”MPU6050 6Axis MotionApps20.h”
library. These data are, on the one hand, the attitude quaternion, which is then transmitted to the
Euler angles, and, on the other hand, the angular velocity received via the gyroscope. The updated
orientation and speed data are acquired each time this function is activated.
• QuatToEuler : As mentioned in the ”IMU” tab, this function is an algebraic method for converting
quaternions to Euler angles. References can be consulted for more information [2].
• OBC data receive : This function configures the Bluepill to collect data using the CH3 timer and
Serial1 as the UART. The information obtained from the communication device is recorded as an
”OBC data value.”
• OBC mode receive : This function, as ”OBC data receive”, configures the Bluepill in data receive
mode utilizing the CH3 timer and Serial1 as an UART connection. ”OBC mode value” stores the data
received via the communication device.
• angle to 180 : For a more logical perception of results, this function is required to describe various
angles in degrees between -179.99 and +180.
30
CHAPTER 4. SOFTWARE CONTROL OF THE ADCS
It is recommended to check at the Figure 4.2 with the flowchart in it in order to comprehend the pro-
gram more clearly. The flowchart in Figure represents all of the software. In addition, each section of the
software modes contains its own more detailed flowchart in order to improve the understanding of the program.
As shown in the Figure 4.2, the software for this project is composed of three distinct modes detailed in
the Table 4.1, which describes the aim, input, output, input condition, and output condition of the various
modes. The next sections will go through these modes in depth.
31
4.1. MODE 1: ACTUAL ORIENTATION CHAPTER 4. SOFTWARE CONTROL OF THE ADCS
As soon as the system enters this mode, microcontroller continuously communicates data obtained from
the IMU over Bluetooth at a rate of around every 100 milliseconds until the user sends a positive number
using the same way to exit mode. The data obtained is the yaw degree that is obtained from the IMU()
subprogram for each sample.
The application directs the user back to ”mode Select” to select a new mode once the user exits the current
mode. Appendix C contains the code for this mode, and the Section 5.1 of this project also contains the
experimental observations for this mode.
The flow chart for this initial mode is shown in the Figure 4.3.
32
4.2. MODE 2: ASSIGNING CURRENT TO RWCHAPTER 4. SOFTWARE CONTROL OF THE ADCS
The intensity is proportional to the torque produced by the servo motor. The capacity of a force to turn an
object is known as torque. A net torque on an object with a fixed point of rotation results in an angular
acceleration on it, which is the equivalent of Newton’s second law in rotational motion [31]. In accordance
with the current that the user specifies, the CubeSat will therefore accelerate more or less speedily and in a
clockwise or anticlockwise direction.
This applet has a while loop that will prompt the user to set the motor current between -100% and 100%,
which corresponds to values limited between -0.5A (CCW) and 0.5A (CW). While in this program mode, the
user may alter the current as many times as necessary by entering the desired value. Before delivering the
33
4.2. MODE 2: ASSIGNING CURRENT TO RWCHAPTER 4. SOFTWARE CONTROL OF THE ADCS
data to the micro driver, the range of values were converted using the ”map()” tool because the PWM only
recognises values between 1 and 1000.
The user must input the value ”-101” in order to exit the subprogram. The motor driver is given a current of
0A upon exit, and the software will wait until another mode is initiated.
To further understand this method, check Figure 4.4, where the appropriate flowchart is displayed.
34
4.3. MODE 3: POSITIONING RW CHAPTER 4. SOFTWARE CONTROL OF THE ADCS
Previously, the ADCS code was based on two separate positioning modes: coarse positioning mode and fine
positioning mode, which were produced by prior studies, and may be found in the references [1] [2] [3].
• Coarse positioning mode: using this method of operation, which covered the majority of the angular
distance and manoeuvre time, the intended location was first approximated within a five degree error
tolerance range [1].
• Fine positioning mode: this mode is engaged to exercise more exact orientation by directing the
last motions after the Coarse Positioning Mode has achieved its objective of being more or less near to
the target location. In this manner, the drive can be managed by a straightforward control algorithm,
carried out by a PID controller, or by a precise control algorithm, carried out by a more intricate
control loop [1].
35
4.3. MODE 3: POSITIONING RW CHAPTER 4. SOFTWARE CONTROL OF THE ADCS
The purpose of this project is to guide the CubeSat to the appropriate angle as precisely as possible. Due to
this, only the fine positioning mode has been used, disregarding the coarse positioning mode. The CubeSat
wouldn’t stop adjusting the angle it was situated at. The CubeSat would continue oscillating indefinitely
until it reached maximum accuracy, even if the mistake was very minor, and it would constantly be aware of
rectifying any angle error brought on by any circumstance, thanks to the implementation of PID controllers.
Torque has been identified as the action variable that has to be regulated in order to rotate the CubeSat. A
reaction wheel will be employed to perform the orientation manoeuvre; it will give torque in one of the three
degrees of rotational freedom. As a result, the first step is to create a controller that can rectify an angle by
sending a current signal into the actual plant. The motor that powers the reaction wheel will receive this
current signal, which is proportional to the torque. A PID controller will be used to manage the system [4].
PID controller is a control mechanism that determines the difference between the intended and real variables
through a feedback loop [32]. The components of a PID control loop are as follows:
• A sensor that measures the controllable variable It has previously been stated that the MPU9250 sensor
would be used in this project.
• A controller determines the output that causes the actuator to move using the signal from the sensor.
The sensor outputs an analogue signal that indicates the process or system’s current position (PV Process
Variable). The value that has to be attained is the set point (SP SetPoint) that the controller has set. The
error, or difference between the desired value (SP) and the measured value (PV), is obtained by the controller
by deducting the PV from the SP. Each of the three components of the PID controller uses the error signal.
These three components (P+I+D) together form the output signal (MV Manipulated Variable) that the
controller will utilise to operate the actuator [32].
Figure 4.6: Block diagram of a PID controller in a feedback loop. (Source: [32])
36
4.3. MODE 3: POSITIONING RW CHAPTER 4. SOFTWARE CONTROL OF THE ADCS
Proportional
The proportional is merely the result of multiplying the error by the proportional constant (Kp). In doing
so, the output of the PID may be adjusted linearly with the error. Increased Kp translates into a higher
output value with the same error. The output does not change if the error is stable, which results in a fixed,
uncorrectable error known as ”offset” [32].
Integral
The integral eliminates that offset by integrating the error in time. Every X times, the mistake is added and
accumulated, and the value gained is multiplied by the integral constant Ki and added to the output, causing
the output to move cyclically and gradually correcting the offset. The interval X is the integration time Ti,
which denotes how frequently this computation is repeated [32].
Derivative
The derivative component attempts to minimise the mistake by proportionately correcting it at the same rate
that it happens. This is accomplished by deriving the error with respect to time every X times, multiplying
the result by the derivative constant Kd, and adding the resulting value to the output along with the preceding
components (P+I). In other words, it determines how quickly the error varies. The Td, or derivation time,
indicates how frequently this computation is repeated [32].
The procedures used in Joan Serrano’s work [4], which focuses on cascade control loops, have been applied
to the implementation of the controller. The motor that powers the reaction wheel will receive the torque
signal. Even though they are proportional values, the motor will interpret this signal as current; nonetheless,
the constants have been set under the assumption that this system is ideal. As can be observed in the
descriptions of the MAXON motor D.2, the torque constant, or relationship between the motor’s torque and
current, which is 8.82 [mNm/A], can be utilized by adding an extra gain.
Following Joan Serrano’s research [4], a cascaded P+PI controller has been built. This system is made up of
two feedback loops based on PID. The output of the first controller, as seen in the Figure 4.7, determines the
second controller’s set point.
Figure 4.7: Block diagram structure for a cascaded control (Source: [4])
The control of the CubeSat’s angular speed is shown by the inner loop in the Figure 4.8. As seen in Joan
Serrano’s work [4], a PI controller is required to control the angular speed.
37
4.3. MODE 3: POSITIONING RW CHAPTER 4. SOFTWARE CONTROL OF THE ADCS
Figure 4.8: Block diagram structure for the angular speed inner control loop (Source: [4])
In the ”positioning RW” mode, which is the third mode of the software for this project, it can be seen that the
difference between the ”desiredW,” that is the output of the first controller, and the ”vz”, which represents
the angular velocity of the CubeSat as determined by the IMU, is the input of the second controller, which is
”errorW”.
The ”outputP”, the proportional component of the PI, and the ”outputI”, the integral component of the
PI, have been calculated using the ”errorW”. The output of the second controller is the total of these two
components. On the one hand, multiplying the ”errorW” with the constant ”kpw” results in the ”outputP,”
which is the proportional component. On the other hand, the ”outputI” is a value that is calculated by
multiplying ”Ti” by ”errorW” and the constant ”kiw,” and it is a value that is added to each instance of
”Ti”.
The loop that would control the position is the outter one of the Figure 4.9, which with torque disturbances
would be as in the Figure 4.10.
Figure 4.9: Block diagram structure adding the position outer control loop (Source: [4])
38
4.3. MODE 3: POSITIONING RW CHAPTER 4. SOFTWARE CONTROL OF THE ADCS
Figure 4.10: Block diagram structure for the position controller adding torque disturbances (Source: [4])
The desired angle set by the user through Bluetooth would serve as the loop’s setpoint; this setpoint is
referred to as ”deltaDegree” in the code. The ”degreeError” variable, as implied by its name, represents
the difference between the desired angle and the current angle, and it is equal to the difference between
this setpoint and the ”actualDeltaDegree” determined using the data collected from the IMU. In order to
more precisely define which side the reaction wheel should rotate, these angles are modified between +-180º,
thanks to the function called ”angle to 180”.
After obtaining the error, all that is left to do is multiply it by the proportional constant ”kpp” to get the
output of the first controller. Take into account that the first controller’s output corresponds to the second
controller’s setpoint and is referred to as ”desiredW”.
In summary, the control is provided by the parameters ”kpp,” ”kpw,” and ”kiw” (Table 4.2).
Parameter Symbol
Proportional gain for the position controller kpp
Proportional gain for the angular speed controller kpw
Integral gain for the angular speed controller kiw
To be sure, these parameters could be calculated theoretically, as Joan Serrano indicates in his work [4],
for example, with the Root Locus Procedure. This method involves comparing the actual transfer function
denominator to the ideal transfer function denominator, once the system’s transfer function has been identified
in order to identify the system poles that fulfil the selected dynamics.
However, these parameters have been determined experimentally in this project and discussed in greater
detail in Section 5.4.
39
4.4. FLOWCHART OF THE MAIN MODE CHAPTER 4. SOFTWARE CONTROL OF THE ADCS
40
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Chapter 5
Experimental Results
This part will display the outcomes of implementing the techniques described in the preceding chapters 3 4
for each software mode.
Figure 5.1: Experimental Result of Mode 1, Orientation of the CubeSat (Source: Own)
41
5.2. MODE 2: ASSIGNING CURRENT TO RW CHAPTER 5. EXPERIMENTAL RESULTS
In this initial experiment, 20% and then -20% of current through Bluetooth were introduced sequentially. As
a result, the graph of the variation of current against time (Figure 5.2) and variation of velocity versus time
(Figure 5.3) can be seen. Since the maximum current that may be applied has been set at 0,5A, it is evident
from the Figure 5.2 that the maximum current that the 20% of current achieves is around 0,12A. On the
other hand, it can be seen in the Figure 5.3 that the maximum speed is achieved after around 1 ms.
Figure 5.2: Test 1 of Mode 2: 20% of current in both directions, Current Variations (Source: Own)
Figure 5.3: Test 1 of Mode 2: 20% of current in both directions, Speed Variations (Source: Own)
42
5.2. MODE 2: ASSIGNING CURRENT TO RW CHAPTER 5. EXPERIMENTAL RESULTS
In the second experiment, 50% current was added, and the expected graphics were produced in the same way
as in the first experiment. The maximum current that can be observed in the Figure 5.4 is around 0.3A. After
then, it can be seen in the Figure 5.5 that the maximum speed is reached faster than in the first experiment,
in this case in one millisecond.
Figure 5.4: Test 2 of Mode 2: 50% of current in both directions, Current Variations (Source: Own)
Figure 5.5: Test 2 of Mode 2: 50% of current in both directions, Speed Variations (Source: Own)
43
5.3. SUMMARY OF THE EXPERIMENTAL RESULTS OFCHAPTER
MODE 2 5. EXPERIMENTAL RESULTS
In this final experiment of mode 2, it was decided to apply the maximum current allowed by introducing
100%, which is 0.5A. The outcome is clearly shown in Figure 5.6. Additionally, in the Figure 5.7 it is possible
to see that, in contrast to the first two cases, the maximum speed is reached in this instance considerably
more quickly.
Figure 5.6: Test 3 of Mode 2: 100% of current in both directions, Current Variations (Source: Own)
Figure 5.7: Test 3 of Mode 2: 100% of current in both directions, Speed Variations (Source: Own)
The Table 5.1, which includes the intensity applied and angular acceleration values, is a summary of the
outcomes obtained in this mode.
44
5.4. MODE 3: POSITIONING RW CHAPTER 5. EXPERIMENTAL RESULTS
In conclusion, in the Table 5.1 it can be seen how the angular acceleration of the motor increases as the
intensity applied to the motor increases.
It must be acknowledged that several experiments were performed to produce the desired outcome, but only
three of them will be discussed in this section.
The first experiment has been carried out using the values of the parameters listed in the Table 5.2. The
outcome, as seen in the Figure 5.8, was not what was expected. Additionally, the motor performed poorly
with these parameters, produced an error, and abruptly stopped.
45
5.4. MODE 3: POSITIONING RW CHAPTER 5. EXPERIMENTAL RESULTS
After completing a few tests, it became possible that the motor did not report an error in test 6 while using
the values shown in the Table 5.3. The result (Figure 5.9), nevertheless, fluctuated within a 30-degree error
range. As a consequence, the parameters needed to be improved since the inaccuracy was too large.
46
5.4. MODE 3: POSITIONING RW CHAPTER 5. EXPERIMENTAL RESULTS
As can be seen in the Figure 5.10, the inaccuracy has been decreased to around 5º as a result of further
laboratory testing. The Table 5.4 contains the parameters that were utilised to produce this final outcome.
47
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Chapter 6
Budget summary
The cost of programming a CubeSat’s attitude control system to simulate space missions in low-Earth
orbit is described in this chapter. It should be highlighted that the separate budget document will include
measurements, unit costs, and a general budget for a prototype that will be subdivided into budgets for
hardware, software, and human resources. The budget summary is displayed in Table 6.1.
Chapter Budget
1. Software Development 808,00€
2. Hardware Development 306,70€
3. Human Resources 18560,00€
Total Budget 19674,70€
48
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Chapter 7
Environmental Analysis
The data transmission from satellites that track climate change may be allegedly hampered by the approxi-
mately 7,200 tonnes of space junk that is now encroaching on orbit [33].
An estimated 40,000 satellites are now being built for launch in the upcoming years, and there are already
5,000 active or missing spacecraft in low Earth orbit, according to a recent research by the University of
British Columbia [33].
As a satellite reaches the end of its useful life, the aluminium on those satellites burns and transforms into
reflective aluminium oxide, a highly hazardous chemical for the ozone layer.
Moreover, the space debris pose a danger to the environment and even space weather satellites, even though
the majority of these items that are detected in space manage to disintegrate along their journey [33].
However, this project has only been used for academic purposes, and all work has been done in research
laboratories. As a result, this project wouldn’t have the environmental impact that had been described.
49
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Chapter 8
Conclusions
To conclude, the project’s goal of implementing a reaction wheel-based 1DoF attitude control for a CubeSat
has been accomplished; the created code is available in the Appendix C.
The software has mostly been reduced of the coarse positioning that was previously included because adding
fine positioning alone was sufficient to build an attitude control, causing the system to oscillate with a
negligible inaccuracy around the required angle.
A P+PI controller, which has been built to accomplish attitude control with precision positioning, has been
thoroughly described in the Section 4.3.2.
Additionally, one of the enhancements—the switch in motor—has been accomplished successfully, giving the
system greater stability and precision.
As has been demonstrated, it can be said that the project has succeeded in attaining the goals that were first
put out, creating a more exact attitude control with fine positioning.
• Currently, the results of the project present a small error that can be easily fixed by better tuning
the controller’s implemented parameters. This might be accomplished by first analyzing the internal
loop that makes up the PI controller, and then, after obtaining the necessary parameters, performing a
general analysis of the entire system.
• Using a PCB, which would have the required circuitry and components to drive the motor, would make
the hardware design more aesthetically appealing and result in a more compact CubeSat.
50
8.1. FURTHER WORKS CHAPTER 8. CONCLUSIONS
• Magnetorquers might be employed to detumble, perform coarse attitude adjustments, and desaturate
the reaction wheels as this project as intended only contains a reaction wheel. This allows for the
development of a small 3-axis magnetic control system to strengthen satellite control.
• Due to the CubeSat developed in this project only having one reaction wheel in the yaw orientation,
two more reaction wheels need be implemented in order to regulate speed changes in any direction
(yaw, pitch, and roll).
51
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
References
[1] D. C. Bonillo, “Project of attitude control system for 1u cubesat,” UPC, 2022.
[2] A. P. Fernández, “Project of attitude control system based on reaction wheels,” UPC, 2021.
[3] Y. Q. J. Zhang, “Project of 1 dof attitude control system of 1u cubesat based on reaction wheel,” UPC,
2021.
[4] J. S. Aporta, J. G. Barrio, and A. A. Pujol, “Bachelors thesis attitude control techniques for a 1u
cubesat,” 2022.
[5] “Cubesat.” (2022), [Online]. Available: https://es.wikipedia.org/wiki/CubeSat.
[6] D. Calvo, T. Avilés, V. Lapuerta, and A. Laverón-Simavilla, “Fuzzy attitude control for a nanosatellite
in low earth orbit,” Expert Systems with Applications, vol. 58, pp. 102–118, Oct. 2016.
[7] S. Loff and B. Dunbar. “Cubesats overview — nasa.” (Feb. 2018), [Online]. Available: https://www.
nasa.gov/mission_pages/cubesats/overview.
[8] T. Prejean, “Nanoracks cubesat deployer (nrcsd) interface definition document (idd),” 29 2018. [Online].
Available: https://nanoracks.com/wp-content/uploads/Nanoracks-CubeSat-Deployer-NRCSD-
IDD.pdf.
[9] C. Program, “P-pod mk. iii rev. e user guide the cubesat program, cal poly slo p-pod mk. iii rev. e user
guide the cubesat program, cal poly slo p-pod mk. iii rev. e user guide the cubesat program, cal poly
slo,”
[10] “Adcs: Attitude determination and control system - ece3sat.” (), [Online]. Available: http://www.
ece3sat.com/cubesatmodules/adcs/.
[11] S. R. Starin, “19.1 attitude determination and control systems,”
[12] T. E. S. Agency. “Esa - sensor avanzado de estrellas.” (), [Online]. Available: https://www.esa.int/
Space_in_Member_States/Spain/Sensor_Avanzado_de_Estrellas.
[13] D. J. C. Cerezo, “Desarrollo, implementación y evaluación de un algoritmo de lógica difusa para el
control de actitud de nanosatélites,” Jul. 2017. [Online]. Available: https://oa.upm.es/47742/1/
DANIEL_JAIME_CALVO_CEREZO.pdf.
[14] “Escon module 24/2 servo controller p/n 466023 hardware reference,” 2018.
[15] “Qué es un servomotor, para qué sirve y cómo funciona.” (), [Online]. Available: https : / / www .
cursosaula21.com/que-es-un-servomotor/.
[16] “Online shop for high precise drive systems by maxon — maxon group.” (), [Online]. Available:
https://www.maxongroup.com/maxon/view/product/351006.
52
REFERENCES REFERENCES
[17] “La diferencia entre el motor paso a paso y el servomotor de la máquina de grabado - igolden cnc.” (),
[Online]. Available: https://es.igoldencnc.com/La-diferencia-entre-el-motor-paso-a-paso-
y-el-servomotor-de-la-mC3A1quina-grabado-id3844102.html.
[18] “Online shop for high precise drive systems by maxon — maxon group.” (), [Online]. Available:
https://www.maxongroup.com/maxon/view/product/220300.
[19] “Mpu-9250 - invensense — digikey.” (), [Online]. Available: https://www.digikey.es/es/product-
highlight/i/invensense/mpu-9250-9-axis-gyro-accel-magnet.
[20] “Tarj mpu-9250 - sigma electrónica.” (), [Online]. Available: https://www.sigmaelectronica.net/
producto/tarj-mpu-9250/.
[21] “Usar arduino con los imu de 9dof mpu-9150 y mpu-9250.” (), [Online]. Available: https://www.
luisllamas.es/usar-arduino-con-los-imu-de-9dof-mpu-9150-y-mpu-9250/.
[22] “Trabajo final de grado,”
[23] “Controlar bombilla con arduino, bluetooth y teléfono móvil - parzibyte’s blog.” (), [Online]. Available:
https://parzibyte.me/blog/2020/12/12/controlar-bombilla-arduino-bluetooth-telefono-
movil/.
[24] “Configuración del módulo bluetooth hc-05 — profe tolocka.” (), [Online]. Available: https://www.
profetolocka.com.ar/2018/02/14/configuracion-del-modulo-bluetooth-hc-05/.
[25] C. Dũng, “Hc 0305 serial module at commamd set 201104 revised,” [Online]. Available: https :
//www.academia.edu/17291521/HC_0305_serial_module_AT_commamd_set_201104_revised.
[26] “Stm32f103c8t6 - blue pill — stm32-base project.” (), [Online]. Available: https://stm32-base.org/
boards/STM32F103C8T6-Blue-Pill.html.
[27] “Primeros pasos con la stm32 blue pill.” (), [Online]. Available: https://www.profetolocka.com.ar/
2021/04/12/primeros-pasos-con-la-stm32-blue-pill/.
[28] “Esquema de patillaje (pinout) del stm32f103 ”blue pill”.” (), [Online]. Available: https : / / www .
luisllamas.es/esquema-de-patillaje-pinout-del-stm32-blue-pill/.
[29] “Pulse width modulation (pwm) in stm32f103c8: Controlling speed of dc fan.” (), [Online]. Available:
https://circuitdigest.com/microcontroller- projects/stm32f103c8t6- pwm- tutorial- fan-
speed-control.
[30] “Pwm in avr atmega16/atmega32 — avr atmega controllers.” (), [Online]. Available: https://www.
electronicwings.com/avr-atmega/atmega1632-pwm.
[31] A. C. Contreras, J. J. Sarmiento, G. A. M. Fernández, and V. G. H. Herrera, “Control de torque
para servomotores sin escobillas (torque control for brushless servomotor),” Pistas Educativas, vol. 40,
130 Nov. 2018, issn: 2448-847X. [Online]. Available: http://www.itc.mx/ojs/index.php/pistas/
article/view/1625.
[32] “Controlador pid - wikipedia, la enciclopedia libre.” (), [Online]. Available: https://es.wikipedia.
org/wiki/Controlador_PID.
[33] “¿sabı́as que los satélites en el espacio pueden afectar al medio ambiente? - latinamerican post.” (),
[Online]. Available: https://latinamericanpost.com/es/37409-sabias-que-los-satelites-en-
el-espacio-pueden-afectar-al-medio-ambiente.
53
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Appendix A
// Arduino sketch that returns calibration offsets for MPU6050 // Version 1.1 (31th January
2014)
// Done by Luis Rodenas <[email protected]>
// Based on the I2Cdev library and previous work by Jeff Rowberg <[email protected]>
// Updates (of the library) should (hopefully) always be available at https://github.com/jrowberg/
i2cdevlib
// These offsets were meant to calibrate MPU6050’s internal DMP, but can be also useful for
reading sensors.
// The effect of temperature has not been taken into account so I can’t promise that it will work
if you
// calibrate indoors and then use it outdoors. Best is to calibrate and use at the same room
temperature.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
54
APPENDIX A. MPU CALIBRATION CODE
int mean_ax,mean_ay,mean_az,mean_gx,mean_gy,mean_gz,state=0;
int ax_offset,ay_offset,az_offset,gx_offset,gy_offset,gz_offset;
55
APPENDIX A. MPU CALIBRATION CODE
// initialize device
accelgyro.initialize();
// start message
Serial.println("\nMPU6050 Calibration Sketch");
delay(2000);
Serial.println("\nYour MPU6050 should be placed in horizontal position, with package letters
facing up. \nDon’t touch it until you see a finish message.\n");
delay(3000);
// verify connection
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050
connection failed");
delay(1000);
// reset offsets
accelgyro.setXAccelOffset(0);
accelgyro.setYAccelOffset(0);
accelgyro.setZAccelOffset(0);
accelgyro.setXGyroOffset(0);
accelgyro.setYGyroOffset(0);
accelgyro.setZGyroOffset(0);
}
56
APPENDIX A. MPU CALIBRATION CODE
if (state==1) {
Serial.println("\nCalculating offsets...");
calibration();
state++;
delay(1000);
}
if (state==2) {
meansensors();
Serial.println("\nFINISHED!");
Serial.print("\nSensor readings with offsets:\t");
Serial.print(mean_ax);
Serial.print("\t");
Serial.print(mean_ay);
Serial.print("\t");
Serial.print(mean_az);
Serial.print("\t");
Serial.print(mean_gx);
Serial.print("\t");
Serial.print(mean_gy);
Serial.print("\t");
Serial.println(mean_gz);
Serial.print("Your offsets:\t");
Serial.print(ax_offset);
Serial.print("\t");
Serial.print(ay_offset);
Serial.print("\t");
Serial.print(az_offset);
Serial.print("\t");
Serial.print(gx_offset);
Serial.print("\t");
Serial.print(gy_offset);
Serial.print("\t");
Serial.println(gz_offset);
Serial.println("\nData is printed as: acelX acelY acelZ giroX giroY giroZ");
Serial.println("Check that your sensor readings are close to 0 0 16384 0 0 0");
Serial.println("If calibration was succesful write down your offsets so you can set them in
your projects using something similar to mpu.setXAccelOffset(youroffset)");
while (1);
}
}
57
APPENDIX A. MPU CALIBRATION CODE
while (i<(buffersize+101)){
// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
void calibration(){
ax_offset=-mean_ax/8;
ay_offset=-mean_ay/8;
az_offset=(16384-mean_az)/8;
gx_offset=-mean_gx/4;
gy_offset=-mean_gy/4;
gz_offset=-mean_gz/4;
while (1){
int ready=0;
accelgyro.setXAccelOffset(ax_offset);
accelgyro.setYAccelOffset(ay_offset);
accelgyro.setZAccelOffset(az_offset);
58
APPENDIX A. MPU CALIBRATION CODE
accelgyro.setXGyroOffset(gx_offset);
accelgyro.setYGyroOffset(gy_offset);
accelgyro.setZGyroOffset(gz_offset);
meansensors();
Serial.println("...");
if (abs(mean_ax)<=acel_deadzone) ready++;
else ax_offset=ax_offset-mean_ax/acel_deadzone;
if (abs(mean_ay)<=acel_deadzone) ready++;
else ay_offset=ay_offset-mean_ay/acel_deadzone;
if (abs(16384-mean_az)<=acel_deadzone) ready++;
else az_offset=az_offset+(16384-mean_az)/acel_deadzone;
if (abs(mean_gx)<=giro_deadzone) ready++;
else gx_offset=gx_offset-mean_gx/(giro_deadzone+1);
if (abs(mean_gy)<=giro_deadzone) ready++;
else gy_offset=gy_offset-mean_gy/(giro_deadzone+1);
if (abs(mean_gz)<=giro_deadzone) ready++;
else gz_offset=gz_offset-mean_gz/(giro_deadzone+1);
if (ready==6) break;
}
}
59
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Appendix B
#include <SoftwareSerial.h>
void setup() {
void loop() {
char dato;
if (ModuloHC05.available()) { //Llega algo por bluetooth?
dato=ModuloHC05.read(); //Leer lo que llego
Serial.write(dato); //Sacarlo a la terminal
}
60
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Appendix C
#include <MapleCoOS.h>
//DEFINITIONS
//LIBRARIES
#include <Arduino.h> // Arduino library
#include <stdint.h> // Integer types library
#include <Wire.h> // I2C library
//IMU librarys
#include "MPU6050_6Axis_MotionApps20.h" //Mediante esta biblioteca se pueden obtener datos del
DMP (Digital Motion Processor) de la IMU
#include "I2Cdev.h" //Mediante esta biblioteca se pueden obtener datos del DMP de la IMU
#include "helper_3dmath.h" //Mediante esta biblioteca se pueden realizar operaciones de
cuaterniones
// DEFINITIONS
#define LEDPIN PC13 // Integrated LED of the Bluepill
#define STM32_CLOCK 72000 // Internal STM32 Clock (72MHz, in kHz so period is millisec)
61
APPENDIX C. ADCS ARDUINO CODE
//IMU
const int mpuAddress = 0x68; // Se define la direccion de la IMU, puede ser 0x68 o 0x69
MPU6050 mpu(mpuAddress); //Se crea un objeto MPU6050 para poder extraer datos de la DMP
int fifoCount = 0, packetSize; //Se crea un contador de valores en el FIFO de la MPU y el tamano
del paquete que obtendremos
byte fifoBuffer[42]; //Se crea el buffer que se utilizara para obtener los datos roll, pitch y
yaw.
float roll, pitch, yaw, sqx, sqy, sqz, sqw, test; //Se crea tanto las variables de roll, pitch y
yaw como las variables "float"
//intermedias necesarias para obtenerlas
Quaternion q; //Se crea el cuaternion necesario para obtener los valores de pitch, yaw y roll
VectorInt16 v;
float vz;
// GLOBAL VARIABLES
// FUNCTIONS
// GENERAL USE FUNCTIONS
// OBC Functions
void setup() {
62
APPENDIX C. ADCS ARDUINO CODE
// Initiations
Serial1.begin(9600);
Wire.begin();
Serial1.println("START");
// Setups
// IMU Setup
//IMU
mpu.initialize(); //Inicializacion de la imu
Serial1.println("MPU successfully inicialized");
mpu.dmpInitialize(); //Inicializacion del DMP
mpu.setDMPEnabled(true); //Habilitacion del DMP
Serial1.println("successfull DMP acces");
packetSize = mpu.dmpGetFIFOPacketSize(); //Se obtiene el tamano del paquete que obtendremos del
DMP (42)
mpu.setXAccelOffset(6491);
mpu.setYAccelOffset(4850);
mpu.setZAccelOffset(9354);
mpu.setXGyroOffset(-95);
mpu.setYGyroOffset(-2);
mpu.setZGyroOffset(39);
Serial1.println("MPU calibrated");
63
APPENDIX C. ADCS ARDUINO CODE
delay(100); //Se da un margen de tiempo para que todos los procesos se completen
}
void loop() {
void mode_Select()
{
/*
Function to select Mode
INPUT:
mode_value [’0’: Waiting; ’1’: Actual Orientation; ’2’: Mode Assigning speed to the RW (TEST
mode); ’3’]
OUTPUT:
None, but exits to selected mode
*/
float received_number;
int mode_value;
OBC_mode_value = 0;
Timer1.attachInterrupt(TIMER_CH3, OBC_mode_receive);
while (OBC_mode_value == 0)
{
delay(1); // If not used the while function does not work
// it can be added more conditions to evade being blocked until a data is received.
64
APPENDIX C. ADCS ARDUINO CODE
// for example, it could function an interrupt with a forced exit and an if after or something
}
Timer1.detachInterrupt(TIMER_CH3);
Serial1.println(OBC_mode_value);
mode_value=OBC_mode_value;
switch (mode_value)
{
default:
Serial1.println("Wrong mode value, please enter a correct mode number;");
break;
void actual_orientation(){
float received_number=0;
Serial1.println("Yaw degree attitude");
Serial1.println("Press any positive number to stop");
/*
* It constantly writes the yaw angle while waiting for the user to enter a positive number.
*/
while (received_number == 0)
65
APPENDIX C. ADCS ARDUINO CODE
{
IMU(); //reading the IMU
Serial1.print("Axis Z position: ");
Serial1.println(Yaw_deg); //printing the yaw degree
delay(100);
}
received_number = bufferString.toInt(); // Conversion from String to int
}
}
}
OBC_data_value = 0;
while (OBC_data_value != -101) //to exit while enter -101
{
/*
* This while loop asks user to set the motor current between -100% and 100%, which is between
-0.5 A (CCW) and 0.5 A (CW).
* current_value goes between 1 and 1000 (STM32 bluepill)
* Exits the loop when user enters "-101".
*/
66
APPENDIX C. ADCS ARDUINO CODE
/*
* Sets final speed at 0A and exits mode 3.
*/
pwmWrite(PA8, 1);
}
void positioning_RW(){
IMU();
float received_number=0;
float initial_degree = Yaw_deg; //initial_degree saves the initial Yaw_deg in the beginning of
the program
float actualDeltaDegree;
float degreeError;
float desiredW;
float time1;
float time2;
float errorW;
float outputPI, outputP, outputI = 0;
67
APPENDIX C. ADCS ARDUINO CODE
//PID loop
time1 = millis();
// CONTROLLER PARAMETERS
kpp = 0.25;
kpw = 20;
kiw = 0.075;
while (received_number == 0)
{
IMU();
actualDeltaDegree = Yaw_deg - initial_degree; //calculates the real delta degree angle
actualDeltaDegree = angle_to_180(actualDeltaDegree); //adjusting the angle between +-180
degreeError = deltaDegree - actualDeltaDegree; //calculates the difference between deltaDegree
setpoint and the real deltaDegree
degreeError = angle_to_180(degreeError); //adjusting the angle between +-180
desiredW = kpp*degreeError; //calculates the PID output
errorW = desiredW - vz;
outputP = kpw*errorW;
time2 = millis();
outputI += (time2-time1)*errorW*kiw;
if (outputI>300) outputI=300;
if (outputI<-300) outputI=-300;
time1 = millis();
outputPI = 500 + outputP + outputI; //500 is 0A in PWM
if (outputPI>800) outputPI=800;
if (outputPI<200) outputPI=200;
// float torque = map(outputPI, -4000, 4000, 400, 600);
float torque=outputPI;
68
APPENDIX C. ADCS ARDUINO CODE
delay(10);
void IMU() {
fifoCount = mpu.getFIFOCount(); //Se obtiene el numero de bytes del DMP
if (fifoCount >= 42) { //Si el numero de datos en el DMP es mayor a 42 bytes (mayor que el
packetSize)
mpu.resetFIFO(); //Se resetea el FIFO
fifoCount = mpu.getFIFOCount(); //Se vuelven a obtener el numero de bytes en el FIFO del DMP
}
while (fifoCount < packetSize) { //Mientras el numero de datos es menor al paquete
fifoCount = mpu.getFIFOCount(); //Se vuelven a obtener el numero de bytes en el FIFO del DMP
delay(1); //El delay es necesario para controlar el fifoCount. No se ha podido ver exactamente
como afecta porque al crear un println el problema se resuelve por el incremento de
tiempo.
if (fifoCount > packetSize) { //Si el numero de datos en el DMP es mayor a 42 bytes (mayor que
el packetSize)
mpu.resetFIFO(); //Se resetea el FIFO
fifoCount = mpu.getFIFOCount(); //Se vuelven a obtener el numero de bytes en el FIFO del DMP
69
APPENDIX C. ADCS ARDUINO CODE
}
}
fifoCount = fifoCount - packetSize; //Se resta al fifoCount el packetSize (el resultado deberia
ser siempre 0)
mpu.getFIFOBytes(fifoBuffer, packetSize); //Se obtienen los valores del DMP en forma de bytes
mpu.dmpGetQuaternion(&q, fifoBuffer); //Se obtiene el cuaternion de actitud mediante el DMP
mpu.dmpGetGyro(&v, fifoBuffer);
vz = v.z;
QuatToEuler(q, yaw, pitch, roll); //Se hace el paso del cuaternion de actitud a los angulos de
Euler
// The range of yaw, pitch adn roll anfles goes from 180 to -180: We need to adapt it to 0 to 360
range
if (yaw < 0) yaw += 360;
if (pitch < 0) pitch += 360;
if (roll < 0) roll += 360;
// Variable standardization to the ones used in the original program (the range of these angles
goes from 0 to 360)
Yaw_deg=yaw;
Pitch_deg=pitch;
Roll_deg=roll;
}
void OBC_data_receive()
{
/*
Function to set the Bluepill to receiving data mode. Uses Timer CH3. Serial1 as UART
communication
70
APPENDIX C. ADCS ARDUINO CODE
void OBC_mode_receive()
{
/*
Function to set the Bluepill to receiving mode. Uses Timer CH3. Serial1 as UART communication
if (Serial1.available() > 0)
{
String bufferString = ""; // String for buffer of Serial1
// Keep saving input prompt
while (Serial1.available() > 0)
{
bufferString += (char)Serial1.read(); // Adds chars to the Serial1 buffer
}
// Conversion from String to int
OBC_mode_value = bufferString.toInt();
Serial1.print("Mode Number: ");
Serial1.println(OBC_mode_value);
}
}
71
APPENDIX C. ADCS ARDUINO CODE
72
Programming the attitude control of a CubeSat for
simulation of LEO orbit space missions
Appendix D
Datasheets
73
Hardware Reference
TABLE OF CONTENTS
TABLE OF CONTENTS 2
1 ABOUT 5
1.1 About this Document. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 About the Device. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 About the Safety Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 SPECIFICATIONS 9
2.1 Technical Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3 SETUP 13
3.1 Generally applicable Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Configuration of Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4 Status Indicators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4 WIRING 27
4.1 DC Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2 EC Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
The ESCON Module 24/2 is considered as partly completed machinery according to EU Directive 2006/42/EC, Article 2,
Clause (g) and is intended to be incorporated into or assembled with other machinery or other partly completed
machinery or equipment.
Therefore, you must not put the device into service, …
• unless you have made completely sure that the other machinery fully complies with the EU directive’s requirements!
• unless the other machinery fulfills all relevant health and safety aspects!
• unless all respective interfaces have been established and fulfill the herein stated requirements!
LIST OF FIGURES 53
LIST OF TABLES 54
INDEX 55
1 ABOUT
Notation Meaning
Prohibited
Indicates a dangerous action. Hence, you must not!
Action
(typical)
Mandatory
Indicates a mandatory action. Hence, you must!
Action
(typical)
Littelfuse®
© Littelfuse, USA-Chicago, IL
SMD NANO2®
1.1.6 Copyright
The present document – including all parts thereof – is protected by copyright. Any use (including reproduc-
tion, translation, microfilming, and other means of electronic data processing) beyond the narrow restric-
tions of the copyright law without the prior approval of maxon, is not permitted and subject to prosecution
under the applicable law.
© 2021 maxon. All rights reserved. Subject to change without prior notice.
CCMC | ESCON Module 24/2 Hardware Reference | Edition 2021-08 | DocID rel9004
maxon motor ag
Brünigstrasse 220 +41 41 666 15 00
CH-6072 Sachseln www.maxongroup.com
DANGER
Requirements
• Make sure that all associated devices and components are installed according to local regulations.
• Be aware that, by principle, an electronic apparatus can not be considered fail-safe. Therefore, you must
make sure that any machine/apparatus has been fitted with independent monitoring and safety equip-
ment. If the machine/apparatus should break down, if it is operated incorrectly, if the control unit breaks
down or if the cables break or get disconnected, etc., the complete drive system must return – and be
kept – in a safe operating mode.
• Be aware that you are not entitled to perform any repair on components supplied by maxon.
2 SPECIFICATIONS
Analog input 1
12-bit resolution; −10…+10 V; differential
Analog input 2
Analog output 1
12-bit resolution ; −4…+4 V; referenced to GND
Analog output 2
Digital input 1
Inputs & Outputs +2.4…+36 VDC (Ri = 38.5 kΩ)
Digital input 2
Digital input/output 3
+2.4…+36 VDC (Ri = 38.5 kΩ)/max. 36 VDC (IL <50 mA)
Digital input/output 4
Voltage Outputs Hall sensor supply voltage +5 VDC (IL ≤30 mA)
Weight approx. 7 g
Operation −30…+60 °C
+60…+80 °C
Temperature Extended range *1)
Derating Figure 2-1
*1) Operation within the extended range (temperature and altitude) is permitted. However, a respective derating (declination
of output current Icont) as to the stated values will apply.
*2) Operating altitude in meters above Mean Sea Level, MSL.
Overvoltage 31 V 29 V
Overcurrent 9.6 A —
Thermal overload 95 °C 85 °C
2.2 Standards
The described device has been successfully tested for compliance with the below listed standards. In prac-
tical terms, only the complete system (the fully operational equipment comprising all individual components,
such as motor, servo controller, power supply unit, EMC filter, cabling etc.) can undergo an EMC test to
ensure interference-free operation.
Important Notice
The device’s compliance with the mentioned standards does not imply its compliance within the final, ready
to operate setup. In order to achieve compliance of your operational system, you must perform EMC testing
of the involved equipment as a whole.
Electromagnetic compatibility
IEC/EN 61000-6-3
IEC/EN 55022 Radio disturbance characteristics/radio interference
(CISPR22)
Others
3 SETUP
IMPORTANT NOTICE: PREREQUISITES FOR PERMISSION TO COMMENCE INSTALLATION
The ESCON Module 24/2 is considered as partly completed machinery according to EU Directive 2006/42/
EC, Article 2, Clause (g) and is intended to be incorporated into or assembled with other machinery or
other partly completed machinery or equipment.
WARNING
Risk of Injury
Operating the device without the full compliance of the surrounding system with EU Directive
2006/42/EC may cause serious injuries!
• Do not operate the device, unless you have made completely sure that the other machinery fully com-
plies with the EU directive’s requirements!
• Do not operate the device, unless the other machinery fulfills all relevant health and safety aspects!
• Do not operate the device, unless all respective interfaces have been established and fulfill the
requirements stated in this document!
1) Use the formula below to calculate the required voltage under load.
2) Choose a power supply according to the calculated voltage. Thereby consider:
a) During braking of the load, the power supply must be capable of buffering the recovered
kinetic energy (for example, in a capacitor).
b) If you are using an electronically stabilized power supply, make sure that the overcurrent pro-
tection circuit is configured inoperative within the operating range.
Note
The formula already takes the following into account:
• Maximum PWM duty cycle of 100%
• Controller’s max. voltage drop of 1 V @ 2 A
KNOWN VALUES:
• Operating torque M [mNm]
• Operating speed n [rpm]
• Nominal motor voltage UN [Volt]
• Motor no-load speed at UN, n0 [rpm]
• Speed/torque gradient of the motor Δn/ΔM [rpm/mNm]
SOUGHT VALUE:
• Supply voltage +VCC [Volt]
SOLUTION:
UN Δn
V CC ≥ ------- ⋅ n + --------- ⋅ M + 1 [ V ]
nO ΔM
3.3 Connections
The actual connection will depend on the overall configuration of your drive system and the type of motor
you will be using.
Follow the description in the given order and choose the wiring diagram that best suits the components you
are using. For corresponding wiring diagrams chapter “4 Wiring” on page 4-27.
18 GND Ground
Figure 3-5 Hall Sensor 1 Input Circuit (analogously valid also for Hall Sensors 2 & 3)
3.3.3 Encoder
Best practice
• Differential signals offer good resistance against electrical interference. Therefore we recommend
using a differential scheme. Nevertheless, the controller supports both schemes – differential and sin-
gle-ended (unsymmetrical).
• The controller does not require an index impulse (Ch I, Ch I\).
• For best performance, we strongly recommend using encoders with a line driver. Otherwise, speed
limitations may apply due to slow switching edges.
Differential
Min. differential input voltage ±200 mV
Max. input voltage +12 VDC/−12 VDC
Line receiver (internal) EIA RS422 standard
Max. input frequency 1 MHz
Figure 3-6 Encoder Input Circuit Ch A “Differential” (analogously valid also for Ch B)
Single-ended
Input voltage 0…5 VDC
Max. input voltage +12 VDC/−12 VDC
Logic 0 <1.0 V
Logic 1 >2.4 V
Input high current IIH = typically +420 μA @ 5 V
Input low current IIL = typically −170 μA @ 0 V
Max. input frequency 100 kHz
Figure 3-7 Encoder Input Circuit Ch A “Single-ended” (analogously valid also for Ch B)
DigIN
Input voltage 0…28 VDC
Max. input voltage +36 VDC
Logic 0 typically <1.0 V
Logic 1 typically >2.4 V
typically 47 kΩ (<3.3 V)
Input resistance typically 38.5 kΩ (@ 5 V)
typically 25.5 kΩ (@ 24 V)
Input current at logic 1 typically 130 µA @ +5 VDC
Switching delay <8 ms
DigOUT
Max. input voltage +36 VDC
Max. load current 50 mA
Max. voltage drop 0.5 V @ 50 mA
Only possible with external protective circuitry (free-
Max. load inductance
wheeling diode)
Figure 3-12 DigOUT3 Wiring Examples (analogously valid also for DigOUT4)
Note
Column “Head B” (Table 3-9) refers to USB terminals of your PC.
J7 &
Head B
Head A Signal Description
Pin Pin
4 – ID not connected
Length 1.5 m
LED
Status/Error
Green Red
on off ENABLE
4 WIRING
Note
The subsequent diagrams feature this symbol:
4.1 DC Motors
MAXON DC MOTOR
4.2 EC Motors
CAUTION
Dangerous Action
Errors in implementing the Design can result in serious Injury!
• Only proceed if you are skilled in electronics design!
• Designing a printed circuit board requires special skills and knowledge and may only be performed by
experienced electronic developers!
• This quick guide is only intended as an aid, does not make any claim to completeness, and will not
automatically result in a functional component!
CAPACITOR (C1)
The function of the ESCON Module 24/2 does not necessarily require the use of an external capacitor (C1).
To further reduce voltage ripple and feedback currents, an electrolytic capacitor can be connected to the
voltage supply cable.
V cc
L phase ≥ --- ⋅ ----------------------------- – ( 0.3 ⋅ L motor )
1
2 6 ⋅ f PWM ⋅ I N
If the result of the calculation is negative, no additional chokes are necessary. Nevertheless, the use of
chokes in combination with additional filter components can be useful to reduce the emission of electromag-
netic interference.
An additional choke must feature electromagnetic shielding, a high saturation current, minimal losses, and a
nominal current greater than the continuous current of the motor. The below wiring example refers to an
additional inductance of 150 μH. If a different additional inductance is required, also the filter components
must be adapted accordingly. Should you need further help with the filter design, contact maxon Support at
http://support.maxongroup.com.
Figure 5-26 Wiring of Motor Winding 1 (analogously valid also for Motor Windings 2 & 3)
Recommended components
Straight socket header, pluggable with 0.64 x 0.64 mm pin headers, 2.54 mm pitch, 3 A,
contact material: gold
Preci-Dip (801-87-013-10-005101)
Socket 13 poles, 1 rows Würth (613 013 118 21)
Header E-tec (BL1-013-S842-55)
Preci-Dip (801-87-011-10-005101)
11 poles, 1 row Würth (613 011 118 21)
E-tec (BL1-011-S842-55)
• Vishay (SMBJ33A)
UR=33 V, UBR = 36.7…40.7 V @ 1 mA, UC = 53.3 V @ 11.3 A
TVS Diode D1
• Diotec (P6SMBJ33A)
UR=33 V, UBR = 36.7…40.7 V @ 1 mA, UC = 53.3 V @ 11.3 A
5.2.1 Ground
All ground connections (GND) should be internally connected to the ESCON Module 24/2 (equal potential).
It is customary to equip the motherboard with a ground plane. All ground connections should be connected
to the voltage supply ground via wide conductive tracks.
18 GND Ground
If an earth potential is in place or required, the ground plane should be connected to the earth potential via
one or more capacitors. The use of ceramic capacitors with 100 nF and 100 V is recommended.
5.2.2 Layout
Guidelines for the layout of the motherboard:
• Connector pin [4] +VCC operating voltage:
The pins should be connected to the fuse via wide conductive tracks.
• Connector pins [5] and [18] ground:
All pins should be connected with the ground of the operating voltage via wide conductive tracks.
• The width of the conductive track and the copper coating thickness of the conductors for supply
voltage and motor depend on the current required for the application. A minimum width of 75 mil is
recommended for the track and a minimum thickness of 35 μm for the copper coating.
Figure 5-28 ESCON Module MoBo (left), with mounted ESCON Module 24/2 (right)
5.7.1 Assembly
The ESCON Module MoBo is designed to easily be screw-mounted or integrated into standard rail systems.
For ordering information for the components required Figure 5-30 (only for illustrative purposes) and
Table 5-14.
Specification / Accessories
PHOENIX CONTACT
2 x panel mounting base element 11.25 mm UMK-SE11.25-1 (2970442)
2 x base element 45 mm UMK-BE45 (2970015)
2 x foot element UMK-FE (2970031)
Adapter for DIN rail
CamdenBoss
2 x end section with foot 22.5 mm (CIME/M/SEF2250S)
1 x base element 22.5 mm (CIME/M/BE2250SS)
1 x base element 45 mm (CIME/M/BE4500SS)
Table 5-14 ESCON Module MoBo, mounting on DIN Rail – Specification & Accessories
5.7.2 Connections
Note
The USB interface is located directly at the ESCON Module 24/2.
J1
Signal Description
Pin
Specification / Accessories
Table 5-16 ESCON Module MoBo – Power Plug J1 – Specification & Accessories
J2
Signal Description
Pin
3 not connected –
Table 5-17 ESCON Module MoBo – Motor Plug J2 – Pin Assignment for maxon DC motor (brushed)
J2
Signal Description
Pin
Table 5-18 ESCON Module MoBo – Motor Plug J2 – Pin Assignment for maxon EC motor (brushless)
Specification / Accessories
Table 5-19 ESCON Module MoBo – Motor Plug J2 – Specification & Accessories
J3
Signal Description
Pin
5 GND Ground
Table 5-20 ESCON Module MoBo – Hall Sensor Plug J3 – Pin Assignment
Specification / Accessories
Table 5-21 ESCON Module MoBo – Hall Sensor Plug J3 – Specification & Accessories
J4
Signal Description
Pin
1 not connected –
3 GND Ground
4 not connected –
6 Channel A Channel A
8 Channel B Channel B
9 not connected –
10 not connected –
Accessories
Length 3m
Head A DIN 41651 female, 2.54 mm pitch, 10 pins, with strain relief
Head B DIN 41651 connector, 2.54 mm pitch, 10 poles, with strain relief
Best practice
• Because of its resistance against electrical interferences, we recommend using differential scheme.
Nevertheless, the controller supports both schemes – differential and single-ended.
• The controller does not require an index impulse (Ch I, Ch I\).
• For best performance, we strongly recommend using encoders with line driver. Otherwise, speed
limitations may apply due to slow switching edges.
J5
Signal Description
Pin
5 GND Ground
Table 5-25 ESCON Module MoBo – Digital I/Os Plug J5 – Pin Assignment
Specification / Accessories
Table 5-26 ESCON Module MoBo – Digital I/Os Plug J5 – Specification & Accessories
J6
Signal Description
Pin
7 GND Ground
Table 5-27 ESCON Module MoBo – Analog I/Os Plug J6 – Pin Assignment
Specification / Accessories
Table 5-28 ESCON Module MoBo – Analog I/Os Plug J6 – Specification & Accessories
5.7.3 Wiring
Note
The USB interface is located directly at the ESCON Module 24/2.
Note
The subsequent diagrams feature this symbol:
5.7.3.1 DC Motors
MAXON DC MOTOR
Figure 5-38 ESCON Module MoBo – maxon DC motor with DC Tacho (J2)
Figure 5-39 ESCON Module MoBo – maxon DC motor with Encoder (J2 / J4)
5.7.3.2 EC motors
Figure 5-40 ESCON Module MoBo – maxon EC motor with Hall Sensors (J2 / J3)
Figure 5-41 ESCON Module MoBo – maxon EC motor with Hall Sensors & Encoders (J2 / J3 / J4)
444144 2-pole pluggable screw-type terminal block, 3.5 mm pitch, labeled 1…2
444145 4-pole pluggable screw-type terminal block, 3.5 mm pitch, labeled 1…4
444146 5-pole pluggable screw-type terminal block, 3.5 mm pitch, labeled 1…5
444147 6-pole pluggable screw-type terminal block, 3.5 mm pitch, labeled 1…6
444148 7-pole pluggable screw-type terminal block, 3.5 mm pitch, labeled 1…7
LIST OF FIGURES
LIST OF TABLES
INDEX
275934 45
A 403968 24
additionally applicable regulations 8 438725 9
analog inputs 23 444144 52
444145 52
applicable EU directive 13
444146 52
assignment of the connections 15
444147 52
444148 52
C 486400 39
cables (prefab)
Encoder Cable 45 P
USB Type A - micro B Cable 24
performance data 9
country-specific regulations 8
pin assignment 15
precautions 8
D prerequisites prior installation 13
digital inputs 20, 21 prohibitive signs 6
purpose
E of the device 7
error display 26
ESD 8 R
EU directive, applicable 13 regulations, additionally applicable 8
H S
how to safety alerts 6
calculate required supply voltage 14 safety first! 8
interpret icons (and signs) used in the document 6 signs used 6
support for designing the motherboard 33 sockets
J1 41
I J2 42
incorporation into surrounding system 13 J3 43
informatory signs 6 J4 18, 44
intended purpose J5 46
of the device 7 J6 47
of this document 5 J7 24
interfaces, location and designation 27 standards, fulfilled 12
status display 26
L status LEDs 26
supply voltage, required 14
LEDs 26
symbols used 6
M T
mandatory action signs 6
technical data 9
MoBo (ESCON Module 24/2 Motherboard) 39
U
N
USB interface 24
notations used 5
W
O
wiring diagrams for
operating license 13 DC motors 27, 48
operating status, display 26 EC motors 30, 51
order numbers
maxon motor ag
Brünigstrasse 220 +41 41 666 15 00
CH-6072 Sachseln www.maxongroup.com
D.2. MAXON MOTOR APPENDIX D. DATASHEETS
130
EC 20 flat ∅20 mm, brushless, 5 watt
A with Hall sensors B sensorless
motor
ECEC flat
M 1:1
DETAILS
EC 20 flat Ø20 mm, brushless, 5 Watt, with Hall sensors
Part number 351006
20-49 €80.00
from 50 On request
Start combination
Specifications
TECHNICAL ILLUSTRATIONS
Dimension drawing
Information: Drawings are not to scale.
Nominal voltage 9V
No load speed 9430 rpm
No load current 68.3 mA
Nominal speed 5310 rpm
Nominal torque (max. continuous torque) 8.58 mNm
Nominal current (max. continuous current) 0.974 A
https://www.maxongroup.com/maxon/view/product/351006 1/3
28/12/22, 16:55 Online shop for high precise drive systems by maxon | maxon group
CHARACTERISTICS
THERMAL DATA
MECHANICAL DATA
OTHER SPECIFICATIONS
PRODUCT
Weight 22 g
Description
Thanks to their flat design, the brushless EC flat motors are exactly the right drive for many applications. The well-conceived, simple engineering
allows mainly automated production which results in a favorable price.
Downloads
CAD-FILES (STEP)
https://www.maxongroup.com/maxon/view/product/351006 2/3
28/12/22, 16:55 Online shop for high precise drive systems by maxon | maxon group
CATALOG PAGE
Videos
https://www.maxongroup.com/maxon/view/product/351006 3/3
D.3. FLEX-PRINT CONNECTOR TO PCB-SCREW CLAMPS APPENDIX D. DATASHEETS
135