|
49 | 49 | #include "flight/mixer.h"
|
50 | 50 | #include "flight/rpm_filter.h"
|
51 | 51 | #include "flight/feedforward.h"
|
| 52 | +#ifdef USE_DYN_NOTCH_FILTER |
| 53 | +#include "flight/dyn_notch_filter.h" |
| 54 | +#endif |
52 | 55 |
|
53 | 56 | #include "io/gps.h"
|
54 | 57 |
|
@@ -1125,7 +1128,7 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, timeUs_t currentTim
|
1125 | 1128 | if (feedforwardGain > 0) {
|
1126 | 1129 | // halve feedforward in Level mode since stick sensitivity is weaker by about half
|
1127 | 1130 | feedforwardGain *= FLIGHT_MODE(ANGLE_MODE) ? 0.5f : 1.0f;
|
1128 |
| - // transition now calculated in feedforward.c when new RC data arrives |
| 1131 | + // transition now calculated in feedforward.c when new RC data arrives |
1129 | 1132 | float feedForward = feedforwardGain * pidSetpointDelta * pidRuntime.pidFrequency;
|
1130 | 1133 |
|
1131 | 1134 | #ifdef USE_FEEDFORWARD
|
@@ -1193,7 +1196,31 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, timeUs_t currentTim
|
1193 | 1196 | {
|
1194 | 1197 | pidData[axis].Sum = pidSum;
|
1195 | 1198 | }
|
| 1199 | + |
| 1200 | +#ifdef USE_DYN_NOTCH_FILTER |
| 1201 | + if (isDynNotchActive()) { |
| 1202 | + // if (axis == gyro.gyroDebugAxis) { |
| 1203 | + // GYRO_FILTER_DEBUG_SET(DEBUG_FFT, 0, lrintf(gyroADCf)); |
| 1204 | + // GYRO_FILTER_DEBUG_SET(DEBUG_FFT_FREQ, 3, lrintf(gyroADCf)); |
| 1205 | + // GYRO_FILTER_DEBUG_SET(DEBUG_DYN_LPF, 0, lrintf(gyroADCf)); |
| 1206 | + // } |
| 1207 | + |
| 1208 | + dynNotchPush(axis, pidData[axis].Sum); |
| 1209 | + pidData[axis].Sum = dynNotchFilter(axis, pidData[axis].Sum); |
| 1210 | + |
| 1211 | + // if (axis == gyro.gyroDebugAxis) { |
| 1212 | + // GYRO_FILTER_DEBUG_SET(DEBUG_FFT, 1, lrintf(gyroADCf)); |
| 1213 | + // GYRO_FILTER_DEBUG_SET(DEBUG_DYN_LPF, 3, lrintf(gyroADCf)); |
| 1214 | + // } |
| 1215 | + } |
| 1216 | +#endif |
| 1217 | + DEBUG_SET(DEBUG_PIDSUM, axis, lrintf(pidData[axis].Sum)); |
| 1218 | + } |
| 1219 | +#ifdef USE_DYN_NOTCH_FILTER |
| 1220 | + if (isDynNotchActive()) { |
| 1221 | + dynNotchUpdate(); |
1196 | 1222 | }
|
| 1223 | +#endif |
1197 | 1224 |
|
1198 | 1225 | // Disable PID control if at zero throttle or if gyro overflow detected
|
1199 | 1226 | // This may look very innefficient, but it is done on purpose to always show real CPU usage as in flight
|
|
0 commit comments