diff --git a/.gitignore b/.gitignore
index 22b80c9dc3..b40917524e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,7 @@
/conf/%gconf.xml
/conf/srtm_data/*
/conf/maps_data/*
+/conf/gps/ublox_conf
# /doc/pprz_algebra/
/doc/pprz_algebra/headfile.log
@@ -99,6 +100,7 @@
/sw/logalizer/plotter
/sw/logalizer/gtk_export.ml
/sw/logalizer/sd2log
+/sw/logalizer/plotprofile
# /sw/simulator/
/sw/simulator/gaia
diff --git a/conf/control_panel.xml.example b/conf/control_panel.xml.example
index b54fddac02..88bb2185d3 100644
--- a/conf/control_panel.xml.example
+++ b/conf/control_panel.xml.example
@@ -68,6 +68,8 @@
+
+
diff --git a/conf/messages.xml b/conf/messages.xml
index 6d37a6050a..25b9a4b52d 100644
--- a/conf/messages.xml
+++ b/conf/messages.xml
@@ -676,7 +676,7 @@
-
+
@@ -824,7 +824,28 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -862,8 +883,31 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1161,8 +1205,18 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/modules/geiger_counter.xml b/conf/modules/geiger_counter.xml
new file mode 100644
index 0000000000..a09ec1c90a
--- /dev/null
+++ b/conf/modules/geiger_counter.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/modules/humid_pcap01.xml b/conf/modules/humid_pcap01.xml
new file mode 100644
index 0000000000..2e792e2c2c
--- /dev/null
+++ b/conf/modules/humid_pcap01.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/conf/modules/humid_sht_i2c.xml b/conf/modules/humid_sht_i2c.xml
index a9587748e3..82eb88d942 100644
--- a/conf/modules/humid_sht_i2c.xml
+++ b/conf/modules/humid_sht_i2c.xml
@@ -9,11 +9,11 @@
-
-
+
+
-
+
diff --git a/conf/modules/light_solar.xml b/conf/modules/light_solar.xml
new file mode 100644
index 0000000000..7cf08e80b9
--- /dev/null
+++ b/conf/modules/light_solar.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/modules/temp_tcouple_adc.xml b/conf/modules/temp_tcouple_adc.xml
new file mode 100644
index 0000000000..0b44301318
--- /dev/null
+++ b/conf/modules/temp_tcouple_adc.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/mtk.dtd b/conf/mtk.dtd
index c97575e3fc..60aeb6c8b7 100644
--- a/conf/mtk.dtd
+++ b/conf/mtk.dtd
@@ -22,5 +22,5 @@
\ No newline at end of file
diff --git a/conf/settings/basic.xml b/conf/settings/basic.xml
index 767f0659f7..bb455f1b11 100644
--- a/conf/settings/basic.xml
+++ b/conf/settings/basic.xml
@@ -10,10 +10,10 @@
-
+
-
-
+
+
@@ -21,7 +21,7 @@
-
+
diff --git a/conf/settings/basic_ins.xml b/conf/settings/basic_ins.xml
new file mode 100644
index 0000000000..f11281ab82
--- /dev/null
+++ b/conf/settings/basic_ins.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/settings/tuning.xml b/conf/settings/tuning.xml
index 22ac1e1d7c..cea85bacb2 100644
--- a/conf/settings/tuning.xml
+++ b/conf/settings/tuning.xml
@@ -17,8 +17,8 @@
-
-
+
+
diff --git a/conf/settings/tuning_ins.xml b/conf/settings/tuning_ins.xml
index 2cf8fe880b..1f092a4a56 100644
--- a/conf/settings/tuning_ins.xml
+++ b/conf/settings/tuning_ins.xml
@@ -17,8 +17,8 @@
-
-
+
+
@@ -32,9 +32,6 @@
-
-
-
diff --git a/conf/settings/tuning_basic_ins.xml b/conf/settings/tuning_ins_dcm.xml
similarity index 91%
rename from conf/settings/tuning_basic_ins.xml
rename to conf/settings/tuning_ins_dcm.xml
index 0d84278f26..4ba4f43d96 100644
--- a/conf/settings/tuning_basic_ins.xml
+++ b/conf/settings/tuning_ins_dcm.xml
@@ -17,8 +17,8 @@
-
-
+
+
@@ -32,6 +32,9 @@
+
+
+
diff --git a/conf/telemetry/default_fixedwing_imu.xml b/conf/telemetry/default_fixedwing_imu.xml
index 256cb30917..28e3f604b0 100644
--- a/conf/telemetry/default_fixedwing_imu.xml
+++ b/conf/telemetry/default_fixedwing_imu.xml
@@ -53,6 +53,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -71,17 +96,6 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sw/airborne/arch/sim/subsystems/imu/imu_b2_arch.c b/sw/airborne/arch/sim/subsystems/imu/imu_b2_arch.c
index e486ebbc38..e680ebc675 100644
--- a/sw/airborne/arch/sim/subsystems/imu/imu_b2_arch.c
+++ b/sw/airborne/arch/sim/subsystems/imu/imu_b2_arch.c
@@ -35,6 +35,7 @@ void imu_periodic(void) {
}
+#ifdef USE_NPS
#include "nps_sensors.h"
void imu_feed_gyro_accel(void) {
@@ -61,3 +62,4 @@ void imu_feed_mag(void) {
ami601_status = AMI601_DATA_AVAILABLE;
#endif
}
+#endif //USE_NPS
diff --git a/sw/airborne/arch/sim/subsystems/imu/imu_b2_arch.h b/sw/airborne/arch/sim/subsystems/imu/imu_b2_arch.h
index 8ef38139af..025acd33bf 100644
--- a/sw/airborne/arch/sim/subsystems/imu/imu_b2_arch.h
+++ b/sw/airborne/arch/sim/subsystems/imu/imu_b2_arch.h
@@ -31,8 +31,9 @@
extern int imu_overrun;
+#ifdef USE_NPS
extern void imu_feed_gyro_accel(void);
extern void imu_feed_mag(void);
-
+#endif
#endif /* IMU_B2_HW_H */
diff --git a/sw/airborne/arch/sim/subsystems/radio_control/ppm_arch.c b/sw/airborne/arch/sim/subsystems/radio_control/ppm_arch.c
index de1a37d3d7..be462fc82b 100644
--- a/sw/airborne/arch/sim/subsystems/radio_control/ppm_arch.c
+++ b/sw/airborne/arch/sim/subsystems/radio_control/ppm_arch.c
@@ -28,7 +28,7 @@
#include
#include
-#ifdef NPS
+#ifdef USE_NPS
#include "nps_radio_control.h"
#endif
@@ -55,7 +55,7 @@ value send_ppm(value unit) {
return unit;
}
-#ifdef NPS
+#ifdef USE_NPS
#define PPM_OF_NPS(_nps, _neutral, _min, _max) \
((_nps) >= 0 ? (_neutral) + (_nps) * ((_max)-(_neutral)) : (_neutral) + (_nps) * ((_neutral)- (_min)))
@@ -94,7 +94,7 @@ value send_ppm(value unit) {
return unit;
}
-#ifdef NPS
+#ifdef USE_NPS
void radio_control_feed(void) {}
#endif
diff --git a/sw/airborne/arch/sim/subsystems/radio_control/ppm_arch.h b/sw/airborne/arch/sim/subsystems/radio_control/ppm_arch.h
index 5f9bfd681d..c0f27a3b5e 100644
--- a/sw/airborne/arch/sim/subsystems/radio_control/ppm_arch.h
+++ b/sw/airborne/arch/sim/subsystems/radio_control/ppm_arch.h
@@ -36,7 +36,7 @@
#define PPM_NB_CHANNEL RADIO_CONTROL_NB_CHANNEL
-#ifdef NPS
+#ifdef USE_NPS
extern void radio_control_feed(void);
#endif
diff --git a/sw/airborne/firmwares/non_ap/geiger_counter/geiger_counter.c b/sw/airborne/firmwares/non_ap/geiger_counter/geiger_counter.c
new file mode 100644
index 0000000000..76c22094b4
--- /dev/null
+++ b/sw/airborne/firmwares/non_ap/geiger_counter/geiger_counter.c
@@ -0,0 +1,171 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2011 Martin Mueller
+ *
+ * This file is part of Paparazzi.
+ *
+ * Paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * Paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+/* I2C interface for University of Reading Geiger-Mueller counter */
+
+#include
+
+#define END_MSG 0x13
+
+/* green LED pin PB5 (on arduino pro mini) */
+#define LED_GR_PIN 13
+
+#define GEIGER_CNT_I2C_ADDR 0x76
+
+enum stats {
+ INIT,
+ FOUND_SYNC,
+ FOUND_1,
+ FOUND_2,
+ FOUND_3,
+ FOUND_4,
+ FOUND_5 };
+
+int received data = 0;
+int stat = 0, received data = 0;
+unsigned long count_geiger_1 = 0;
+unsigned long count_geiger_2 = 0;
+unsigned short volt_geiger = 0;
+
+void read_i2c() {
+ unsigned char dat[10];
+ digitalWrite(LED_GR_PIN, LOW);
+ received_data = 0;
+ memcpy(dat, count_geiger_1, 4);
+ memcpy(dat+4, count_geiger_2, 4);
+ memcpy(dat+8, volt_geiger, 2);
+ Wire.send(dat, 2);
+}
+
+void setup() {
+ /* serial port */
+ Serial.begin(2400);
+ pinMode(2,OUTPUT);
+ digitalWrite(2,HIGH);
+#ifdef DEBUG
+ Serial.println("geiger counter init");
+#endif
+
+ /* I2C init */
+ Wire.begin(GEIGER_CNT_I2C_ADDR >> 1);
+ Wire.onRequest(read_i2c);
+
+ /* green LED init */
+ digitalWrite(LED_GR_PIN, LOW);
+ pinMode(LED_GR_PIN, OUTPUT);
+
+ stat = INIT;
+}
+
+void loop() {
+ unsigned char ser;
+ int i;
+
+ /* wait for data */
+ if (Serial.available() > 0) {
+ ser = Serial.read();
+ switch (stat) {
+ case INIT:
+ /* sync on the last byte of the prev message */
+ if (b == END_MSG) {
+ count_geiger_1 = 0;
+ count_geiger_2 = 0;
+ volt_geiger = 0;
+ i = 0;
+ stat = FOUND_SYNC;
+ }
+ break;
+ case FOUND_SYNC:
+ if ((b <= '9') && (b >= '0')) {
+ count_geiger_1 = count_geiger_1 * 10 + (b-'0');
+ if (++i > 7) state = IDLE;
+ } else if (b == ',')) {
+ i = 0;
+ stat = FOUND_1;
+ } else stat = INIT;
+ break;
+ case FOUND_1:
+ /* read counter 1 */
+ if ((b <= '9') && (b >= '0')) {
+ count_geiger_2 = count_geiger_2 * 10 + (b-'0');
+ if (++i > 7) state = IDLE;
+ } else if (b == ',')) {
+#ifdef DEBUG
+ Serial.println(count_geiger_1, DEC);
+#endif
+ i = 0;
+ stat = FOUND_2;
+ } else stat = INIT;
+ break;
+ case FOUND_2:
+ /* read counter 2 */
+ if ((b <= '9') && (b >= '0')) {
+ count_geiger_2 = count_geiger_2 * 10 + (b-'0');
+ if (++i > 7) state = IDLE;
+ } else if (b == ',')) {
+#ifdef DEBUG
+ Serial.println(count_geiger_2, DEC);
+#endif
+ i = 0;
+ stat = FOUND_3;
+ } else stat = INIT;
+ break;
+ case FOUND_3:
+ /* ignore 3 */
+ if ((b <= '9') && (b >= '0')) {
+ if (++i > 7) state = IDLE;
+ } else if (b == ',')) {
+ i = 0;
+ stat = FOUND_4;
+ } else stat = INIT;
+ break;
+ case FOUND_4:
+ /* ignore 4 */
+ if ((b <= '9') && (b >= '0')) {
+ if (++i > 7) state = IDLE;
+ } else if (b == ',')) {
+ i = 0;
+ stat = FOUND_5;
+ } else stat = INIT;
+ break;
+ case FOUND_5:
+ /* read voltage */
+ if ((b <= '9') && (b >= '0')) {
+ volt_geiger = volt_geiger * 10 + (b-'0');
+ if (++i > 7) state = IDLE;
+ } else if (b == 'V')) {
+ digitalWrite(LED_GR_PIN, HIGH);
+#ifdef DEBUG
+ Serial.println(volt_geiger, DEC);
+#endif
+ received_data = 0;
+ stat = INIT;
+ } else stat = INIT;
+ break;
+ default:
+ stat = INIT;
+ }
+ }
+}
+
diff --git a/sw/airborne/modules/meteo/geiger_counter.c b/sw/airborne/modules/meteo/geiger_counter.c
new file mode 100644
index 0000000000..3c98c238a7
--- /dev/null
+++ b/sw/airborne/modules/meteo/geiger_counter.c
@@ -0,0 +1,77 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2011 Martin Mueller
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+/** \file geiger_counter.c
+ * \brief I2C interface for University of Reading Geiger counter
+ *
+ */
+
+#include "modules/meteo/geiger_counter.h"
+#include "mcu_periph/i2c.h"
+#include "mcu_periph/uart.h"
+#include "messages.h"
+#include "downlink.h"
+
+#ifndef DOWNLINK_DEVICE
+#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
+#endif
+
+#ifndef GEIGER_CNT_DEV
+#define GEIGER_CNT_DEV i2c0
+#endif
+
+#define GEIGER_CNT_I2C_ADDR 0x76
+
+struct i2c_transaction geiger_trans;
+uint32_t count_geiger_1, count_geiger_2;
+uint16_t volt_geiger;
+
+void geiger_counter_init( void ) {
+}
+
+void geiger_counter_periodic( void ) {
+ I2CReceive(GEIGER_CNT_DEV, geiger_trans, GEIGER_CNT_I2C_ADDR, 10);
+}
+
+void geiger_counter_event( void ) {
+ if (geiger_trans.status == I2CTransSuccess) {
+ count_geiger_1 = (geiger_trans.buf[3] << 24) |
+ (geiger_trans.buf[2] << 16) |
+ (geiger_trans.buf[1] << 8) |
+ (geiger_trans.buf[0]);
+ count_geiger_2 = (geiger_trans.buf[7] << 24) |
+ (geiger_trans.buf[6] << 16) |
+ (geiger_trans.buf[5] << 8) |
+ (geiger_trans.buf[4]);
+ volt_geiger = (geiger_trans.buf[9] << 8) |
+ (geiger_trans.buf[8]);
+ geiger_trans.status = I2CTransDone;
+
+ if (volt_geiger & 0x8000) {
+ volt_geiger &= 0x7FFF;
+ DOWNLINK_SEND_GEIGER_COUNTER(DefaultChannel,
+ &count_geiger_1, &count_geiger_2, &volt_geiger);
+ }
+ }
+}
diff --git a/sw/airborne/modules/meteo/geiger_counter.h b/sw/airborne/modules/meteo/geiger_counter.h
new file mode 100644
index 0000000000..cbc900708d
--- /dev/null
+++ b/sw/airborne/modules/meteo/geiger_counter.h
@@ -0,0 +1,11 @@
+#ifndef GEIGER_COUNTER_H
+#define GEIGER_COUNTER_H
+
+#include "std.h"
+
+void geiger_counter_init(void);
+void geiger_counter_periodic(void);
+void geiger_counter_event(void);
+
+#endif
+
diff --git a/sw/airborne/modules/meteo/humid_dpicco.h b/sw/airborne/modules/meteo/humid_dpicco.h
index 7272e5763e..1b95a76d0a 100644
--- a/sw/airborne/modules/meteo/humid_dpicco.h
+++ b/sw/airborne/modules/meteo/humid_dpicco.h
@@ -10,6 +10,8 @@
#define DPICCO_TEMP_RANGE 165.0
#define DPICCO_TEMP_OFFS -40.0
+extern float dpicco_temp;
+
extern void dpicco_init( void );
extern void dpicco_periodic( void );
extern void dpicco_event( void );
diff --git a/sw/airborne/modules/meteo/humid_hih.c b/sw/airborne/modules/meteo/humid_hih.c
index 2e61b5ca45..6904c54d80 100644
--- a/sw/airborne/modules/meteo/humid_hih.c
+++ b/sw/airborne/modules/meteo/humid_hih.c
@@ -31,6 +31,8 @@
#include
#include "modules/meteo/humid_hih.h"
#include "modules/meteo/temp_tmp102.h"
+#include "modules/meteo/humid_dpicco.h"
+#include "modules/meteo/humid_sht.h"
#include "mcu_periph/adc.h"
#include "mcu_periph/uart.h"
#include "messages.h"
@@ -58,8 +60,12 @@ void humid_hih_init( void ) {
}
void humid_hih_periodic( void ) {
- float fvout;
+ float fvout, fhih_temp;
+ /* get temperature from external source */
+ fhih_temp = ftempsht;
+ /****************************************/
+
adc_humid_hih = buf_humid_hih.sum / buf_humid_hih.av_nb_sample;
/* 36k/68k voltage divider, 3.3V full sweep, 10 bits adc */
@@ -69,8 +75,8 @@ void humid_hih_periodic( void ) {
fhih_humid = ((fvout / 5.0)-0.16)/0.0062;
/* temperature compensation */
- fhih_humid = fhih_humid/(1.0546 - (0.00216 * ftmp_temperature));
+ fhih_humid = fhih_humid/(1.0546 - (0.00216 * fhih_temp));
- DOWNLINK_SEND_HIH_STATUS(DefaultChannel, &adc_humid_hih, &fhih_humid, &ftmp_temperature);
+ DOWNLINK_SEND_HIH_STATUS(DefaultChannel, &adc_humid_hih, &fhih_humid, &fhih_temp);
}
diff --git a/sw/airborne/modules/meteo/humid_pcap01.c b/sw/airborne/modules/meteo/humid_pcap01.c
new file mode 100644
index 0000000000..345095bc3c
--- /dev/null
+++ b/sw/airborne/modules/meteo/humid_pcap01.c
@@ -0,0 +1,263 @@
+/*
+ * $Id: humid_pcap01.c $
+ *
+ * Copyright (C) 2011 Norman Wildmann, Martin Mueller
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+/** \file humid_pcap01.c
+ * \brief ACAM Picocap Single-chip Solution for Capacitance Measurement
+ *
+ * This reads the values for temperature and humidity from the ACAM capacitance and resistance
+ * measurement unit through I2C.
+ */
+
+#include "led.h"
+#include "sys_time.h"
+#include "mcu_periph/i2c.h"
+#include "mcu_periph/uart.h"
+#include "messages.h"
+#include "downlink.h"
+#include "modules/meteo/humid_pcap01.h"
+#ifdef PCAP01_LOAD_FIRMWARE
+#include "modules/meteo/humid_pcap01_firmware.h"
+#endif
+
+#ifndef DOWNLINK_DEVICE
+#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
+#endif
+
+uint8_t pcap01_meas_started;
+struct i2c_transaction pcap01_trans;
+PCAP01VALUE pcap01Value;
+
+#ifndef PCAP01_I2C_DEV
+#define PCAP01_I2C_DEV i2c0
+#endif
+
+void writePCAP01_SRAM(uint8_t data, uint16_t s_add)
+{
+ while (pcap01_trans.status == I2CTransPending);
+
+ pcap01_trans.buf[0] = 0x90+(unsigned char)(s_add>>8);
+ pcap01_trans.buf[1] = (unsigned char)(s_add);
+ pcap01_trans.buf[2] = data;
+ I2CTransmit(PCAP01_I2C_DEV, pcap01_trans, PCAP01_ADDR, 3);
+}
+
+uint8_t readPCAP01_SRAM(uint16_t s_add)
+{
+ while (pcap01_trans.status == I2CTransPending);
+
+ pcap01_trans.buf[0] = 0x10+(unsigned char)(s_add>>8);
+ pcap01_trans.buf[1] = (unsigned char)(s_add);
+ I2CTransceive(PCAP01_I2C_DEV, pcap01_trans, PCAP01_ADDR, 2, 1);
+ while (pcap01_trans.status == I2CTransPending);
+
+ return pcap01_trans.buf[0];
+}
+/**
+* \brief PCAP01_Control
+*
+* Function to send control commands to the PCAP01
+*
+* \param control Control command
+* possible commands:
+* PCAP01_PU_RESET : Hard reset of the device
+* PCAP01_IN_RESET : Software reset
+* PCAP01_START : Start measurement
+* PCAP01_START : Start measurement
+* PCAP01_TERM : Stop measurement
+*/
+ void PCAP01_Control(uint8_t control)
+{
+ while (pcap01_trans.status == I2CTransPending);
+
+ pcap01_trans.buf[0] = control;
+ pcap01_trans.buf[1] = 0;
+ pcap01_trans.buf[2] = 0;
+ pcap01_trans.buf[3] = 0;
+ I2CTransmit(PCAP01_I2C_DEV, pcap01_trans, PCAP01_ADDR, 4);
+}
+
+ void pcap01writeRegister(uint8_t reg,uint32_t value)
+ {
+ while (pcap01_trans.status == I2CTransPending);
+
+ pcap01_trans.buf[0] = PCAP01_WRITE_REG + reg;
+ pcap01_trans.buf[1] = (unsigned char) (value>>16);
+ pcap01_trans.buf[2] = (unsigned char) (value>>8);
+ pcap01_trans.buf[3] = (unsigned char) (value);
+ I2CTransmit(PCAP01_I2C_DEV, pcap01_trans, PCAP01_ADDR, 4);
+ }
+
+#ifdef PCAP01_LOAD_FIRMWARE
+void writePCAP01_firmware(void)
+{
+ int i = 0;
+ char testbyte = 44;
+ uint16_t testaddress = 71;
+ // Hard reset
+ PCAP01_Control(PCAP01_PU_RESET);
+ sys_time_usleep(50000);
+ //write testbyte
+ writePCAP01_SRAM(testbyte, testaddress);
+
+ //check testbyte
+ if (readPCAP01_SRAM(testaddress) != testbyte)
+ return;
+ else
+ {
+LED_ON(3);
+ //Hard reset
+ PCAP01_Control(PCAP01_PU_RESET);
+ //write firmware
+ for (i = 0;i< sizeof(firmware); i++)
+ {
+ writePCAP01_SRAM(firmware[i],i);
+ }
+ //fill with ffs
+ for (;i< 4029; i++)
+ {
+ writePCAP01_SRAM(0xff,i);
+ }
+ i++;
+#ifdef PCAP01_200HZ
+ //write end bytes of sram
+ writePCAP01_SRAM(0x04,i++);
+ writePCAP01_SRAM(0x01,i++);
+ writePCAP01_SRAM(0x01,i++);
+#endif
+#ifdef PCAP01_STANDARD
+ //write end bytes of sram
+ writePCAP01_SRAM(0x02,i++);
+ writePCAP01_SRAM(0x01,i++);
+ writePCAP01_SRAM(0x03,i++);
+#endif
+ }
+}
+#endif // PCAP01_LOAD_FIRMWARE
+
+void pcap01_init(void) {
+ pcap01_trans.status = I2CTransDone;
+ pcap01Value.status = PCAP01_IDLE;
+#ifdef PCAP01_LOAD_FIRMWARE
+ writePCAP01_firmware();
+#endif
+ pcap01writeRegister(PCAP01_REG0, PCAP01_REG0_VALUE);
+ pcap01writeRegister(PCAP01_REG1, PCAP01_REG1_VALUE);
+ pcap01writeRegister(PCAP01_REG2, PCAP01_REG2_VALUE);
+ pcap01writeRegister(PCAP01_REG3, PCAP01_REG3_VALUE);
+ pcap01writeRegister(PCAP01_REG4, PCAP01_REG4_VALUE);
+ pcap01writeRegister(PCAP01_REG5, PCAP01_REG5_VALUE);
+ pcap01writeRegister(PCAP01_REG6, PCAP01_REG6_VALUE);
+ pcap01writeRegister(PCAP01_REG7, PCAP01_REG7_VALUE);
+ pcap01writeRegister(PCAP01_REG8, PCAP01_REG8_VALUE);
+ pcap01writeRegister(PCAP01_REG9, PCAP01_REG9_VALUE);
+ pcap01writeRegister(PCAP01_REG10, PCAP01_REG10_VALUE);
+ pcap01writeRegister(PCAP01_REG11, PCAP01_REG11_VALUE);
+ pcap01writeRegister(PCAP01_REG12, PCAP01_REG12_VALUE);
+ pcap01writeRegister(PCAP01_REG13, PCAP01_REG13_VALUE);
+ pcap01writeRegister(PCAP01_REG14, PCAP01_REG14_VALUE);
+ pcap01writeRegister(PCAP01_REG15, PCAP01_REG15_VALUE);
+ pcap01writeRegister(PCAP01_REG16, PCAP01_REG16_VALUE);
+ pcap01writeRegister(PCAP01_REG17, PCAP01_REG17_VALUE);
+ pcap01writeRegister(PCAP01_REG18, PCAP01_REG18_VALUE);
+ pcap01writeRegister(PCAP01_REG19, PCAP01_REG19_VALUE);
+ pcap01writeRegister(PCAP01_REG20, PCAP01_REG20_VALUE);
+ PCAP01_Control(PCAP01_IN_RESET);
+ sys_time_usleep(500000);
+ PCAP01_Control(PCAP01_START);
+}
+
+void pcap01readRegister(uint8_t reg)
+ {
+ uint16_t byte1 = 0x40 | reg;
+ pcap01_trans.buf[0] = byte1;
+ I2CTransceive(PCAP01_I2C_DEV, pcap01_trans, PCAP01_ADDR, 1, 3);
+ }
+
+/**
+* \brief pcap01_readData
+*
+* function where current measurement data from pcap01 is read into
+* global sensor variable
+*
+* \param control Control command
+* possible commands:
+* PCAP01_PU_RESET : Hard reset of the device
+* PCAP01_IN_RESET : Software reset
+* PCAP01_START : Start measurement
+* PCAP01_START : Start measurement
+* PCAP01_TERM : Stop measurement
+*/
+void pcap01_periodic(void)
+{
+ pcap01Value.status = PCAP01_GET_HUMID;
+#ifdef PCAP01_STANDARD
+ pcap01readRegister(PCAP01_REG1);
+#endif
+#ifdef PCAP01_200HZ
+ pcap01readRegister(PCAP01_REG2);
+#endif
+}
+
+void pcap01_event(void)
+{
+ float humidity;
+ float temperature;
+
+ if (pcap01_trans.status == I2CTransSuccess) {
+ switch (pcap01Value.status) {
+
+ case PCAP01_GET_HUMID:
+ pcap01Value.C_ratio = pcap01_trans.buf[0] << 16;
+ pcap01Value.C_ratio |= (pcap01_trans.buf[1] << 8);
+ pcap01Value.C_ratio |= pcap01_trans.buf[2];
+ pcap01Value.status = PCAP01_GET_TEMP;
+#ifdef PCAP01_STANDARD
+ pcap01readRegister(PCAP01_REG13);
+#endif
+#ifdef PCAP01_200HZ
+ pcap01readRegister(PCAP01_REG3);
+#endif
+ break;
+
+ case PCAP01_GET_TEMP:
+ pcap01Value.R_ratio = pcap01_trans.buf[0] << 16;
+ pcap01Value.R_ratio |= (pcap01_trans.buf[1] << 8);
+ pcap01Value.R_ratio |= pcap01_trans.buf[2];
+ humidity = pcap01Value.C_ratio * (-0.0023959245437) + 516.4124438673063;
+ temperature = pcap01Value.R_ratio * 61.927 - 259.74;
+ DOWNLINK_SEND_PCAP01_STATUS(DefaultChannel,
+ &pcap01Value.C_ratio,
+ &pcap01Value.R_ratio,
+ &humidity,
+ &temperature);
+ pcap01_trans.status = I2CTransDone;
+ pcap01Value.status = PCAP01_IDLE;
+ break;
+
+ default:
+ pcap01_trans.status = I2CTransDone;
+ break;
+ }
+ }
+}
diff --git a/sw/airborne/modules/meteo/humid_pcap01.h b/sw/airborne/modules/meteo/humid_pcap01.h
new file mode 100644
index 0000000000..0ebac83cad
--- /dev/null
+++ b/sw/airborne/modules/meteo/humid_pcap01.h
@@ -0,0 +1,120 @@
+#ifndef PCAP01_H
+#define PCAP01_H
+
+#include "std.h"
+
+//#define PCAP01_STANDARD
+#define PCAP01_200HZ
+
+typedef struct {
+ uint32_t temp;
+ uint32_t hum_t;
+ uint32_t hum;
+ uint32_t R_ratio;
+ uint32_t C_ratio;
+ uint32_t NV_temp;
+ uint32_t V_rh;
+ uint32_t status;
+}PCAP01VALUE;
+
+#define PCAP01_ADDR 0xA0
+
+#define PCAP01_IDLE 0
+#define PCAP01_GET_HUMID 1
+#define PCAP01_GET_TEMP 2
+
+//OpCodes für PCap Programmierung
+#define PCAP01_PU_RESET 0x88
+#define PCAP01_IN_RESET 0x8a
+#define PCAP01_START 0x8c
+#define PCAP01_TERM 0x84
+
+#define PCAP01_WRITE_REG 0xC0
+#define PCAP01_READ_REG 0x40
+#define PCAP01_READ_STAT 0x48
+#define PCAP01_WRITE_SRAM 0x90
+#define PCAP01_WRITE_OTP 0xA0
+
+// Configuration Registers
+#define PCAP01_REG0 0x00
+#define PCAP01_REG1 0x01
+#define PCAP01_REG2 0x02
+#define PCAP01_REG3 0x03
+#define PCAP01_REG4 0x04
+#define PCAP01_REG5 0x05
+#define PCAP01_REG6 0x06
+#define PCAP01_REG7 0x07
+#define PCAP01_REG8 0x08
+#define PCAP01_REG9 0x09
+#define PCAP01_REG10 0x0A
+#define PCAP01_REG11 0x0B
+#define PCAP01_REG12 0x0C
+#define PCAP01_REG13 0x0D
+#define PCAP01_REG14 0x0E
+#define PCAP01_REG15 0x0F
+#define PCAP01_REG16 0x10
+#define PCAP01_REG17 0x11
+#define PCAP01_REG18 0x12
+#define PCAP01_REG19 0x13
+#define PCAP01_REG20 0x14
+
+#ifdef PCAP01_200HZ
+// Register configuration values
+#define PCAP01_REG0_VALUE 0x420F0F
+#define PCAP01_REG1_VALUE 0x201004
+#define PCAP01_REG2_VALUE 0x1F460A
+#define PCAP01_REG3_VALUE 0x090004
+#define PCAP01_REG4_VALUE 0x08040D
+#define PCAP01_REG5_VALUE 0xC0001E
+#define PCAP01_REG6_VALUE 0x000C40
+#define PCAP01_REG7_VALUE 0x1F0000
+#define PCAP01_REG8_VALUE 0x800053
+#define PCAP01_REG9_VALUE 0x00A88F
+#define PCAP01_REG10_VALUE 0x18004B
+#define PCAP01_REG11_VALUE 0x000000
+#define PCAP01_REG12_VALUE 0x000000
+#define PCAP01_REG13_VALUE 0x000000
+#define PCAP01_REG14_VALUE 0x000000
+#define PCAP01_REG15_VALUE 0x000000
+#define PCAP01_REG16_VALUE 0x000000
+#define PCAP01_REG17_VALUE 0x000006
+#define PCAP01_REG18_VALUE 0x0000A6
+#define PCAP01_REG19_VALUE 0x000001
+#define PCAP01_REG20_VALUE 0x000001
+#endif
+#ifdef PCAP01_STANDARD
+// Register configuration values
+#define PCAP01_REG0_VALUE 0x4200FF
+#define PCAP01_REG1_VALUE 0x201022
+#define PCAP01_REG2_VALUE 0x0F460B
+#define PCAP01_REG3_VALUE 0x070010
+#define PCAP01_REG4_VALUE 0x080000
+#define PCAP01_REG5_VALUE 0x000000
+#define PCAP01_REG6_VALUE 0x000040
+#define PCAP01_REG7_VALUE 0x1F0000
+#define PCAP01_REG8_VALUE 0xA00010
+#define PCAP01_REG9_VALUE 0xFF000F
+#define PCAP01_REG10_VALUE 0x180047
+#define PCAP01_REG11_VALUE 0x000000
+#define PCAP01_REG12_VALUE 0x000000
+#define PCAP01_REG13_VALUE 0x000000
+#define PCAP01_REG14_VALUE 0x000000
+#define PCAP01_REG15_VALUE 0x000000
+#define PCAP01_REG16_VALUE 0x000000
+#define PCAP01_REG17_VALUE 0x000000
+#define PCAP01_REG18_VALUE 0x000000
+#define PCAP01_REG19_VALUE 0x200000
+#define PCAP01_REG20_VALUE 0x000001
+#endif
+
+void writePCAP01_SRAM(uint8_t data, uint16_t s_add);
+uint8_t readPCAP01_SRAM(uint16_t s_add);
+void PCAP01_Control(uint8_t control);
+void pcap01readRegister(uint8_t reg);
+void pcap01writeRegister(uint8_t reg,uint32_t value);
+void writePCAP01_firmware(void);
+void pcap01_init(void);
+void pcap01_periodic(void);
+void pcap01_event(void);
+
+#endif
diff --git a/sw/airborne/modules/meteo/humid_sht.h b/sw/airborne/modules/meteo/humid_sht.h
index cdfbe421d0..7419aca52f 100644
--- a/sw/airborne/modules/meteo/humid_sht.h
+++ b/sw/airborne/modules/meteo/humid_sht.h
@@ -9,11 +9,17 @@
/* GPIO P0.x defaults */
#ifndef DAT_PIN
+/* ADC1 Port, ADC_4, P0.30 */
#define DAT_PIN 30
+/* IRH Port, IRH_2, P0.25 */
+// #define DAT_PIN 25
#endif
#ifndef SCK_PIN
+/* ADC1 Port, ADC_3, P0.4 */
#define SCK_PIN 4
+/* IRH Port, IRH_1, P0.22 */
+// #define SCK_PIN 22
#endif
#define noACK 0
diff --git a/sw/airborne/modules/meteo/humid_sht_i2c.c b/sw/airborne/modules/meteo/humid_sht_i2c.c
index 3360eaa1a2..94b4e7d06e 100644
--- a/sw/airborne/modules/meteo/humid_sht_i2c.c
+++ b/sw/airborne/modules/meteo/humid_sht_i2c.c
@@ -49,8 +49,8 @@ struct i2c_transaction sht_trans;
uint8_t sht_status;
uint8_t sht_serial[8] = {0};
uint32_t sht_serial1=0, sht_serial2=0;
-uint16_t humidsht, tempsht;
-float fhumidsht, ftempsht;
+uint16_t humidsht_i2c, tempsht_i2c;
+float fhumidsht_i2c, ftempsht_i2c;
int8_t humid_sht_crc(volatile uint8_t* data) {
uint8_t i, bit, crc = 0;
@@ -70,126 +70,126 @@ int8_t humid_sht_crc(volatile uint8_t* data) {
return 0;
}
-void humid_sht_init(void) {
- sht_status = SHT_UNINIT;
+void humid_sht_init_i2c(void) {
+ sht_status = SHT2_UNINIT;
}
-void humid_sht_periodic( void ) {
+void humid_sht_periodic_i2c( void ) {
switch (sht_status) {
- case SHT_UNINIT:
+ case SHT2_UNINIT:
/* do soft reset, then wait at least 15ms */
- sht_status = SHT_RESET;
- sht_trans.buf[0] = SHT_SOFT_RESET;
+ sht_status = SHT2_RESET;
+ sht_trans.buf[0] = SHT2_SOFT_RESET;
I2CTransmit(SHT_I2C_DEV, sht_trans, SHT_SLAVE_ADDR, 1);
break;
- case SHT_SERIAL:
+ case SHT2_SERIAL:
/* get serial number part 1 */
- sht_status = SHT_SERIAL1;
+ sht_status = SHT2_SERIAL1;
sht_trans.buf[0] = 0xFA;
sht_trans.buf[1] = 0x0F;
I2CTransceive(SHT_I2C_DEV, sht_trans, SHT_SLAVE_ADDR, 2, 8);
break;
- case SHT_SERIAL1:
- case SHT_SERIAL2:
+ case SHT2_SERIAL1:
+ case SHT2_SERIAL2:
break;
default:
/* trigger temp measurement, no master hold */
- sht_trans.buf[0] = SHT_TRIGGER_TEMP;
- sht_status = SHT_TRIG_TEMP;
+ sht_trans.buf[0] = SHT2_TRIGGER_TEMP;
+ sht_status = SHT2_TRIG_TEMP;
I2CTransmit(SHT_I2C_DEV, sht_trans, SHT_SLAVE_ADDR, 1);
/* send serial number every 30 seconds */
- RunOnceEvery((4*30), DOWNLINK_SEND_SHT_SERIAL(DefaultChannel, &sht_serial1, &sht_serial2));
+ RunOnceEvery((4*30), DOWNLINK_SEND_SHT_I2C_SERIAL(DefaultChannel, &sht_serial1, &sht_serial2));
break;
}
}
/* needs 85ms delay from temp trigger measurement */
void humid_sht_p_temp( void ) {
- if (sht_status == SHT_GET_TEMP) {
+ if (sht_status == SHT2_GET_TEMP) {
/* get temp */
- sht_status = SHT_READ_TEMP;
+ sht_status = SHT2_READ_TEMP;
I2CReceive(SHT_I2C_DEV, sht_trans, SHT_SLAVE_ADDR, 3);
}
}
/* needs 29ms delay from humid trigger measurement */
void humid_sht_p_humid( void ) {
- if (sht_status == SHT_GET_HUMID) {
+ if (sht_status == SHT2_GET_HUMID) {
/* read humid */
- sht_status = SHT_READ_HUMID;
+ sht_status = SHT2_READ_HUMID;
I2CReceive(SHT_I2C_DEV, sht_trans, SHT_SLAVE_ADDR, 3);
}
}
-void humid_sht_event( void ) {
+void humid_sht_event_i2c( void ) {
if (sht_trans.status == I2CTransSuccess) {
switch (sht_status) {
- case SHT_TRIG_TEMP:
- sht_status = SHT_GET_TEMP;
+ case SHT2_TRIG_TEMP:
+ sht_status = SHT2_GET_TEMP;
sht_trans.status = I2CTransDone;
break;
- case SHT_READ_TEMP:
+ case SHT2_READ_TEMP:
/* read temperature */
- tempsht = (sht_trans.buf[0] << 8) | sht_trans.buf[1];
- tempsht &= 0xFFFC;
+ tempsht_i2c = (sht_trans.buf[0] << 8) | sht_trans.buf[1];
+ tempsht_i2c &= 0xFFFC;
if (humid_sht_crc(sht_trans.buf) == 0) {
/* trigger humid measurement, no master hold */
- sht_trans.buf[0] = SHT_TRIGGER_HUMID;
- sht_status = SHT_TRIG_HUMID;
+ sht_trans.buf[0] = SHT2_TRIGGER_HUMID;
+ sht_status = SHT2_TRIG_HUMID;
I2CTransmit(SHT_I2C_DEV, sht_trans, SHT_SLAVE_ADDR, 1);
}
else {
/* checksum error, restart */
- sht_status = SHT_IDLE;
+ sht_status = SHT2_IDLE;
sht_trans.status == I2CTransDone;
}
break;
- case SHT_TRIG_HUMID:
- sht_status = SHT_GET_HUMID;
+ case SHT2_TRIG_HUMID:
+ sht_status = SHT2_GET_HUMID;
sht_trans.status = I2CTransDone;
break;
- case SHT_READ_HUMID:
+ case SHT2_READ_HUMID:
/* read humidity */
- humidsht = (sht_trans.buf[0] << 8) | sht_trans.buf[1];
- humidsht &= 0xFFFC;
- fhumidsht = -6. + 125. / 65536. * humidsht;
- ftempsht = -46.85 + 175.72 / 65536. * tempsht;
+ humidsht_i2c = (sht_trans.buf[0] << 8) | sht_trans.buf[1];
+ humidsht_i2c &= 0xFFFC;
+ fhumidsht_i2c = -6. + 125. / 65536. * humidsht_i2c;
+ ftempsht_i2c = -46.85 + 175.72 / 65536. * tempsht_i2c;
- sht_status = SHT_IDLE;
+ sht_status = SHT2_IDLE;
sht_trans.status = I2CTransDone;
if (humid_sht_crc(sht_trans.buf) == 0) {
- DOWNLINK_SEND_SHT_STATUS(DefaultChannel, &humidsht, &tempsht, &fhumidsht, &ftempsht);
+ DOWNLINK_SEND_SHT_I2C_STATUS(DefaultChannel, &humidsht_i2c, &tempsht_i2c, &fhumidsht_i2c, &ftempsht_i2c);
}
break;
- case SHT_RESET:
- sht_status = SHT_SERIAL;
+ case SHT2_RESET:
+ sht_status = SHT2_SERIAL;
sht_trans.status = I2CTransDone;
break;
- case SHT_SERIAL1:
+ case SHT2_SERIAL1:
/* read serial number part 1 */
sht_serial[5] = sht_trans.buf[0];
sht_serial[4] = sht_trans.buf[2];
sht_serial[3] = sht_trans.buf[4];
sht_serial[2] = sht_trans.buf[6];
/* get serial number part 2 */
- sht_status = SHT_SERIAL2;
+ sht_status = SHT2_SERIAL2;
sht_trans.buf[0] = 0xFC;
sht_trans.buf[1] = 0xC9;
I2CTransceive(SHT_I2C_DEV, sht_trans, SHT_SLAVE_ADDR, 2, 6);
break;
- case SHT_SERIAL2:
+ case SHT2_SERIAL2:
/* read serial number part 2 */
sht_serial[1] = sht_trans.buf[0];
sht_serial[0] = sht_trans.buf[1];
@@ -197,8 +197,8 @@ void humid_sht_event( void ) {
sht_serial[6] = sht_trans.buf[4];
sht_serial1=sht_serial[7]<<24|sht_serial[6]<<16|sht_serial[5]<<8|sht_serial[4];
sht_serial2=sht_serial[3]<<24|sht_serial[2]<<16|sht_serial[1]<<8|sht_serial[0];
- DOWNLINK_SEND_SHT_SERIAL(DefaultChannel, &sht_serial1, &sht_serial2);
- sht_status = SHT_IDLE;
+ DOWNLINK_SEND_SHT_I2C_SERIAL(DefaultChannel, &sht_serial1, &sht_serial2);
+ sht_status = SHT2_IDLE;
sht_trans.status = I2CTransDone;
break;
diff --git a/sw/airborne/modules/meteo/humid_sht_i2c.h b/sw/airborne/modules/meteo/humid_sht_i2c.h
index 746717a607..1c26fe5f8d 100644
--- a/sw/airborne/modules/meteo/humid_sht_i2c.h
+++ b/sw/airborne/modules/meteo/humid_sht_i2c.h
@@ -3,37 +3,37 @@
#include "std.h"
-#define SHT_WRITE_USER 0xE6
-#define SHT_READ_USER 0xE7
-#define SHT_TRIGGER_TEMP 0xF3
-#define SHT_TRIGGER_HUMID 0xF5
-#define SHT_SOFT_RESET 0xFE
+#define SHT2_WRITE_USER 0xE6
+#define SHT2_READ_USER 0xE7
+#define SHT2_TRIGGER_TEMP 0xF3
+#define SHT2_TRIGGER_HUMID 0xF5
+#define SHT2_SOFT_RESET 0xFE
-enum sht_stat{
- SHT_UNINIT,
- SHT_IDLE,
- SHT_RESET,
- SHT_SERIAL,
- SHT_SERIAL1,
- SHT_SERIAL2,
- SHT_SET_CONFIG,
- SHT_READ_SERIAL,
- SHT_TRIG_TEMP,
- SHT_GET_TEMP,
- SHT_READ_TEMP,
- SHT_TRIG_HUMID,
- SHT_GET_HUMID,
- SHT_READ_HUMID
+enum sht_stat_i2c{
+ SHT2_UNINIT,
+ SHT2_IDLE,
+ SHT2_RESET,
+ SHT2_SERIAL,
+ SHT2_SERIAL1,
+ SHT2_SERIAL2,
+ SHT2_SET_CONFIG,
+ SHT2_READ_SERIAL,
+ SHT2_TRIG_TEMP,
+ SHT2_GET_TEMP,
+ SHT2_READ_TEMP,
+ SHT2_TRIG_HUMID,
+ SHT2_GET_HUMID,
+ SHT2_READ_HUMID
};
int8_t humid_sht_crc(volatile uint8_t* data);
-void humid_sht_init(void);
-void humid_sht_periodic(void);
+void humid_sht_init_i2c(void);
+void humid_sht_periodic_i2c(void);
void humid_sht_p_temp(void);
void humid_sht_p_humid(void);
-void humid_sht_event(void);
+void humid_sht_event_i2c(void);
-extern uint16_t humidsht, tempsht;
-extern float fhumidsht, ftempsht;
+extern uint16_t humidsht_i2c, tempsht_i2c;
+extern float fhumidsht_i2c, ftempsht_i2c;
#endif
diff --git a/sw/airborne/modules/meteo/light_solar.c b/sw/airborne/modules/meteo/light_solar.c
new file mode 100644
index 0000000000..38b20450a0
--- /dev/null
+++ b/sw/airborne/modules/meteo/light_solar.c
@@ -0,0 +1,80 @@
+/*
+ * $Id: light_solar.c $
+ *
+ * Copyright (C) 2011 Martin Mueller
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+/** \file light_solar.c
+ * \brief University of Reading solar radiation sensor interface
+ *
+ * This reads the values for intensity from the University of Reading solar sensor.
+ */
+
+
+#include "mcu_periph/adc.h"
+#include "mcu_periph/uart.h"
+#include "messages.h"
+#include "downlink.h"
+#include "modules/meteo/light_solar.h"
+
+#ifndef ADC_CHANNEL_LIGHT_SOLAR_UP
+#define ADC_CHANNEL_LIGHT_SOLAR_UP ADC_1
+#endif
+#ifndef ADC_CHANNEL_LIGHT_SOLAR_DN
+#define ADC_CHANNEL_LIGHT_SOLAR_DN ADC_2
+#endif
+
+#ifndef ADC_CHANNEL_LIGHT_NB_SAMPLES
+#define ADC_CHANNEL_LIGHT_NB_SAMPLES 16
+#endif
+
+#ifndef DOWNLINK_DEVICE
+#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
+#endif
+
+uint16_t up[LIGHT_NB], dn[LIGHT_NB];
+int32_t light_cnt;
+
+static struct adc_buf buf_light_sol_up;
+static struct adc_buf buf_light_sol_dn;
+
+void light_solar_init( void ) {
+ adc_buf_channel(ADC_CHANNEL_LIGHT_SOLAR_UP, &buf_light_sol_up, ADC_CHANNEL_LIGHT_NB_SAMPLES);
+ adc_buf_channel(ADC_CHANNEL_LIGHT_SOLAR_DN, &buf_light_sol_dn, ADC_CHANNEL_LIGHT_NB_SAMPLES);
+
+ light_cnt = 0;
+}
+
+void light_solar_periodic( void ) {
+ up[light_cnt] = buf_light_sol_up.sum / buf_light_sol_up.av_nb_sample;
+ dn[light_cnt] = buf_light_sol_dn.sum / buf_light_sol_dn.av_nb_sample;
+
+ /* 10k/10k voltage divider, 10 bits adc, 3.3V max */
+
+ if (++light_cnt >= LIGHT_NB) {
+ DOWNLINK_SEND_SOLAR_RADIATION(DefaultChannel,
+ &up[0], &dn[0], &up[1], &dn[1], &up[2], &dn[2], &up[3], &dn[3],
+ &up[4], &dn[4], &up[5], &dn[5], &up[6], &dn[6], &up[7], &dn[7],
+ &up[8], &dn[8], &up[9], &dn[9]);
+ light_cnt = 0;
+ }
+}
+
diff --git a/sw/airborne/modules/meteo/light_solar.h b/sw/airborne/modules/meteo/light_solar.h
new file mode 100644
index 0000000000..7fbcb1bd01
--- /dev/null
+++ b/sw/airborne/modules/meteo/light_solar.h
@@ -0,0 +1,14 @@
+#ifndef TEMP_SOLAR_H
+#define TEMP_SOLAR_H
+
+#include "std.h"
+
+#define LIGHT_NB 10
+
+extern uint16_t up[LIGHT_NB], dn[LIGHT_NB];
+extern int32_t light_cnt;
+
+void light_solar_init(void);
+void light_solar_periodic(void);
+
+#endif
diff --git a/sw/airborne/modules/meteo/temp_tcouple_adc.c b/sw/airborne/modules/meteo/temp_tcouple_adc.c
new file mode 100644
index 0000000000..048f8ea826
--- /dev/null
+++ b/sw/airborne/modules/meteo/temp_tcouple_adc.c
@@ -0,0 +1,91 @@
+/*
+ * $Id: temp_tcouple_adc.c $
+ *
+ * Copyright (C) 2011 Martin Mueller
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+/** \file temp_tcouple_adc.c
+ * \brief Universitaet Tuebingen thermocouple interface
+ *
+ * This reads the values for reference and measurement temperature
+ * from the Universitaet Tuebingen thermocouple sensor.
+ */
+
+
+#include "mcu_periph/adc.h"
+#include "mcu_periph/uart.h"
+#include "messages.h"
+#include "downlink.h"
+#include "modules/meteo/temp_tcouple_adc.h"
+
+#ifndef ADC_CHANNEL_TEMP_REF
+#define ADC_CHANNEL_TEMP_REF ADC_4
+#endif
+#ifndef ADC_CHANNEL_TEMP_VAL
+#define ADC_CHANNEL_TEMP_VAL ADC_3
+#endif
+
+#ifndef ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES
+#define ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES 16
+#endif
+
+#ifndef DOWNLINK_DEVICE
+#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
+#endif
+
+uint16_t ref[TCOUPLE_NB], val[TCOUPLE_NB];
+float fref[TCOUPLE_NB], fval[TCOUPLE_NB];
+int32_t temp_cnt;
+
+static struct adc_buf buf_temp_tcouple_ref;
+static struct adc_buf buf_temp_tcouple_val;
+
+void temp_tcouple_adc_init( void ) {
+ adc_buf_channel(ADC_CHANNEL_TEMP_REF,
+ &buf_temp_tcouple_ref,
+ ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES);
+ adc_buf_channel(ADC_CHANNEL_TEMP_VAL,
+ &buf_temp_tcouple_val,
+ ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES);
+ temp_cnt = 0;
+}
+
+void temp_tcouple_adc_periodic( void ) {
+ val[temp_cnt] = buf_temp_tcouple_val.sum / buf_temp_tcouple_val.av_nb_sample;
+ ref[temp_cnt] = buf_temp_tcouple_ref.sum / buf_temp_tcouple_ref.av_nb_sample;
+
+ /* no voltage divider, 10 bits adc, 3.3V max */
+ /* T = U * 52.288899706 - 7.977784737996595 */
+ fval[temp_cnt] = ((float)(val[temp_cnt] * 3.3) / 1023.)
+ * 52.288899706 - 7.977784737996595;
+ fref[temp_cnt] = ((float)(ref[temp_cnt] * 3.3) / 1023.)
+ * 100. - 13.;
+
+ if (++temp_cnt >= TCOUPLE_NB) {
+ DOWNLINK_SEND_TEMP_TCOUPLE(DefaultChannel,
+ &fval[0], &fval[1], &fval[2], &fval[3],
+ &fref[0], &fref[1], &fref[2], &fref[3],
+ &val[0], &val[1], &val[2], &val[3],
+ &ref[0], &ref[1], &ref[2], &ref[3]);
+ temp_cnt = 0;
+ }
+}
+
diff --git a/sw/airborne/modules/meteo/temp_tcouple_adc.h b/sw/airborne/modules/meteo/temp_tcouple_adc.h
new file mode 100644
index 0000000000..95f8a1b23f
--- /dev/null
+++ b/sw/airborne/modules/meteo/temp_tcouple_adc.h
@@ -0,0 +1,13 @@
+#ifndef TEMP_TCOUPLE_ADC_H
+#define TEMP_TCOUPLE_ADC_H
+
+#include "std.h"
+
+#define TCOUPLE_NB 4
+
+extern int32_t tcouple_cnt;
+
+void temp_tcouple_adc_init(void);
+void temp_tcouple_adc_periodic(void);
+
+#endif
diff --git a/sw/logalizer/Makefile b/sw/logalizer/Makefile
index 4768fac813..01dd11580b 100644
--- a/sw/logalizer/Makefile
+++ b/sw/logalizer/Makefile
@@ -27,7 +27,7 @@ OCAMLC = ocamlc
OCAMLOPT = ocamlopt
INCLUDES= $(shell ocamlfind query -r -i-format xml-light) $(shell ocamlfind query -r -i-format lablgtk2) -I ../lib/ocaml
-all: play plotter plot sd2log
+all: play plotter plot sd2log plotprofile
play : log_file.cmo play_core.cmo play.cmo
@echo OL $@
@@ -105,6 +105,9 @@ MORE_CFLAGS = -DHAVE_DLFCN_H=1 -DSTDC_HEADERS=1 -I. -I. -I.. -g -O2 -I/usr/
disp3d: disp3d.c
$(CC) $(MORE_CFLAGS) -g -o $@ $^ $(MORE_FLAGS)
+plotprofile: plotprofile.c
+ gcc -g -O2 -Wall `pkg-config glib-2.0 --cflags` -o $@ $^ `pkg-config glib-2.0 --libs` `pcre-config --libs` -lglibivy
+
test1: test1.c
$(CC) $(MORE_CFLAGS) -g -o $@ $^ $(MORE_FLAGS) -lglut
diff --git a/sw/logalizer/plotprofile.c b/sw/logalizer/plotprofile.c
new file mode 100644
index 0000000000..39f0cdcf2a
--- /dev/null
+++ b/sw/logalizer/plotprofile.c
@@ -0,0 +1,138 @@
+
+/*
+
+http://users.softlab.ntua.gr/~ttsiod/gnuplotStreaming.html
+
+*/
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define HEIGHT_SPAN 20000
+
+FILE *Gplt, *Gplh;
+int32_t alt = 0;
+int32_t temp[HEIGHT_SPAN] = {0};
+int32_t humid[HEIGHT_SPAN] = {0};
+
+void on_GPS(IvyClientPtr app, void *user_data, int argc, char *argv[]){
+/*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7.73 11 GPS 0 55577549 665183336 0 -4310 0 0 1642 345957748 31 0
+*/
+
+ int32_t _alt;
+
+ _alt = atoi(argv[5]);
+ alt = _alt / 100;
+// if ((_alt/100) < HEIGHT_SPAN) alt = _alt;
+
+// printf("alt %f\n", (float) _alt/100.);
+}
+
+void on_TMP_STATUS(IvyClientPtr app, void *user_data, int argc, char *argv[]){
+/*
+
+
+
+
+*/
+
+ float _temp;
+ int i;
+
+ _temp = atof(argv[2]);
+ if (alt < HEIGHT_SPAN) temp[alt] = _temp * 100;
+
+// printf("temp %f\n", _temp);
+ fprintf(Gplt, "plot '-' w points pt 0 title \"Temp\"\n");
+ for (i = 0; i < HEIGHT_SPAN; i++){
+ if (temp[i] != 0) fprintf(Gplt, "%f %d\n", temp[i]/100., i);
+ }
+ fprintf(Gplt,"e\n");
+}
+
+void on_SHT_STATUS(IvyClientPtr app, void *user_data, int argc, char *argv[]){
+/*
+
+
+
+
+
+
+*/
+
+ float _humid;
+ int i;
+
+ _humid = atof(argv[3]);
+ if (alt < HEIGHT_SPAN) humid[alt] = _humid * 100;
+
+// printf("humid %f\n", _humid);
+ fprintf(Gplh, "plot '-' w points pt 0 title \"Humid\"\n");
+ for (i = 0; i < HEIGHT_SPAN; i++){
+ if (humid[i] != 0) fprintf(Gplh, "%f %d\n", humid[i]/100., i);
+ }
+ fprintf(Gplh,"e\n");
+}
+
+int main( int argc, char* argv[] )
+{
+ double xmint, xmaxt, xminh, xmaxh, ymin, ymax;
+ GMainLoop *ml;
+
+ ml = g_main_loop_new(NULL, FALSE);
+
+ IvyInit ("IvyPlotProfile", "IvyPlotProfile READY", NULL, NULL, NULL, NULL);
+ IvyBindMsg(on_GPS, NULL, "^(\\S*) GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
+ IvyBindMsg(on_TMP_STATUS, NULL, "^(\\S*) TMP_STATUS (\\S*) (\\S*)");
+ IvyBindMsg(on_SHT_STATUS, NULL, "^(\\S*) SHT_STATUS (\\S*) (\\S*) (\\S*) (\\S*)");
+// IvyBindMsg(on_SHT_STATUS, NULL, "^(\\S*) DPICCO_STATUS (\\S*) (\\S*) (\\S*) (\\S*)");
+ IvyStart("127.255.255.255");
+
+ xmint = 5;
+ xmaxt = 35;
+ xminh = 0;
+ xmaxh = 100;
+ ymin = 500;
+ ymax = 2300;
+
+ Gplt = popen("gnuplot -geometry 300x300 -noraise","w");
+ setlinebuf(Gplt);
+ fprintf(Gplt, "set xrange[%f:%f]\n", xmint, xmaxt);
+ fprintf(Gplt, "set yrange[%f:%f]\n", ymin, ymax);
+
+ Gplh = popen("gnuplot -geometry 300x300 -noraise","w");
+ setlinebuf(Gplh);
+ fprintf(Gplh, "set xrange[%f:%f]\n", xminh, xmaxh);
+ fprintf(Gplh, "set yrange[%f:%f]\n", ymin, ymax);
+
+ g_main_loop_run(ml);
+
+ fclose(Gplt);
+ fclose(Gplh);
+ return 0;
+}
diff --git a/sw/simulator/sim_ac_jsbsim.c b/sw/simulator/sim_ac_jsbsim.c
index 55f66a17a8..a72840fd36 100644
--- a/sw/simulator/sim_ac_jsbsim.c
+++ b/sw/simulator/sim_ac_jsbsim.c
@@ -57,7 +57,11 @@ static void sim_parse_options(int argc, char** argv);
static void sim_init(void);
static gboolean sim_periodic(gpointer data);
+#ifdef __APPLE__
+string ivyBus = "224.255.255.255";
+#else
string ivyBus = "127.255.255.255";
+#endif
string fgAddress = "127.0.0.1";
static void ivy_transport_init(void);