Cleanup PID initialisations

This commit is contained in:
Josh Stewart 2016-04-08 23:52:32 +10:00
parent f1e2db7e2a
commit d10608e493
3 changed files with 10 additions and 2 deletions

View File

@ -16,6 +16,14 @@ Flood clear mode etc.
#include "corrections.h"
#include "globals.h"
long PID_O2, PID_output, PID_AFRTarget;
PID egoPID(&PID_O2, &PID_output, &PID_AFRTarget, configPage3.egoKP, configPage3.egoKI, configPage3.egoKD, REVERSE); //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call
void initialiseCorrections()
{
egoPID.SetMode(AUTOMATIC); //Turn O2 PID on
}
/*
correctionsTotal() calls all the other corrections functions and combines their results.
This is the only function that should be called from anywhere outside the file
@ -207,8 +215,6 @@ This continues until either:
PID (Best suited to wideband sensors):
*/
long PID_O2, PID_output, PID_AFRTarget;
PID egoPID(&PID_O2, &PID_output, &PID_AFRTarget, configPage3.egoKP, configPage3.egoKI, configPage3.egoKD, REVERSE); //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call
byte correctionsAFRClosedLoop()
{

View File

@ -73,6 +73,7 @@ void initialiseIdle()
idle_pwm_max_count = 1000000L / (16 * configPage3.idleFreq * 2); //Converts the frequency in Hz to the number of ticks (at 16uS) it takes to complete 1 cycle. Note that the frequency is divided by 2 coming from TS to allow for up to 512hz
idlePID.SetOutputLimits(0, idle_pwm_max_count);
TIMSK4 |= (1 << OCIE4C); //Turn on the C compare unit (ie turn on the interrupt)
idlePID.SetMode(AUTOMATIC); //Turn PID on
break;
case 4:

View File

@ -216,6 +216,7 @@ void setup()
initialiseIdle();
initialiseFan();
initialiseAuxPWM();
initialiseCorrections();
//Once the configs have been loaded, a number of one time calculations can be completed
req_fuel_uS = configPage1.reqFuel * 100; //Convert to uS and an int. This is the only variable to be used in calculations