mirror of https://github.com/rusefi/speeduino.git
Experimental new stepper homing method
This commit is contained in:
parent
4d18ee7911
commit
ad52690101
1
idle.h
1
idle.h
|
@ -24,6 +24,7 @@ struct table2D iacCrankDutyTable;
|
|||
struct StepperIdle idleStepper;
|
||||
bool idleOn; //Simply tracks whether idle was on last time around
|
||||
unsigned int iacStepTime;
|
||||
unsigned int completedHomeSteps;
|
||||
|
||||
volatile byte *idle_pin_port;
|
||||
volatile byte idle_pin_mask;
|
||||
|
|
24
idle.ino
24
idle.ino
|
@ -90,7 +90,8 @@ void initialiseIdle()
|
|||
iacCrankStepsTable.axisX = configPage4.iacCrankBins;
|
||||
iacStepTime = configPage4.iacStepTime * 1000;
|
||||
|
||||
homeStepper(); //Returns the stepper to the 'home' position
|
||||
//homeStepper(); //Returns the stepper to the 'home' position
|
||||
completedHomeSteps = 0;
|
||||
idleStepper.stepperStatus = SOFF;
|
||||
break;
|
||||
|
||||
|
@ -175,7 +176,7 @@ void idleControl()
|
|||
}
|
||||
else
|
||||
{
|
||||
//Means we're in COOLING status. We need to remain in this state for the step time before the next step can be taken
|
||||
//Means we're in COOLING status but have been in this state long enough to
|
||||
idleStepper.stepperStatus = SOFF;
|
||||
}
|
||||
}
|
||||
|
@ -185,9 +186,18 @@ void idleControl()
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( completedHomeSteps < (configPage4.iacStepHome * 3) ) //Home steps are divided by 3 from TS
|
||||
{
|
||||
digitalWrite(pinStepperDir, STEPPER_BACKWARD); //Sets stepper direction to backwards
|
||||
digitalWrite(pinStepperStep, HIGH);
|
||||
idleStepper.stepStartTime = micros();
|
||||
idleStepper.stepperStatus = STEPPING;
|
||||
completedHomeSteps++;
|
||||
idleOn = true;
|
||||
}
|
||||
//Check for cranking pulsewidth
|
||||
if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
|
||||
else if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
|
||||
{
|
||||
//Currently cranking. Use the cranking table
|
||||
idleStepper.targetIdleStep = table2D_getValue(&iacCrankStepsTable, (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)) * 3; //All temps are offset by 40 degrees. Step counts are divided by 3 in TS. Multiply back out here
|
||||
|
@ -203,7 +213,11 @@ void idleControl()
|
|||
else if( (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) < iacStepTable.axisX[IDLE_TABLE_SIZE-1])
|
||||
{
|
||||
//Standard running
|
||||
idleStepper.targetIdleStep = table2D_getValue(&iacStepTable, (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)) * 3; //All temps are offset by 40 degrees. Step counts are divided by 3 in TS. Multiply back out here
|
||||
if ((mainLoopCount & 255) == 1)
|
||||
{
|
||||
//Only do a lookup of the required value around 4 times per second. Any more than this can create too much jitter and require a hyster value that is too high
|
||||
idleStepper.targetIdleStep = table2D_getValue(&iacStepTable, (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)) * 3; //All temps are offset by 40 degrees. Step counts are divided by 3 in TS. Multiply back out here
|
||||
}
|
||||
if ( idleStepper.targetIdleStep > (idleStepper.curIdleStep - configPage4.iacStepHyster) && idleStepper.targetIdleStep < (idleStepper.curIdleStep + configPage4.iacStepHyster) ) { return; } //Hysteris check
|
||||
else if(idleStepper.targetIdleStep < idleStepper.curIdleStep) { digitalWrite(pinStepperDir, STEPPER_BACKWARD); idleStepper.curIdleStep--; }//Sets stepper direction to backwards
|
||||
else if (idleStepper.targetIdleStep > idleStepper.curIdleStep) { digitalWrite(pinStepperDir, STEPPER_FORWARD); idleStepper.curIdleStep++; }//Sets stepper direction to forwards
|
||||
|
|
|
@ -918,6 +918,7 @@ void loop()
|
|||
boostControl(); //Most boost tends to run at about 30Hz, so placing it here ensures a new target time is fetched frequently enough
|
||||
idleControl(); //Perform any idle related actions. Even at higher frequencies, running 4x per second is sufficient.
|
||||
}
|
||||
if(configPage4.iacAlgorithm == 4) { idleControl(); } //Run idlecontrol every loop for stepper idle.
|
||||
|
||||
//Always check for sync
|
||||
//Main loop runs within this clause
|
||||
|
|
Loading…
Reference in New Issue