Design Manual (Cansat)
Design Manual (Cansat)
Design Manual (Cansat)
Design Manual
Dedicated to
All the Japanese People
In a grateful appreciation
Acknowledgements
We wish to express our sincere appreciation to the following institutes and individuals
who have assisted me in the development of this text book: Professor Shinichi
NAKASUKA of the University of Tokyo, Ms. Rei Kawashima, first secretary general of
UNISEC Japan, all the staff members of Institute for Education on Space (IfES) at
Wakayama University and Ms. Emiko Ando, secretary of CLTP office, All participants of
first CanSat Leadership Training Program (CLTP1), Faculty of Engineering, Cairo
University. King Fahd University of Petroleum and Minerals (KFUPM).
Preface
The concept of Can-sat was proposed by professor Robert Twiggs of Stanford
University in 1999. Can-Sat is Soda can size satellite. Can-Sat is fundamental concept
in teaching space engineering to undergraduate students. The Can-Sat provides an
affordable way to acquire the students with the basic knowledge to many challenges in
building a satellite. In Can-Sat projects, students will be able to design, build and test a
small electronic payload that can fit inside a Soda can. The Can-Sat is launched and
ejected from a rocket or a balloon. By the use of a parachute, the Can-Sat slowly
descends back to earth performing its mission while transmitting telemetry. Post launch
and recovery data acquisition will allow the students to analyze the cause of success
and/or failure.
The present textbook is written especially to spread the knowledge of CanSatbased space education in a very systematic and interesting way. Up to our knowledge it
is the first textbook of its kind. The technical contains of the textbook were a collections
of lectures series given during the First CanSat Leader Training Program (CLTP1)
which help in Japan from February 14 to March 18, 2011 at Wakayama University. Also
from the experience gain from different participants attended this course. The book
covers most of the background required to design a baseline CanSat for data gathering
during its launching and descent and send it a ground station PC.
Table of Contents
Chapter 1: Introduction.................................................................................................................................................... 9
1.1 Motivation .................................................................................................................................................................... 9
1.2 Organization of the book ................................................................................................................................. 11
Chapter 2: Mission Profile and System Development ............................................................................... 13
2.1 Introduction .............................................................................................................................................................. 13
2.2 Mission Types........................................................................................................................................................... 13
2.3 Generalized hardware architecture for the CanSat ......................................................................... 14
Chapter 3: Introduction to mbed.............................................................................................................................. 15
3.1 Introduction .............................................................................................................................................................. 15
3.2 Create your first program ................................................................................................................................ 22
3.3 Playing with the built-in LEDs ...................................................................................................................... 23
3.4 Using a tact switch .............................................................................................................................................. 28
3.5 Communication with your PC ....................................................................................................................... 33
3.6 Analog input (connection with an accelerometer) .......................................................................... 37
3.7 Read the mbed API library .............................................................................................................................. 45
3.8 Writing a class library ........................................................................................................................................ 47
3.9 Using the mbed local file system ............................................................................................................... 61
3.10 Using the real-time clock .............................................................................................................................. 65
3.11 Writing a data recorder................................................................................................................................... 69
Chapter 4: Introduction to Global Positioning System (GPS)............................................................... 76
4.1 Introduction .............................................................................................................................................................. 76
4.2 GPS Standard data Format............................................................................................................................. 77
4.3 NMEA 0183 Format .............................................................................................................................................. 77
4.4 GPS Datum................................................................................................................................................................ 80
4.5 Geodetic Coordinate System ........................................................................................................................ 81
4.5.1 Conventional Terrestrial Reference System............................................................................... 82
4.5.2 The WGS 84 (World Geodetic System 1984) .............................................................................. 83
4.6 Converting from WGS84 to navigation coordinates (ENU) ....................................................... 83
4.7 Matlab Program Converting from WGS84 to navigation coordinates (ENU) .................. 85
Chapter 5: CanSat Hardware and Firmware Development ..................................................................... 89
6
CHAPTER 1: INTRODUCTION
Rei Kawashima,
First Secretary General of
UNISEC
1.1 MOTIVATION
In November 1998 at the University Space Systems Symposium (USSS) held in Hawaii,
Prof. Bob Twiggs, Figure 1-1 (Stanford University Space Development Laboratory)
suggested the so-called "CanSat" concept, whereby the entire satellite would adopt the
size of a 350-ml can. This challenge launched the establishment of international
workshops and competitions. During the workshops and competitions throughout the
past decade, college students have designed and built CanSats; launched them by
rockets, balloons and/or model aircrafts; and collected data during the descent of the
CanSats by parachute, simulating the development of experiments in space. During
these hands-on activities, the students have been working on student-led satellite
development projects, realizing low-cost and short-term development programs [1].
affordable opportunity for educators and students to acquire basic knowledge of space
engineering and to experience engineering challenges in building a satellite. The
student will be able to design and build a small electronic payload that can fit inside a
standard drink can (350 ml). The CanSats will be launched by a rocket or balloon and
released in the air. Using a parachute, the CanSat will slowly descend back to the
ground as it performs its designated mission (i.e., taking pictures and transmitting
telemetry). By analyzing the data recorded by the CanSat, participants will investigate
the reasons of its success and/or failure.
Chapter 1 serves as introduction to the subject with the motivation for space
engineering education.
Chapter 2: summaries the basic mission type for CanSat
Chapter 3 presents an introduction to the most important hardware components
of the CanSat which is the microcontroller. The material is dedicated to certain
type of microcontroller which is mbed NXP LPC1768 with its development online
environment. This environment makes it easy to use such microcontroller and
use other developers contributions from the mbed web site. Enormous example
and illustrations are given in chapter 3 to acquire the students the required skills
to write their own code.
Chapter 4 introduces the basic concepts and protocols of the GPS (Global
Positioning System). This sensor is quite new compared with the well know
accelerometers, gyroscope, pressure and temperature.
Chapter 5 deals with the interfaces of the mbed to different MEMS Transducers
(MicroElectroMechanical Sensors) like the accelerometer, gyroscope,
temperature, GPS, and pressure. Well test codes and developed class library for
each of commercial transducers are presented in this chapter. At the end of the
chapter, a program for system integration to read all the sensor and send then to
a serially connected PC is developed.
Chapter 6 introduces the basic concept of parachute analysis, simulation and
design and a nonlinear model to predict the motion of real parachute during
descending is developed and coded using MATLAB. Test example for a
descending parachute from given altitude is simulated and the results were
validated using lower order model.
Chapter 7 presents the concept for the telemetry between the CanSat and
Ground station PC. Commericall available RF comuunication modules were used.
11
Their interface with mbed and the needed firmware are developed. Ground
station PC software was developed using MATLAB.
Chapter 8 introduces the different technique and know-how for the mechanical
construction of CanSat.
Chapter 9 discusses some of the testing techniques for different MEMS sensors
used before launching to ensure the reliability of the developed CanSat.
Chapter 10 presents the technique to interpret and analyze the data acquired
during CanSat mission.
12
13
b) Fly-back CanSat
c) Come-back CanSat
14
The mbed NXP LPC1768 is a 32-bit ARM Cortex-M3 Core running at 96MHz,
512KB FLASH, 64KB RAM with a comprehensive set of peripherals and a built-in
USB interface
Designed specifically to make ARM microcontrollers easily accessible for rapid
prototyping and experimentation
- 0.1" DIP pins so you can use it in breadboard, stripboard and through-hole
PCBs
- Powered via USB or an external power source
- Re-program it like a FLASH drive; it appears as a USB disk, and you just
drag on your .bin files
- Has on-board LEDs, and provides a serial port over the USB connection
to allow for printf-style debugging
- Lots of interfaces including Ethernet, USB Device and Host, CAN, SPI,
I2C and other I/O
More technical information about mbed NXP LPC1768 are presented in Appendix A.
Figures 3-4 and 3-5 show how you can sign up your account after plunging the mbed to
your PC.
16
17
b) Handbook
c) Forum
d) cookbook
e)
To downloading a simple Hello World program from the www.mbed.org web site to the
mbed to the following:
19
20
21
22
LED1 to LED4
- can be turn on and off from a program
Status LED
- turns on when powered
- indicates the transmission status
23
24
Using array can reduced the program length as in the following code
#include "mbed.h"
DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
int main() {
while(1) {
myleds[0] = 1;
wait(0.2);
myleds[0] = 0;
wait(0.2);
}
}
The following code lights all LEDS
#include "mbed.h"
DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
int main() {
while(1) {
myleds[0] =
myleds[1] =
myleds[2] =
myleds[3] =
wait(0.2);
myleds[0] =
myleds[1] =
myleds[2] =
myleds[3] =
wait(0.2);
}
}
1;
1;
1;
1;
0;
0;
0;
0;
myleds[i] = 0;
}
wait(0.2);
}
}
Use a different "for" loop
#include "mbed.h"
DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
int main() {
for (int i = 0;; i = (i + 1) % 4) {
myleds[i] = 1;
wait(0.2);
myleds[i] = 0;
wait(0.2);
}
}
To write a function, the following code give an example
#include "mbed.h"
DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
void setMyLeds(bool arg) {
for (int i = 0; i < 4; i++) {
myleds[i] = arg;
}
}
int main() {
while(1) {
setMyLeds(1);
wait(0.2);
setMyLeds(0);
wait(0.2);
}
}
The function argument, body and data types is described in Figure 3-17.
26
function name
argument
type argument
name
void setM yLeds( bool
arg ) {
return type
}
Figure 3-17 defining a function
To write another function is illustrated in the following code
#include "mbed.h"
DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
void setMyLeds(bool arg0, bool arg1, bool arg2, bool arg3)
{
myleds[0] = arg0;
myleds[1] = arg1;
myleds[2] = arg2;
myleds[3] = arg3;
}
int main() {
while(1) {
setMyLeds(1, 1, 1, 1);
wait(0.2);
setMyLeds(0, 0, 0, 0);
wait(0.2);
}
}
Example 3-1: Count-down in binary
Write a program to count down from 15 to 0
- when the count reaches 0, flash all the LEDs, as shown in the following
Figure 3-18.
0 to 15 in binary
27
Using the breadboard illustrated in Figure 3-21. Connection of both the tact switch and
mbed can be realized quickly, as shown in Figure 3-22. A breadboard (protoboard) is a
construction base for prototyping of electronics. The term is commonly used to refer to
solderless readboard (plugboard). Because the solderless breadboard does not require
soldering, it is reusable. This makes it easy to use for creating temporary prototypes
and experimenting with circuit design.
29
Figure 3-22 mbed and tact switch connected using the breadboard
Reading a switch input
When the tact switch is pressed, the voltage of the p21 pin becomes the same
voltage as the vout pin; when released, the voltage goes down to the ground
level.
Write a program to turn on the LED1 while the tact switch is pressed, as shown in
Figure 3-23.
#include "mbed.h"
DigitalOut myled(LED1);
DigitalIn switchPressed(p21);
int main() {
while (true) {
myled = switchPressed;
}
}
#include "mbed.h"
DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
InterruptIn switchEvent(p21);
volatile bool interruptEnabled;
void switchReleased() {
static int n = 0;
if (interruptEnabled) {
myleds[(n + 3) % 4] = 0;
myleds[n % 4] = 1;
n++;
interruptEnabled = false;
}
}
int main() {
switchEvent.fall(switchReleased);
while (true) {
wait(0.1);
interruptEnabled = true;
}
}
file, which sometimes seems to only download part of the installer application for an
unknown reason. To solve this, download the installer with a different browser (Firefox,
Chrome), and try again; this should solve the issue.
There is several applications for HyperTerminal. TeraTerm will be used in the following
sections as shown in Figure 3-26 and Figure 3-27.
Terminal applications for different OS
MacOS X
o CoolTerm (download and install required)
o screen command (available by default)
Windows
o CoolTerm (download and install required)
o TeraTerm (download and install required)
Linux
o screen command (available by default)
34
35
#include "mbed.h"
int main() {
printf("Echoes back to the screen anything you type\n");
while (true) {
putchar(getchar());
}
}
36
37
There are several physical processes that can be used to develop a sensor to measure
acceleration. In applications that involve flight, such as aircraft and satellites,
accelerometers are based on properties of rotating masses. In the industrial world,
however, the most common design is based on a combination of Newtons law of mass
acceleration and Hookes law of spring action.
38
39
#include "mbed.h"
AnalogIn x(p15);
AnalogIn y(p16);
AnalogIn z(p17);
DigitalIn zeroGDetect(p25);
DigitalOut gSelect(p26);
DigitalOut sleep(p24);
int main() {
gSelect = 1; // 6g mode
sleep = 1; // do not sleep
while (true) {
printf("x = %5.3f, y = %5.3f, z = %5.3f\n", x.read(),
y.read(), z.read());
wait(1.0);
}
}
40
float
toG
( float
value
)
42
#include "mbed.h"
AnalogIn x(p15);
AnalogIn y(p16);
AnalogIn z(p17);
DigitalIn zeroGDetect(p25);
DigitalOut gSelect(p26);
DigitalOut sleep(p24);
float toG(float value) {
return ((value * 3.3) - 1.65) / 0.206;
}
int main() {
gSelect = 1; // 6g mode
sleep = 1; // do not sleep
while (true) {
float accelX = toG(x.read());
float accelY = toG(y.read());
float accelZ = toG(z.read());
float accel = sqrt(accelX * accelX + accelY *
accelY + accelZ * accelZ);
float tiltX = asin(accelX/accel);
float tiltY = asin(accelY/accel);
float tiltZ = asin(accelZ/accel);
printf("accelX = %5.3f, accelY = %5.3f, accelZ
= %5.3f\n", accelX, accelY, accelZ);
printf("tiltX = %5.3f, tiltY = %5.3f, tiltZ
= %5.3f\n", tiltX, tiltY, tiltZ);
wait(1.0);
}
}
The commonly used mathematical function is listed in Table 3-3
43
Zero G Detection
ZeroG pin becomes HIGH, when all 3 axes are at 0g
- Reading ZeroG pin is much faster than reading all 3 axes
- Can use an interrupt on a "Zero G event" occurrence
Enabling the application of free-fall protection
Reading 0G-Detect pin
#include "mbed.h"
DigitalOut leds[] = {LED1, LED2, LED3, LED4};
DigitalIn zeroGDetect(p25);
DigitalOut gSelect(p26);
DigitalOut sleep(p24);
int main() {
gSelect = 1; // 6g mode
sleep = 1; // do not sleep
while (true) {
if (zeroGDetect) { // zeroGDetect becomes 1 (true) if
0G is detected
for (int i = 0; i < 4; i++) {
leds[i] = 1;
}
}
wait(0.1);
}
}
Use an interrupt to detect 0G
#include "mbed.h"
DigitalOut leds[] = {LED1, LED2, LED3, LED4};
InterruptIn zeroGEvent(p25);
DigitalOut gSelect(p26);
DigitalOut sleep(p24);
void trigger() {
for (int i = 0; i < 4; i++) {
leds[i] = 1;
}
}
int main() {
gSelect = 1; // 6g mode
sleep = 1; // do not sleep
44
zeroGEvent.rise(trigger);
while (true) {
wait(60);
}
}
Accelerometer calibration article is presented in Appendix C for further reading.
45
46
A class is an expanded concept of a data structure: instead of holding only data, it can
hold both data and functions.
An object is an instantiation of a class. In terms of variables, a class would be the type,
and an object would be the variable.
Classes are generally declared using the keyword class, with the following format:
class class_name {
access_specifier_1:
member1;
access_specifier_2:
member2;
...
} object_names;
Where class_name is a valid identifier for the class, object_names is an optional list of
names for objects of this class. The body of the declaration can contain members, that
can be either data or function declarations, and optionally access specifiers. a class can
include a special function called constructor, which is automatically called whenever a
new object of this class is created. This constructor function must have the same name
as the class, and cannot have any return type; not even void.
The accelerometer class name, constructors, and function can be listed as follows:
Name
- Accelerometer
Constructor
- Accelerometer(pins...)
Functions
- float getAccel() // get total acceleration
- float getAccelX(), getAccelY(), getAccelZ()
- float getTiltX(), getTiltY(), getTiltZ()
- void setScale(scale) // 1.5G or 6G mode
- void setSleep(bool) // set sensor to sleep mode
- bool detectedZeroG()
48
49
float x = getAccelX();
float y = getAccelY();
float z = getAccelZ();
float a = sqrt(x * x + y * y + z * z);
return asin(x / a);
}
float Accelerometer::getTiltY()
float x = getAccelX();
float y = getAccelY();
float z = getAccelZ();
float a = sqrt(x * x + y *
return asin(y / a);
}
float Accelerometer::getTiltZ()
float x = getAccelX();
float y = getAccelY();
float z = getAccelZ();
float a = sqrt(x * x + y *
return asin(z / a);
}
y + z * z);
{
y + z * z);
51
52
53
54
55
56
57
58
59
60
the microprocessor program makes an access to the local drive, it will be marked as
"removed" on the host computer. This means it is no longer accessible from the host
computer. The drive will only re-appear when the microcontroller program exits. Note
that if the program does not exit, you will need to hold down the reset button on the
mbed to be able to see the drive again.
The first example is to write "Hello World!" to a file is to write down a program to perform
the following function;
Create a local file system "local"
Create & open a new file "out.txt" on the file system, see Figure 3-60.
Write a message "Hello World!" to the file
Close the file
The resulting code will be as follows;
#include "mbed.h"
LocalFileSystem local("local");
int main() {
FILE *fp = fopen("/local/out.txt", "w");
fprintf(fp, "Hello World!\n");
fclose(fp);
}
To Run the program do the following steps:
Eject (or unmount) the mbed USB disk from your computer
o use "safely remove hardware" on Windows
o do NOT unplug the USB cable
Press the reset button
The mbed USB disk will automatically be mounted, when the program finishes
63
Use a text editor to create a file "number.txt" on your mbed USB disk; The first
line of the file should consist of your favorite number (positive integer)
Read the file and get the number x
Create a new file "sum.txt" and write a sentence (with appropriate substitutions to
x and xxx); The sum of all the integers from 1 to x is xxx.
+
30
+
31
+
31
+
Days fro Janauray first until December 1, 2011,Time 00:00:00
The time format in the printf and strftime statements are defined in the following table.
65
The following figures, Figure 3-62, shows the result on your terminal application
66
t.tm_sec = n6;
t.tm_min = n5;
t.tm_hour = n4;
t.tm_mday = n3;
t.tm_mon = n2 - 1;
t.tm_year = n1 + 100;
set_time(mktime(&t));
}
int main() {
if (time(NULL) == (time_t) -1) {
set_time(0);
}
printf("Adjust RTC - Enter t or T\n");
while (true) {
switch (getchar()) {
case 'T':
adjustTime();
break;
case 't':
printTime(5);
break;
}
}
}
68
69
70
71
72
73
}
fclose(fp);
}
75
The idea behind GPS is rather simple. If the distances from a point on the Earth (a GPS
receiver) to three GPS satellites are known along with the satellite locations, then the location of
the point (or receiver) can be determined by simply applying the well-known concept of
76
resection [4-1]. That is all! But how can we get the distances to the satellites as well as the
satellite locations?.
Each GPS satellite continuously transmits a microwave radio signal composed of two
carriers, two codes (or more for modernized satellites), and a navigation message. When a
GPS receiver is switched on, it will pick up the GPS signal through the receiver antenna. Once
the receiver acquires the GPS signal, it will process it using its built-in processing software.
The partial outcome of the signal processing consists of the distances to the GPS satellites
through the digital codes (known as the pseudo ranges) and the satellite coordinates through
the navigation message. Theoretically, only three distances to three simultaneously tracked
satellites are needed. In this case, the receiver would be located at the intersection of three
spheres; each has a radius of one receiver-satellite distance and is centered on that particular
satellite as shown in Figure 4-2.
77
receiver). A high-speed version of NMEA 0183 is also available, which operates at a rate up to
38.4 K-baud.
The NMEA 0183 data streams may include information on position, datum, water depth,
and other variables. The data is sent in the form of sentences, each starting with a dollar sign
"$" and terminating with a carriage return-line feed "<CR><LF>"; the dollar sign "$" is followed
by a five-character address field, which identifies the talker (the first two characters) and the
format and data type (the last three characters). The data fields are separated by "," delimiter.
A null field (i.e., a field with zero length) is used when the value of the field is unavailable or
unreliable. The last field in any sentence follows a checksum delimiter character "*" and is a
checksum field. The maximum total number of characters in any sentence is 82 (i.e., a
maximum of 79 characters between the starting delimiter "$" and the terminating "<CR><LF>").
A number of these sentences are dedicated to GNSS (Global Navigation Satellite System),
including GPS and GLONASS (the Russian GPS counterpart) systems, while the remaining
sentences support other devices such echo sounders, gyroscopes, and others. Table 4-1
shows common GNSS-related NMEA sentences, which are defined in the current
version of NMEA 0183.
Our discussion will be restricted to one sentence only, which is commonly used
in practice-the GGA, or GPS fix data. This sentence represents the time, position, and
solution-related information. Figure 4-3 shows the general structure of the GGA
sentence, while Table 4-2 explains the terms of the sentence.
Table 4-1 Common GNSS-Related NEMA Sentences
NMEA Sentence
AlM
GBS
GGA
GMP
GNS
GRS
GSA
GST
GSV
Description
GPS almanac data
GNSS satellite fault detection
GPS fix data
GNSS map projection fix data
GNSS fix data
GNSS range residuals
GNSS DOP and active satellites
GNSS pseudorange error statistics
GNSS satellites in view
78
xx
x.x
x.x
M
x.x
M
x.x
xxxx
*
hh
<CR><LF>
Explanation
Start of sentence delimiter
Talker identifier (GPS in this case)
Data identifier (GPS fix data in this case)
Data field delimiter
Time of position in UTC system
(hoursminutesseconds.decimall. Decimal
digits are variable.
Latitude (degreesminutes.decimall. Decimal digits are variable.
N/S (North or South)
Longitude (degreesminutes.decimal). Decimal digits are variable.
E/W (East or West)
GPS quality indicator (0 = Fix not available or invalid)
(1 = Point positioning with CIA-code)
(2 = DGPS with CIA-code)
(3 = Point Positioning with P-code)
(4 = RTK with ambiguity parameters fixed to integer values)
(5 = RTK with float ambiguity parameters)
(6 = Estimated [dead reckoning] mode)
(7 = Manula input model)
(8 = Simulator mode)
Number of satellites used in producing the solution
Horizontal Dilution of Precision (HOOP)
Altitude above geoid (Orthometric height)
Meters (units of Orthometric height)
Geoidal Height above the WGS84 ellipsoid (geoid-ellipsoid
separation) Meters (units of Geoidal Height)
Age of Differential GPS data in seconds (time since last RTCM
message type 1 or 9 was received; null filed when Differential GPS
mode is not used).
Differential reference station 10 (range 0000-1023)
Checksum delimiter character
Checksum field (last field in the sentence)
Sentence terminator
Most GPS receivers available on the market support the NMEA 0183 standards.
However, not all receivers with the NMEA 0183 port output all the GPS-specific
messages. In addition, some GPS receiver manufacturers may slightly change the
standard format. However, they typically provide software to interpret the data
sentence.
79
In addition to the geodetic datum, the so-called vertical datum is used in practice as a
reference surface to which the heights (elevations) of points are referred. Because the height of
a point directly located on the vertical datum is zero, such a vertical reference surface is
commonly known as the surface of zero height. The vertical datum is often selected to be the
surface that best approximates the mean sea level on a global basis (the geoid), as shown in
Figure 4-4.
location; therefore, it is also known as the local-level system. The ENU system is a
right-handed. It is possible to transform the ENU coordinates into geodetic coordinates,
and vice versa.
Figure 4-6 (a) Concept of geodetic coordinate; (b) geodetic and Cartesian
coordinates.
4.5.1 CONVENTIONAL TERRESTRIAL REFERENCE SYSTEM
The Conventional Terrestrial Reference System (CTRS) is a three dimensional
geocentric coordinate system (i.e., its origin coincides with the center of the Earth; as
shown in Figure 4-5). The CTRS is rigidly tied to the Earth (i.e., it rotates with the Earth).
It is therefore also known as the Earth-centered, Earth-fixed (ECEF) coordinate system.
The orientation of the axes of the CTRS is defined as follows: The z-axis points toward
the conventional terrestrial pole, which is defined as the average location of the pole
during the period 1900-1905. The x-axis is defined by the intersection of the terrestrial
equatorial plane and the meridianal plane that contains the mean location of the
Greenwich observatory (known as the mean Greenwich meridian). It is clear from the
definition of the x- and z-axes that the xz-plane contains the mean Greenwich meridian.
The y-axis is selected to make the coordinate system right-handed (i.e., 90 degrees
east of the x-axis, measured in the equatorial plane). The three axes intersect at the
center of the Earth, as shown in Figure 4-5.
82
(4-1)
83
Where
a and e2 are the semi-major axis and the first numerical eccentricity of the Earth
respectively. To convert small changes in latitude, longitude and height into
ECEF coordinates we need to Taylor expand equation (4-1) about
d , d and h h dh .
(4-2)
(4-3)
Substituting equation (4-2) into equation (4-3), and ignoring terms of O(d3) and
O(dhd2) and higher, we get
84
(4-4)
Note: The coordinates (;;h) are ellipsoidal (WGS84), not spheroidal (geocentric). The
difference is most easily explained by Figure 4-8.
85
The resulting output is a n x 3 matrix with the first, second, and third columns,
representing the east, north and up displacement respectively in meters.
86
m-file dllh2denu.m
function denu = dllh2denu(llh0,llh)
% CONSTANTS
%--------a = 6378137;
b = 6356752.3142;
e2 = 1 - (b/a)^2;
% Location of reference point in radians
%-------------------------------------phi = llh0(1)*pi/180;
lam = llh0(2)*pi/180;
h = llh0(3)
% Location of data points in radians
%---------------------------------dphi= llh(:,1)*pi/180 - phi;
dlam= llh(:,2)*pi/180 - lam;
dh = llh(:,3) - h;
87
88
5.1 INTRODUCTION
The mission considered for the present CanSat under consideration is a data gathering
mission as presented in Chapter 2. This chapter will present the inference between
mbed and the different transducers connect to it. The MEMS transducer considered in
this mission is listed in Table 5-1. The appendices written in the last column of the table
it is for the full technical details of the corresponding transducer.
Table 5-1. Basic hardware for the Can-Sat Development
Component
Model
Note
2-Axis Gyro
LPR530AL
Appendix F
3 Axis
MMA7361LC
Appendix B
Accelerometer
Pressure Sensor
DSP 1000
Appendix D
GPS Module
GT-723F
Appendix E
5.3 GPS
Chapter 4 provides a complete presentation to the GPS systems the GPS employed
here is GT-723F, shown in Figure 5-2. Only hardware implementation and firmware
class for the present GPS will be presented. Figure 5-3 shows the GPS-mbed circuit
diagram. The power source for GPS is taken from the mbed VU-5V output pin. General
purpose LI-PO 7.4V, 1300 mAh Li-Po Power pack is connected to the circuit with the
required regulator to provide 5 V and high current for servo and other on-board
electronics where the mbed output current is not enough. The jumper JP1 in the circuit
serve as hardware trigger for starting of the data gathering and storage from different
89
transducer. Software trigger can also be employed using accelerometer reading as the
value of acceleration goes to high during a rocket launch.
90
Ticker Send_data;
91
int main()
{
pc.baud(9600);
GPS.pc = &pc;
Send_data.attach(&Print_data,1);
while(1)
{
// endless loop for continuous reading of GPS data
}
}
void Print_data()
{
GPS.update();
No_Sat=GPS.Satnum;
Direction_GPS=GPS.Course;
Speed_GPS=GPS.Speed;
Latitude=GPS.Sec_Lat;
Longitude=GPS.Sec_Lon;
Altitude=GPS.Altitude;
T_Angle=GPS.Theta;
//RTC access
time_t seconds=time(NULL);
char buf[32];
strftime(buf, sizeof(buf), "%X", localtime(&seconds));
//Print to PC
pc.printf("Time:, %s ,",buf);
pc.printf("GPS :, %2d, %.2f, %.2f, %.2f, %.2f, %.2f,
",No_Sat,GPS.Course, GPS.Speed , GPS.Sec_Lat, GPS.Sec_Lon,GPS.Altitude);
float b)
92
chop_message(nmea2);
present_array();
}
myGPS::myGPS(PinName tx,PinName rx) :ser(tx,rx)
{
T_Lon = T_Lat= 0;
}
//--------------------read nmea from GPS unit-------------------void myGPS::read_nmea(void) {
//
//
char nmeabuff[100];
for(int i = 0; i< 5;i++)
do{
myGPS::ser.scanf("%s",nmea1);
}while(!((nmea1[2]=='P') and (nmea1[3]=='G') and (nmea1[4]=='G') and
(nmea1[5]=='A')));
// pc->printf("%s\r\n",nmea1);
do{
myGPS::ser.scanf("%s",nmea2);
}while(!((nmea2[2]=='P') and (nmea2[3]=='R') and (nmea2[4]=='M') and
(nmea2[5]=='C')));
// pc->printf("%s\r\n",nmea2);
}
//---------------- chop the nmea message separated by comma's----------int myGPS::chop_message(char nmea[]) {
for (int k=0; k<MAX_STR; k++) {
// just to make sure thet the
char array is set to 0x00
for (int l=0; l<STR_LEN; l++) {
gp[k][l]= 0x00;
};
}
int strcnt=0;
// string counter
int strpos=0;
// position inside the string
for (int k=0; k < MESS_LEN; k++) {
if (nmea[k] == '*') {
// detect end of message is
found
gp[strcnt][strpos]= 0x00;
// close the string with 0x00
return 0;
// the work is done, end of this
function
}
if (nmea[k] == 0x2c) {
// detect the comma
if (strpos == 0) {
gp[strcnt][0]= 'E';
// comma at position zero, string
must be empty
gp[strcnt][1]= 'm';
// comma at position zero, string
must be empty
gp[strcnt][2]= 'p';
// comma at position zero, string
must be empty
93
gp[strcnt][3]= 't';
gp[strcnt][4]= 'y';
must be empty
must be empty
gp[strcnt][5]= 0x00;
must be empty
} else {
gp[strcnt][strpos]= 0x00;
}
strcnt += 1;
strpos =0;
} else {
gp[strcnt][strpos]= nmea[k];
strpos += 1;
}
}
return 0;
}
94
The h code
include "mbed.h"
#define MESS_LEN
#define MAX_STR
#define STR_LEN
100
20
40
class myGPS
{
public:
myGPS(PinName tx,PinName rx);
access this function;
//~myGPS();
float Sec_Lon;
float Sec_Lat;
float Course;
float Speed;
float Theta;
int Satnum;
float Altitude;
Serial ser;
void setTarget(float, float);
void update();
Serial *pc;
private:
float T_Lon,T_Lat;
char nmea1[100];
char nmea2[100];
void read_nmea(void) ;
int chop_message(char []);
void present_array() ;
char gp[MAX_STR][STR_LEN];
};
5.4 ACCELEROMETER
Accelerometers, shown in Figure 5-4, are sensors and instruments for measuring,
displaying and analyzing acceleration and vibration. They can be used on a stand-alone
basis, or in conjunction with a data acquisition system. Accelerometers are available in
many forms. They can be raw sensing elements, packaged transducers, or a sensor
system or instrument, incorporating features such as totalizing, local or remote display
and data recording. Accelerometers can have from one to three axes of measurement,
the multiple axes typically being orthogonal to each other. These devices work on many
95
96
float temp;
// Accelerometer pin assignment
AnalogIn x(p15);
AnalogIn y(p16);
AnalogIn z(p17);
DigitalIn Zero_g(p18);
//
myAccelero accel(p15,p16,p17); //x,y,z,0g
float X_g;
float Y_g;
float Z_g;
Ticker myticker;
Ticker Send_data;
void update()
{
X_g=accel.getAccelX();
Y_g=accel.getAccelY();
Z_g=accel.getAccelZ();
}
void Print_data()
{
//RTC access
time_t seconds=time(NULL);
char buf[32];
strftime(buf, sizeof(buf), "%X", localtime(&seconds));
//Print to PC
pc.printf("Time:, %s ,",buf);
pc.printf("Accel:, %.2f, %.2f, %.2f, ",X_g,Y_g,Z_g);
}
int main()
{
pc.baud(9600);
accel.setScale(myAccelero::SCALE_6G);
Send_data.attach(&Print_data,1);
97
// Endless loop
while(1)
{
}
}
98
float x=getAccelX();
float y=getAccelY();
float z=getAccelZ();
float a=sqrt(x*x+y*y+z*z);
return asin(z/a)*180/ 3.14;
}
void myAccelero::setScale(Scale scale){
switch (scale){
case SCALE_1_5G:
this->scale=0.8;
break;
case SCALE_6G:
this->scale=0.206;
break;
}
}
/*bool myAccelero::detectedZeroG(){
return zeroGDetect;
}
void myAccelero::setZeroGDetectListner(T* t, void(T::*func)(void)){
zeroG.rise(func);
}
template<typename T>void myAccelero::setzeroGDetectListner(T*
t,void(T::*func)(void)){
zeroG.rise(t,func);
}
*/
The h code
#ifndef myAccelero_H
#define myAccelero_H
#include "mbed.h"
class myAccelero{
public:
myAccelero(PinName xoutPin,PinName youtPin,PinName zoutPin);
enum Scale{SCALE_1_5G,SCALE_6G};
float getAccel();
float getAccelX();
float getAccelY();
float getAccelZ();
float getTiltX();
float getTiltY();
float getTiltZ();
//bool detectedZeroG();
//void setZeroGDetectListner(void(*func)(void));
//template<typename T>void setZeroGDetectListner(T* t,
void(T::*func)(void));
void setScale(Scale scale);
99
private:
AnalogIn xout,yout,zout;
//DigitalIn ZeroGdetect;
//InterruptIn zeroG;
float scale;
};
#endif
5.5 GYROSCOPE
Gyroscopes, shown in Figure 5-6, are used in various applications to sense either the
angle turned through by a vehicle or structure (displacement gyroscopes) or, more
commonly, its angular rate of turn about some defined axis (rate gyroscopes). The
sensors are used in a variety of roles such as:
100
Ticker myticker;
Ticker Send_data;
void update()
{
Gyro.update();
}
void Print_data()
{
//RTC access
time_t seconds=time(NULL);
char buf[32];
strftime(buf, sizeof(buf), "%X", localtime(&seconds));
//Print to PC
pc.printf("Time:, %s ,",buf);
pc.printf("Gyro:, %.2f, %.2f, %.2f,%.2f, ",Gyro.x,Gyro.y,Gyro.z);
}
int main()
{
pc.baud(9600);
Gyro.pc = &pc;
Gyro.dt = 0.2;
Gyro.initialize();// Automatic initialization of gyro at the bigining,
Warning "Keep the gyro at rest at the beginning"
myticker.attach(&update,Gyro.dt);
Send_data.attach(&Print_data,1);
// Endless loop
while(1)
{
}
}
void myGyro::initialize()
101
{
x0 = gyro.getGyroX();
y0 = gyro.getGyroY();
z0 = gyro.getGyroZ();
// if o == 0 then 1 else o
Xaxi =(Xaxi-omega*(Xaxi%omega))*cos(toRad(o)*dt)
+(omega*Xaxi)*sin(toRad(o)*dt)
+omega*(omega%Xaxi);
Xaxi = Xaxi*(1./sqrt(Xaxi%Xaxi));
Yaxi =(Yaxi-omega*(Yaxi%omega))*cos(toRad(o)*dt)
+(omega*Yaxi)*sin(toRad(o)*dt)
+omega*(omega%Yaxi);
Yaxi = Yaxi*(1./sqrt(Yaxi%Yaxi));
Zaxi = Xaxi*Yaxi;
}
The h code
102
#include "mbed.h"
#include "math.h"
// constructor
// destructor
// update gyro data
class vector
{
public:
void set(float x,float y, float z)
{
vector::x=x;
vector::y=y;
vector::z=z;
}
vector(float x,float y, float z)
{
vector::x=x;
vector::y=y;
vector::z=z;
}
vector operator +(const vector& V)
{
return vector(x+V.x,y+V.y,z+V.z);
}
vector operator -(const vector& V)
{
return vector(x-V.x,y-V.y,z-V.z);
}
vector operator -()
{
return vector(-x,-y,-z);
}
vector operator *(const vector& V)
{
return vector(y*V.z-z*V.y,z*V.x-x*V.z,x*V.y-y*V.x);
}
vector operator *(const float& A)
{
return vector(x*A,y*A,z*A);
}
float operator %(const vector& V)
{
103
return x*V.x+y*V.y+z*V.z;
}
float x,y,z;
};
vector Xaxi;
vector Yaxi;
vector Zaxi;
float x,y,z;
float dt;
Serial *pc;
private:
int x0,y0,z0;
ITG3200 gyro;
vector omega;
};
104
The circuit diagram is shown in Figure 5-8 and the main is listed below. Online
SCP1000.lib class from mbed.org web site can be used for the present temperatue and
pressure transducer.
105
SCP1000 scp1000(p5,p6,p7,p8);
float temp;
int press;
Ticker myticker;
Ticker Send_data;
void update()
{
temp=scp1000.readTemperature();
press=scp1000.readPressure();
}
void Print_data()
{
//RTC access
time_t seconds=time(NULL);
char buf[32];
strftime(buf, sizeof(buf), "%X", localtime(&seconds));
temp=scp1000.readTemperature();
press=scp1000.readPressure();
//Print to PC
pc.printf("Time:, %s ,",buf);
pc.printf("Temp:, %.2f, Press:, %d\r\n",temp,press);
}
int main()
{
pc.baud(9600);
Send_data.attach(&Print_data,1);
while(1)
{
}
}
106
107
myGPS GPS(p13,p14);
//int i;
int No_Sat;
float Direction_GPS;
float Speed_GPS;
float Latitude;
float Longitude;
float Altitude;
float T_Angle;
// Motor variables
float propeller=0.0;
float rudder=0.5;
float elevator=0.5;
float para_sw=0.5;
//
myAccelero accel(p15,p16,p17); //x,y,z,0g
float X_g;
float Y_g;
float Z_g;
Ticker myticker;
Ticker Send_data;
void update()
{
Gyro.update();
X_g=accel.getAccelX();
Y_g=accel.getAccelY();
Z_g=accel.getAccelZ();
temp=scp1000.readTemperature();
press=scp1000.readPressure();
}
void Print_data()
{
GPS.update();
No_Sat=GPS.Satnum;
Direction_GPS=GPS.Course;
Speed_GPS=GPS.Speed;
Latitude=GPS.Sec_Lat;
Longitude=GPS.Sec_Lon;
Altitude=GPS.Altitude;
T_Angle=GPS.Theta;
//RTC access
time_t seconds=time(NULL);
char buf[32];
strftime(buf, sizeof(buf), "%X", localtime(&seconds));
108
temp=scp1000.readTemperature();
press=scp1000.readPressure();
// wait(0.01);
//Print to PC
pc.printf("Time:, %s ,",buf);
pc.printf("GPS :, %2d, %.2f, %.2f, %.2f, %.2f, %.2f,
",No_Sat,GPS.Course, GPS.Speed , GPS.Sec_Lat, GPS.Sec_Lon,GPS.Altitude);
pc.printf("Gyro:, %.2f, %.2f, %.2f,%.2f, ",Gyro.x,Gyro.y,Gyro.z);
pc.printf("Accel:, %.2f, %.2f, %.2f, ",X_g,Y_g,Z_g);
pc.printf("Motor:, %.2f,%.2f,%.2f,%.2f,
",propeller,rudder,elevator,para_sw);
pc.printf("Temp:, %.2f, Press:, %d\r\n",temp,press);
}
109
(6-1)
N = CN S q
(6-2)
and
110
Where
CT = tangential force coefficient, dimensionless
CN = normal force coefficient, dimensionless
The resultant force, R, and the moment, M, are shown in the. The airflow fixed
system is preferred for aerodynamic performance calculations, and the parachute fixed
system for wing stress calculations. The aerodynamic coefficients CL> CD, CT, CN, and
CM can easily be determined in wind-tunnel measurements.
(6-3)
For a parachute with an angle of attack, equal to zero, the drag force and the
tangential force are synonymous. Figure 6-3 shows the coefficients CT, CD, and CM
versus angle of attack for stable and unstable parachutes.
The coefficient presentation shows two interesting facts. The slope of the moment
coefficient curve, dCM/d for the unstable parachute is positive between -25 degrees
and +25 degrees; this is, by definition, destabilizing. This parachute will oscillate
approximately 25 degrees. The slope of the moment coefficient, dCM/d, for the stable
parachute is negative over the total angle of attack; this is, by definition, stabilizing. The
steeper the negative dCM/d slope, the greater is the stabilizing tendency of the
parachute, and the better is its damping capability against unstabilizing forces such as
sudden gusts of wind.
111
Figure 6-3 Coefficients CD, CT, and CM Versus Angle of Attack, , for Stable and
Unstable Parachute [6-1].
= WT or Dp + DL = Wp + WL
Where
DT = total drag, N
112
Dp = drag of parachute,N
DL = drag of load, N
WT= total weight, N
Wp= weight of parachute, N
WL= weight of load, N
In most cases, the drag of the load can be neglected in relation to the large drag of the
parachute. With drag, D = (CDS)P /2 v2 and DT = W T, and solving for v, the important
equation for rate of descent, ve, is obtained.
Ve
(6-4)
2W
SC D
Veo
2W
S o C Do o
(6-5)
Ve
2W
S o C Do o
(6-6)
/ o
deceleration of aircraft. Beginning in the 194Os, parachutes were used for recovery of
unmanned aircraft, missiles, ordnance devices, and, later, recovery of manned and
unmanned spacecraft.
Constructed Shape: The Plan and Profile columns define the constructed diameter
and the cross section of the parachute canopy.
Dc, the constructed diameter of the canopy, can be obtained from the drawing of the
specific parachute.
Nominal Diameter: Do, the nominal diameter of the parachute, can be calculated from
the total canopy surface area, So, including the area of the vent and all other openings:
Do 4S o / 1.1284 S o
(6-7)
Inflated Shape: Dp, the projected diameter of the inflated parachute canopy, is best
calculated from the projected or inflated canopy area, S p. as measured in wind-tunnel
tests. The projected diameter of a parachute varies with parachute type, canopy
porosity, suspension-line length, velocity, and canopy design. A large projected
diameter, Dp, will generally result in a large drag coefficient, CDo. The ratio of projected
diameter to nominal diameter, Dp/Do, is an indication of the drag effectiveness of the
parachute design; the larger the projected diameter in relation to the normal diameter,
the larger the drag coefficient.
Drag Coefficient: CDo is the drag coefficient related to the total canopy surface area, So,
The drag coefficient indicates how effectively a parachute canopy produces drag with a
minimum of cloth area, thereby minimizing weight and volume.
Opening-Force Coefficient. Cx, the opening-force coefficient, indicates the difference
between the instantaneous opening force and the steady drag force at constant speed.
This condition, called the infinite mass case, is obtained in wind-tunnel tests and in
parachute applications with high canopy loadings, W/(CdS)p. as exemplified by aircraft
deceleration parachutes and first-stage drogue chutes.
Average Angle of Oscillation. The angle of oscillation is measured in wind-tunnel tests
or during free-flight tests. Oscillation on most solid textile parachutes varies with size
and descent velocity. Large parachutes oscillate less than small parachutes. Unstable
parachutes tend to descend in an oscillating mode at rates of descent in excess of 7.62
m/s, glide at descent General Application. The general application column in Table 6-1
through 6-5 indicates the primary use of the particular parachute type. In descent rates
below 4.572 m/s, and mix glide and oscillation during medium rates of descent.
General Application. The general application column in Table 6-1 through 6-5
indicates the primary use of the particular parachute type.
Sw in Table 6-4 is the wetted upper canopy surface area on gliding parachutes.
Sw/So in Table 6-4 is the ratio of the upper surface area to total cloth area, including all
ribs and stabilizer panels.
114
115
116
117
C
dv
g D v
dt
m
dy
v
dt
(6-7)
Where
m = mass of parachutist
c = drag coefficient
g = gravitational acceleration
The results of the simulation are shown in Figure 6-5. The parachute is dropped from
500 meters altitude and has a mass of 1Kg and CD of 0.75 after opening. The chute
opens after 3 second in this simulation. The terminal (descent) velocity is 5.211 which in
an excellent agreement with the value computed using equation 6-4 which is 5.21176
m/sec. The total descending time for this CanSat is about 100 seconds.
Parachute Velocity & Position Vs Time (ODE23 solution)
velocity (m/sec)
15
10
10
20
30
40
50
60
70
80
90
100
110
10
20
30
40
50
60
time (sec)
70
80
90
100
110
distance (km)
1.5
0.5
PCHUT.M
118
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
dy/dt = v
nfig = 0;
set properties
global m g c1 c2 topen
m = 0.25;
% mass of parachutist (kg)
d = 1;
% parachute diameter (m)
A = 0.25*pi*d*d; % parachute reference area (m^2)
Rho = 1.225
% air density (kg/m^3)
Cd = 0.15
% Drag coefficient w/o chute
c1 = 0.5*Rho*Cd*A;
% nominal drag coefficient with no chute (kg/sec)
c2 = 5*c1;
% nominal drag coefficient with chute open (kg/sec)
g = 9.8;
% acceleration due to gravity (m/s^2)
pos = 0.5;
% initial height (km)
tol = 1.0e-3;
% max relative error allowed in solution
set time interval of interest, initial conditions, and time to open chute
to = 0;
tf = 600.0; % initial and final times (sec)
zo = [0 0]'; % initial position (m) and velocity (m/s) in vector form
disp(' Initially you are at a height of 500 m above ground.')
topen = input(' Input time for parachute to open (< 600 sec) : ');
call ODE23 to solve problem (original ODEs are in function file PCHUT3A.M)
options = odeset('RelTol',tol);
[t,z] = ode23('pchut4a',[to tf],zo,options);
plot velocity and position vs time
nfig = nfig+1;
figure(nfig)
subplot(2,1,1), plot(t,z(:,2),'b-'), grid, axis([to tf 0 10]);
119
end of simulation
PCHUTA.M
%
%
%
c = c2;
end of function
120
end
Model rocket
RC model airplane
Balloon
High raise building
The advantages and disadvantage of each launching option will be disscusse and techniques to
design Water rocket laucher and ballon for launching will be given
. To be contined
121
The two XBEE-PRO modules are similar and before connection to both the CanSat and
PC they must be paired first and this will be described the next section. Hardware and
firmware development for the XBEE-PRO with mbed will be presented. Finally the
software for the ground station PC using MATLAB PC will be presented.
XBee-Pro modules from Digi International can be used in two modes: In one mode they
represent a mesh network. This is however not used by most users. In the mostly used
wireless serial link mode, they forward data on their serial interface via wireless to a
paired module.
This allows sending serial data wireless. Make sure to configure your mbed with the
same settings as your ground control station PC and the Xbee-Pro modules.
Baud: 9600
Parity: N (none)
Data bits: 8
Stop bits: 1
Abbreviation for this mode: 57600 8N1
7.3.2 INSTALLATION
The simplest way to install the Xbee-Pro modules is to use X-CTU (XCTU) software [71]. This is a windows software from the manufacturer of the XBee-Pro modules and its
very simple to use. Then just connect theUSB XBee Explorer, described above, to your
windows computer. Now you can flash your XBee-Pro modules. If the program asks you
to reset the XBee-Pro, you have to connect the RST pin to the GND pin of the XBee
Explorer. You can make this with tweezers.
1.
2.
3.
4.
124
126
127
//MatLab output
xbee.printf("Hello World");
//
myAccelero accel(p15,p16,p17); //x,y,z,0g
float X_g;
float Y_g;
float Z_g;
Ticker myticker;
Ticker Send_data;
void update()
{
Gyro.update();
X_g=accel.getAccelX();
Y_g=accel.getAccelY();
Z_g=accel.getAccelZ();
temp=scp1000.readTemperature();
press=scp1000.readPressure();
129
}
void Print_data()
{
GPS.update();
No_Sat=GPS.Satnum;
Direction_GPS=GPS.Course;
Speed_GPS=GPS.Speed;
Latitude=GPS.Sec_Lat;
Longitude=GPS.Sec_Lon;
Altitude=GPS.Altitude;
T_Angle=GPS.Theta;
//RTC access
time_t seconds=time(NULL);
char buf[32];
strftime(buf, sizeof(buf), "%X", localtime(&seconds));
temp=scp1000.readTemperature();
press=scp1000.readPressure();
// wait(0.01);
//Print to PC
pc.printf("Time:, %s ,",buf);
pc.printf("GPS :, %2d, %.2f, %.2f, %.2f, %.2f, %.2f,
",No_Sat,GPS.Course, GPS.Speed , GPS.Sec_Lat,
GPS.Sec_Lon,GPS.Altitude);
pc.printf("Gyro:, %.2f, %.2f, %.2f,%.2f,
",Gyro.x,Gyro.y,Gyro.z);
pc.printf("Accel:, %.2f, %.2f, %.2f, ",X_g,Y_g,Z_g);
pc.printf("Temp:, %.2f, Press:, %d\r\n",temp,press);
//MatLab output
xbee.printf("%s, ",buf);
xbee.printf("%2d, %.2f, %.2f, %.2f, %.2f, %.2f, ",No_Sat,
Direction_GPS, Speed_GPS ,Latitude,Longitude,Altitude);
xbee.printf("%.2f, %.2f, %.2f, ",Gyro.x,Gyro.y,Gyro.z);
xbee.printf("%.2f, %.2f, %.2f, ",X_g,Y_g,Z_g);
xbee.printf("%.2f, %.2f\r\n",temp,press);
}
int main()
{
pc.baud(9600);
xbee.baud(9600);
GPS.pc = &pc;
Gyro.pc = &pc;
Gyro.dt = 0.2;
130
131
132
% ---------------WX_old = 0;
WY_old = 0;
WZ_old = 0;
% Pressure
% -------P_old = 100000;
% Temperature
% ----------T_old = 15;
% GPS data
% --------X_Target = 0;
Y_Target = 0;
Z_Target = 0;
LONG_TARGET = 10*pi/180;
LATI_TARGET = 10*pi/180;
X_old = 100;
Y_old = 100;
Z_old = 100;
% Controls
% -------RDRC_old =
ELVC_old =
PROP_old =
PARA_old =
0;
0;
0;
0;
clc;
fprintf('Communication with CanSat is ready... \n');
A=input('Hit any key to start to start. Press 0 then Enter key to
exit.\n','s');
if strcmp(A,'0')
break
end;
scrsz = get(0,'ScreenSize');
H = figure('Position',[50 50 scrsz(3)-100 scrsz(4)-150],'Name','Come-Back
CanSat Ground Station','NumberTitle','off');
while 1
XBEE = 0;
COMPORT = serial('COM10','BaudRate', 9600,'Parity', 'none','DataBits',8,
'StopBits',1);
COMPORT.Terminator = 'CR/LF';
COMPORT.BytesAvailableFcnMode = 'terminator';
COMPORT.BytesAvailableFcn = @Xbee;
COMPORT.timeout = 300;
fopen(COMPORT);
pause(0.6)
fprintf('Data from the main program = %s \n',DATA);
fclose(COMPORT);
133
delete(COMPORT);
LDATA= size(DATA);
VAR_START = findstr(DATA, ',');
NVAR = size(VAR_START);
NVAR(2)
% Assign the Varibale
% hh:mm:ss, GPS:,No. of Sat,Course,Speed, Latitude, Longitude,Altitude,
Gyro:,Wx,Wy,Wz, Accel:, Ax,Ay,Az, Motor:,RDR,ELV,PROP,PARA
if
NVAR(2) ==
TIME_STR =
NSAT_STR =
SPED_STR =
CORS_STR =
LATI_STR =
LONG_STR =
ALTI_STR =
WX_STR =
WY_STR =
WZ_STR =
AX_STR =
AY_STR =
AZ_STR =
RDRC_STR =
ELVC_STR =
PROP_STR =
PARA_STR =
T_STR
=
P_STR
=
18
DATA(1:VAR_START(1)-1);
DATA(VAR_START(1)+1:VAR_START(2)-1);
DATA(VAR_START(2)+1:VAR_START(3)-1);
DATA(VAR_START(3)+1:VAR_START(4)-1);
DATA(VAR_START(4)+1:VAR_START(5)-1);
DATA(VAR_START(5)+1:VAR_START(6)-1);
DATA(VAR_START(6)+1:VAR_START(7)-1);
DATA(VAR_START(7)+1:VAR_START(8)-1);
DATA(VAR_START(8)+1:VAR_START(9)-1);
DATA(VAR_START(9)+1:VAR_START(10)-1);
DATA(VAR_START(10)+1:VAR_START(11)-1);
DATA(VAR_START(11)+1:VAR_START(12)-1);
DATA(VAR_START(12)+1:VAR_START(13)-1);
DATA(VAR_START(13)+1:VAR_START(14)-1);
DATA(VAR_START(14)+1:VAR_START(15)-1);
DATA(VAR_START(15)+1:VAR_START(16)-1);
DATA(VAR_START(16)+1:VAR_START(17)-1);
DATA(VAR_START(17)+1:VAR_START(18)-1);
DATA(VAR_START(18)+1:LDATA(2));
LTIME = size(TIME_STR)
if LTIME(2) > 8
TIME_START = findstr(TIME_STR,':');
HOURS_STR
= TIME_STR(1:TIME_START(1)-1);
MINUTES_STR = TIME_STR(TIME_START(1)+1:TIME_START(2)-1);
SECONDS_STR = TIME_STR(TIME_START(2)+1:LTIME(2));
time_new =
str2num(SECONDS_STR) + 60 * str2num(MINUTES_STR) +
3600 * str2num(HOURS_STR); % Time in Seconds
if time_old == 0
time_old = time_new;
fprintf('NEW TIME CALCULATED 1\n');
continue;
end
end
fprintf('New point will be drawn\n');
time_new
time_old
%
% Write the raw data to a FILE here
% ---------------------------------
134
AX_new = str2num(AX_STR);
AY_new = str2num(AY_STR);
AZ_new = str2num(AZ_STR);
WX_new = str2num(WX_STR);
WY_new = str2num(WY_STR);
WZ_new = str2num(WZ_STR);
P_new
T_new
= str2num(P_STR);
= str2num(T_STR);
LATI = str2num(LATI_STR)*pi/(180*60*60);
LONG = str2num(LONG_STR)*pi/(180*60*60);
ALTI = str2num(ALTI_STR);
X_new
Y_new
Z_new
RDRC_new
ELVC_new
PROP_new
PARA_new
=
=
=
=
str2num(RDRC_STR);
str2num(ELVC_STR);
str2num(PROP_STR);
str2num(PARA_STR);
time_new
AX_new =
AY_new =
AZ_new =
= time_old;
AX_old;
AY_old;
AZ_old;
else
WX_new = WX_old;
WY_new = WY_old;
WZ_new = WZ_old;
P_new
T_new
= P_old;
= T_old;
X_new
Y_new
Z_new
= X_old;
= Y_old;
= Z_old;
RDRC_new
ELVC_new
PROP_new
PARA_new
=
=
=
=
RDRC_old;
ELVC_old;
PROP_old;
PARA_old;
end
%
% Decode the data from the stream of received from the COM Port
% ------------------------------------------------------------%
% Image
% ----subplot(4,4,16);
rgb = imread('Ground_Station.jpg');
135
image(rgb);
axis off
axis image
hold on;
%
% Plot the data
% ------------%
% Check that the time is 0
% GPS Data
% -------subplot(4,4,[3 4 7 8]);
plot3([X_old X_new], [Y_old Y_new], [Z_old Z_new],'r-');
GRID ON
title('Come-Back CanSat Trajectory');
hold on;
plot3(X_Target, Y_Target,
Z_Target,'ro','MarkerSize',20,'MarkerFaceColor','r');
hold on;
% X-Acceleration
% -------------subplot(4,4,1);
plot([time_old time_new], [AX_old AX_new],'b--');
title('X-Linear Acceleration');
hold on
% Y-Acceleration
% -------------subplot(4,4,2);
plot([time_old time_new], [AY_old AY_new],'b--');
title('Y-Linear Acceleration');
hold on
% Z-Acceleration
% -------------subplot(4,4,5);
plot([time_old time_new], [AZ_old AZ_new],'b--');
title('Z-Linear Acceleration');
hold on;
% Angular Acceleration in x-direction
% ----------------------------------subplot(4,4,6);
plot([time_old time_new], [WX_old WX_new],'g-');
title('X-Angular Acceleration');
hold on
% Angular Acceleration in y-direction
% ----------------------------------subplot(4,4,9);
plot([time_old time_new], [WY_old WY_new],'g-');
title('Y-Angular Acceleration');
hold on
136
137
AY_old = AY_new;
AZ_old = AZ_new ;
% Angular Velcoity; Gyro Data
% --------------------------WX_old = WX_new;
WY_old = WY_new;
WZ_old = WZ_new;
% Pressure
% -------P_old = P_new;
% Temperature
% ----------T_old = T_new;
% GPS data
% --------X_old = X_new;
Y_old = Y_new;
Z_old = Z_new;
% Time
% ---time_old = time_new;
RDRC_old
ELVC_old
PROP_old
PARA_old
%
%
%
=
=
=
=
RDRC_new;
ELVC_new;
PROP_new;
PARA_new;
fprintf(fp1,'%f, %f , %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\
n',time_new, X_new, Y_new, Z_new, AX_new, AY_new, AZ_new, WX_new, WY_new,
WZ_new, P_new, T_new, RDRC_new, ELVC_new, PROP_new, PARA_new );
%
% Close the serial port
%
end
fclose(fp1);
138
The CanSat must have a mass of no more than 1000 g; considering its relatively
low weight and the small distance it will possibly fall, a wide range of material could be
considered as appropriate to fulfil the requirements, plastics and many different metals
would be suitable. 350 ml or 500 ml volume can may be used or you can manufacture
your own design cansat from different light-weight metal or composite materials such as
glass fabric, carbon composit or alumininum. Aluminium or aluminium alloys provide the
rigid structure desired while being light-weight, non-brittle commonly available and
cheap.
139
140
this case the thermal insulator will play a major role, delaying cooling as much as
possible.
After CanSat construction some simple temperature and shock resistance test
can be performed on it. The results of these tests can then be used to determine
whether the design was sufficient CanSat structure. CanSat also should be tested in
windy, stormy and icy conditions.
141
142
143
144
145
REFERENCES
1-1
www.cltp.info
1-2
http://www.cansatcompetition.com/
1-3
http://www.arliss.org
3-1
3-2
Pedro Castillo, Rogelio Lozano and Alejandro E. Dzul, Modelling and Control
of Mini-Flying Machines, Springer-Verlag London Limited 2005
Ahmed El-Rabbany, Introduction to GPS, GNSS Technology and Applications
Series, second Edition, Artech House, 2006.
S. P. Drake, Converting GPS Coordinates (h) to Navigation Coordinates
(ENU), DSTO Electronics and Surveillance Research Laboratory, DSTO-TN0432, 2002.
T.W. Knacke, Parachute Recovery System, Design Manual, Parapublishing
1992.
http://www.digi.com
4-1
4-2
5-1
7-1
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
Arithmetic operations
Basic mathematical opeprators
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Modulus (%)
Short-hand notation to perform a mathematical operation and an assignment at the
same time
+=, -=, *=, /=, %=
- Add 4 to a variable x and assign x to the result
x += 4;
Bitwise operators
Bitwise-and (&)
203
3 & 5 produces 1
2 & 4 produces 0
Bitwise-or (|)
3 | 5 produces 7
2 | 4 produces 6
Bitwise-xor (^)
3 ^ 5 produces 6
2 ^ 4 produces 6
Shift operators
Left shift operator(<<)produces the operand to the left of the operator shifted to
the left by the number of bits specified after the operator
1 << 1 produces 2
1 << 5 produces 32
7 << 3 produces 56
Right shift operator(>>)produces the operand to the left of the operator shifted to
the right by the number of bits specified after the operator
1 >> 1 produces 0
5 >> 1 produces 2
7 >> 2 produces 1
Relational operators
Relational operators establish a relationship between the values of the operands. They
produce a Boolean true if the relationship is true, and false if the relationship is false.
equivalent (==)
204
Logical operators
The binary logical operators produce a true or false based on the logical
relationship of its arguments
- Logical AND (&&)
- Logical OR (||)
The unary logical not operator will take a Boolean and produce its negation
- Logical NOT (!)
If you print a bool, youll typically see a 1 for true and 0 for False Integer
and bool conversion
do
statement
while (expression);
Example:
if (n == -1)
printf("error\n");
if (n == 0)
n = 1;
else
n = n + 1;
while (n < 100)
n = n * n;
do
n = n * n;
while (n < 100);
for statement
for (initialization; conditional; step)
statement
for (int i = 0; i < 100; i++)
printf("square of %d = %d\n", i, i * i);
switch statement
switch (selector) {
case value1:
statement;
break;
case value2:
statement;
break;
...
default:
statement;
}
Example:
206
switch (response) {
case 'y':
printf("Yes\n");
break;
case 'n':
printf("No\n");
break;
case 'c':
printf("Cancel\n");
break;
default:
printf("Invalid\n");
}
207
CLTP Office
c/o University Space Engineering Consortium (UNISEC)
Central Yayoi 2Fl., 2-3-2 Yayoi, Bunkyo-ku, Tokyo, 113-0032, Japan
Tel :+81-3-5800-6645
Fax:+81-3-3868-2208
E-mail: [email protected]
www.cltp.info
ISBN-978-4-906837-00-7
C3053