Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
rpm_sensor.c
Go to the documentation of this file.
1/*
2 * Copyright (C) Freek van Tienen <freek.v.tienen@gmail.com>
3 *
4 * This file is part of paparazzi
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 */
29#include "modules/core/abi.h"
31
34
35#ifndef RPM_FILTER_TAU
36#define RPM_FILTER_TAU RPM_SENSOR_PERIODIC_PERIOD
37#endif
38
39#ifndef RPM_SENSOR_ACTUATOR_IDX
40#error "You need to define an actuator for which the RPM is read, please define RPM_SENSOR_ACTUATOR_IDX"
41#endif
42
43
44#if PERIODIC_TELEMETRY
46
47static void rpm_sensor_send_motor(struct transport_tx *trans, struct link_device *dev)
48{
50}
51#endif
52
53/* Initialize the RPM measurement by configuring the telemetry */
63
64/* RPM periodic */
66{
67 struct act_feedback_t feedback = {0};
70 feedback.set.rpm = true;
72}
73
74/* Get the RPM sensor */
76{
77 uint16_t rpm_meas = 0;
79 if (period_us > 0) {
80 rpm_meas = ((uint32_t)1000000 * 60) / period_us;
81 }
82
83 return rpm_meas;
84}
Main include for ABI (AirBorneInterface).
#define ACT_FEEDBACK_RPM_SENSOR_ID
struct Electrical electrical
Definition electrical.c:92
Interface for electrical status: supply voltage, current, battery status, etc.
float current
current in A
Definition electrical.h:47
Simple first order low pass filter with bilinear transform.
static float update_first_order_low_pass(struct FirstOrderLowPass *filter, float value)
Update first order low pass filter state with a new value.
static void init_first_order_low_pass(struct FirstOrderLowPass *filter, float tau, float sample_time, float value)
Init first order low pass filter.
First order low pass filter structure.
uint16_t foo
Definition main_demo5.c:58
int32_t rpm
RPM.
Definition actuators.h:51
struct act_feedback_t::act_feedback_set_t set
Bitset registering what is set as feedback.
uint8_t idx
General index of the actuators (generated in airframe.h)
Definition actuators.h:45
uint32_t get_pwm_input_period_in_usec(uint32_t channel)
Definition pwm_input.c:44
arch independent PWM input capture API
static struct FirstOrderLowPass rpm_lp
Definition rpm_sensor.c:32
static void rpm_sensor_send_motor(struct transport_tx *trans, struct link_device *dev)
Definition rpm_sensor.c:47
void rpm_sensor_periodic(void)
Definition rpm_sensor.c:65
uint16_t rpm
Definition rpm_sensor.c:33
uint16_t rpm_sensor_get_rpm(void)
Definition rpm_sensor.c:75
#define RPM_FILTER_TAU
Definition rpm_sensor.c:36
void rpm_sensor_init(void)
Definition rpm_sensor.c:54
#define RPM_PULSE_PER_RND
Definition rpm_sensor.h:33
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition telemetry.c:51
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
Definition telemetry.h:66
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.