auto-sync
This commit is contained in:
parent
cafe248b61
commit
47c1fca16f
|
@ -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
|
||||
#include "rusefi_types.h"
|
||||
typedef struct {
|
||||
|
@ -1091,7 +1091,11 @@ typedef struct {
|
|||
/**
|
||||
* offset 1640
|
||||
*/
|
||||
int unused3[136];
|
||||
brain_pin_e stepperEnablePin;
|
||||
/**
|
||||
* offset 1644
|
||||
*/
|
||||
int unused3[135];
|
||||
/**
|
||||
* offset 2184
|
||||
*/
|
||||
|
@ -1271,4 +1275,4 @@ typedef struct {
|
|||
} persistent_config_s;
|
||||
|
||||
// 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
|
||||
;
|
||||
|
||||
static OutputPin idlePin;
|
||||
static SimplePwm idleValvePwm;
|
||||
static OutputPin idleSolenoidPin;
|
||||
static SimplePwm idleSolenoid;
|
||||
|
||||
static StepperMotor iacMotor;
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -64,8 +64,10 @@ static void showIdleInfo(void) {
|
|||
scheduleMsg(logger, "idleMode=%s position=%f isStepper=%s", getIdle_mode_e(engineConfiguration->idleMode),
|
||||
boardConfiguration->idlePosition, boolToString(boardConfiguration->useStepperIdle));
|
||||
if (boardConfiguration->useStepperIdle) {
|
||||
scheduleMsg(logger, "direction=%s", hwPortname(boardConfiguration->idle.stepperDirectionPin));
|
||||
scheduleMsg(logger, "step=%s", hwPortname(boardConfiguration->idle.stepperStepPin));
|
||||
scheduleMsg(logger, "direction=%s reactionTime=%f", hwPortname(boardConfiguration->idle.stepperDirectionPin),
|
||||
engineConfiguration->idleStepperReactionTime);
|
||||
scheduleMsg(logger, "step=%s steps=%d", hwPortname(boardConfiguration->idle.stepperStepPin),
|
||||
engineConfiguration->idleStepperTotalSteps);
|
||||
} else {
|
||||
scheduleMsg(logger, "idle valve freq=%d on %s", boardConfiguration->idle.solenoidFrequency,
|
||||
hwPortname(boardConfiguration->idle.solenoidPin));
|
||||
|
@ -78,27 +80,43 @@ static void setIdleControlEnabled(int 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
|
||||
* todo: unify?
|
||||
*/
|
||||
idleValvePwm.setSimplePwmDutyCycle(value / 100);
|
||||
idleSolenoid.setSimplePwmDutyCycle(value / 100);
|
||||
}
|
||||
|
||||
static void setIdleValvePosition(int position) {
|
||||
boardConfiguration->idlePosition = position;
|
||||
static void doSetIdleValvePosition(int positionPercent) {
|
||||
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) {
|
||||
iacMotor.targetPosition = position;
|
||||
iacMotor.setTargetPosition(cltCorrectedPosition / 100 * engineConfiguration->idleStepperTotalSteps);
|
||||
} 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) {
|
||||
(void) param;
|
||||
chRegSetThreadName("IdleValve");
|
||||
|
@ -117,8 +135,11 @@ static msg_t ivThread(int param) {
|
|||
getHwPin(boardConfiguration->clutchUpPin));
|
||||
}
|
||||
|
||||
if (engineConfiguration->idleMode != IM_AUTO)
|
||||
if (engineConfiguration->idleMode != IM_AUTO) {
|
||||
// let's re-apply CLT correction
|
||||
doSetIdleValvePosition(boardConfiguration->idlePosition);
|
||||
continue;
|
||||
}
|
||||
|
||||
efitimems_t now = currentTimeMillis();
|
||||
|
||||
|
@ -154,13 +175,12 @@ void startIdleThread(Logging*sharedLogger, Engine *engine) {
|
|||
|
||||
if (boardConfiguration->useStepperIdle) {
|
||||
iacMotor.initialize(boardConfiguration->idle.stepperStepPin, boardConfiguration->idle.stepperDirectionPin,
|
||||
engineConfiguration->idleStepperReactionTime,
|
||||
engineConfiguration->idleStepperTotalSteps);
|
||||
engineConfiguration->idleStepperReactionTime, engineConfiguration->idleStepperTotalSteps);
|
||||
} else {
|
||||
/**
|
||||
* 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,
|
||||
applyIdleSolenoidPinState);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ static msg_t stThread(StepperMotor *motor) {
|
|||
}
|
||||
|
||||
while (true) {
|
||||
int targetPosition = motor->targetPosition;
|
||||
int targetPosition = motor->getTargetPosition();
|
||||
int currentPosition = motor->currentPosition;
|
||||
|
||||
if (targetPosition == currentPosition) {
|
||||
|
@ -59,6 +59,14 @@ StepperMotor::StepperMotor() {
|
|||
totalSteps = 0;
|
||||
}
|
||||
|
||||
int StepperMotor::getTargetPosition() {
|
||||
return targetPosition;
|
||||
}
|
||||
|
||||
void StepperMotor::setTargetPosition(int targetPosition) {
|
||||
this->targetPosition = targetPosition;
|
||||
}
|
||||
|
||||
void StepperMotor::pulse() {
|
||||
palWritePad(stepPort, stepPin, true);
|
||||
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) {
|
||||
this->reactionTime = reactionTime;
|
||||
this->totalSteps = totalSteps;
|
||||
this->reactionTime = maxF(1, reactionTime);
|
||||
this->totalSteps = maxI(3, totalSteps);
|
||||
if (stepPin == GPIO_UNASSIGNED || directionPin == GPIO_UNASSIGNED) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -14,21 +14,20 @@ public:
|
|||
StepperMotor();
|
||||
void initialize(brain_pin_e stepPin, brain_pin_e directionPin, float reactionTime, int totalSteps);
|
||||
void pulse();
|
||||
void setTargetPosition(int targetPosition);
|
||||
int getTargetPosition();
|
||||
|
||||
GPIO_TypeDef * directionPort;
|
||||
ioportmask_t directionPin;
|
||||
|
||||
int currentPosition;
|
||||
int targetPosition;
|
||||
float reactionTime;
|
||||
int totalSteps;
|
||||
|
||||
private:
|
||||
|
||||
int targetPosition;
|
||||
GPIO_TypeDef * stepPort;
|
||||
ioportmask_t stepPin;
|
||||
|
||||
THD_WORKING_AREA(stThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||
|
||||
};
|
||||
|
||||
#endif /* STEPPER_H_ */
|
||||
|
|
|
@ -473,7 +473,7 @@ bit hasMapSensor;@see isMapAveragingEnabled
|
|||
|
||||
float cylinderBore;Cylinder diameter, in mm.
|
||||
|
||||
float idleStepperReactionTime;;"ms", 1, 0, 0, 300, 0
|
||||
float idleStepperReactionTime;;"ms", 1, 0, 1, 300, 0
|
||||
float hipThreshold;
|
||||
|
||||
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 alternatorControlIFactor;
|
||||
float alternatorControlDFactor;
|
||||
int idleStepperTotalSteps;;"count", 1, 0, 0, 3000, 0
|
||||
int[136] unused3;
|
||||
int idleStepperTotalSteps;;"count", 1, 0, 5, 3000, 0
|
||||
brain_pin_e stepperEnablePin;
|
||||
|
||||
int[135] unused3;
|
||||
|
||||
int tpsAccelLength;;"len", 1, 0, 1, 200, 3
|
||||
float tpsAccelEnrichmentThreshold;;"roc", 1, 0, 0, 200, 3
|
||||
|
|
|
@ -40,7 +40,7 @@ enable2ndByteCanID = false
|
|||
|
||||
; see PAGE_0_SIZE in C source code
|
||||
; CONFIG_DEFINITION_START
|
||||
; this section was generated by ConfigDefinition.jar on Tue Apr 14 21:10:17 EDT 2015
|
||||
; this section was generated by ConfigDefinition.jar on Tue Apr 14 22:35:19 EDT 2015
|
||||
|
||||
pageSize = 15288
|
||||
page = 1
|
||||
|
@ -428,7 +428,7 @@ page = 1
|
|||
;skipping knockDetectionWindowStart offset 1536
|
||||
;skipping knockDetectionWindowEnd offset 1540
|
||||
;skipping cylinderBore offset 1544
|
||||
idleStepperReactionTime = scalar, F32, 1548, "ms", 1, 0, 0, 300, 0
|
||||
idleStepperReactionTime = scalar, F32, 1548, "ms", 1, 0, 1, 300, 0
|
||||
;skipping hipThreshold offset 1552
|
||||
fsioInputModes1 = scalar, F32, 1556, "ms", 1, 0, 0, 200, 1
|
||||
fsioInputModes2 = scalar, F32, 1560, "ms", 1, 0, 0, 200, 1
|
||||
|
@ -450,8 +450,9 @@ page = 1
|
|||
;skipping alternatorControlPFactor offset 1624
|
||||
;skipping alternatorControlIFactor offset 1628
|
||||
;skipping alternatorControlDFactor offset 1632
|
||||
idleStepperTotalSteps = scalar, S32, 1636, "count", 1, 0, 0, 3000, 0
|
||||
;skipping unused3 offset 1640
|
||||
idleStepperTotalSteps = scalar, S32, 1636, "count", 1, 0, 5, 3000, 0
|
||||
stepperEnablePin = bits, U32, 1640, [0:6], "GPIOA_0", "GPIOA_1", "GPIOA_2", "GPIOA_3", "GPIOA_4", "GPIOA_5", "GPIOA_6", "GPIOA_7", "GPIOA_8", "GPIOA_9", "GPIOA_10", "GPIOA_11", "GPIOA_12", "GPIOA_13", "GPIOA_14", "GPIOA_15", "GPIOB_0", "GPIOB_1", "GPIOB_2", "GPIOB_3", "GPIOB_4", "GPIOB_5", "GPIOB_6", "GPIOB_7", "GPIOB_8", "GPIOB_9", "GPIOB_10", "GPIOB_11", "GPIOB_12", "GPIOB_13", "GPIOB_14", "GPIOB_15", "GPIOC_0", "GPIOC_1", "GPIOC_2", "GPIOC_3", "GPIOC_4", "GPIOC_5", "GPIOC_6", "GPIOC_7", "GPIOC_8", "GPIOC_9", "GPIOC_10", "GPIOC_11", "GPIOC_12", "GPIOC_13", "GPIOC_14", "GPIOC_15", "GPIOD_0", "GPIOD_1", "GPIOD_2", "GPIOD_3", "GPIOD_4", "GPIOD_5", "GPIOD_6", "GPIOD_7", "GPIOD_8", "GPIOD_9", "GPIOD_10", "GPIOD_11", "GPIOD_12", "GPIOD_13", "GPIOD_14", "GPIOD_15", "GPIOE_0", "GPIOE_1", "GPIOE_2", "GPIOE_3", "GPIOE_4", "GPIOE_5", "GPIOE_6", "GPIOE_7", "GPIOE_8", "GPIOE_9", "GPIOE_10", "GPIOE_11", "GPIOE_12", "GPIOE_13", "GPIOE_14", "GPIOE_15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
;skipping unused3 offset 1644
|
||||
tpsAccelLength = scalar, S32, 2184, "len", 1, 0, 1, 200, 3
|
||||
tpsAccelEnrichmentThreshold = scalar, F32, 2188, "roc", 1, 0, 0, 200, 3
|
||||
tpsAccelEnrichmentMultiplier = scalar, F32, 2192, "coeff", 1, 0, 0, 200, 3
|
||||
|
|
Loading…
Reference in New Issue