English
In our wiki-space campaign we have decided the first launch date, this is the next January 28th. For this launch the following objectives:1. Launch a stratospheric balloon with our launch ramp and the system arrives at least 30 km.
2. At 30 km high, launch a rocket stage with a monitoring system.
3. At 2 km to open a parachute.
4. See the results, analyze and report.
Then you can see the code that we will introduce the AWIP to the igniter is turned on at 30 km and the parachute at 2 km. This has been done by Juan Martínez and Joshua Tristancho and reviewed by Victor Kravchenko.
Castellano
En nuestra wiki-campaña espacial nos hemos propuesto la primera fecha de lanzamiento, esta es el 28 de enero. Para este lanzamiento los objetivos son los siguientes:
- Lanzar nuestro globo estratosferico con nuestra rampa le lanzamiento y que llegue a un mínimo de 30 km.
- A 30 km lanzar la etapa del cohete con un sistema de seguimiento.
- A 2 km que se abra un paracaídas.
- Ver los resultados, analizarlos y reportarlos.
Code (codigo):
// ATmega168@16MHz 5V
// Garmin GPS-18x VLC 010-00321-36 http://www8.garmin.com/ manuals/GPS18x_ TechnicalSpecifications.pdf
// ITG-3200 http://invensense.com/mems/ gyro/documents/PS-ITG-3200-00- 01.4.pdf
// LIS331HH http://www.st.com/stonline/ products/literature/ds/16366. pdf
// Garmin GPS-18x VLC 010-00321-36 http://www8.garmin.com/
// ITG-3200 http://invensense.com/mems/
// LIS331HH http://www.st.com/stonline/
#include <Wire.h>
#include <SoftwareSerial.h>
#include <EEPROM.h>
#include <math.h>
#define IGNITION_ALTITUDE 30000 // Above this altitude in meters the igniter is activated
#define PARACHUTE_ALTITUDE 2000 // Below this altitude in meters the parachute is deployed
#define SAFETY_ALTITUDE 3000 // Safety altitude above wich the parachute can be deployed
#define APOGEE_ADDR 0 // Apogee EEPROM Address
#define IGNITION_PIN 12 // Ouput pin number to activate the igniter 5V
#define PARACHUTE_PIN 10 // Ouput pin number to activate the parachute 5V
#define GPSRX_PIN 11 // Input pin for GPS Rx serial port
#define GPSTX_PIN 13 // Output pin for GPS Tx serial port
#define PARACHUTE_ALTITUDE 2000 // Below this altitude in meters the parachute is deployed
#define SAFETY_ALTITUDE 3000 // Safety altitude above wich the parachute can be deployed
#define APOGEE_ADDR 0 // Apogee EEPROM Address
#define IGNITION_PIN 12 // Ouput pin number to activate the igniter 5V
#define PARACHUTE_PIN 10 // Ouput pin number to activate the parachute 5V
#define GPSRX_PIN 11 // Input pin for GPS Rx serial port
#define GPSTX_PIN 13 // Output pin for GPS Tx serial port
//#include "itg3200.h" // GYRO ITG-3200
#define GyroID B1101001
//Register 22 - FS_SEL, DLPF_CFG
#define R22 0x16
#define R22INIT B00011011
//Register 62 - Power Management
#define R62 0x3e
#define R62INIT B00000001
//Registers 27 to 34 - Sensor Registers
#define TempH 0x1b
#define TempL 0x1c
#define GyroXH 0x1d
#define GyroXL 0x1e
#define GyroYH 0x1f
#define GyroYL 0x20
#define GyroZH 0x21
#define GyroZL 0x22
#define GyroID B1101001
//Register 22 - FS_SEL, DLPF_CFG
#define R22 0x16
#define R22INIT B00011011
//Register 62 - Power Management
#define R62 0x3e
#define R62INIT B00000001
//Registers 27 to 34 - Sensor Registers
#define TempH 0x1b
#define TempL 0x1c
#define GyroXH 0x1d
#define GyroXL 0x1e
#define GyroYH 0x1f
#define GyroYL 0x20
#define GyroZH 0x21
#define GyroZL 0x22
//#include "lis331hh.h" Accelerometer LIS331HH
#define AccID 0x18
//Register CTRL_REG0 - Power management and conf
#define RCTR0 0x20
#define RCTR0INIT B00100111
//Sensor Registers
#define AccXH 0x29
#define AccXL 0x28
#define AccYH 0x2B
#define AccYL 0x2A
#define AccZH 0x2D
#define AccZL 0x2C
#define AccStat 0x27
#define AccID 0x18
//Register CTRL_REG0 - Power management and conf
#define RCTR0 0x20
#define RCTR0INIT B00100111
//Sensor Registers
#define AccXH 0x29
#define AccXL 0x28
#define AccYH 0x2B
#define AccYL 0x2A
#define AccZH 0x2D
#define AccZL 0x2C
#define AccStat 0x27
void i2cSetRegister(int device, int address, int value)
{
Wire.beginTransmission(device) ;
Wire.send(address);
Wire.send(value);
Wire.endTransmission();
}
{
Wire.beginTransmission(device)
Wire.send(address);
Wire.send(value);
Wire.endTransmission();
}
byte i2cGetRegister(int device, int address)
{
Wire.beginTransmission(device) ;
Wire.send(address);
Wire.endTransmission();
Wire.requestFrom(device, 1);
if(Wire.available())
return Wire.receive();
return B00000000;
}
{
Wire.beginTransmission(device)
Wire.send(address);
Wire.endTransmission();
Wire.requestFrom(device, 1);
if(Wire.available())
return Wire.receive();
return B00000000;
}
int i2cGetValue(int device, int addressH, int addressL)
{
return i2cGetRegister(device, addressH) * 256 + i2cGetRegister(device, addressL);
}
{
return i2cGetRegister(device, addressH) * 256 + i2cGetRegister(device, addressL);
}
// Globals
SoftwareSerial GPS = SoftwareSerial(GPSRX_PIN, GPSTX_PIN);
int addr;
int val; // Last byte read from GPS
float alt; // Last altitude read from GPS
float apogee; // Highest altitude read from GPS. This variable is mirrored in EEPROM.
byte k[]={0,0,0,0,0,0,0,0,0,0,0,0, 0}; // Read buffer for GPS input
SoftwareSerial GPS = SoftwareSerial(GPSRX_PIN,
int addr;
int val; // Last byte read from GPS
float alt; // Last altitude read from GPS
float apogee; // Highest altitude read from GPS. This variable is mirrored in EEPROM.
byte k[]={0,0,0,0,0,0,0,0,0,0,0,0,
float EEPROMGetFloat(int addr)
{
float num;
((byte*)&num)[0]=EEPROM.read( addr++);
((byte*)&num)[1]=EEPROM.read( addr++);
((byte*)&num)[2]=EEPROM.read( addr++);
((byte*)&num)[3]=EEPROM.read( addr++);
return num;
}
{
float num;
((byte*)&num)[0]=EEPROM.read(
((byte*)&num)[1]=EEPROM.read(
((byte*)&num)[2]=EEPROM.read(
((byte*)&num)[3]=EEPROM.read(
return num;
}
void EEPROMSetFloat(int addr, float num)
{
EEPROM.write(addr++,((byte*)& num)[0]);
EEPROM.write(addr++,((byte*)& num)[1]);
EEPROM.write(addr++,((byte*)& num)[2]);
EEPROM.write(addr++,((byte*)& num)[3]);
}
{
EEPROM.write(addr++,((byte*)&
EEPROM.write(addr++,((byte*)&
EEPROM.write(addr++,((byte*)&
EEPROM.write(addr++,((byte*)&
}
byte Next()
{
// BYTE, BIN, OCT, HEX, 1 = number of decimals
val=byte(GPS.read());
Serial.print(val,BYTE); // For debbuging purpose only
return val;
}
{
// BYTE, BIN, OCT, HEX, 1 = number of decimals
val=byte(GPS.read());
Serial.print(val,BYTE); // For debbuging purpose only
return val;
}
int ReadParam(byte chr=',')
{
int i=0;
while(true)
if(i>=sizeof(k))
return -1; // Buffer overrun
else if((k[i]=Next())==chr)
return i; // Read 'i' bytes
else
i++;
}
{
int i=0;
while(true)
if(i>=sizeof(k))
return -1; // Buffer overrun
else if((k[i]=Next())==chr)
return i; // Read 'i' bytes
else
i++;
}
void setup ()
{
pinMode(IGNITION_PIN,OUTPUT);
digitalWrite(IGNITION_PIN,LOW) ;
pinMode(PARACHUTE_PIN,OUTPUT);
digitalWrite(PARACHUTE_PIN, LOW);
GPS.begin(4800);
Serial.begin(4800);
// EEPROM dumping
/*
for(addr=0;addr<512;addr++)
{
if (!(addr%16)){Serial.println(); Serial.print(addr/1000.0f,3); Serial.print(": ");}
Serial.print(EEPROM.read(addr) /1000.0f,3);Serial.print(" ");
//EEPROM.write(addr,0); // WARNING: This line will erase all the EEPROM memory
}
Serial.println();
*/
addr=0;
val=0;
alt=0;
apogee=EEPROMGetFloat(APOGEE_ ADDR);
{
pinMode(IGNITION_PIN,OUTPUT);
digitalWrite(IGNITION_PIN,LOW)
pinMode(PARACHUTE_PIN,OUTPUT);
digitalWrite(PARACHUTE_PIN,
GPS.begin(4800);
Serial.begin(4800);
// EEPROM dumping
/*
for(addr=0;addr<512;addr++)
{
if (!(addr%16)){Serial.println();
Serial.print(EEPROM.read(addr)
//EEPROM.write(addr,0); // WARNING: This line will erase all the EEPROM memory
}
Serial.println();
*/
addr=0;
val=0;
alt=0;
apogee=EEPROMGetFloat(APOGEE_
Wire.begin();
// Hyperterminal at 57600 and Arduino at 115200 bauds
//Serial.begin(115200);
// Accelerometer LIS331HH setup
i2cSetRegister(AccID, RCTR0, RCTR0INIT);
// Gyro ITG-3200 setup
i2cSetRegister(GyroID, R62, R62INIT);
i2cSetRegister(GyroID, R22, R22INIT);
// Hardware-on-the-loop config
//i=0;
}
void loop()// Hyperterminal at 57600 and Arduino at 115200 bauds
//Serial.begin(115200);
// Accelerometer LIS331HH setup
i2cSetRegister(AccID, RCTR0, RCTR0INIT);
// Gyro ITG-3200 setup
i2cSetRegister(GyroID, R62, R62INIT);
i2cSetRegister(GyroID, R22, R22INIT);
// Hardware-on-the-loop config
//i=0;
}
{
int i;
if(Next()=='$')if(Next()=='G')
{
if(ReadParam()>=0) // Time in UTC of position
if(ReadParam()>=0) // Latitude of position
if(ReadParam()>=0) // Latitude N or S
if(ReadParam()>=0) // Longitude of position
if(ReadParam()>=0) // Longitude E or W
if(ReadParam()>=0) // GPS quality
if(ReadParam()>=0) // Number of satellites (00 to 12)
if(ReadParam()>=0) // Horizontal dilution of precision (0.5 to 99.9)
if(ReadParam()>0) // Antenna altitude above mean sea level (-9999.9 to 99999.9)
{
alt=atof((char*)&k[0]);
if(ReadParam()>=0) // Units of antenna altitude, meters M
if(ReadParam()>=0) // Height of geoid above ellipsoid (-999.9 to 9999.9)
if(ReadParam()>=0) // Units of geoid height, meters M
if(ReadParam()>=0) // Age of differential GPS data, seconds Null
if(ReadParam('*')>=0) // Differential reference station ID Null
if(ReadParam(10)>0) // Checksum
{
if(alt>apogee)
{
apogee=alt;
EEPROMSetFloat(APOGEE_ADDR,
}
if(alt>IGNITION_ALTITUDE)
if(alt<PARACHUTE_ALTITUDE)if(
}
}
}
}
No hay comentarios:
Publicar un comentario