Skip to content

Commit

Permalink
Trigger gm 3 vs 5 (rusefi#4140)
Browse files Browse the repository at this point in the history
* add parameter

* two modes

* add new mode to list

* format

* s

Co-authored-by: Matthew Kennedy <[email protected]>
  • Loading branch information
mck1117 and mck1117 authored May 6, 2022
1 parent 97bac3e commit b650bbe
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 22 deletions.
2 changes: 1 addition & 1 deletion firmware/config/engines/chevrolet_camaro_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void setCamaro4() {
engineConfiguration->ignitionMode = IM_WASTED_SPARK;

setCrankOperationMode();
engineConfiguration->trigger.type = TT_GM_LS_24;
engineConfiguration->trigger.type = TT_GM_24x;

engineConfiguration->map.sensor.hwChannel = EFI_ADC_0; // PA0

Expand Down
10 changes: 7 additions & 3 deletions firmware/controllers/algo/engine_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@ typedef enum {

TT_ROVER_K = 26,

TT_GM_LS_24 = 27,

TT_HONDA_CBR_600 = 28,

TT_2JZ_1_12 = 29,
Expand Down Expand Up @@ -519,13 +517,19 @@ typedef enum {

TT_VVT_TOYOTA_4_1 = 73,

// GM 24x with 5/10 degree gaps
TT_GM_24x = 27,

// GM 24x with 3/12 degree gaps
TT_GM_24x_2 = 74,

// do not forget to edit "#define trigger_type_e_enum" line in integration/rusefi_config.txt file to propogate new value to rusefi.ini TS project
// do not forget to invoke "gen_config.bat" once you make changes to integration/rusefi_config.txt
// todo: one day a hero would integrate some of these things into Makefile in order to reduce manual magic
//
// Another point: once you add a new trigger, run get_trigger_images.bat which would run rusefi_test.exe from unit_tests
//
TT_UNUSED = 74, // this is used if we want to iterate over all trigger types
TT_UNUSED = 75, // this is used if we want to iterate over all trigger types

// java code generator handles this value in a special way
// also looks like 2 enums are either 1 byte or 4 bytes
Expand Down
38 changes: 28 additions & 10 deletions firmware/controllers/trigger/decoders/trigger_gm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ void configureGmTriggerWaveform(TriggerWaveform *s) {
s->setTriggerSynchronizationGap(6);
}

static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s, int mult)
static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s, int mult, float shortToothWidth)
{
int window = (isShortLong ? 5 : 10) * mult;
int window = (isShortLong ? shortToothWidth : (15 - shortToothWidth)) * mult;
int end = startAngle + mult * 15;

s->addEvent720(startAngle + window, T_PRIMARY, TV_RISE);
Expand All @@ -101,15 +101,15 @@ static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s,
}

/**
* TT_GM_LS_24
* TT_GM_24x and TT_GM_24x_2
* https://www.mediafire.com/?40mfgeoe4ctti
* http://www.ls1gto.com/forums/archive/index.php/t-190549.htm
* http://www.ls2.com/forums/showthread.php/834483-LS-Timing-Reluctor-Wheels-Explained
*
*
* based on data in https://rusefi.com/forum/viewtopic.php?f=3&t=936&p=30303#p30285
*/
void initGmLS24(TriggerWaveform *s) {
static void initGmLS24(TriggerWaveform *s, float shortToothWidth) {
s->initialize(FOUR_STROKE_CRANK_SENSOR);

/*
Expand All @@ -121,14 +121,15 @@ void initGmLS24(TriggerWaveform *s) {
* encodes the pattern of which type of gap occurs in the
* pattern. Starting from the LSB, each bit left is the
* next gap in sequence as the crank turns. A 0 indicates
* long-short, while a 1 indicates short-long.
* long-short (late rising edge), while a 1 indicates
* short-long (early rising edge).
*
* The first few bits read are 0xE (LSB first!) = 0 - 1 - 1 - 1, so the pattern
* looks like this:
* ___ _ ___ ___ ___
* |___| |_| |_| |_| |_ etc
* ___ _ ___ ___ _
* |___| |_| |_| |___| |_ etc
*
* | 0 | 1 | 1 | 1 |
* | 0 | 1 | 1 | 0 |
*
* ___ = 10 degrees, _ = 5 deg
*
Expand All @@ -148,15 +149,32 @@ void initGmLS24(TriggerWaveform *s) {
bool bit = code & 0x000001;
code = code >> 1;

angle = gm_tooth_pair(angle, bit, s, CRANK_MODE_MULTIPLIER);
angle = gm_tooth_pair(angle, bit, s, CRANK_MODE_MULTIPLIER, shortToothWidth);
}

s->tdcPosition = 50;
s->useOnlyPrimaryForSync = true;
}

// TT_GM_24x
void initGmLS24_5deg(TriggerWaveform *s) {
initGmLS24(s, 5);

// This is tooth #20, at 310 degrees ATDC #1
s->setTriggerSynchronizationGap(2.0f);
s->setSecondTriggerSynchronizationGap(0.5f);
s->setThirdTriggerSynchronizationGap(2.0f);

s->tdcPosition = 50;
}

// TT_GM_24x_2
void initGmLS24_3deg(TriggerWaveform *s) {
initGmLS24(s, 3);

// This is tooth #20, at 312 degrees ATDC #1
s->setTriggerSynchronizationGap(4.0f);
s->setSecondTriggerSynchronizationGap(0.25f);
s->setThirdTriggerSynchronizationGap(4.0f);

s->tdcPosition = 48;
}
3 changes: 2 additions & 1 deletion firmware/controllers/trigger/decoders/trigger_gm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ class TriggerWaveform;

void configureGm60_2_2_2(TriggerWaveform *s);
void configureGmTriggerWaveform(TriggerWaveform *s);
void initGmLS24(TriggerWaveform *s);
void initGmLS24_5deg(TriggerWaveform *s);
void initGmLS24_3deg(TriggerWaveform *s);
8 changes: 6 additions & 2 deletions firmware/controllers/trigger/decoders/trigger_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,12 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperatio
configureTriTach(this);
break;

case TT_GM_LS_24:
initGmLS24(this);
case TT_GM_24x:
initGmLS24_5deg(this);
break;

case TT_GM_24x_2:
initGmLS24_3deg(this);
break;

case TT_SUBARU_7_WITHOUT_6:
Expand Down
5 changes: 4 additions & 1 deletion firmware/controllers/trigger/decoders/triggers-meta.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# this file is consumed by TriggerProcessor.java during the gen_config.sh code generation phase

triggers:
- name: TT_GM_LS_24
- name: TT_GM_24x
isFirstCrankBased: true

- name: TT_GM_24x_2
isFirstCrankBased: true

- name: TT_HONDA_K_12_1
Expand Down
2 changes: 1 addition & 1 deletion firmware/integration/rusefi_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ adc_channel_e fuelLevelSensor;+This is the processor pin that your fuel level se

struct trigger_config_s @brief Trigger wheel(s) configuration

#define trigger_type_e_enum "custom toothed wheel", "Ford Aspire", "Dodge Neon 1995", "Miata NA", "INVALID", "GM_7X", "Cooper R50", "Mazda SOHC 4", "60/2", "36/1", "Mercedes Two Segment", "Mitsubishi 4G93", "Honda 4+24", "Honda 1+4+24", "Dodge Neon 2003", "Mazda DOHC 1+4", "1+1", "INVALID", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Honda 1+24", "Dodge Stratus", "36_2_2_2", "Nissan Primera", "dev 2JZ 3/34 simulator", "Rover K", "GM LS 24", "Honda CBR 600", "2JZ_1_12", "Honda CBR 600 custom", "3/1 skipped", "Dodge Neon 2003 crank", "Miata NB", "INVALID", "INVALID", "Subaru 7+6", "Jeep 18-2-2-2", "WIP", "Dodge Neon 1995 crank only", "Jeep XJ 4 cyl", "FiatIAQ_P8", "Mazda Z5", "INVALID", "Renix 44-2-2", "Renix 66-2-2-2", "Honda K 12+1", "INVALID", "36/2", "Subaru SVX", "1+16", "Subaru 7 without 6", "INVALID", "TriTach", "GM 60/2/2/2", "Skoda Favorit", "Barra 3+1 Cam", "Kawa KX450F", "Nissan VQ35", "INVALID", "Nissan VQ30", "Nissan QR25", "Mitsubishi 3A92", "Subaru SVX Crank 1", "Subaru SVX Cam VVT", "Ford PIP", "Suzuki G13B", "Honda K 4+1", "Nissan MR18 Crank", "32/2", "36-2-1", "36-2-1-1", "trg72"
#define trigger_type_e_enum "custom toothed wheel", "Ford Aspire", "Dodge Neon 1995", "Miata NA", "INVALID", "GM_7X", "Cooper R50", "Mazda SOHC 4", "60/2", "36/1", "Mercedes Two Segment", "Mitsubishi 4G93", "Honda 4+24", "Honda 1+4+24", "Dodge Neon 2003", "Mazda DOHC 1+4", "1+1", "INVALID", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Honda 1+24", "Dodge Stratus", "36_2_2_2", "Nissan Primera", "dev 2JZ 3/34 simulator", "Rover K", "GM 24x 5 degree", "Honda CBR 600", "2JZ_1_12", "Honda CBR 600 custom", "3/1 skipped", "Dodge Neon 2003 crank", "Miata NB", "INVALID", "INVALID", "Subaru 7+6", "Jeep 18-2-2-2", "WIP", "Dodge Neon 1995 crank only", "Jeep XJ 4 cyl", "FiatIAQ_P8", "Mazda Z5", "INVALID", "Renix 44-2-2", "Renix 66-2-2-2", "Honda K 12+1", "INVALID", "36/2", "Subaru SVX", "1+16", "Subaru 7 without 6", "INVALID", "TriTach", "GM 60/2/2/2", "Skoda Favorit", "Barra 3+1 Cam", "Kawa KX450F", "Nissan VQ35", "INVALID", "Nissan VQ30", "Nissan QR25", "Mitsubishi 3A92", "Subaru SVX Crank 1", "Subaru SVX Cam VVT", "Ford PIP", "Suzuki G13B", "Honda K 4+1", "Nissan MR18 Crank", "32/2", "36-2-1", "36-2-1-1", "INVALID", "INVALID", "GM 24x 3 degree", "trg75"

custom trigger_type_e 4 bits, U32, @OFFSET@, [0:6], @@trigger_type_e_enum@@
trigger_type_e type;+https://github.com/rusefi/rusefi/wiki/All-Supported-Triggers\nset trigger_type X
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ private static String getTriggerName(TriggerWheelInfo triggerName) {
return "Honda 1+24";
case TT_SUBARU_7_6:
return "Subaru 7/6";
case TT_GM_LS_24:
case TT_GM_24x:
return "GM 24x";
case TT_GM_24x_2:
return "GM 24x 2";
case TT_SKODA_FAVORIT:
return "Skoda Favorit";
case TT_GM_7X:
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/tests/trigger/test_real_gm_24x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TEST(crankingGm24x, gmRealCrankingFromFile) {
EngineTestHelper eth(TEST_ENGINE);
engineConfiguration->isFasterEngineSpinUpEnabled = true;

eth.setTriggerType(TT_GM_LS_24);
eth.setTriggerType(TT_GM_24x);

while (reader.haveMore()) {
reader.processLine(&eth);
Expand All @@ -20,4 +20,4 @@ TEST(crankingGm24x, gmRealCrankingFromFile) {

ASSERT_EQ( 0, eth.recentWarnings()->getCount())<< "warningCounter#vwRealCranking";
ASSERT_EQ( 128, round(Sensor::getOrZero(SensorType::Rpm)))<< reader.lineIndex();
}
}

0 comments on commit b650bbe

Please sign in to comment.