Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 "modules/core/commands.h"
30 #include "generated/airframe.h"
31 #include "generated/airframe.h"
33 #include "generated/modules.h"
34 
36 
37 bool is_servo;
43 
44 #ifndef TIME_PER_DEFLECTION
46 #define TIME_PER_DEFLECTION 0.8
47 #endif
48 
50 
52 {
53 
54  steps = 8;
55 
56  servo_test_val = SERVO_SERVO_TEST_NEUTRAL;
57  is_servo = true;
58  do_servo_run = false;
60  servo_run_timer = 0;
61  servo_run_step = (SERVO_SERVO_TEST_MAX - SERVO_SERVO_TEST_MIN) / 2 / steps;
62 
63  servo_mean = SERVO_SERVO_TEST_NEUTRAL;
64 
65 }
66 
67 
69 {
70 
71  /*Go up and down with increasing amplitude*/
73  if (is_servo) {
75  } else if (servo_run_counter < steps / 2) {
77  } else {
79  }
80  servo_run_timer += 1;
81 
82  /*Give time to reach the setpoint*/
83  if (servo_run_timer > (TIME_PER_DEFLECTION * SERVO_TESTER_PERIODIC_FREQ)) {
84  servo_run_timer = 0;
85  servo_run_counter += 1;
86  }
87  } else if (do_servo_run == true) {
88  /*Reset de servo run*/
89  do_servo_run = false;
92  }
93 
94  Bound(servo_test_val, SERVO_SERVO_TEST_MIN, SERVO_SERVO_TEST_MAX);
95  Set_SERVO_TEST_Servo(servo_test_val);
96 }
Hardware independent code for commands handling.
Hardware independent API for actuators (servos, motor controllers).
int32_t steps
Definition: servo_tester.c:42
int32_t servo_run_timer
Definition: servo_tester.c:40
bool do_servo_run
Definition: servo_tester.c:38
int32_t servo_run_counter
Definition: servo_tester.c:39
#define TIME_PER_DEFLECTION
Time in seconds per deflection, before going to the next.
Definition: servo_tester.c:46
void servo_tester_periodic()
Definition: servo_tester.c:68
int32_t servo_run_step
Definition: servo_tester.c:41
bool is_servo
Definition: servo_tester.c:37
int32_t servo_test_val
Definition: servo_tester.c:35
void servo_tester_init()
Definition: servo_tester.c:51
int32_t servo_mean
Definition: servo_tester.c:49
Module useful for testing a servo and finding the response.
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83