Improve performane on all targets // remove emf_avoidance

This commit is contained in:
borisbstyle 2016-02-27 15:56:45 +01:00
parent 35ce724a22
commit a5278740bd
3 changed files with 12 additions and 12 deletions

View File

@ -5,7 +5,7 @@
* Author: borisb
*/
#define INTERRUPT_WAIT_TIME 8
#define INTERRUPT_WAIT_TIME 0
extern uint32_t targetLooptime;

View File

@ -124,8 +124,8 @@ void setGyroSamplingSpeed(uint16_t looptime) {
masterConfig.pid_process_denom = 2;
} else if (looptime < 375) {
masterConfig.acc_hardware = 0;
masterConfig.baro_hardware = 0;
masterConfig.mag_hardware = 0;
masterConfig.baro_hardware = 1;
masterConfig.mag_hardware = 1;
masterConfig.pid_process_denom = 2;
}
} else {
@ -144,20 +144,15 @@ void setGyroSamplingSpeed(uint16_t looptime) {
gyroSampleRate = 125;
maxDivider = 8;
masterConfig.pid_process_denom = 1;
masterConfig.emf_avoidance = 0;
if (currentProfile->pidProfile.pidController == 2) masterConfig.pid_process_denom = 2;
if (looptime < 250) {
masterConfig.pid_process_denom = 3;
masterConfig.emf_avoidance = 1;
} else if (looptime < 375) {
if (currentProfile->pidProfile.pidController == 2) {
masterConfig.pid_process_denom = 3;
} else {
masterConfig.pid_process_denom = 2;
}
#ifndef CC3D
masterConfig.emf_avoidance = 1;
#endif
}
} else {
masterConfig.gyro_lpf = 1;
@ -168,6 +163,13 @@ void setGyroSamplingSpeed(uint16_t looptime) {
}
#endif
masterConfig.gyro_sync_denom = constrain(looptime / gyroSampleRate, 1, maxDivider);
if (looptime < 1000) {
masterConfig.use_fast_pwm = 1;
masterConfig.motor_pwm_rate = lrintf(1.0f / (gyroSampleRate * masterConfig.gyro_sync_denom * masterConfig.pid_process_denom * 0.000001f));
} else {
masterConfig.use_fast_pwm = 0;
}
}
}

View File

@ -668,14 +668,12 @@ int main(void) {
setTaskEnabled(TASK_GYROPID, true);
if(sensors(SENSOR_ACC)) {
setTaskEnabled(TASK_ACCEL, true);
switch(targetLooptime) {
switch(targetLooptime) { // Switch statement kept in place to change acc rates in the future
case(500):
accTargetLooptime = 5000;
break;
case(375):
case(250):
case(125):
accTargetLooptime = 10000;
accTargetLooptime = 1000;
break;
default:
case(1000):