Paparazzi UAS
v5.18.0_stable
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 "
subsystems/commands.h
"
30
#include "generated/airframe.h"
31
#include "generated/airframe.h"
32
#include "
subsystems/actuators.h
"
33
#include "generated/modules.h"
34
35
int32_t
servo_test_val
;
36
37
bool
is_servo
;
38
bool
do_servo_run
;
39
int32_t
servo_run_counter
;
40
int32_t
servo_run_timer
;
41
int32_t
servo_run_step
;
42
int32_t
steps
;
43
44
#ifndef TIME_PER_DEFLECTION
45
46
#define TIME_PER_DEFLECTION 0.8
47
#endif
48
49
int32_t
servo_mean
;
50
51
void
servo_tester_init
()
52
{
53
54
steps
= 8;
55
56
servo_test_val
= SERVO_SERVO_TEST_NEUTRAL;
57
is_servo
=
true
;
58
do_servo_run
=
false
;
59
servo_run_counter
= 0;
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
68
void
servo_tester_periodic
()
69
{
70
71
/*Go up and down with increasing amplitude*/
72
if
(
do_servo_run
&& (
servo_run_counter
<
steps
)) {
73
if
(
is_servo
) {
74
servo_test_val
=
servo_mean
+
servo_run_counter
*
servo_run_step
* ((
servo_run_counter
% 2) * 2 - 1);
75
}
else
if
(
servo_run_counter
<
steps
/ 2) {
76
servo_test_val
=
servo_mean
+
servo_run_counter
*
servo_run_step
* 2;
77
}
else
{
78
servo_test_val
=
servo_mean
+ abs(
servo_run_counter
-
steps
) *
servo_run_step
* 2;
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
;
90
servo_run_counter
= 0;
91
servo_test_val
=
servo_mean
;
92
}
93
94
Bound(
servo_test_val
, SERVO_SERVO_TEST_MIN, SERVO_SERVO_TEST_MAX);
95
Set_SERVO_TEST_Servo(
servo_test_val
);
96
}
servo_run_counter
int32_t servo_run_counter
Definition:
servo_tester.c:39
servo_tester.h
do_servo_run
bool do_servo_run
Definition:
servo_tester.c:38
servo_mean
int32_t servo_mean
Definition:
servo_tester.c:49
servo_run_step
int32_t servo_run_step
Definition:
servo_tester.c:41
steps
int32_t steps
Definition:
servo_tester.c:42
is_servo
bool is_servo
Definition:
servo_tester.c:37
TIME_PER_DEFLECTION
#define TIME_PER_DEFLECTION
Time in seconds per deflection, before going to the next.
Definition:
servo_tester.c:46
servo_tester_periodic
void servo_tester_periodic()
Definition:
servo_tester.c:68
int32_t
signed long int32_t
Definition:
types.h:19
servo_run_timer
int32_t servo_run_timer
Definition:
servo_tester.c:40
commands.h
Hardware independent code for commands handling.
servo_tester_init
void servo_tester_init()
Definition:
servo_tester.c:51
servo_test_val
int32_t servo_test_val
Definition:
servo_tester.c:35
actuators.h
sw
airborne
modules
servo_tester
servo_tester.c
Generated on Tue Feb 1 2022 13:51:16 for Paparazzi UAS by
1.8.17