auto-sync
This commit is contained in:
parent
de9de04543
commit
5fef502111
|
@ -1,4 +1,4 @@
|
||||||
// this section was generated by config_definition.jar on Tue Apr 14 19:23:48 EDT 2015
|
// this section was generated by config_definition.jar on Tue Apr 14 22:35:17 EDT 2015
|
||||||
// begin
|
// begin
|
||||||
#include "rusefi_types.h"
|
#include "rusefi_types.h"
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1091,7 +1091,11 @@ typedef struct {
|
||||||
/**
|
/**
|
||||||
* offset 1640
|
* offset 1640
|
||||||
*/
|
*/
|
||||||
int unused3[136];
|
brain_pin_e stepperEnablePin;
|
||||||
|
/**
|
||||||
|
* offset 1644
|
||||||
|
*/
|
||||||
|
int unused3[135];
|
||||||
/**
|
/**
|
||||||
* offset 2184
|
* offset 2184
|
||||||
*/
|
*/
|
||||||
|
@ -1271,4 +1275,4 @@ typedef struct {
|
||||||
} persistent_config_s;
|
} persistent_config_s;
|
||||||
|
|
||||||
// end
|
// end
|
||||||
// this section was generated by config_definition.jar on Tue Apr 14 19:23:48 EDT 2015
|
// this section was generated by config_definition.jar on Tue Apr 14 22:35:17 EDT 2015
|
||||||
|
|
|
@ -41,15 +41,15 @@ static Logging *logger;
|
||||||
EXTERN_ENGINE
|
EXTERN_ENGINE
|
||||||
;
|
;
|
||||||
|
|
||||||
static OutputPin idlePin;
|
static OutputPin idleSolenoidPin;
|
||||||
static SimplePwm idleValvePwm;
|
static SimplePwm idleSolenoid;
|
||||||
|
|
||||||
static StepperMotor iacMotor;
|
static StepperMotor iacMotor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* that's the position with CLT and IAT corrections
|
* that's the position with CLT and IAT corrections
|
||||||
*/
|
*/
|
||||||
static float actualIdlePosition = -1.0f;
|
static float actualIdlePosition = -100.0f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Idle level calculation algorithm lives in idle_controller.cpp
|
* Idle level calculation algorithm lives in idle_controller.cpp
|
||||||
|
@ -64,8 +64,10 @@ static void showIdleInfo(void) {
|
||||||
scheduleMsg(logger, "idleMode=%s position=%f isStepper=%s", getIdle_mode_e(engineConfiguration->idleMode),
|
scheduleMsg(logger, "idleMode=%s position=%f isStepper=%s", getIdle_mode_e(engineConfiguration->idleMode),
|
||||||
boardConfiguration->idlePosition, boolToString(boardConfiguration->useStepperIdle));
|
boardConfiguration->idlePosition, boolToString(boardConfiguration->useStepperIdle));
|
||||||
if (boardConfiguration->useStepperIdle) {
|
if (boardConfiguration->useStepperIdle) {
|
||||||
scheduleMsg(logger, "direction=%s", hwPortname(boardConfiguration->idle.stepperDirectionPin));
|
scheduleMsg(logger, "direction=%s reactionTime=%f", hwPortname(boardConfiguration->idle.stepperDirectionPin),
|
||||||
scheduleMsg(logger, "step=%s", hwPortname(boardConfiguration->idle.stepperStepPin));
|
engineConfiguration->idleStepperReactionTime);
|
||||||
|
scheduleMsg(logger, "step=%s steps=%d", hwPortname(boardConfiguration->idle.stepperStepPin),
|
||||||
|
engineConfiguration->idleStepperTotalSteps);
|
||||||
} else {
|
} else {
|
||||||
scheduleMsg(logger, "idle valve freq=%d on %s", boardConfiguration->idle.solenoidFrequency,
|
scheduleMsg(logger, "idle valve freq=%d on %s", boardConfiguration->idle.solenoidFrequency,
|
||||||
hwPortname(boardConfiguration->idle.solenoidPin));
|
hwPortname(boardConfiguration->idle.solenoidPin));
|
||||||
|
@ -78,27 +80,43 @@ static void setIdleControlEnabled(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setIdleValvePwm(percent_t value) {
|
static void setIdleValvePwm(percent_t value) {
|
||||||
if (value < 0.01 || value > 99.9)
|
|
||||||
return;
|
|
||||||
scheduleMsg(logger, "setting idle valve PWM %f", value);
|
|
||||||
showIdleInfo();
|
|
||||||
/**
|
/**
|
||||||
* currently idle level is an percent value (0-100 range), and PWM takes a float in the 0..1 range
|
* currently idle level is an percent value (0-100 range), and PWM takes a float in the 0..1 range
|
||||||
* todo: unify?
|
* todo: unify?
|
||||||
*/
|
*/
|
||||||
idleValvePwm.setSimplePwmDutyCycle(value / 100);
|
idleSolenoid.setSimplePwmDutyCycle(value / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setIdleValvePosition(int position) {
|
static void doSetIdleValvePosition(int positionPercent) {
|
||||||
boardConfiguration->idlePosition = position;
|
boardConfiguration->idlePosition = positionPercent;
|
||||||
|
|
||||||
|
percent_t cltCorrectedPosition = interpolate2d(engine->engineState.clt, config->cltIdleCorrBins, config->cltIdleCorr,
|
||||||
|
CLT_CURVE_SIZE) * positionPercent;
|
||||||
|
|
||||||
|
// let's put the value into the right range
|
||||||
|
cltCorrectedPosition = maxF(cltCorrectedPosition, 0.01);
|
||||||
|
cltCorrectedPosition = minF(cltCorrectedPosition, 99.9);
|
||||||
|
|
||||||
|
if (absF(cltCorrectedPosition - actualIdlePosition) < 1) {
|
||||||
|
return; // value is pretty close, let's leave the poor valve alone
|
||||||
|
}
|
||||||
|
actualIdlePosition = cltCorrectedPosition;
|
||||||
|
|
||||||
if (boardConfiguration->useStepperIdle) {
|
if (boardConfiguration->useStepperIdle) {
|
||||||
iacMotor.targetPosition = position;
|
iacMotor.setTargetPosition(cltCorrectedPosition / 100 * engineConfiguration->idleStepperTotalSteps);
|
||||||
} else {
|
} else {
|
||||||
setIdleValvePwm(position);
|
setIdleValvePwm(cltCorrectedPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setIdleValvePosition(int positionPercent) {
|
||||||
|
if (positionPercent < 1 || positionPercent > 99)
|
||||||
|
return;
|
||||||
|
scheduleMsg(logger, "setting idle valve position %d", positionPercent);
|
||||||
|
showIdleInfo();
|
||||||
|
doSetIdleValvePosition(positionPercent);
|
||||||
|
}
|
||||||
|
|
||||||
static msg_t ivThread(int param) {
|
static msg_t ivThread(int param) {
|
||||||
(void) param;
|
(void) param;
|
||||||
chRegSetThreadName("IdleValve");
|
chRegSetThreadName("IdleValve");
|
||||||
|
@ -117,8 +135,11 @@ static msg_t ivThread(int param) {
|
||||||
getHwPin(boardConfiguration->clutchUpPin));
|
getHwPin(boardConfiguration->clutchUpPin));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (engineConfiguration->idleMode != IM_AUTO)
|
if (engineConfiguration->idleMode != IM_AUTO) {
|
||||||
|
// let's re-apply CLT correction
|
||||||
|
doSetIdleValvePosition(boardConfiguration->idlePosition);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
efitimems_t now = currentTimeMillis();
|
efitimems_t now = currentTimeMillis();
|
||||||
|
|
||||||
|
@ -154,13 +175,12 @@ void startIdleThread(Logging*sharedLogger, Engine *engine) {
|
||||||
|
|
||||||
if (boardConfiguration->useStepperIdle) {
|
if (boardConfiguration->useStepperIdle) {
|
||||||
iacMotor.initialize(boardConfiguration->idle.stepperStepPin, boardConfiguration->idle.stepperDirectionPin,
|
iacMotor.initialize(boardConfiguration->idle.stepperStepPin, boardConfiguration->idle.stepperDirectionPin,
|
||||||
engineConfiguration->idleStepperReactionTime,
|
engineConfiguration->idleStepperReactionTime, engineConfiguration->idleStepperTotalSteps);
|
||||||
engineConfiguration->idleStepperTotalSteps);
|
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
* Start PWM for idleValvePin
|
* Start PWM for idleValvePin
|
||||||
*/
|
*/
|
||||||
startSimplePwmExt(&idleValvePwm, "Idle Valve", boardConfiguration->idle.solenoidPin, &idlePin,
|
startSimplePwmExt(&idleSolenoid, "Idle Valve", boardConfiguration->idle.solenoidPin, &idleSolenoidPin,
|
||||||
boardConfiguration->idle.solenoidFrequency, boardConfiguration->idlePosition / 100,
|
boardConfiguration->idle.solenoidFrequency, boardConfiguration->idlePosition / 100,
|
||||||
applyIdleSolenoidPinState);
|
applyIdleSolenoidPinState);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ static msg_t stThread(StepperMotor *motor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int targetPosition = motor->targetPosition;
|
int targetPosition = motor->getTargetPosition();
|
||||||
int currentPosition = motor->currentPosition;
|
int currentPosition = motor->currentPosition;
|
||||||
|
|
||||||
if (targetPosition == currentPosition) {
|
if (targetPosition == currentPosition) {
|
||||||
|
@ -59,6 +59,14 @@ StepperMotor::StepperMotor() {
|
||||||
totalSteps = 0;
|
totalSteps = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int StepperMotor::getTargetPosition() {
|
||||||
|
return targetPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StepperMotor::setTargetPosition(int targetPosition) {
|
||||||
|
this->targetPosition = targetPosition;
|
||||||
|
}
|
||||||
|
|
||||||
void StepperMotor::pulse() {
|
void StepperMotor::pulse() {
|
||||||
palWritePad(stepPort, stepPin, true);
|
palWritePad(stepPort, stepPin, true);
|
||||||
chThdSleepMilliseconds(ST_DELAY_MS);
|
chThdSleepMilliseconds(ST_DELAY_MS);
|
||||||
|
@ -67,8 +75,8 @@ void StepperMotor::pulse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StepperMotor::initialize(brain_pin_e stepPin, brain_pin_e directionPin, float reactionTime, int totalSteps) {
|
void StepperMotor::initialize(brain_pin_e stepPin, brain_pin_e directionPin, float reactionTime, int totalSteps) {
|
||||||
this->reactionTime = reactionTime;
|
this->reactionTime = maxF(1, reactionTime);
|
||||||
this->totalSteps = totalSteps;
|
this->totalSteps = maxI(3, totalSteps);
|
||||||
if (stepPin == GPIO_UNASSIGNED || directionPin == GPIO_UNASSIGNED) {
|
if (stepPin == GPIO_UNASSIGNED || directionPin == GPIO_UNASSIGNED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,20 @@ public:
|
||||||
StepperMotor();
|
StepperMotor();
|
||||||
void initialize(brain_pin_e stepPin, brain_pin_e directionPin, float reactionTime, int totalSteps);
|
void initialize(brain_pin_e stepPin, brain_pin_e directionPin, float reactionTime, int totalSteps);
|
||||||
void pulse();
|
void pulse();
|
||||||
|
void setTargetPosition(int targetPosition);
|
||||||
|
int getTargetPosition();
|
||||||
|
|
||||||
GPIO_TypeDef * directionPort;
|
GPIO_TypeDef * directionPort;
|
||||||
ioportmask_t directionPin;
|
ioportmask_t directionPin;
|
||||||
|
|
||||||
int currentPosition;
|
int currentPosition;
|
||||||
int targetPosition;
|
|
||||||
float reactionTime;
|
float reactionTime;
|
||||||
int totalSteps;
|
int totalSteps;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int targetPosition;
|
||||||
GPIO_TypeDef * stepPort;
|
GPIO_TypeDef * stepPort;
|
||||||
ioportmask_t stepPin;
|
ioportmask_t stepPin;
|
||||||
|
|
||||||
THD_WORKING_AREA(stThreadStack, UTILITY_THREAD_STACK_SIZE);
|
THD_WORKING_AREA(stThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* STEPPER_H_ */
|
#endif /* STEPPER_H_ */
|
||||||
|
|
|
@ -473,7 +473,7 @@ bit hasMapSensor;@see isMapAveragingEnabled
|
||||||
|
|
||||||
float cylinderBore;Cylinder diameter, in mm.
|
float cylinderBore;Cylinder diameter, in mm.
|
||||||
|
|
||||||
float idleStepperReactionTime;;"ms", 1, 0, 0, 300, 0
|
float idleStepperReactionTime;;"ms", 1, 0, 1, 300, 0
|
||||||
float hipThreshold;
|
float hipThreshold;
|
||||||
|
|
||||||
custom pin_input_mode_e 4 scalar, F32, @OFFSET@, "ms", 1, 0, 0, 200, 1
|
custom pin_input_mode_e 4 scalar, F32, @OFFSET@, "ms", 1, 0, 0, 200, 1
|
||||||
|
@ -483,8 +483,10 @@ custom pin_input_mode_e 4 scalar, F32, @OFFSET@, "ms", 1, 0, 0, 200, 1
|
||||||
float alternatorControlPFactor;
|
float alternatorControlPFactor;
|
||||||
float alternatorControlIFactor;
|
float alternatorControlIFactor;
|
||||||
float alternatorControlDFactor;
|
float alternatorControlDFactor;
|
||||||
int idleStepperTotalSteps;;"count", 1, 0, 0, 3000, 0
|
int idleStepperTotalSteps;;"count", 1, 0, 5, 3000, 0
|
||||||
int[136] unused3;
|
brain_pin_e stepperEnablePin;
|
||||||
|
|
||||||
|
int[135] unused3;
|
||||||
|
|
||||||
int tpsAccelLength;;"len", 1, 0, 1, 200, 3
|
int tpsAccelLength;;"len", 1, 0, 1, 200, 3
|
||||||
float tpsAccelEnrichmentThreshold;;"roc", 1, 0, 0, 200, 3
|
float tpsAccelEnrichmentThreshold;;"roc", 1, 0, 0, 200, 3
|
||||||
|
|
Loading…
Reference in New Issue