Skip to content

Commit

Permalink
[meteo] add Meteo France DAQ board driver
Browse files Browse the repository at this point in the history
get data from DAQ board and log on SD
send report to the ground for real-time monitoring
  • Loading branch information
gautierhattenberger committed Feb 18, 2014
1 parent 7c5cb08 commit 54141b0
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 2 deletions.
4 changes: 3 additions & 1 deletion conf/airframes/ENAC/fixed-wing/apogee.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<configure name="EXTRA_DL_PORT" value="UART6"/>
<configure name="EXTRA_DL_BAUD" value="B57600"/>
</load>
<load name="meteo_france_DAQ.xml"/>
</modules>

<firmware name="fixedwing">
Expand All @@ -32,7 +33,8 @@
<subsystem name="radio_control" type="sbus"/>

<!-- Communication -->
<subsystem name="telemetry" type="transparent"/>
<subsystem name="telemetry" type="xbee_api"/>
<subsystem name="sdlog"/>

<!-- Actuators are automatically chosen according to board-->
<subsystem name="imu" type="apogee"/>
Expand Down
35 changes: 34 additions & 1 deletion conf/messages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,9 @@
<field name="sonar_distance" type="float" unit="m"/>
</message>

<!--237 is free -->
<message name="PAYLOAD_FLOAT" id="237">
<field name="values" type="float[]"/>
</message>

<message name="NPS_POS_LLH" id="238">
<field name="pprz_lat" type="float" unit="rad" alt_unit="deg" alt_unit_coef="57.29578"/>
Expand Down Expand Up @@ -2428,6 +2430,37 @@
<field name="yaw" type="int8"/>
</message>

<message name="MF_DAQ" id="53" link="forwarded">
<field name="pad" type="uint16"/>
<field name="timestamp" type="float"/>
<field name="pressure" type="float"/>
<field name="temp" type="float"/>
<field name="humidity" type="float"/>
<field name="Pdiff" type="float"/>
<field name="Thw" type="float"/>
</message>

<message name="MF_DAQ_STATE" id="54" link="forwarded">
<field name="flight_time" type="uint16" unit="s"/>
<field name="p" type="float"/>
<field name="q" type="float"/>
<field name="r" type="float"/>
<field name="phi" type="float"/>
<field name="theta" type="float"/>
<field name="psi" type="float"/>
<field name="ax" type="float"/>
<field name="ay" type="float"/>
<field name="az" type="float"/>
<field name="ve" type="float"/>
<field name="vn" type="float"/>
<field name="vu" type="float"/>
<field name="lat" type="float"/>
<field name="lon" type="float"/>
<field name="alt" type="float"/>
<field name="we" type="float"/>
<field name="wn" type="float"/>
</message>

<message name="KITE_COMMAND" id="96">
<field name="POWER" type="uint16"/>
<field name="TURN" type="uint16"/>
Expand Down
18 changes: 18 additions & 0 deletions conf/modules/meteo_france_DAQ.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="meteo_france_DAQ" dir="meteo">
<doc>
<description>Data acquisition board used by Meteo France</description>
</doc>
<header>
<file name="meteo_france_DAQ.h"/>
</header>
<init fun="init_mf_daq()"/>
<periodic fun="mf_daq_send_state()" freq="10."/>
<periodic fun="mf_daq_send_report()" freq="1." autorun="TRUE"/>
<datalink message="MF_DAQ" fun="parse_mf_daq_msg()"/>
<makefile>
<file name="meteo_france_DAQ.c"/>
</makefile>
</module>

91 changes: 91 additions & 0 deletions sw/airborne/modules/meteo/meteo_france_DAQ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (C) 2014 Gautier Hattenberger
*
* 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 modules/meteo/meteo_france_DAQ.c
*
* Communication module with the Data Acquisition board
* from Meteo France
*
* DAQ board sends measurments to the AP
* AP sends periodic report to the ground, store data on SD card
* and sends A/C state to DAQ board
*/

#include "modules/meteo/meteo_france_DAQ.h"

#include "state.h"
#include "autopilot.h"
#include "subsystems/datalink/datalink.h"
#include "subsystems/datalink/downlink.h"
#include "subsystems/chibios-libopencm3/sdLog.h"
#include "subsystems/chibios-libopencm3/chibios_sdlog.h"

#include "modules/datalink/extra_pprz_dl.h"

struct MF_DAQ mf_daq;

void init_mf_daq(void) {
mf_daq.nb = 0;
}

void mf_daq_send_state(void) {
// Send aircraft state to DAQ board
DOWNLINK_SEND_MF_DAQ_STATE(PprzTransport, EXTRA_PPRZ_UART,
&autopilot_flight_time,
&stateGetBodyRates_f()->p,
&stateGetBodyRates_f()->q,
&stateGetBodyRates_f()->r,
&stateGetNedToBodyEulers_f()->phi,
&stateGetNedToBodyEulers_f()->theta,
&stateGetNedToBodyEulers_f()->psi,
&stateGetAccelNed_f()->x,
&stateGetAccelNed_f()->y,
&stateGetAccelNed_f()->z,
&stateGetSpeedEnu_f()->x,
&stateGetSpeedEnu_f()->y,
&stateGetSpeedEnu_f()->z,
&stateGetPositionLla_f()->lat,
&stateGetPositionLla_f()->lon,
&stateGetPositionLla_f()->alt,
&stateGetHorizontalWindspeed_f()->y,
&stateGetHorizontalWindspeed_f()->x);
}

void mf_daq_send_report(void) {
// Send report over normal telemetry
if (mf_daq.nb > 0) {
DOWNLINK_SEND_PAYLOAD_FLOAT(DefaultChannel, DefaultDevice, mf_daq.nb, mf_daq.values);
}
}

void parse_mf_daq_msg(void) {
mf_daq.nb = DL_PAYLOAD_FLOAT_values_length(dl_buffer);
if (mf_daq.nb > 0) {
// Store data struct directly from dl_buffer
memcpy(mf_daq.values, DL_PAYLOAD_FLOAT_values(dl_buffer), mf_daq.nb * sizeof(float));
// Log on SD card
DOWNLINK_SEND_PAYLOAD_FLOAT(PprzLogTransport, SDLOG, mf_daq.nb, mf_daq.values);
}
}


54 changes: 54 additions & 0 deletions sw/airborne/modules/meteo/meteo_france_DAQ.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2014 Gautier Hattenberger
*
* 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 modules/meteo/meteo_france_DAQ.h
*
* Communication module with the Data Acquisition board
* from Meteo France
*
* DAQ board sends measurments to the AP
* AP sends periodic report to the ground, store data on SD card
* and sends A/C state to DAQ board
*/

#ifndef METEO_FRANCE_DAQ_H
#define METEO_FRANCE_DAQ_H

#include "std.h"

#define MF_DAQ_SIZE 32

struct MF_DAQ {
float values[MF_DAQ_SIZE];
uint8_t nb;
};

extern struct MF_DAQ mf_daq;

extern void init_mf_daq(void);
extern void mf_daq_send_state(void);
extern void mf_daq_send_report(void);
extern void parse_mf_daq_msg(void);

#endif

0 comments on commit 54141b0

Please sign in to comment.