- Wed Nov 03, 2021 1:07 am
#53821
Greetings all and thanks for such an active community I have been able to learn loads of stuff by lurking for a bit. I am just getting into my little project and have a NO2C board in the mail. My goal is to swap an older motor out of a jeep for a newer Manifold Injected motor and have a reliable runner that is fun to drive and tinker on. I had originally hoped to transplant the 1997-OBD2 computer but the more I learned the more headache and heartache were on the horizon.. Enter speeduino to save me.
My first ask is for a double-check on some of my figuring and written code. I have researched out the Crankshaft sensor pattern for my flywheel and modified the jeep_2000 code. The cam is 180 degrees of "on". The crank has 4 notches 20 degrees apart and then a 120 degree wait for the next set. Tell me what you think? Anything I need to tweak. It will be a while before I get to test it as I still haven't got the new motor installed yet probably a week or two.
My first ask is for a double-check on some of my figuring and written code. I have researched out the Crankshaft sensor pattern for my flywheel and modified the jeep_2000 code. The cam is 180 degrees of "on". The crank has 4 notches 20 degrees apart and then a 120 degree wait for the next set. Tell me what you think? Anything I need to tweak. It will be a while before I get to test it as I still haven't got the new motor installed yet probably a week or two.
Code: Select all
/** @} */
/** Jeep 2.5L - 16 crank teeth over 720 degrees, in groups of 4 (1994 to 2002 2.5l 4 cylinder MPI Jeep engines).
* This is NOT for any of the PRE 1991 Renix Computer 2.5l motors with TBI.
* Crank wheel is high for 360 crank degrees. Quite similar to the 24X setup.
* As we only need timing within 360 degrees, only 8 tooth angles are defined.
* Tooth number 1 represents the first tooth seen after the cam signal goes high.
* Signal should be high for 2 degrees. TDC should be at -6.
* I Need to upload a new image to the forum for the 4cyl model. LINK HERE
* @teamtortoise JeepI4 (4cyl)
* Modified from: @defgroup dec_jeep Jeep 2000 (6 cyl)
* @{
*/
void triggerSetup_JeepI4()
{
triggerToothAngle = 0; //The number of degrees that passes from tooth to tooth (primary)
toothAngles[0] = 294;
toothAngles[1] = 314;
toothAngles[2] = 334;
toothAngles[3] = 354;
toothAngles[4] = 474;
toothAngles[5] = 494;
toothAngles[6] = 514; //This is published wrong as 334 in some jeep manuals.
toothAngles[7] = 534; //this is published wrong as 514 in some manuals.
MAX_STALL_TIME = (3333UL * 120); //Minimum 50rpm. (3333uS is the time per degree at 50rpm). Largest gap between teeth is 120 degrees.
if(initialisationComplete == false) { toothCurrentCount = 9; toothLastToothTime = micros(); } //Set a startup value here to avoid filter errors when starting. This MUST have the initi check to prevent the fuel pump just staying on all the time
secondDerivEnabled = false;
decoderIsSequential = false;
triggerToothAngleIsCorrect = true;
}
void triggerPri_JeepI4()
{
if(toothCurrentCount == 9) { currentStatus.hasSync = false; } //Indicates sync has not been achieved (Still waiting for 1 revolution of the crank to take place)
else
{
curTime = micros();
curGap = curTime - toothLastToothTime;
if ( curGap >= triggerFilterTime )
{
if(toothCurrentCount == 0)
{
toothCurrentCount = 1; //Reset the counter
toothOneMinusOneTime = toothOneTime;
toothOneTime = curTime;
currentStatus.hasSync = true;
currentStatus.startRevolutions++; //Counter
triggerToothAngle = 120; //There are groups of 4 pulses (Each 20 degrees apart), with each group being 120 degrees apart. Hence #1 is always 120
}
else
{
toothCurrentCount++; //Increment the tooth counter
triggerToothAngle = toothAngles[(toothCurrentCount-1)] - toothAngles[(toothCurrentCount-2)]; //Calculate the last tooth gap in degrees
}
setFilter(curGap); //Recalc the new filter value
validTrigger = true; //Flag this pulse as being a valid trigger (ie that it passed filters)
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
} //Trigger filter
} //Sync check
}
void triggerSec_JeepI4()
{
toothCurrentCount = 0; //All we need to do is reset the tooth count back to zero, indicating that we're at the beginning of a new revolution
return;
}
uint16_t getRPM_JeepI4() //Does this need to change? I am unsure what uint16_t refrences but it sure looks like 16 teeth from the previous map.
{
return stdGetRPM(360);
}
int getCrankAngle_JeepI4()
{
//This is the current angle ATDC the engine is at. This is the last known position based on what tooth was last 'seen'. It is only accurate to the resolution of the trigger wheel (Eg 36-1 is 10 degrees)
unsigned long tempToothLastToothTime;
int tempToothCurrentCount;
//Grab some variables that are used in the trigger code and assign them to temp variables.
noInterrupts();
tempToothCurrentCount = toothCurrentCount;
tempToothLastToothTime = toothLastToothTime;
lastCrankAngleCalc = micros(); //micros() is no longer interrupt safe
interrupts();
int crankAngle;
if (toothCurrentCount == 0) { crankAngle = 236 + configPage4.triggerAngle; } //This is the special case to handle when the 'last tooth' seen was the cam tooth. 236 is the angle at which the crank tooth goes high.
else { crankAngle = toothAngles[(tempToothCurrentCount - 1)] + configPage4.triggerAngle;} //Perform a lookup of the fixed toothAngles array to find what the angle of the last tooth passed was.
//Estimate the number of degrees travelled since the last tooth}
elapsedTime = (lastCrankAngleCalc - tempToothLastToothTime);
crankAngle += timeToAngle(elapsedTime, CRANKMATH_METHOD_INTERVAL_REV);
if (crankAngle >= 720) { crankAngle -= 720; }
if (crankAngle > CRANK_ANGLE_MAX) { crankAngle -= CRANK_ANGLE_MAX; }
if (crankAngle < 0) { crankAngle += 360; }
return crankAngle;
}
void triggerSetEndTeeth_JeepI4()
{
lastToothCalcAdvance = currentStatus.advance;
}
/** @} */