Skip to content

Commit 8be7dc0

Browse files
authored
Implement Nitrous Relay and Nitrous Relay Mode settings rusefi#6783 (rusefi#7122)
1 parent 67476b3 commit 8be7dc0

File tree

6 files changed

+40
-12
lines changed

6 files changed

+40
-12
lines changed

firmware/controllers/algo/nitrous_controller.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ void NitrousController::onSlowCallback() {
2222
} else {
2323
isNitrousConditionSatisfied = false;
2424
}
25+
enginePins.nitrousRelay.setValue(isNitrousConditionSatisfied);
2526
}
2627

2728
void NitrousController::updateArmingState() {

firmware/controllers/system/efi_gpio.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ EnginePins::EnginePins() :
153153
fanRelay2("Fan Relay 2", CONFIG_PIN_OFFSETS(fan2)),
154154
acRelay("A/C Relay", CONFIG_PIN_OFFSETS(acRelay)),
155155
fuelPumpRelay("Fuel pump Relay", CONFIG_PIN_OFFSETS(fuelPump)),
156+
nitrousRelay("Nitrous Relay", CONFIG_PIN_OFFSETS(nitrousRelay)),
156157
#if EFI_HD_ACR
157158
harleyAcr("Harley ACR", CONFIG_OFFSET(acrPin)),
158159
harleyAcr2("Harley ACR 2", CONFIG_OFFSET(acrPin2)),

firmware/controllers/system/efi_gpio.h

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class EnginePins {
8989
// see acRelayPin
9090
RegisteredOutputPin acRelay;
9191
RegisteredOutputPin fuelPumpRelay;
92+
RegisteredOutputPin nitrousRelay;
9293
#if EFI_HD_ACR
9394
RegisteredNamedOutputPin harleyAcr;
9495
RegisteredOutputPin harleyAcr2;

firmware/integration/rusefi_config.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1798,8 +1798,10 @@ uint8_t autoscale knockFuelTrim;Fuel trim when knock, max 30%;"%", 1, 0, 0, 30,
17981798
uint8_t dfcoRetardDeg;Retard timing by this amount during DFCO. Smooths the transition back from fuel cut. After fuel is restored, ramp timing back in over the period specified.;"deg", 1, 0, 0, 30, 0
17991799
uint8_t autoscale dfcoRetardRampInTime;Smooths the transition back from fuel cut. After fuel is restored, ramp timing back in over the period specified.;"s", 0.1, 0, 0, 1, 1
18001800

1801+
output_pin_e nitrousRelayPin;
1802+
pin_output_mode_e nitrousRelayPinMode;
18011803

1802-
#define END_OF_CALIBRATION_PADDING 76
1804+
#define END_OF_CALIBRATION_PADDING 73
18031805
uint8_t[END_OF_CALIBRATION_PADDING] unusedOftenChangesDuringFirmwareUpdate;;"units", 1, 0, 0, 1, 0
18041806

18051807
! end of engine_configuration_s

firmware/tunerstudio/tunerstudio.template.ini

+2
Original file line numberDiff line numberDiff line change
@@ -4990,6 +4990,8 @@ dialog = tcuControls, "Transmission Settings"
49904990
panel = NitrousControlLuaGaugeDialog, {nitrousControlArmingMethod == @@nitrous_arming_method_e_LUA_GAUGE@@}
49914991

49924992
dialog = NitrousControlSettings, "Settings"
4993+
field = "Nitrous Relay", nitrousRelayPin
4994+
field = "Nitrous Relay Mode", nitrousRelayPinMode
49934995
field = "Minimum TPS", nitrousMinimumTps
49944996
field = "Minimum CLT", nitrousMinimumClt
49954997
field = "Maximum MAP", nitrousMaximumMap

unit_tests/tests/nitrous_control/test_nitrous_condition.cpp

+32-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ namespace {
2323

2424
void SetUp() override;
2525

26-
void satisfyAllConditions();
26+
void checkNitrousCondition(bool expected, const char* context);
27+
2728
private:
2829
void armNitrousControl();
2930
void satisfyTpsCondition();
@@ -49,18 +50,38 @@ namespace {
4950
.setNitrousDeactivationRpmWindow({ TEST_DEACTIVATION_RPM_WINDOW })
5051
);
5152

52-
satisfyAllConditions();
53-
}
5453

55-
void NitrousConditionTest::satisfyAllConditions() {
54+
EXPECT_FALSE(getModule<NitrousController>().isArmed);
55+
EXPECT_FALSE(getModule<NitrousController>().isTpsConditionSatisfied);
56+
EXPECT_FALSE(getModule<NitrousController>().isCltConditionSatisfied);
57+
EXPECT_FALSE(getModule<NitrousController>().isMapConditionSatisfied);
58+
EXPECT_FALSE(getModule<NitrousController>().isAfrConditionSatisfied);
59+
EXPECT_FALSE(getModule<NitrousController>().isNitrousRpmConditionSatisfied);
60+
61+
checkNitrousCondition(false, "No conditions are satisfied");
62+
5663
armNitrousControl();
64+
checkNitrousCondition(false, "Armed condition is satisfied");
65+
5766
satisfyTpsCondition();
67+
checkNitrousCondition(false, "Armed + TPS conditions are satisfied");
68+
5869
satisfyCltCondition();
70+
checkNitrousCondition(false, "Armed + TPS + CLT conditions are satisfied");
71+
5972
satisfyMapCondition();
73+
checkNitrousCondition(false, "Armed + TPS + CLT + MAP conditions are satisfied");
74+
6075
satisfyAfrCondition();
76+
checkNitrousCondition(false, "Armed + TPS + CLT + MAP + AFR conditions are satisfied");
77+
6178
satisfyRpmCondition();
79+
checkNitrousCondition(true, "Armed + TPS + CLT + MAP + AFR + RPM conditions are satisfied");
80+
}
6281

63-
EXPECT_TRUE(getModule<NitrousController>().isNitrousRpmConditionSatisfied);
82+
void NitrousConditionTest::checkNitrousCondition(const bool expected, const char* const context) {
83+
EXPECT_EQ(getModule<NitrousController>().isNitrousConditionSatisfied, expected) << context;
84+
EXPECT_EQ(enginePins.nitrousRelay.getLogicValue(), expected) << context;
6485
}
6586

6687
void NitrousConditionTest::armNitrousControl() {
@@ -105,41 +126,41 @@ namespace {
105126
periodicSlowCallback();
106127

107128
EXPECT_FALSE(getModule<NitrousController>().isArmed);
108-
EXPECT_FALSE(getModule<NitrousController>().isNitrousConditionSatisfied);
129+
checkNitrousCondition(false, "Without armed condition");
109130
}
110131

111132
TEST_F(NitrousConditionTest, checkWithoutSatisfiedTpsCondition) {
112133
updateApp(TEST_MIN_TPS - EPS5D, &TestBase::periodicSlowCallback);
113134

114135
EXPECT_FALSE(getModule<NitrousController>().isTpsConditionSatisfied);
115-
EXPECT_FALSE(getModule<NitrousController>().isNitrousConditionSatisfied);
136+
checkNitrousCondition(false, "Without TPS condition");
116137
}
117138

118139
TEST_F(NitrousConditionTest, checkWithoutSatisfiedCltCondition) {
119140
updateClt(TEST_MIN_CLT - EPS5D, &TestBase::periodicSlowCallback);
120141

121142
EXPECT_FALSE(getModule<NitrousController>().isCltConditionSatisfied);
122-
EXPECT_FALSE(getModule<NitrousController>().isNitrousConditionSatisfied);
143+
checkNitrousCondition(false, "Without CLT condition");
123144
}
124145

125146
TEST_F(NitrousConditionTest, checkWithoutSatisfiedMapCondition) {
126147
updateMap(TEST_MAX_MAP + EPS5D, &TestBase::periodicSlowCallback);
127148

128149
EXPECT_FALSE(getModule<NitrousController>().isMapConditionSatisfied);
129-
EXPECT_FALSE(getModule<NitrousController>().isNitrousConditionSatisfied);
150+
checkNitrousCondition(false, "Without MAP condition");
130151
}
131152

132153
TEST_F(NitrousConditionTest, checkWithoutSatisfiedAfrCondition) {
133154
updateLambda1(TEST_LAMBDA1 + EPS5D, &TestBase::periodicSlowCallback);
134155

135156
EXPECT_FALSE(getModule<NitrousController>().isAfrConditionSatisfied);
136-
EXPECT_FALSE(getModule<NitrousController>().isNitrousConditionSatisfied);
157+
checkNitrousCondition(false, "Without AFR condition");
137158
}
138159

139160
TEST_F(NitrousConditionTest, checkWithoutSatisfiedRpmCondition) {
140161
updateRpm(TEST_ACTIVATION_RPM - EPS5D, &TestBase::periodicSlowCallback);
141162

142163
EXPECT_FALSE(getModule<NitrousController>().isNitrousRpmConditionSatisfied);
143-
EXPECT_FALSE(getModule<NitrousController>().isNitrousConditionSatisfied);
164+
checkNitrousCondition(false, "Without RPM condition");
144165
}
145166
}

0 commit comments

Comments
 (0)