I recently noticed an issue with our current Deadband feature.
In the picture below you can see what happens to our rcData when it gets processed by the deadband code.
As you can see there is a "step" in the rcCommand. This step causes a significant loss in steering precision around the center of the roll and pitch-stick.
So I developed a (in my opinion) better solution, where the deadband is not applyed to the rcCommand, but to the rcData.
The code consists of two parts in the multiwii.pde and the definition in the condig.h
multiwii.pde (line 98)
Code: Select all
#if defined(DEADBAND)
static uint16_t deadbandfactor = (500-DEADBAND)/DEADBAND;
#endif
multiwii.pde (line ~250, right above the old deadband implementation, which then must be deleted)
Code: Select all
for(axis=0;axis<2;axis++) {
uint16_t tmp = abs(rcData[axis]-MIDRC);
#if defined(DEADBAND)
if (tmp>DEADBAND) {
tmp -= DEADBAND-((tmp-DEADBAND)/deadbandfactor);
}
else { tmp=0; }
#endif
uint16_t tmp2 = tmp/100;
rcCommand[axis] = lookupRX[tmp2] + (tmp-tmp2*100) * (lookupRX[tmp2+1]-lookupRX[tmp2]) / 100;
if (rcData[axis]<MIDRC) rcCommand[axis] = -rcCommand[axis];
}
rcCommand[THROTTLE] = MINTHROTTLE + (int32_t)(MAXTHROTTLE-MINTHROTTLE)* (rcData[THROTTLE]-MINCHECK)/(2000-MINCHECK);
rcCommand[YAW] = abs(rcData[YAW]-MIDRC);
#if defined(DEADBAND)
if (rcCommand[YAW]>DEADBAND) {
rcCommand[YAW] -= DEADBAND-((rcCommand[YAW]-DEADBAND)/deadbandfactor);
}
else { rcCommand[YAW]=0; }
#endif
if (rcData[YAW]<MIDRC) rcCommand[YAW] = -rcCommand[YAW];
config.h
Code: Select all
/* introduce a deadband around the stick center */
//Must be greater than zero, comment if you dont want a deadband on roll, pitch and yaw
#define DEADBAND 5
I tested the code and it works but it would be great if someone of the wise guys could also check the code.
Best regards,
Peter