|
48 | 48 |
|
49 | 49 | #include "static_mem.h"
|
50 | 50 |
|
| 51 | +#include "platform_defaults.h" |
| 52 | + |
51 | 53 | #define PROPTEST_NBR_OF_VARIANCE_VALUES 100
|
52 | 54 |
|
53 | 55 | static bool startPropTest = false;
|
54 | 56 | static bool startBatTest = false;
|
55 | 57 |
|
| 58 | +static float propTestThreshold = HEALTH_PROPELLER_TEST_THRESHOLD; |
| 59 | + |
56 | 60 | static uint16_t propTestPWMRatio = CONFIG_MOTORS_DEFAULT_PROP_TEST_PWM_RATIO;
|
57 | 61 | static uint16_t batTestPWMRatio = CONFIG_MOTORS_DEFAULT_BAT_TEST_PWM_RATIO;
|
58 | 62 |
|
@@ -115,13 +119,26 @@ static float variance(float *buffer, uint32_t length)
|
115 | 119 | */
|
116 | 120 | static bool evaluatePropTest(float low, float high, float value, uint8_t motor)
|
117 | 121 | {
|
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 |
119 | 138 | {
|
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); |
123 | 141 | }
|
124 |
| - |
125 | 142 | motorPass |= (1 << motor);
|
126 | 143 |
|
127 | 144 | return true;
|
@@ -289,7 +306,7 @@ void healthRunTests(sensorData_t *sensors)
|
289 | 306 | {
|
290 | 307 | for (int m = 0; m < NBR_OF_MOTORS; m++)
|
291 | 308 | {
|
292 |
| - if (!evaluatePropTest(0, PROPELLER_BALANCE_TEST_THRESHOLD, accVarX[m] + accVarY[m], m)) |
| 309 | + if (!evaluatePropTest(0, propTestThreshold, accVarX[m] + accVarY[m], m)) |
293 | 310 | {
|
294 | 311 | nrFailedTests++;
|
295 | 312 | for (int j = 0; j < 3; j++)
|
@@ -334,6 +351,11 @@ PARAM_ADD_CORE(PARAM_UINT8, startPropTest, &startPropTest)
|
334 | 351 | */
|
335 | 352 | PARAM_ADD_CORE(PARAM_UINT8, startBatTest, &startBatTest)
|
336 | 353 |
|
| 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 | + |
337 | 359 | /**
|
338 | 360 | * @brief PWM ratio to use when testing propellers. Required for brushless motors. [0 - UINT16_MAX]
|
339 | 361 | */
|
|
0 commit comments