Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
servo_tester.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Ewoud Smeur <ewoud_smeur@msn.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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
28 #include "servo_tester.h"
29 #include "subsystems/commands.h"
30 #include "generated/airframe.h"
31 #include "generated/airframe.h"
32 #include "subsystems/actuators.h"
33 #include "generated/modules.h"
34 
36 
41 
42 #ifndef TIME_PER_DEFLECTION
43 
44 #define TIME_PER_DEFLECTION 0.8
45 #endif
46 
48 
50 {
51  servo_test_val = SERVO_SERVO_TEST_NEUTRAL;
52  do_servo_run = false;
54  servo_run_timer = 0;
55  servo_run_step = (SERVO_SERVO_TEST_MAX - SERVO_SERVO_TEST_MIN) / 2 / 8;
56 
57  servo_mean = SERVO_SERVO_TEST_NEUTRAL;
58 }
59 
60 
62 {
63 
64  /*Go up and down with increasing amplitude*/
65  if (do_servo_run && (servo_run_counter < 8)) {
67  servo_run_timer += 1;
68 
69  /*Give time to reach the setpoint*/
70  if (servo_run_timer > (TIME_PER_DEFLECTION*SERVO_TESTER_PERIODIC_FREQ)) {
71  servo_run_timer = 0;
72  servo_run_counter += 1;
73  }
74  } else if (do_servo_run == true) {
75  /*Reset de servo run*/
76  do_servo_run = false;
79  }
80 
81  Bound(servo_test_val, SERVO_SERVO_TEST_MIN, SERVO_SERVO_TEST_MAX);
82  Set_SERVO_TEST_Servo(servo_test_val);
83 }
84 
Module useful for testing a servo and finding the response.
bool do_servo_run
Definition: servo_tester.c:37
int32_t servo_mean
Definition: servo_tester.c:47
int32_t servo_run_step
Definition: servo_tester.c:40
Hardware independent API for actuators (servos, motor controllers).
#define TIME_PER_DEFLECTION
Time in seconds per deflection, before going to the next.
Definition: servo_tester.c:44
void servo_tester_periodic()
Definition: servo_tester.c:61
Hardware independent code for commands handling.
int32_t servo_run_timer
Definition: servo_tester.c:39
signed long int32_t
Definition: types.h:19
void servo_tester_init()
Definition: servo_tester.c:49
int32_t servo_test_val
Definition: servo_tester.c:35
int32_t servo_run_counter
Definition: servo_tester.c:38