rusefi/firmware/config/engines/test_engine.cpp

126 lines
3.8 KiB
C++
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file test_engine.cpp
*
2017-01-06 07:04:41 -08:00
* set engine_type 26
2016-08-20 18:03:09 -07:00
* VVT
2017-01-06 07:04:41 -08:00
* set engine_type 45
2015-07-10 06:01:56 -07:00
*
2017-03-19 13:25:15 -07:00
* See also custom_engine.cpp
*
2015-07-10 06:01:56 -07:00
* @date Nov 14, 2014
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*/
#include "pch.h"
2015-07-10 06:01:56 -07:00
#include "test_engine.h"
2023-07-23 19:00:45 -07:00
#include "proteus_meta.h"
2015-07-10 06:01:56 -07:00
2020-08-25 13:19:23 -07:00
// TEST_ENGINE
void setTestCamEngineConfiguration() {
engineConfiguration->trigger.type = trigger_type_e::TT_ONE_PLUS_ONE;
setCamOperationMode();
2015-07-10 06:01:56 -07:00
2016-08-27 08:02:34 -07:00
engineConfiguration->mafAdcChannel = EFI_ADC_1;
engineConfiguration->tps1_1AdcChannel = EFI_ADC_2;
2015-07-10 06:01:56 -07:00
engineConfiguration->vbattAdcChannel = EFI_ADC_NONE;
setWholeIatCorrTimingTable(0);
2015-07-10 06:01:56 -07:00
// Many tests were written when the default target AFR was 14.0, so use that for tests by default.
engineConfiguration->stoichRatioPrimary = 14.0f;
2015-07-10 06:01:56 -07:00
engineConfiguration->ignitionMode = IM_ONE_COIL;
setConstantDwell(3); // 50% duty cycle @ 5000 rpm
2015-07-10 06:01:56 -07:00
engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned;
engineConfiguration->ignitionPins[0] = Gpio::C7; // #1
engineConfiguration->ignitionPins[1] = Gpio::Unassigned; // #2
engineConfiguration->ignitionPins[2] = Gpio::Unassigned; // #3
engineConfiguration->ignitionPins[3] = Gpio::Unassigned; // #4
engineConfiguration->ignitionPins[4] = Gpio::Unassigned; // #5
engineConfiguration->ignitionPins[5] = Gpio::Unassigned; // #6
2015-07-10 06:01:56 -07:00
}
2016-08-20 18:03:09 -07:00
void setTestCrankEngineConfiguration() {
setTestCamEngineConfiguration();
engineConfiguration->trigger.type = trigger_type_e::TT_HALF_MOON;
setCrankOperationMode();
// this is related to 'setDefaultBaseEngine' having 'skippedWheelOnCam = true' which is a weird fact by itself
engineConfiguration->skippedWheelOnCam = false;
}
void setTestDcWastegateConfiguration() {
engineConfiguration->isBoostControlEnabled = 1;
2023-02-18 19:39:45 -08:00
engineConfiguration->etbFunctions[0] = DC_Wastegate;
setTable(config->boostTableOpenLoop, 50);
engineConfiguration->tps1_1AdcChannel = EFI_ADC_1; // PA1
// PWM pin
engineConfiguration->etbIo[0].controlPin = Gpio::C0;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = Gpio::C1;
// Disable pin
engineConfiguration->etbIo[0].disablePin = Gpio::C2;
// we only have pwm/dir, no dira/dirb
engineConfiguration->etb_use_two_wires = false;
}
void setTestVVTEngineConfiguration() {
setCrankOperationMode();
2016-08-20 18:03:09 -07:00
engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL;
2016-08-20 18:03:09 -07:00
engineConfiguration->trigger.customTotalToothCount = 3;
engineConfiguration->trigger.customSkippedToothCount = 1;
2017-01-06 07:04:41 -08:00
// set algorithm 3
setAlgorithm(LM_SPEED_DENSITY);
2016-08-20 18:03:09 -07:00
engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;
engineConfiguration->camInputs[0] = Gpio::A5;
2016-08-20 20:02:09 -07:00
2017-01-06 07:04:41 -08:00
// set global_trigger_offset_angle 0
2016-08-23 20:03:01 -07:00
engineConfiguration->globalTriggerAngleOffset = 0;
engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH;
2017-03-05 18:12:24 -08:00
}
2019-04-12 19:10:57 -07:00
#if EFI_UNIT_TEST
void setTestEngineIssue366both() {
setTestCamEngineConfiguration();
2016-08-20 20:02:09 -07:00
2017-03-06 14:42:16 -08:00
engineConfiguration->trigger.customTotalToothCount = 2;
engineConfiguration->trigger.customSkippedToothCount = 1;
engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL;
2017-03-06 14:42:16 -08:00
}
void setTestEngineIssue366rise() {
setTestEngineIssue366both();
2016-08-20 18:03:09 -07:00
}
2017-03-06 14:42:16 -08:00
#endif /* EFI_UNIT_TEST */
#ifdef HARDWARE_CI
2023-07-23 19:00:45 -07:00
// set engine_type 30
void setProteusAnalogPwmTest() {
// lowest cpu trigger possible
engineConfiguration->trigger.type = trigger_type_e::TT_HALF_MOON;
// Disable trigger stim
engineConfiguration->triggerSimulatorPins[0] = Gpio::Unassigned;
engineConfiguration->triggerSimulatorPins[1] = Gpio::Unassigned;
// The idle control pin is connected to the default TPS input, analog volt 2
engineConfiguration->idle.solenoidPin = Gpio::PROTEUS_IGN_10;
// 5893hz is coprime with the analog sample rate, 500hz, so hopefully we get less aliasing
engineConfiguration->idle.solenoidFrequency = 5893;
// Test range is 20% to 80%
engineConfiguration->tpsMin = 200;
engineConfiguration->tpsMax = 800;
}
2023-07-23 19:00:45 -07:00
#endif // HARDWARE_CI