Minor cleanups of the fan control additions

This commit is contained in:
Josh Stewart 2015-06-02 22:56:18 +10:00
parent 65d23e6258
commit 204f024218
4 changed files with 17 additions and 22 deletions

View File

@ -10,13 +10,13 @@ These functions control the auxillary outputs
void initialiseFan()
{
if(configPage4.FanInv == 1) {FanHIGH = LOW, FanLOW = HIGH; }
else {FanHIGH = HIGH, FanLOW = LOW;}
digitalWrite(pinFan, FanLOW); //Initiallise program with the fan in the off state
if(configPage4.fanInv == 1) {fanHIGH = LOW, fanLOW = HIGH; }
else {fanHIGH = HIGH, fanLOW = LOW;}
digitalWrite(pinFan, fanLOW); //Initiallise program with the fan in the off state
}
void FanControl()
void fanControl()
{
if (currentStatus.coolant >= (configPage4.FanSP - CALIBRATION_TEMPERATURE_OFFSET)) {digitalWrite(pinFan,FanHIGH);}
else if (currentStatus.coolant <= (configPage4.FanSP - configPage4.FanHyster)){ digitalWrite(pinFan, FanLOW);}
if (currentStatus.coolant >= (configPage4.fanSP - CALIBRATION_TEMPERATURE_OFFSET)) { digitalWrite(pinFan,fanHIGH); }
else if (currentStatus.coolant <= (configPage4.fanSP - configPage4.fanHyster)) { digitalWrite(pinFan, fanLOW); }
}

View File

@ -236,11 +236,6 @@ struct config3 {
//Page 4 of the config mostly deals with idle control
//See ini file for further info
struct config4 {
byte FanInv : 1; // Fan output inversion bit
byte FanEnable : 1; // Fan enable bit
byte FanSP; // Cooling fan start temperature
byte FanHyster; // Fan hysteresis
byte iacCLValues[10]; //Closed loop target RPM value
byte iacOLStepVal[10]; //Open loop step values for stepper motors
byte iacOLPWMVal[10]; //Open loop duty values for PMWM valves
@ -258,6 +253,10 @@ struct config4 {
byte iacStepHome; //When using a stepper motor, the number of steps to be taken on startup to home the motor
byte iacStepHyster; //Hysteresis temperature (*10). Eg 2.2C = 22
byte fanInv : 1; // Fan output inversion bit
byte fanEnable : 1; // Fan enable bit
byte fanSP; // Cooling fan start temperature
byte fanHyster; // Fan hysteresis
};
byte pinInjector1; //Output pin injector 1

View File

@ -81,8 +81,8 @@ unsigned long scheduleEnd;
byte coilHIGH = HIGH;
byte coilLOW = LOW;
byte FanHIGH = HIGH; // Used to invert the cooling fan output
byte FanLOW = LOW; // Used to invert the cooling fan output
byte fanHIGH = HIGH; // Used to invert the cooling fan output
byte fanLOW = LOW; // Used to invert the cooling fan output
struct statuses currentStatus;
volatile int mainLoopCount;
@ -361,15 +361,6 @@ void loop()
currentStatus.O2 = o2CalibrationTable[currentStatus.O2ADC];
}
// Only check the fan controls every 1000 loops to save processing power // ################
if ((mainLoopCount & 1001) == 1)
{
if (configPage4.FanEnable == 1)
{
FanControl(); // Fucntion to turn the cooling fan on/off
}
}
//Always check for sync
//Main loop runs within this clause
if (currentStatus.hasSync && (currentStatus.RPM > 0))

View File

@ -77,6 +77,11 @@ ISR(TIMER2_OVF_vect)
//increament secl (secl is simply a counter that increments every second and is used to track whether the system has unexpectedly reset
currentStatus.secl++;
//Check the fan output status
if (configPage4.fanEnable == 1)
{
fanControl(); // Fucntion to turn the cooling fan on/off
}
}
//Reset Timer2 to trigger in another ~1ms