better Electronic Throttle body control #493
This commit is contained in:
parent
c9edbf4225
commit
9a11d26cc3
|
@ -262,6 +262,7 @@ void setFrankensoBoardTestConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
// ETB_BENCH_ENGINE
|
||||
void setEtbTestConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
setCustomEngineConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
setMinimalPinsEngineConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
// VAG test ETB
|
||||
// set tps_min 54
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Mar 02 13:30:15 EST 2019
|
||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Mar 09 23:22:39 EST 2019
|
||||
// begin
|
||||
#ifndef ENGINE_CONFIGURATION_GENERATED_H_
|
||||
#define ENGINE_CONFIGURATION_GENERATED_H_
|
||||
|
@ -2311,7 +2311,11 @@ typedef struct {
|
|||
/**
|
||||
* offset 3984
|
||||
*/
|
||||
int mainUnusedEnd[624];
|
||||
float etbDeadband;
|
||||
/**
|
||||
* offset 3988
|
||||
*/
|
||||
int mainUnusedEnd[623];
|
||||
/** total size 6480*/
|
||||
} engine_configuration_s;
|
||||
|
||||
|
@ -2558,4 +2562,4 @@ typedef struct {
|
|||
|
||||
#endif
|
||||
// end
|
||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Mar 02 13:30:15 EST 2019
|
||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Mar 09 23:22:39 EST 2019
|
||||
|
|
|
@ -1644,8 +1644,10 @@
|
|||
#define etb_iTermMin_offset_hex f8c
|
||||
#define etb_iTermMax_offset 3982
|
||||
#define etb_iTermMax_offset_hex f8e
|
||||
#define mainUnusedEnd_offset 3984
|
||||
#define mainUnusedEnd_offset_hex f90
|
||||
#define etbDeadband_offset 3984
|
||||
#define etbDeadband_offset_hex f90
|
||||
#define mainUnusedEnd_offset 3988
|
||||
#define mainUnusedEnd_offset_hex f94
|
||||
#define cltCrankingCorrBins_offset 6480
|
||||
#define cltCrankingCorrBins_offset_hex 1950
|
||||
#define cltCrankingCorr_offset 6512
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
*
|
||||
* todo: make this more universal if/when we get other hardware options
|
||||
*
|
||||
* Mar 2019 best results so far achieved with three-wire H-bridges like VNH2SP30
|
||||
*
|
||||
* Jan 2019 actually driven around the block but still need some work.
|
||||
*
|
||||
* Jan 2017 status:
|
||||
|
@ -112,7 +114,9 @@ static percent_t currentEtbDuty;
|
|||
|
||||
// looks like my H-bridge does not like 100% duty cycle and it just hangs up?
|
||||
// so we use 98% to indicate that things are alive and never use PM_FULL of PWM generator
|
||||
#define PERCENT_TO_DUTY(X) (maxF(minF((X / 100.0), FULL_PWM_THRESHOLD - 0.01), 0.01 - FULL_PWM_THRESHOLD))
|
||||
//#define ETB_DUTY_LIMIT FULL_PWM_THRESHOLD
|
||||
#define ETB_DUTY_LIMIT 0.4
|
||||
#define PERCENT_TO_DUTY(X) (maxF(minF((X / 100.0), ETB_DUTY_LIMIT - 0.01), 0.01 - ETB_DUTY_LIMIT))
|
||||
|
||||
//#define PERCENT_TO_DUTY(X) ((X) / 100.0)
|
||||
|
||||
|
@ -180,6 +184,14 @@ private:
|
|||
pid.iTermMin = engineConfiguration->etb_iTermMin;
|
||||
pid.iTermMax = engineConfiguration->etb_iTermMax;
|
||||
|
||||
/*
|
||||
if (absF(actualThrottlePosition - targetPosition) < 0.5) {
|
||||
// we are pretty close to desired position, let's hold it
|
||||
dcMotor.BrakeVcc();
|
||||
scheduleMsg(&logger, "VCC braking %f %f", targetPosition, actualThrottlePosition);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
currentEtbDuty = feedForward +
|
||||
pid.getValue(targetPosition, actualThrottlePosition);
|
||||
|
||||
|
@ -254,7 +266,12 @@ void setEtbPFactor(float value) {
|
|||
static void etbReset() {
|
||||
// TODO: what is this about?
|
||||
// I am experiencing some weird instability with my H-bridge with my Monte Carlo attempts
|
||||
dcMotor.Break();
|
||||
scheduleMsg(&logger, "etbReset");
|
||||
for (int i = 0;i < 5;i++) {
|
||||
// this is some crazy code to remind H-bridge that we are alive
|
||||
dcMotor.BrakeGnd();
|
||||
chThdSleepMilliseconds(10);
|
||||
}
|
||||
mockPedalPosition = MOCK_UNDEFINED;
|
||||
pid.reset();
|
||||
}
|
||||
|
@ -378,14 +395,23 @@ void setDefaultEtbBiasCurve(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->etbBiasBins[6] = 99;
|
||||
engineConfiguration->etbBiasBins[7] = 100;
|
||||
|
||||
engineConfiguration->etbBiasValues[0] = -100 / 255.0f * 100;
|
||||
engineConfiguration->etbBiasValues[1] = -95 / 255.0f * 100;
|
||||
engineConfiguration->etbBiasValues[2] = -80 / 255.0f * 100;
|
||||
// engineConfiguration->etbBiasValues[0] = -100 / 255.0f * 100;
|
||||
// engineConfiguration->etbBiasValues[1] = -95 / 255.0f * 100;
|
||||
// engineConfiguration->etbBiasValues[2] = -80 / 255.0f * 100;
|
||||
// engineConfiguration->etbBiasValues[3] = 0 / 255.0f * 100;
|
||||
// engineConfiguration->etbBiasValues[4] = 115 / 255.0f * 100;
|
||||
// engineConfiguration->etbBiasValues[5] = 142 / 255.0f * 100;
|
||||
// engineConfiguration->etbBiasValues[6] = 142 / 255.0f * 100;
|
||||
// engineConfiguration->etbBiasValues[7] = 142 / 255.0f * 100;
|
||||
|
||||
engineConfiguration->etbBiasValues[0] = -20;
|
||||
engineConfiguration->etbBiasValues[1] = -18;
|
||||
engineConfiguration->etbBiasValues[2] = -17;
|
||||
engineConfiguration->etbBiasValues[3] = 0 / 255.0f * 100;
|
||||
engineConfiguration->etbBiasValues[4] = 115 / 255.0f * 100;
|
||||
engineConfiguration->etbBiasValues[5] = 142 / 255.0f * 100;
|
||||
engineConfiguration->etbBiasValues[6] = 142 / 255.0f * 100;
|
||||
engineConfiguration->etbBiasValues[7] = 142 / 255.0f * 100;
|
||||
engineConfiguration->etbBiasValues[4] = 20;
|
||||
engineConfiguration->etbBiasValues[5] = 21;
|
||||
engineConfiguration->etbBiasValues[6] = 22;
|
||||
engineConfiguration->etbBiasValues[7] = 25;
|
||||
}
|
||||
|
||||
void initElectronicThrottle(void) {
|
||||
|
|
|
@ -778,5 +778,5 @@ int getRusEfiVersion(void) {
|
|||
if (initBootloader() != 0)
|
||||
return 123;
|
||||
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
||||
return 20190226;
|
||||
return 20190308;
|
||||
}
|
||||
|
|
|
@ -23,11 +23,16 @@ float TwoPinDcMotor::Get() {
|
|||
return value;
|
||||
}
|
||||
|
||||
void TwoPinDcMotor::Break() {
|
||||
void TwoPinDcMotor::BrakeGnd() {
|
||||
m_dir1->setValue(false);
|
||||
m_dir2->setValue(false);
|
||||
}
|
||||
|
||||
void TwoPinDcMotor::BrakeVcc() {
|
||||
m_dir1->setValue(true);
|
||||
m_dir2->setValue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param duty value between -1.0 and 1.0
|
||||
*/
|
||||
|
@ -59,7 +64,7 @@ bool TwoPinDcMotor::Set(float duty)
|
|||
|
||||
if(duty < 0.01f)
|
||||
{
|
||||
Break();
|
||||
BrakeGnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
|
||||
virtual bool Set(float duty) override;
|
||||
float Get();
|
||||
void Break();
|
||||
void BrakeGnd();
|
||||
void BrakeVcc();
|
||||
bool isOpenDirection();
|
||||
};
|
||||
|
|
|
@ -978,7 +978,8 @@ tChargeMode_e tChargeMode;
|
|||
float hip9011Gain;
|
||||
int16_t etb_iTermMin;iTerm min value;"", 1, 0, -30000, 30000.0, 0
|
||||
int16_t etb_iTermMax;iTerm max value;"", 1, 0, -30000, 30000.0, 0
|
||||
int[624] mainUnusedEnd;
|
||||
float etbDeadband;;"", 1, 0, 0, 100.0, 2
|
||||
int[623] mainUnusedEnd;
|
||||
|
||||
|
||||
end_struct
|
||||
|
|
|
@ -63,7 +63,7 @@ enable2ndByteCanID = false
|
|||
|
||||
; see PAGE_0_SIZE in C source code
|
||||
; CONFIG_DEFINITION_START
|
||||
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Mar 05 18:08:49 EST 2019
|
||||
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Mar 09 23:22:39 EST 2019
|
||||
|
||||
pageSize = 20000
|
||||
page = 1
|
||||
|
@ -823,7 +823,8 @@ page = 1
|
|||
;no TS info - skipping hip9011Gain offset 3976
|
||||
etb_iTermMin = scalar, S16, 3980, "", 1, 0, -30000, 30000.0, 0
|
||||
etb_iTermMax = scalar, S16, 3982, "", 1, 0, -30000, 30000.0, 0
|
||||
;no TS info - skipping mainUnusedEnd offset 3984
|
||||
etbDeadband = scalar, F32, 3984, "", 1, 0, 0, 100.0, 2
|
||||
;no TS info - skipping mainUnusedEnd offset 3988
|
||||
cltCrankingCorrBins = array, F32, 6480, [8], "C", 1, 0, -100.0, 250.0, 2
|
||||
cltCrankingCorr = array, F32, 6512, [8], "%", 1, 0, 0.0, 500.0, 2
|
||||
idleAdvanceBins = array, F32, 6544, [8], "RPM", 1, 0, 0.0, 18000, 2
|
||||
|
@ -3124,6 +3125,7 @@ cmd_set_engine_type_etb_test = "w\x00\x30\x00\x3A"
|
|||
field = "pid max", etb_maxValue, {throttlePedalPositionAdcChannel != 16}
|
||||
field = "iTermMin", etb_iTermMin, {throttlePedalPositionAdcChannel != 16}
|
||||
field = "iTermMax", etb_iTermMax, {throttlePedalPositionAdcChannel != 16}
|
||||
field = "etbDeadband", Deadband, {throttlePedalPositionAdcChannel != 16}
|
||||
|
||||
dialog = testSpark, "Spark"
|
||||
commandButton = "Spark #1", cmd_test_spk1
|
||||
|
|
|
@ -2242,6 +2242,7 @@ cmd_set_engine_type_etb_test = "w\x00\x30\x00\x3A"
|
|||
field = "pid max", etb_maxValue, {throttlePedalPositionAdcChannel != 16}
|
||||
field = "iTermMin", etb_iTermMin, {throttlePedalPositionAdcChannel != 16}
|
||||
field = "iTermMax", etb_iTermMax, {throttlePedalPositionAdcChannel != 16}
|
||||
field = "etbDeadband", Deadband, {throttlePedalPositionAdcChannel != 16}
|
||||
|
||||
dialog = testSpark, "Spark"
|
||||
commandButton = "Spark #1", cmd_test_spk1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi.config;
|
||||
|
||||
// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Mar 02 13:30:15 EST 2019
|
||||
// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Mar 09 23:22:39 EST 2019
|
||||
public class Fields {
|
||||
public static final int LE_COMMAND_LENGTH = 200;
|
||||
public static final int BLOCKING_FACTOR = 400;
|
||||
|
@ -1039,7 +1039,8 @@ public class Fields {
|
|||
public static final int hip9011Gain_offset = 3976;
|
||||
public static final int etb_iTermMin_offset = 3980;
|
||||
public static final int etb_iTermMax_offset = 3982;
|
||||
public static final int mainUnusedEnd_offset = 3984;
|
||||
public static final int etbDeadband_offset = 3984;
|
||||
public static final int mainUnusedEnd_offset = 3988;
|
||||
public static final int cltCrankingCorrBins_offset = 6480;
|
||||
public static final int cltCrankingCorrBins_offset_hex = 1950;
|
||||
public static final int cltCrankingCorr_offset = 6512;
|
||||
|
@ -1889,6 +1890,7 @@ public class Fields {
|
|||
public static final Field HIP9011GAIN = Field.create("HIP9011GAIN", 3976, FieldType.FLOAT);
|
||||
public static final Field ETB_ITERMMIN = Field.create("ETB_ITERMMIN", 3980, FieldType.INT);
|
||||
public static final Field ETB_ITERMMAX = Field.create("ETB_ITERMMAX", 3982, FieldType.INT);
|
||||
public static final Field ETBDEADBAND = Field.create("ETBDEADBAND", 3984, FieldType.FLOAT);
|
||||
public static final Field FSIOFORMULAS1 = Field.create("FSIOFORMULAS1", 6672, FieldType.INT);
|
||||
public static final Field FSIOFORMULAS2 = Field.create("FSIOFORMULAS2", 6872, FieldType.INT);
|
||||
public static final Field FSIOFORMULAS3 = Field.create("FSIOFORMULAS3", 7072, FieldType.INT);
|
||||
|
|
|
@ -44,6 +44,7 @@ public class EtbMonteCarloSequence {
|
|||
":iFactor:" + iFactor +
|
||||
":dFactor:" + dFactor;
|
||||
MessagesCentral.getInstance().postMessage(EtbMonteCarloSequence.class, stats);
|
||||
CommandQueue.getInstance().write("etbreset");
|
||||
CommandQueue.getInstance().write("set etb_o " + offset);
|
||||
CommandQueue.getInstance().write("set etb_p " + pFactor);
|
||||
CommandQueue.getInstance().write("set etb_i " + iFactor);
|
||||
|
|
|
@ -44,11 +44,6 @@ public class EtbTestSequence {
|
|||
|
||||
private final JButton button = new JButton("ETB Test");
|
||||
|
||||
private SequenceStep FIRST_STEP = new EtbTarget(10 * SECOND, 4 /*position*/);
|
||||
|
||||
{
|
||||
addSequence(FIRST_STEP);
|
||||
}
|
||||
|
||||
protected static SequenceStep addSequence(SequenceStep first_step) {
|
||||
return first_step.addNext(new SequenceStep(SECOND) {
|
||||
|
@ -85,7 +80,7 @@ public class EtbTestSequence {
|
|||
.addNext(10 * SECOND, 30 /*position*/)
|
||||
.addNext(10 * SECOND, 50 /*position*/)
|
||||
.addNext(10 * SECOND, 70 /*position*/)
|
||||
.addNext(10 * SECOND, 100 /*position*/)
|
||||
.addNext(10 * SECOND, 95 /*position*/)
|
||||
.addNext(10 * SECOND, 50 /*position*/)
|
||||
.addNext(10 * SECOND, 70 /*position*/)
|
||||
.addNext(10 * SECOND, 4 /*position*/)
|
||||
|
@ -97,7 +92,10 @@ public class EtbTestSequence {
|
|||
button.addActionListener(e -> {
|
||||
// 3000 data points at 10Hz should be 300 seconds worth of data
|
||||
metric.start(/* buffer size: */3000, /*period, ms: */ 100);
|
||||
FIRST_STEP.execute(executor);
|
||||
|
||||
SequenceStep firstStep = new EtbTarget(10 * SECOND, 4 /*position*/);
|
||||
addSequence(firstStep);
|
||||
firstStep.execute(executor);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue