paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [4465] Simple CSC code for sending vane sensor value


From: Allen Ibara
Subject: [paparazzi-commits] [4465] Simple CSC code for sending vane sensor values over can
Date: Wed, 20 Jan 2010 04:19:39 +0000

Revision: 4465
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4465
Author:   aibara
Date:     2010-01-20 04:19:39 +0000 (Wed, 20 Jan 2010)
Log Message:
-----------
Simple CSC code for sending vane sensor values over can

Added Paths:
-----------
    paparazzi3/trunk/conf/autopilot/vane_sensor.makefile
    paparazzi3/trunk/sw/airborne/csc/csc_vane.c
    paparazzi3/trunk/sw/airborne/csc/csc_vane.h

Added: paparazzi3/trunk/conf/autopilot/vane_sensor.makefile
===================================================================
--- paparazzi3/trunk/conf/autopilot/vane_sensor.makefile                        
        (rev 0)
+++ paparazzi3/trunk/conf/autopilot/vane_sensor.makefile        2010-01-20 
04:19:39 UTC (rev 4465)
@@ -0,0 +1,4 @@
+# Vane sensors using generic PWM input
+ap.CFLAGS += -DUSE_VANE_SENSOR
+ap.srcs += $(SRC_CSC)/csc_vane.c
+

Added: paparazzi3/trunk/sw/airborne/csc/csc_vane.c
===================================================================
--- paparazzi3/trunk/sw/airborne/csc/csc_vane.c                         (rev 0)
+++ paparazzi3/trunk/sw/airborne/csc/csc_vane.c 2010-01-20 04:19:39 UTC (rev 
4465)
@@ -0,0 +1,33 @@
+#include "csc_adc.h"
+#include "csc_ap_link.h"
+#include "csc_vane.h"
+
+#include "LPC21xx.h"
+#include "led.h"
+#include "pwm_input.h"
+
+#define PWM_INPUT_COUNTS_PER_REV 61358.
+#define PWM_INPUT_MSG_PRESCALE 8
+#define VANE_NB 2
+const static float avg_factor = 0.5;
+
+void csc_vane_init(void)
+{
+
+}
+
+void csc_vane_periodic(void)
+{
+  static float angle[VANE_NB];
+  static uint8_t prescale = 0;
+
+  for (int i = 0; i < VANE_NB; i++) {
+    angle[i] = avg_factor * angle[i] + (1. - avg_factor) * RadOfDeg(360. * 
pwm_input_duration[i] / PWM_INPUT_COUNTS_PER_REV);
+  }
+
+  if (prescale++ >= PWM_INPUT_MSG_PRESCALE) {
+    prescale = 0;
+    csc_ap_link_send_vane(angle);
+  }
+}
+

Added: paparazzi3/trunk/sw/airborne/csc/csc_vane.h
===================================================================
--- paparazzi3/trunk/sw/airborne/csc/csc_vane.h                         (rev 0)
+++ paparazzi3/trunk/sw/airborne/csc/csc_vane.h 2010-01-20 04:19:39 UTC (rev 
4465)
@@ -0,0 +1,8 @@
+#include "csc_adc.h"
+#include "csc_ap_link.h"
+
+#include "LPC21xx.h"
+#include "led.h"
+
+void csc_vane_init(void);
+void csc_vane_periodic(void);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]