[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [6160] some more meteo sensor modules.
From: |
Martin Mueller |
Subject: |
[paparazzi-commits] [6160] some more meteo sensor modules. |
Date: |
Sat, 16 Oct 2010 09:00:55 +0000 |
Revision: 6160
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6160
Author: mmm
Date: 2010-10-16 09:00:42 +0000 (Sat, 16 Oct 2010)
Log Message:
-----------
some more meteo sensor modules.
Modified Paths:
--------------
paparazzi3/trunk/conf/airframes/mm/fixed-wing/funjetmm.xml
paparazzi3/trunk/conf/messages.xml
Added Paths:
-----------
paparazzi3/trunk/conf/modules/ir_mlx.xml
paparazzi3/trunk/conf/modules/temp_tmp102.xml
paparazzi3/trunk/sw/airborne/modules/meteo/ir_mlx.c
paparazzi3/trunk/sw/airborne/modules/meteo/ir_mlx.h
paparazzi3/trunk/sw/airborne/modules/meteo/temp_tmp102.c
paparazzi3/trunk/sw/airborne/modules/meteo/temp_tmp102.h
Modified: paparazzi3/trunk/conf/airframes/mm/fixed-wing/funjetmm.xml
===================================================================
--- paparazzi3/trunk/conf/airframes/mm/fixed-wing/funjetmm.xml 2010-10-15
19:56:09 UTC (rev 6159)
+++ paparazzi3/trunk/conf/airframes/mm/fixed-wing/funjetmm.xml 2010-10-16
09:00:42 UTC (rev 6160)
@@ -55,9 +55,11 @@
<!-- modules -->
<modules>
+ <load name="ir_mlx.xml"/>
+ <!--load name="temp_tmp102.xml"/>
<load name="humid_dpicco.xml"/>
<load name="humid_sht.xml"/>
- <load name="baro_scp_i2c.xml"/>
+ <load name="baro_scp_i2c.xml"/-->
</modules>
<!-- commands section -->
Modified: paparazzi3/trunk/conf/messages.xml
===================================================================
--- paparazzi3/trunk/conf/messages.xml 2010-10-15 19:56:09 UTC (rev 6159)
+++ paparazzi3/trunk/conf/messages.xml 2010-10-16 09:00:42 UTC (rev 6160)
@@ -531,9 +531,19 @@
</message>
<!-- 84 is free -->
- <!-- 85 is free -->
- <!-- 86 is free -->
+ <message name="MLX_STATUS" id="85">
+ <field name="itemp_case" type="uint16"/>
+ <field name="temp_case" type="float" unit="deg_celsius" format="%.2f"/>
+ <field name="itemp_obj" type="uint16"/>
+ <field name="temp_obj" type="float" unit="deg_celsius" format="%.2f"/>
+ </message>
+
+ <message name="TMP_STATUS" id="86">
+ <field name="itemp" type="uint16"/>
+ <field name="temp" type="float" unit="deg_celsius" format="%.2f"/>
+ </message>
+
<message name="WIND_INFO_RET" id="87">
<field name="east" type="float" unit="m/s"/>
<field name="north" type="float" unit="m/s"/>
@@ -548,8 +558,8 @@
<message name="SHT_STATUS" id="89">
<field name="ihumid" type="uint16"/>
<field name="itemp" type="uint16"/>
- <field name="humid" type="float" unit="rel_hum"/>
- <field name="temp" type="float" unit="deg_celsius"/>
+ <field name="humid" type="float" unit="rel_hum" format="%.2f"/>
+ <field name="temp" type="float" unit="deg_celsius" format="%.2f"/>
</message>
<message name="ENOSE_STATUS" id="90">
@@ -563,8 +573,8 @@
<message name="DPICCO_STATUS" id="91">
<field name="humid" type="uint16"/>
<field name="temp" type="uint16"/>
- <field name="fhumid" type="float" unit="rel_hum"/>
- <field name="ftemp" type="float" unit="deg_celsius"/>
+ <field name="fhumid" type="float" unit="rel_hum" format="%.2f"/>
+ <field name="ftemp" type="float" unit="deg_celsius" format="%.2f"/>
</message>
<message name="ANTENNA_DEBUG" id="92">
Added: paparazzi3/trunk/conf/modules/ir_mlx.xml
===================================================================
--- paparazzi3/trunk/conf/modules/ir_mlx.xml (rev 0)
+++ paparazzi3/trunk/conf/modules/ir_mlx.xml 2010-10-16 09:00:42 UTC (rev
6160)
@@ -0,0 +1,14 @@
+<!DOCTYPE module SYSTEM "module.dtd">
+
+<module name="ir_mlx" dir="meteo">
+ <header>
+ <file name="ir_mlx.h"/>
+ </header>
+ <init fun="ir_mlx_init()"/>
+ <periodic fun="ir_mlx_periodic()" freq="8"/>
+ <event fun="ir_mlx_event()"/>
+ <makefile target="ap">
+ <file name="ir_mlx.c"/>
+ </makefile>
+</module>
+
Added: paparazzi3/trunk/conf/modules/temp_tmp102.xml
===================================================================
--- paparazzi3/trunk/conf/modules/temp_tmp102.xml
(rev 0)
+++ paparazzi3/trunk/conf/modules/temp_tmp102.xml 2010-10-16 09:00:42 UTC
(rev 6160)
@@ -0,0 +1,14 @@
+<!DOCTYPE module SYSTEM "module.dtd">
+
+<module name="temp_tmp102" dir="meteo">
+ <header>
+ <file name="temp_tmp102.h"/>
+ </header>
+ <init fun="tmp102_init()"/>
+ <periodic fun="tmp102_periodic()" freq="8"/>
+ <event fun="tmp102_event()"/>
+ <makefile target="ap">
+ <file name="temp_tmp102.c"/>
+ </makefile>
+</module>
+
Added: paparazzi3/trunk/sw/airborne/modules/meteo/ir_mlx.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/ir_mlx.c
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/ir_mlx.c 2010-10-16 09:00:42 UTC
(rev 6160)
@@ -0,0 +1,101 @@
+/*
+ * $Id: ir_mlx.c $
+ *
+ * Copyright (C) 2010 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 ir_mlx.c
+ * \brief Melexis 90614 I2C
+ *
+ * This reads the values for temperatures from the Melexis 90614 IR sensor
through I2C.
+ */
+
+
+#include "ir_mlx.h"
+
+#include "sys_time.h"
+#include "i2c.h"
+#include "led.h"
+#include "uart.h"
+#include "messages.h"
+#include "downlink.h"
+
+#ifndef MLX_I2C_DEV
+#define MLX_I2C_DEV i2c0
+#endif
+
+struct i2c_transaction mlx_trans;
+
+uint8_t ir_mlx_status;
+uint16_t ir_mlx_itemp_case;
+float ir_mlx_temp_case;
+uint16_t ir_mlx_itemp_obj;
+float ir_mlx_temp_obj;
+
+/* I2C address is set to 3 */
+#define MLX90614_ADDR 0x06
+
+// printf("Ta = %2.2f°C (0x%04X)\n", (tp*0.02)-273.15, tp);
+
+
+void ir_mlx_init( void ) {
+ ir_mlx_status = IR_MLX_UNINIT;
+}
+
+void ir_mlx_periodic( void ) {
+ if (cpu_time_sec > 1) {
+ /* start two byte case temperature */
+ mlx_trans.buf[0] = MLX90614_TA;
+ I2CTransceive(MLX_I2C_DEV, mlx_trans, MLX90614_ADDR, 1, 2);
+ ir_mlx_status = IR_MLX_RD_CASE_TEMP;
+ }
+}
+
+void ir_mlx_event( void ) {
+ if ((mlx_trans.status == I2CTransSuccess)) {
+ if (ir_mlx_status == IR_MLX_RD_CASE_TEMP) {
+ /* read two byte case temperature */
+ ir_mlx_itemp_case = mlx_trans.buf[1] << 8;
+ ir_mlx_itemp_case |= mlx_trans.buf[0];
+ ir_mlx_temp_case = ir_mlx_itemp_case*0.02 - 273.15;
+
+ /* start two byte obj temperature */
+ mlx_trans.buf[0] = MLX90614_TOBJ;
+ ir_mlx_status = IR_MLX_RD_CASE_TEMP;
+ I2CTransceive(MLX_I2C_DEV, mlx_trans, MLX90614_ADDR, 1, 2);
+ ir_mlx_status = IR_MLX_RD_OBJ_TEMP;
+ }
+ else if (ir_mlx_status == IR_MLX_RD_OBJ_TEMP) {
+ /* read two byte obj temperature */
+ ir_mlx_itemp_obj = mlx_trans.buf[1] << 8;
+ ir_mlx_itemp_obj |= mlx_trans.buf[0];
+ ir_mlx_temp_obj = ir_mlx_itemp_obj*0.02 - 273.15;
+ mlx_trans.status = I2CTransDone;
+
+ DOWNLINK_SEND_MLX_STATUS(DefaultChannel,
+ &ir_mlx_itemp_case,
+ &ir_mlx_temp_case,
+ &ir_mlx_itemp_obj,
+ &ir_mlx_temp_obj);
+ }
+ }
+}
+
Added: paparazzi3/trunk/sw/airborne/modules/meteo/ir_mlx.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/ir_mlx.h
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/ir_mlx.h 2010-10-16 09:00:42 UTC
(rev 6160)
@@ -0,0 +1,18 @@
+#ifndef IR_MLX_H
+#define IR_MLX_H
+
+#include "std.h"
+
+#define MLX90614_TA 0x06
+#define MLX90614_TOBJ 0x07
+
+#define IR_MLX_UNINIT 0
+#define IR_MLX_IDLE 1
+#define IR_MLX_RD_CASE_TEMP 2
+#define IR_MLX_RD_OBJ_TEMP 3
+
+void ir_mlx_init(void);
+void ir_mlx_periodic(void);
+void ir_mlx_event(void);
+
+#endif
Added: paparazzi3/trunk/sw/airborne/modules/meteo/temp_tmp102.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/temp_tmp102.c
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/temp_tmp102.c 2010-10-16
09:00:42 UTC (rev 6160)
@@ -0,0 +1,96 @@
+/*
+ * $Id: temp_tmp102.c $
+ *
+ * Copyright (C) 2010 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_tmp102.c
+ * \brief TI TMP102 I2C sensor interface
+ *
+ * This reads the values for temperature from the TI TMP201 sensor through
I2C.
+ */
+
+
+#include "temp_tmp102.h"
+
+#include "i2c.h"
+#include "led.h"
+#include "uart.h"
+#include "messages.h"
+#include "downlink.h"
+
+uint8_t tmp_meas_started;
+struct i2c_transaction tmp_trans;
+
+#ifndef TMP_I2C_DEV
+#define TMP_I2C_DEV i2c0
+#endif
+
+/*
+ address depends on to what pin A0 is connected to
+ A0: GND Vcc SDA SCL
+ Addr: 0x90 0x92 0x94 0x96
+*/
+
+#define TMP102_SLAVE_ADDR 0x90
+
+/* OS=0 R1=1 R0=1 F1=0 POL=0 TM=0 SD=0 */
+#define TMP102_CONF1 0x60
+/* CR1=1 CR0=1 AL=1 EM=1 0000 */
+#define TMP102_CONF2 0xF0
+
+
+void tmp102_init(void) {
+ tmp_meas_started = FALSE;
+ /* configure 8Hz and enhanced mode */
+ tmp_trans.buf[0] = TMP102_CONF_REG;
+ tmp_trans.buf[1] = TMP102_CONF1;
+ tmp_trans.buf[2] = TMP102_CONF2;
+ I2CTransmit(TMP_I2C_DEV, tmp_trans, TMP102_SLAVE_ADDR, 3);
+}
+
+void tmp102_periodic( void ) {
+ tmp_trans.buf[0] = TMP102_TEMP_REG;
+ I2CTransceive(TMP_I2C_DEV, tmp_trans, TMP102_SLAVE_ADDR, 1, 2);
+ tmp_meas_started = TRUE;
+}
+
+void tmp102_event( void ) {
+
+ if ((tmp_trans.status == I2CTransSuccess) && (tmp_meas_started == TRUE)) {
+
+ uint16_t tmp_temperature;
+ float ftmp_temperature;
+
+ /* read two byte temperature */
+ tmp_temperature = tmp_trans.buf[0] << 8;
+ tmp_temperature |= tmp_trans.buf[1];
+ tmp_temperature >>= 3;
+ if (tmp_temperature & 0x1000)
+ tmp_temperature |= 0xE000;
+
+ ftmp_temperature = ((int16_t) tmp_temperature) / 16.;
+
+ DOWNLINK_SEND_TMP_STATUS(DefaultChannel, &tmp_temperature,
&ftmp_temperature);
+ tmp_trans.status = I2CTransDone;
+ }
+}
+
Added: paparazzi3/trunk/sw/airborne/modules/meteo/temp_tmp102.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/temp_tmp102.h
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/temp_tmp102.h 2010-10-16
09:00:42 UTC (rev 6160)
@@ -0,0 +1,16 @@
+#ifndef TEMP_TMP102_H
+#define TEMP_TMP102_H
+
+#include "std.h"
+
+#define TMP102_TEMP_REG 0x00
+#define TMP102_CONF_REG 0x01
+#define TMP102_T_LOW_REG 0x02
+#define TMP102_T_HIGH_REG 0x03
+
+
+void tmp102_init(void);
+void tmp102_periodic(void);
+void tmp102_event(void);
+
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [6160] some more meteo sensor modules.,
Martin Mueller <=