Hi !
In the current code there are some problems with the locking in of a new hight for the Baro/PID controller:
Original:
Code: Select all
#if BARO
if (baroMode) {
if (abs(rcCommand[THROTTLE]-initialThrottleHold)>20) {
baroMode = 0; // so that a new althold reference is defined
}
rcCommand[THROTTLE] = initialThrottleHold + BaroPID;
}
#endif
Problem1:
At the moment the throttlestick is altered a new hight is locked for the PID controller long before the copter could have possibly reached a new hight or has altered his position. This can also lead to a feedbackproblem.
Problem2:
With this code the throttlechannel is rasterized in 21 steps, that gives a sluggish throttleresponse and an unnatural feeling for the pilot.
Possible Solution:
Give the pilot full control over the throttlechannel.
Lock in a new hight for the Baro PID controller only under the following circumstances:
The copter has done a substantial hight (in my code 60cm) change and the pilot wanted it by stickinput (change "20").
I changed the code and tested it for 2 days - and the baro behaviour improved. Perhaps i have to raise the value of "60" for my BMP085 to e.g. "100".
I posted my findings in my german forum (
http://fpv-community.de/showthread.php? ... post146766) and another user reports (
http://fpv-community.de/showthread.php? ... post146996) that his copter behaves significantly better than with the original DEV 20120504.
My findings should also apply for the new DEV, but is untested.
Please look into this. I think my new code is far from perfect, but it flies better.
I am new to C and arduino programming.
Cheers
Crashpilot1000
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EDIT 26.05.2012: I did a new Version:
http://fpv-community.de/showthread.php? ... post148827/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
New Code:
Code: Select all
static uint8_t baroloopcounter=0;
static int32_t thrsticksum=0;
static int16_t thrstickmw=0;
static int32_t estaltsum=0;
static int32_t estaltmw=0;
Code: Select all
#if BARO
if (baroMode)
{
if (baroloopcounter <64)
{
estaltsum=estaltsum+EstAlt;
thrsticksum=thrsticksum+rcCommand[THROTTLE];
thrstickmw=0;
estaltmw=0;
baroloopcounter=baroloopcounter+1;
}
else
{
baroloopcounter=0;
estaltmw=estaltsum>>6;
thrstickmw=thrsticksum>>6;
estaltsum=0;
thrsticksum=0;
// debug3=thrstickmw - initialThrottleHold;
// debug4=estaltmw - AltHold;
if (abs(estaltmw - AltHold)>60 && abs(thrstickmw - initialThrottleHold)>20) //Did the hight significant change over time on purpose?
{
baroMode = 0; // so that a new althold reference is defined
}
}
rcCommand[THROTTLE] = rcCommand[THROTTLE] + BaroPID;
}
#endif