This commit is contained in:
Josh Stewart 2021-09-11 10:42:39 +10:00
parent 3297321d9c
commit b2878d66f8
3 changed files with 138 additions and 136 deletions

View File

@ -558,7 +558,7 @@ page = 4
FILTER_FLEX = scalar, U08, 125, "%", 1.0, 0.0, 0, 240, 0
#if CELSIUS
vvtMinClt = array, U08, 126, "C", 1.0, -40, -40, 215, 0
vvtMinClt = scalar, U08, 126, "C", 1.0, -40, -40, 215, 0
#else
vvtMinClt = scalar, U08, 126, "F", 1.8, -22.23, -40, 215, 0
#endif

View File

@ -35,6 +35,8 @@ void wmiControl();
#define N2O_STAGE2_PIN_HIGH() *n2o_stage2_pin_port |= (n2o_stage2_pin_mask)
#define READ_N2O_ARM_PIN() ((*n2o_arming_pin_port & n2o_arming_pin_mask) ? true : false)
#define VVT_TIME_DELAY_MULTIPLIER 50
#define FAN_ON() ((configPage6.fanInv) ? FAN_PIN_LOW() : FAN_PIN_HIGH())
#define FAN_OFF() ((configPage6.fanInv) ? FAN_PIN_HIGH() : FAN_PIN_LOW())
@ -62,6 +64,9 @@ long boost_pwm_target_value;
long boost_cl_target_boost;
byte boostCounter;
byte vvtCounter;
uint32_t vvtWarmTime;
bool vvtIsHot;
bool vvtTimeHold;
byte fanHIGH = HIGH; // Used to invert the cooling fan output
byte fanLOW = LOW; // Used to invert the cooling fan output

View File

@ -9,16 +9,12 @@ A full copy of the license may be found in the projects root directory
#include "src/PID_v1/PID_v1.h"
#include "decoders.h"
uint32_t vvtTime;
bool vvtHot;
bool vvtTimeHold;
//Old PID method. Retained incase the new one has issues
//integerPID boostPID(&MAPx100, &boost_pwm_target_value, &boostTargetx100, configPage6.boostKP, configPage6.boostKI, configPage6.boostKD, DIRECT);
integerPID_ideal boostPID(&currentStatus.MAP, &currentStatus.boostDuty , &currentStatus.boostTarget, &configPage10.boostSens, &configPage10.boostIntv, configPage6.boostKP, configPage6.boostKI, configPage6.boostKD, DIRECT); //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call
integerPID vvtPID(&vvt_pid_current_angle, &currentStatus.vvt1Duty, &vvt_pid_target_angle, configPage10.vvtCLKP, configPage10.vvtCLKI, configPage10.vvtCLKD, configPage6.vvtPWMdir); //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call
integerPID vvt2PID(&vvt2_pid_current_angle, &currentStatus.vvt2Duty, &vvt2_pid_target_angle, configPage10.vvtCLKP, configPage10.vvtCLKI, configPage10.vvtCLKD, configPage4.vvt2PWMdir); //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call
/*
Fan control
*/
@ -130,8 +126,8 @@ void initialiseAuxPWM()
ENABLE_VVT_TIMER(); //Turn on the B compare unit (ie turn on the interrupt)
BIT_CLEAR(currentStatus.status4, BIT_STATUS4_VVT1_ERROR);
BIT_CLEAR(currentStatus.status4, BIT_STATUS4_VVT2_ERROR);
vvtTimeHold=false;
if (currentStatus.coolant >= (int)(configPage4.vvtMinClt - CALIBRATION_TEMPERATURE_OFFSET)) {vvtHot=true;} //Checks to see if coolant's already at operating temperature
vvtTimeHold = false;
if (currentStatus.coolant >= (int)(configPage4.vvtMinClt - CALIBRATION_TEMPERATURE_OFFSET)) { vvtIsHot = true; } //Checks to see if coolant's already at operating temperature
}
if( (configPage6.vvtEnabled == 0) && (configPage10.wmiEnabled >= 1) )
{
@ -306,14 +302,15 @@ void vvtControl()
{
if( (configPage6.vvtEnabled == 1) && (currentStatus.coolant >= (int)(configPage4.vvtMinClt - CALIBRATION_TEMPERATURE_OFFSET)) && (BIT_CHECK(currentStatus.engine, BIT_ENGINE_RUN)))
{
if (vvtTimeHold==false)
if(vvtTimeHold == false)
{
vvtTime = runSecsX10;
vvtTimeHold=true;
vvtWarmTime = runSecsX10;
vvtTimeHold = true;
}
if (((runSecsX10 - vvtTime) >= (configPage4.vvtDelay * 50)) || (vvtHot==true)) {
vvtHot=true;
//currentStatus.vvt1Duty = 0;
if( (vvtIsHot == true) || ((runSecsX10 - vvtWarmTime) >= (configPage4.vvtDelay * VVT_TIME_DELAY_MULTIPLIER)) )
{
vvtIsHot = true;
//Calculate the current cam angle
if( configPage4.TrigPattern == 9 ) { currentStatus.vvt1Angle = getCamAngle_Miata9905(); }