Some initial work on idle control

This commit is contained in:
Josh Stewart 2015-05-29 17:33:00 +10:00
parent 48f426317d
commit a2137403ce
7 changed files with 87 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#define vePage 1
#define ignPage 2
#define afrPage 3
#define iacPage 4
byte currentPage;

View File

@ -283,6 +283,16 @@ void receiveValue(byte offset, byte newValue)
}
break;
case iacPage: //Idle Air Control settings page (Page 4)
pnt_configPage = (byte *)&configPage4;
//For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size
if( offset < page_size)
{
*(pnt_configPage + byte(offset)) = newValue;
}
return;
break;
default:
break;
}
@ -354,6 +364,16 @@ void sendPage()
//Serial.flush();
break;
case iacPage:
pnt_configPage = (byte *)&configPage4; //Create a pointer to Page 2 in memory
offset = 0; //No offset required on page 4
for(byte x=offset; x<page_size; x++)
{
response[x] = *(pnt_configPage + byte(x)); //Each byte is simply the location in memory of configPage2 + the offset + the variable number (x)
}
Serial.write((byte *)&response, sizeof(response));
break;
default:
break;
}

View File

@ -233,6 +233,28 @@ struct config3 {
};
//Page 4 of the config mostly deals with idle control
//See ini file for further info
struct config4 {
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
byte iacBins[10]; //Temperature Bins for the above 3 curves
byte iacCrankSteps[4]; //Steps to use when cranking (Stepper motor)
byte iacCrankDuty[4]; //Duty cycle to use on PWM valves when cranking
byte iacCrankBins[4]; //Temperature Bins for the above 2 curves
byte iacAlgorithm : 3; //Valid values are: "None", "On/Off", "PWM", "PWM Closed Loop", "Stepper", "Stepper Closed Loop"
byte iacStepTime : 3; //How long to pulse the stepper for to ensure the step completes (ms)
byte unused38 : 2;
byte iacFastTemp; //Fast idle temp when using a simple on/off valve
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 pinInjector1; //Output pin injector 1
byte pinInjector2; //Output pin injector 2
byte pinInjector3; //Output pin injector 3 is on

15
idle.h Normal file
View File

@ -0,0 +1,15 @@
#define STEPPER_FORWARD 1
#define STEPPER_BACKWARD 0
enum StepperStatus {SOFF, STEPPING}; //The 2 statuses that a stepper can have. STEPPING means that a high pulse is currently being sent and will need to be turned off at some point.
struct StepperIdle
{
int curIdleStep; //Tracks the current location of the stepper
int targetIdleStep; //What the targetted step is
volatile StepperStatus stepperStatus;
volatile unsigned long stepStartTime; //The time the curren
};
void initialiseIdle();

24
idle.ino Normal file
View File

@ -0,0 +1,24 @@
/*
Speeduino - Simple engine management for the Arduino Mega 2560 platform
Copyright (C) Josh Stewart
A full copy of the license may be found in the projects root directory
*/
/*
These functions over the PWM and stepper idle control
*/
void initialiseIdle()
{
}
void initialiseIdlePWM()
{
}
void initialiseIdleStepper()
{
}

View File

@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "timers.h"
#include "display.h"
#include "decoders.h"
#include "idle.h"
#ifdef __SAM3X8E__
//Do stuff for ARM based CPUs
@ -48,6 +49,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
struct config1 configPage1;
struct config2 configPage2;
struct config3 configPage3;
struct config4 configPage4;
int req_fuel_uS, inj_opentime_uS;
#define MAX_RPM 10000 //This is the maximum rpm that the ECU will attempt to run at. It is NOT related to the rev limiter, but is instead dictates how fast certain operations will be allowed to run. Lower number gives better performance
@ -153,6 +155,7 @@ void setup()
initialiseSchedulers();
initialiseTimers();
initialiseDisplay();
initialiseIdle();
//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

View File

@ -45,6 +45,8 @@ ISR(TIMER2_OVF_vect)
if(ignitionSchedule3.Status == RUNNING) { if(ignitionSchedule3.startTime < targetOverdwellTime) { endCoil3Charge(); } if(ignitionSchedule3.startTime < targetTachoPulseTime) { digitalWrite(pinTachOut, HIGH); } }
if(ignitionSchedule4.Status == RUNNING) { if(ignitionSchedule4.startTime < targetOverdwellTime) { endCoil4Charge(); } if(ignitionSchedule4.startTime < targetTachoPulseTime) { digitalWrite(pinTachOut, HIGH); } }
//Check if there's any actions pending for a stepper idle
//Loop executed every 250ms loop (1ms x 250 = 250ms)