Skip to content

Commit 5c7b98d

Browse files
authored
Merge pull request #1471 from bitcraze/Aris/Propeller_Test
Updated Propeller Test in cfclient
2 parents f6f4fb7 + 03bf9d4 commit 5c7b98d

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

src/config/config.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,6 @@
213213
#define RADIO_DATARATE RADIO_RATE_2M
214214
#define RADIO_ADDRESS 0xE7E7E7E7E7ULL
215215

216-
/**
217-
* \def PROPELLER_BALANCE_TEST_THRESHOLD
218-
* This is the threshold for a propeller/motor to pass. It calculates the variance of the accelerometer X+Y
219-
* when the propeller is spinning.
220-
*/
221-
#define PROPELLER_BALANCE_TEST_THRESHOLD 2.5f
222-
223216
/**
224217
* \def BAT_LOADING_SAG_THRESHOLD
225218
* This is the threshold for a battery and connector to pass. It loads the power path by spinning all 4 motors

src/modules/src/health.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@
4848

4949
#include "static_mem.h"
5050

51+
#include "platform_defaults.h"
52+
5153
#define PROPTEST_NBR_OF_VARIANCE_VALUES 100
5254

5355
static bool startPropTest = false;
5456
static bool startBatTest = false;
5557

58+
static float propTestThreshold = HEALTH_PROPELLER_TEST_THRESHOLD;
59+
5660
static uint16_t propTestPWMRatio = CONFIG_MOTORS_DEFAULT_PROP_TEST_PWM_RATIO;
5761
static uint16_t batTestPWMRatio = CONFIG_MOTORS_DEFAULT_BAT_TEST_PWM_RATIO;
5862

@@ -115,13 +119,26 @@ static float variance(float *buffer, uint32_t length)
115119
*/
116120
static bool evaluatePropTest(float low, float high, float value, uint8_t motor)
117121
{
118-
if (value < low || value > high)
122+
if (high != 0)
123+
{
124+
if (value < low || value > high)
125+
{
126+
DEBUG_PRINT("Propeller test on M%d [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n",
127+
motor + 1, (double)low, (double)high, (double)value);
128+
return false;
129+
}
130+
else if (value > low && value < high)
131+
{
132+
DEBUG_PRINT("Propeller test on M%d [PASS]. low: %0.2f, high: %0.2f, measured: %0.2f\n",
133+
motor + 1, (double)low, (double)high, (double)value);
134+
return true;
135+
}
136+
}
137+
else
119138
{
120-
DEBUG_PRINT("Propeller test on M%d [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n",
121-
motor + 1, (double)low, (double)high, (double)value);
122-
return false;
139+
DEBUG_PRINT("Propeller test on M%d. No threshold set. measured: %0.2f\n",
140+
motor + 1, (double)value);
123141
}
124-
125142
motorPass |= (1 << motor);
126143

127144
return true;
@@ -289,7 +306,7 @@ void healthRunTests(sensorData_t *sensors)
289306
{
290307
for (int m = 0; m < NBR_OF_MOTORS; m++)
291308
{
292-
if (!evaluatePropTest(0, PROPELLER_BALANCE_TEST_THRESHOLD, accVarX[m] + accVarY[m], m))
309+
if (!evaluatePropTest(0, propTestThreshold, accVarX[m] + accVarY[m], m))
293310
{
294311
nrFailedTests++;
295312
for (int j = 0; j < 3; j++)
@@ -334,6 +351,11 @@ PARAM_ADD_CORE(PARAM_UINT8, startPropTest, &startPropTest)
334351
*/
335352
PARAM_ADD_CORE(PARAM_UINT8, startBatTest, &startBatTest)
336353

354+
/**
355+
* @brief Set nonzero to create a threshold ([0 - propTestThreshold]) for the propeller test.
356+
*/
357+
PARAM_ADD_CORE(PARAM_FLOAT | PARAM_PERSISTENT, propTestThreshold, &propTestThreshold)
358+
337359
/**
338360
* @brief PWM ratio to use when testing propellers. Required for brushless motors. [0 - UINT16_MAX]
339361
*/

src/platform/interface/platform_defaults.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,8 @@
186186
#endif
187187

188188

189+
// This is the threshold for a propeller/motor to pass. It calculates the
190+
// variance of the accelerometer X+Y when the propeller is spinning.
191+
#ifndef HEALTH_PROPELLER_TEST_THRESHOLD
192+
#define HEALTH_PROPELLER_TEST_THRESHOLD 0.0f
193+
#endif

0 commit comments

Comments
 (0)