mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-10 06:59:54 +08:00
Merge remote-tracking branch 'paparazzi/master' into dev
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -68,6 +68,8 @@
|
||||
|
||||
<program name="Http Server" command="sw/ground_segment/tmtc/boa"/>
|
||||
|
||||
<program name="Plot Meteo Profile" command="sw/logalizer/plotprofile"/>
|
||||
|
||||
<program name="Weather Station" command="sw/ground_segment/misc/davis2ivy">
|
||||
<arg flag="-b" variable="ivy_bus"/>
|
||||
<arg flag="-d" constant="/dev/ttyUSB1"/>
|
||||
|
||||
+60
-6
@@ -676,7 +676,7 @@
|
||||
<field name="density" type="float" unit="mg/m3" format="%.2f"/>
|
||||
</message>
|
||||
|
||||
<message name="SHT_SERIAL" id="99">
|
||||
<message name="SHT_I2C_SERIAL" id="99">
|
||||
<field name="serial0" type="uint32"/>
|
||||
<field name="serial1" type="uint32"/>
|
||||
</message>
|
||||
@@ -824,7 +824,28 @@
|
||||
<field name="t9" type="uint16"/>
|
||||
</message>
|
||||
|
||||
<!--119 is free -->
|
||||
<message name="SOLAR_RADIATION" id="119">
|
||||
<field name="up_t0" type="uint16"/>
|
||||
<field name="dn_t0" type="uint16"/>
|
||||
<field name="up_t1" type="uint16"/>
|
||||
<field name="dn_t1" type="uint16"/>
|
||||
<field name="up_t2" type="uint16"/>
|
||||
<field name="dn_t2" type="uint16"/>
|
||||
<field name="up_t3" type="uint16"/>
|
||||
<field name="dn_t3" type="uint16"/>
|
||||
<field name="up_t4" type="uint16"/>
|
||||
<field name="dn_t4" type="uint16"/>
|
||||
<field name="up_t5" type="uint16"/>
|
||||
<field name="dn_t5" type="uint16"/>
|
||||
<field name="up_t6" type="uint16"/>
|
||||
<field name="dn_t6" type="uint16"/>
|
||||
<field name="up_t7" type="uint16"/>
|
||||
<field name="dn_t7" type="uint16"/>
|
||||
<field name="up_t8" type="uint16"/>
|
||||
<field name="dn_t8" type="uint16"/>
|
||||
<field name="up_t9" type="uint16"/>
|
||||
<field name="dn_t9" type="uint16"/>
|
||||
</message>
|
||||
|
||||
<message name="TCAS_TA" ID="120">
|
||||
<field name="ac_id" type="uint8"/>
|
||||
@@ -862,8 +883,31 @@
|
||||
<field name="speed_sp" type="float"/>
|
||||
</message>
|
||||
|
||||
<!--126 is free -->
|
||||
<!--127 is free -->
|
||||
<message name="TEMP_TCOUPLE" id="126">
|
||||
<field name="fval0" type="float"/>
|
||||
<field name="fval1" type="float"/>
|
||||
<field name="fval2" type="float"/>
|
||||
<field name="fval3" type="float"/>
|
||||
<field name="fref0" type="float"/>
|
||||
<field name="fref1" type="float"/>
|
||||
<field name="fref2" type="float"/>
|
||||
<field name="fref3" type="float"/>
|
||||
<field name="val0" type="uint16"/>
|
||||
<field name="val1" type="uint16"/>
|
||||
<field name="val2" type="uint16"/>
|
||||
<field name="val3" type="uint16"/>
|
||||
<field name="ref0" type="uint16"/>
|
||||
<field name="ref1" type="uint16"/>
|
||||
<field name="ref2" type="uint16"/>
|
||||
<field name="ref3" type="uint16"/>
|
||||
</message>
|
||||
|
||||
<message name="SHT_I2C_STATUS" id="127">
|
||||
<field name="ihumid" type="uint16"/>
|
||||
<field name="itemp" type="uint16"/>
|
||||
<field name="humid" type="float" unit="rel_hum" format="%.2f"/>
|
||||
<field name="temp" type="float" unit="deg_celsius" format="%.2f"/>
|
||||
</message>
|
||||
|
||||
<message name="CAMERA_SNAPSHOT" id="128">
|
||||
<field name="snapshot_image_number" type="uint16"/>
|
||||
@@ -1161,8 +1205,18 @@
|
||||
<field name="ins_zdd" type="int32" alt_unit="m/s2" alt_unit_coef="0.0009766"/>
|
||||
</message>
|
||||
|
||||
<!--152 is free -->
|
||||
<!--153 is free -->
|
||||
<message name="PCAP01_STATUS" id="152">
|
||||
<field name="ihumid" type="uint32"/>
|
||||
<field name="itemp" type="uint32"/>
|
||||
<field name="humid" type="float" unit="rel_hum" format="%.2f"/>
|
||||
<field name="temp" type="float" unit="deg_celsius" format="%.2f"/>
|
||||
</message>
|
||||
|
||||
<message name="GEIGER_COUNTER" id="153">
|
||||
<field name="tube1" type="uint32" unit="events"/>
|
||||
<field name="tube2" type="uint32" unit="events"/>
|
||||
<field name="vsupply" type="uint16" unit="volts"/>
|
||||
</message>
|
||||
|
||||
<message name="INS_REF" id="154">
|
||||
<field name="ecef_x0" type="int32" alt_unit="m" alt_unit_coef="0.01"/>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
|
||||
<module name="geiger_counter" dir="meteo">
|
||||
<header>
|
||||
<file name="geiger_counter.h"/>
|
||||
</header>
|
||||
<init fun="geiger_counter_init()"/>
|
||||
<periodic fun="geiger_counter_periodic()" freq="1"/>
|
||||
<event fun="geiger_counter_event()"/>
|
||||
<makefile target="ap">
|
||||
<file name="geiger_counter.c"/>
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
|
||||
<module name="humdid_pcap01" dir="meteo">
|
||||
<header>
|
||||
<file name="humid_pcap01.h"/>
|
||||
</header>
|
||||
<init fun="pcap01_init()"/>
|
||||
<periodic fun="pcap01_periodic()" freq="3"/>
|
||||
<event fun="pcap01_event()"/>
|
||||
<makefile target="ap">
|
||||
<file name="humid_pcap01.c"/>
|
||||
</makefile>
|
||||
</module>
|
||||
@@ -9,11 +9,11 @@
|
||||
<header>
|
||||
<file name="humid_sht_i2c.h"/>
|
||||
</header>
|
||||
<init fun="humid_sht_init()"/>
|
||||
<periodic fun="humid_sht_periodic()" freq="4" delay="0"/>
|
||||
<init fun="humid_sht_init_i2c()"/>
|
||||
<periodic fun="humid_sht_periodic_i2c()" freq="4" delay="0"/>
|
||||
<periodic fun="humid_sht_p_temp()" freq="4" delay="6"/>
|
||||
<periodic fun="humid_sht_p_humid()" freq="4" delay="9"/>
|
||||
<event fun="humid_sht_event()"/>
|
||||
<event fun="humid_sht_event_i2c()"/>
|
||||
<makefile target="ap">
|
||||
<file name="humid_sht_i2c.c"/>
|
||||
</makefile>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
|
||||
<module name="light_solar" dir="meteo">
|
||||
<header>
|
||||
<file name="light_solar.h"/>
|
||||
</header>
|
||||
<init fun="light_solar_init()"/>
|
||||
<periodic fun="light_solar_periodic()" freq="60"/>
|
||||
<makefile target="ap">
|
||||
<file name="light_solar.c"/>
|
||||
<define name="ADC_CHANNEL_LIGHT_SOLAR_UP" value="ADC_1"/>
|
||||
<define name="USE_ADC_1"/>
|
||||
<define name="ADC_CHANNEL_LIGHT_SOLAR_DN" value="ADC_2"/>
|
||||
<define name="USE_ADC_2"/>
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
|
||||
<module name="temp_tcouple_adc" dir="meteo">
|
||||
<header>
|
||||
<file name="temp_tcouple_adc.h"/>
|
||||
</header>
|
||||
<init fun="temp_tcouple_adc_init()"/>
|
||||
<periodic fun="temp_tcouple_adc_periodic()" freq="60"/>
|
||||
<makefile target="ap">
|
||||
<file name="temp_tcouple_adc.c"/>
|
||||
<define name="ADC_CHANNEL_TEMP_REF" value="ADC_4"/>
|
||||
<define name="USE_ADC_4"/>
|
||||
<define name="ADC_CHANNEL_TEMP_VAL" value="ADC_3"/>
|
||||
<define name="USE_ADC_3"/>
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
+1
-1
@@ -22,5 +22,5 @@
|
||||
<!ATTLIST field
|
||||
name CDATA #REQUIRED
|
||||
format CDATA #REQUIRED
|
||||
scaling CDATA #IMPLIED
|
||||
scaling CDATA #IMPLIED
|
||||
unit CDATA #IMPLIED>
|
||||
@@ -10,10 +10,10 @@
|
||||
<dl_setting MAX="10" MIN="-10" STEP="5" VAR="nav_shift" module="subsystems/nav" handler="IncreaseShift" shortname="inc. shift"/>
|
||||
<dl_setting MAX="0" MIN="0" STEP="1" VAR="estimator_flight_time" shortname="flight time" module="autopilot" handler="ResetFlightTimeAndLaunch"/>
|
||||
<dl_setting MAX="200" MIN="-200" STEP="10" VAR="nav_radius" module="subsystems/nav" handler="SetNavRadius">
|
||||
<strip_button icon="circle-right.png" name="Circle right" value="1"/>
|
||||
<strip_button icon="circle-right.png" name="Circle right" value="1"/>
|
||||
<strip_button icon="circle-left.png" name="Circle left" value="-1"/>
|
||||
<key_press key="greater" value="1"/>
|
||||
<key_press key="less" value="-1"/>
|
||||
<key_press key="greater" value="1"/>
|
||||
<key_press key="less" value="-1"/>
|
||||
</dl_setting>
|
||||
</dl_settings>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="pprz_mode" module="autopilot" values="MANUAL|AUTO1|AUTO2|HOME|NOGPS|FAILSAFE"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="launch"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="kill_throttle"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="telemetry_mode_Ap_DefaultChannel" shortname="tele_AP" module="downlink"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="telemetry_mode_Ap_DefaultChannel" shortname="tele_AP" module="downlink" values="Default|Minimal|Extremal"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="gps.reset" module="subsystems/gps" handler="Reset" shortname="GPS reset"/>
|
||||
</dl_settings>
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE settings SYSTEM "settings.dtd">
|
||||
|
||||
<!-- A conf to use for standard operation with IMU (no tuning) -->
|
||||
|
||||
<settings>
|
||||
<dl_settings>
|
||||
<dl_settings NAME="flight params">
|
||||
<dl_setting MAX="1000" MIN="0" STEP="10" VAR="flight_altitude" shortname="altitude"/>
|
||||
<dl_setting MAX="360" MIN="0" STEP="1" VAR="nav_course"/>
|
||||
<dl_setting MAX="10" MIN="-10" STEP="5" VAR="nav_shift" module="subsystems/nav" handler="IncreaseShift" shortname="inc. shift"/>
|
||||
<dl_setting MAX="0" MIN="0" STEP="1" VAR="estimator_flight_time" shortname="flight time" module="autopilot" handler="ResetFlightTimeAndLaunch"/>
|
||||
<dl_setting MAX="200" MIN="-200" STEP="10" VAR="nav_radius" module="subsystems/nav" handler="SetNavRadius">
|
||||
<strip_button icon="circle-right.png" name="Circle right" value="1"/>
|
||||
<strip_button icon="circle-left.png" name="Circle left" value="-1"/>
|
||||
<key_press key="greater" value="1"/>
|
||||
<key_press key="less" value="-1"/>
|
||||
</dl_setting>
|
||||
</dl_settings>
|
||||
|
||||
<dl_settings NAME="mode">
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="pprz_mode" module="autopilot" values="MANUAL|AUTO1|AUTO2|HOME|NOGPS|FAILSAFE"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="launch"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="kill_throttle"/>
|
||||
<dl_setting MAX="5" MIN="0" STEP="1" VAR="telemetry_mode_Ap_DefaultChannel" shortname="tele_AP" module="downlink" values="Default|Minimal|Extremal|Raw|Scaled|DebugIMU"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="gps.reset" module="subsystems/gps" handler="Reset" shortname="GPS reset"/>
|
||||
</dl_settings>
|
||||
|
||||
<dl_settings NAME="ins">
|
||||
<dl_setting MAX="0.3" MIN="-0.3" STEP="0.01" VAR="ins_roll_neutral" shortname="roll_neutral" module="subsystems/ahrs" param="INS_ROLL_NEUTRAL_DEFAULT" unit="rad"/>
|
||||
<dl_setting MAX="0.5" MIN="-0.3" STEP="0.01" VAR="ins_pitch_neutral" shortname="pitch_neutral" param="INS_PITCH_NEUTRAL_DEFAULT" unit="rad"/>
|
||||
</dl_settings>
|
||||
</dl_settings>
|
||||
</settings>
|
||||
@@ -17,8 +17,8 @@
|
||||
<dl_setting MAX="1000" MIN="0" STEP="1" VAR="stage_time"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="launch"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="kill_throttle"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="telemetry_mode_Ap_DefaultChannel" shortname="tele_AP" module="downlink"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="telemetry_mode_Fbw_DefaultChannel" shortname="tele_FBW" module="downlink"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="telemetry_mode_Ap_DefaultChannel" shortname="tele_AP" module="downlink" values="Default|Minimal|Extremal"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="telemetry_mode_Fbw_DefaultChannel" shortname="tele_FBW" module="downlink" values="Default|Debug"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="gps.reset" module="subsystems/gps" handler="Reset" shortname="GPS reset"/>
|
||||
|
||||
<dl_setting MAX="200" MIN="-200" STEP="10" VAR="nav_radius" module="subsystems/nav" handler="SetNavRadius">
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
<dl_setting MAX="1000" MIN="0" STEP="1" VAR="stage_time"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="launch"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="kill_throttle"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="telemetry_mode_Ap_DefaultChannel" shortname="tele_AP" module="downlink"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="telemetry_mode_Fbw_DefaultChannel" shortname="tele_FBW" module="downlink"/>
|
||||
<dl_setting MAX="5" MIN="0" STEP="1" VAR="telemetry_mode_Ap_DefaultChannel" shortname="tele_AP" module="downlink" values="Default|Minimal|Extremal|Raw|Scaled|DebugIMU"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="telemetry_mode_Fbw_DefaultChannel" shortname="tele_FBW" module="downlink" values="Default|Debug"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="gps.reset" module="subsystems/gps" handler="Reset" shortname="GPS reset"/>
|
||||
|
||||
<dl_setting MAX="200" MIN="-200" STEP="10" VAR="nav_radius" module="subsystems/nav" handler="SetNavRadius">
|
||||
@@ -32,9 +32,6 @@
|
||||
<dl_settings NAME="control">
|
||||
|
||||
<dl_settings NAME="ins">
|
||||
<dl_setting MAX="100" MIN="0" STEP="1" VAR="imu_health" shortname="health" module="subsystems/ahrs" />
|
||||
<dl_setting MAX="100" MIN="0" STEP="1" VAR="renorm_sqrt_count" shortname="err_norm" module="subsystems/ahrs" />
|
||||
<dl_setting MAX="100" MIN="0" STEP="1" VAR="imu_overrun" shortname="ADC overrun" module="subsystems/imu" />
|
||||
<dl_setting MAX="0.3" MIN="-0.3" STEP="0.01" VAR="ins_roll_neutral" shortname="roll_neutral" module="subsystems/ahrs" param="INS_ROLL_NEUTRAL_DEFAULT" unit="rad"/>
|
||||
<dl_setting MAX="0.5" MIN="-0.3" STEP="0.01" VAR="ins_pitch_neutral" shortname="pitch_neutral" param="INS_PITCH_NEUTRAL_DEFAULT" unit="rad"/>
|
||||
</dl_settings>
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
<dl_setting MAX="1000" MIN="0" STEP="1" VAR="stage_time"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="launch"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="kill_throttle"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="telemetry_mode_Ap_DefaultChannel" shortname="tele_AP" module="downlink"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="telemetry_mode_Fbw_DefaultChannel" shortname="tele_FBW" module="downlink"/>
|
||||
<dl_setting MAX="5" MIN="0" STEP="1" VAR="telemetry_mode_Ap_DefaultChannel" shortname="tele_AP" module="downlink" values="Default|Minimal|Extremal|Raw|Scaled|DebugIMU"/>
|
||||
<dl_setting MAX="1" MIN="0" STEP="1" VAR="telemetry_mode_Fbw_DefaultChannel" shortname="tele_FBW" module="downlink" values="Default|Debug"/>
|
||||
<dl_setting MAX="2" MIN="0" STEP="1" VAR="gps.reset" module="subsystems/gps" handler="Reset" shortname="GPS reset"/>
|
||||
|
||||
<dl_setting MAX="200" MIN="-200" STEP="10" VAR="nav_radius" module="subsystems/nav" handler="SetNavRadius">
|
||||
@@ -32,6 +32,9 @@
|
||||
<dl_settings NAME="control">
|
||||
|
||||
<dl_settings NAME="ins">
|
||||
<dl_setting MAX="100" MIN="0" STEP="1" VAR="imu_health" shortname="health" module="subsystems/ahrs" />
|
||||
<dl_setting MAX="100" MIN="0" STEP="1" VAR="renorm_sqrt_count" shortname="err_norm" module="subsystems/ahrs" />
|
||||
<dl_setting MAX="100" MIN="0" STEP="1" VAR="imu_overrun" shortname="ADC overrun" module="subsystems/imu" />
|
||||
<dl_setting MAX="0.3" MIN="-0.3" STEP="0.01" VAR="ins_roll_neutral" shortname="roll_neutral" module="subsystems/ahrs" param="INS_ROLL_NEUTRAL_DEFAULT" unit="rad"/>
|
||||
<dl_setting MAX="0.5" MIN="-0.3" STEP="0.01" VAR="ins_pitch_neutral" shortname="pitch_neutral" param="INS_PITCH_NEUTRAL_DEFAULT" unit="rad"/>
|
||||
</dl_settings>
|
||||
@@ -53,6 +53,31 @@
|
||||
<message name="SURVEY" period="2.1"/>
|
||||
<message name="GPS_SOL" period="5.0"/>
|
||||
</mode>
|
||||
<mode name="extremal">
|
||||
<message name="ALIVE" period="5"/>
|
||||
<message name="GPS" period="5.1"/>
|
||||
<message name="ESTIMATOR" period="5.3"/>
|
||||
<message name="BAT" period="10.1"/>
|
||||
<message name="DESIRED" period="10.2"/>
|
||||
<message name="NAVIGATION" period="5.4"/>
|
||||
<message name="PPRZ_MODE" period="7.5"/>
|
||||
<message name="STATE_FILTER_STATUS" period="8."/>
|
||||
<message name="DOWNLINK" period="5.7"/>
|
||||
</mode>
|
||||
<mode name="raw_sensors">
|
||||
<message name="DL_VALUE" period="0.5"/>
|
||||
<message name="ALIVE" period="2.1"/>
|
||||
<message name="IMU_ACCEL_RAW" period=".05"/>
|
||||
<message name="IMU_GYRO_RAW" period=".05"/>
|
||||
<message name="IMU_MAG_RAW" period=".05"/>
|
||||
</mode>
|
||||
<mode name="scaled_sensors">
|
||||
<message name="DL_VALUE" period="0.5"/>
|
||||
<message name="ALIVE" period="2.1"/>
|
||||
<message name="IMU_GYRO" period=".075"/>
|
||||
<message name="IMU_ACCEL" period=".075"/>
|
||||
<message name="IMU_MAG" period=".1"/>
|
||||
</mode>
|
||||
<mode name="debug_imu">
|
||||
<message name="ATTITUDE" period="0.1"/>
|
||||
<message name="ALIVE" period="5"/>
|
||||
@@ -71,17 +96,6 @@
|
||||
<message name="IMU_GYRO_RAW" period=".5"/>
|
||||
<message name="IMU_MAG_RAW" period=".5"/>
|
||||
</mode>
|
||||
<mode name="extremal">
|
||||
<message name="ALIVE" period="5"/>
|
||||
<message name="GPS" period="5.1"/>
|
||||
<message name="ESTIMATOR" period="5.3"/>
|
||||
<message name="BAT" period="10.1"/>
|
||||
<message name="DESIRED" period="10.2"/>
|
||||
<message name="NAVIGATION" period="5.4"/>
|
||||
<message name="PPRZ_MODE" period="7.5"/>
|
||||
<message name="STATE_FILTER_STATUS" period="8."/>
|
||||
<message name="DOWNLINK" period="5.7"/>
|
||||
</mode>
|
||||
</process>
|
||||
<process name="Fbw">
|
||||
<mode name="default">
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <caml/mlvalues.h>
|
||||
|
||||
#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
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#define PPM_NB_CHANNEL RADIO_CONTROL_NB_CHANNEL
|
||||
|
||||
#ifdef NPS
|
||||
#ifdef USE_NPS
|
||||
extern void radio_control_feed(void);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2011 Martin Mueller <martinmm@pfump.org>
|
||||
*
|
||||
* 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 <Wire.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2011 Martin Mueller <martinmm@pfump.org>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <std.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
|
||||
/*
|
||||
|
||||
http://users.softlab.ntua.gr/~ttsiod/gnuplotStreaming.html
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/time.h>
|
||||
#include <glib.h>
|
||||
#include <Ivy/ivy.h>
|
||||
#include <Ivy/ivyglibloop.h>
|
||||
|
||||
#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[]){
|
||||
/*
|
||||
<message name="GPS" id="8">
|
||||
<field name="mode" type="uint8" unit="byte_mask"/>
|
||||
<field name="utm_east" type="int32" unit="cm" alt_unit="m"/>
|
||||
<field name="utm_north" type="int32" unit="cm" alt_unit="m"/>
|
||||
<field name="course" type="int16" unit="decideg" alt_unit="deg"/>
|
||||
<field name="alt" type="int32" unit="cm" alt_unit="m"/>
|
||||
<field name="speed" type="uint16" unit="cm/s" alt_unit="m/s"/>
|
||||
<field name="climb" type="int16" unit="cm/s" alt_unit="m/s"/>
|
||||
<field name="week" type="uint16" unit="weeks"></field>
|
||||
<field name="itow" type="uint32" unit="ms"/>
|
||||
<field name="utm_zone" type="uint8"/>
|
||||
<field name="gps_nb_err" type="uint8"/>
|
||||
</message>
|
||||
|
||||
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[]){
|
||||
/*
|
||||
<message name="TMP_STATUS" id="86">
|
||||
<field name="itemp" type="uint16"/>
|
||||
<field name="temp" type="float" unit="deg_celsius" format="%.2f"/>
|
||||
</message>
|
||||
*/
|
||||
|
||||
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[]){
|
||||
/*
|
||||
<message name="SHT_STATUS" id="89">
|
||||
<field name="ihumid" type="uint16"/>
|
||||
<field name="itemp" type="uint16"/>
|
||||
<field name="humid" type="float" unit="rel_hum" format="%.2f"/>
|
||||
<field name="temp" type="float" unit="deg_celsius" format="%.2f"/>
|
||||
</message>
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user