mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 13:55:18 +03:00
Disable ADC debug output and enable AltHold debugging output.
This commit is contained in:
parent
91bfdf05ca
commit
e30a373c92
2 changed files with 13 additions and 11 deletions
|
@ -32,7 +32,7 @@ extern int16_t debug[4];
|
||||||
|
|
||||||
uint16_t adcGetChannel(uint8_t channel)
|
uint16_t adcGetChannel(uint8_t channel)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
if (adcConfig[0].enabled) {
|
if (adcConfig[0].enabled) {
|
||||||
debug[0] = adcValues[adcConfig[0].dmaIndex];
|
debug[0] = adcValues[adcConfig[0].dmaIndex];
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#include "flight/mixer.h"
|
#include "flight/mixer.h"
|
||||||
#include "flight/imu.h"
|
#include "flight/imu.h"
|
||||||
|
|
||||||
|
extern int16_t debug[4];
|
||||||
|
|
||||||
int16_t gyroADC[XYZ_AXIS_COUNT], accADC[XYZ_AXIS_COUNT], accSmooth[XYZ_AXIS_COUNT];
|
int16_t gyroADC[XYZ_AXIS_COUNT], accADC[XYZ_AXIS_COUNT], accSmooth[XYZ_AXIS_COUNT];
|
||||||
int32_t accSum[XYZ_AXIS_COUNT];
|
int32_t accSum[XYZ_AXIS_COUNT];
|
||||||
|
|
||||||
|
@ -374,12 +376,12 @@ bool isThrustFacingDownwards(rollAndPitchInclination_t *inclination)
|
||||||
|
|
||||||
int32_t calculateBaroPid(int32_t vel_tmp, float accZ_tmp, float accZ_old)
|
int32_t calculateBaroPid(int32_t vel_tmp, float accZ_tmp, float accZ_old)
|
||||||
{
|
{
|
||||||
uint32_t baroPID = 0;
|
uint32_t newBaroPID = 0;
|
||||||
int32_t error;
|
int32_t error;
|
||||||
int32_t setVel;
|
int32_t setVel;
|
||||||
|
|
||||||
if (!isThrustFacingDownwards(&inclination)) {
|
if (!isThrustFacingDownwards(&inclination)) {
|
||||||
return baroPID;
|
return newBaroPID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Altitude P-Controller
|
// Altitude P-Controller
|
||||||
|
@ -392,17 +394,17 @@ int32_t calculateBaroPid(int32_t vel_tmp, float accZ_tmp, float accZ_old)
|
||||||
|
|
||||||
// P
|
// P
|
||||||
error = setVel - vel_tmp;
|
error = setVel - vel_tmp;
|
||||||
baroPID = constrain((pidProfile->P8[PIDVEL] * error / 32), -300, +300);
|
newBaroPID = constrain((pidProfile->P8[PIDVEL] * error / 32), -300, +300);
|
||||||
|
|
||||||
// I
|
// I
|
||||||
errorAltitudeI += (pidProfile->I8[PIDVEL] * error) / 8;
|
errorAltitudeI += (pidProfile->I8[PIDVEL] * error) / 8;
|
||||||
errorAltitudeI = constrain(errorAltitudeI, -(1024 * 200), (1024 * 200));
|
errorAltitudeI = constrain(errorAltitudeI, -(1024 * 200), (1024 * 200));
|
||||||
baroPID += errorAltitudeI / 1024; // I in range +/-200
|
newBaroPID += errorAltitudeI / 1024; // I in range +/-200
|
||||||
|
|
||||||
// D
|
// D
|
||||||
baroPID -= constrain(pidProfile->D8[PIDVEL] * (accZ_tmp + accZ_old) / 64, -150, 150);
|
newBaroPID -= constrain(pidProfile->D8[PIDVEL] * (accZ_tmp + accZ_old) / 64, -150, 150);
|
||||||
|
|
||||||
return baroPID;
|
return newBaroPID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void calculateEstimatedAltitude(uint32_t currentTime)
|
void calculateEstimatedAltitude(uint32_t currentTime)
|
||||||
|
@ -444,10 +446,10 @@ void calculateEstimatedAltitude(uint32_t currentTime)
|
||||||
EstAlt = accAlt;
|
EstAlt = accAlt;
|
||||||
vel += vel_acc;
|
vel += vel_acc;
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
debug[0] = accSum[2] / accSumCount; // acceleration
|
debug[1] = accSum[2] / accSumCount; // acceleration
|
||||||
debug[1] = vel; // velocity
|
debug[2] = vel; // velocity
|
||||||
debug[2] = accAlt; // height
|
debug[3] = accAlt; // height
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
accSum_reset();
|
accSum_reset();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue