| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | /** | |||
| 2 | * @file trigger_gm.cpp | |||
| 3 | * | |||
| 4 | * @date Mar 28, 2014 | |||
| 5 | * @author Andrey Belomutskiy, (c) 2012-2020 | |||
| 6 | */ | |||
| 7 | ||||
| 8 | #include "pch.h" | |||
| 9 | ||||
| 10 | #include "trigger_gm.h" | |||
| 11 | ||||
| 12 | #define GM_60_W 6 | |||
| 13 | ||||
| 14 | 54 | static float addTooth(float offset, TriggerWaveform *s) { | ||
| 15 | 54 | s->addToothRiseFall(offset + GM_60_W / 2, GM_60_W / 2, TriggerWheel::T_SECONDARY); | ||
| 16 | 54 | return offset + GM_60_W; | ||
| 17 | } | |||
| 18 | ||||
| 19 | /** | |||
| 20 | * https://github.com/rusefi/rusefi/issues/2264 | |||
| 21 | * GM/Daewoo Distributor on the F8CV | |||
| 22 | */ | |||
| 23 | 1 | void configureGm60_2_2_2(TriggerWaveform *s) { | ||
| 24 | 1 | s->initialize(FOUR_STROKE_CAM_SENSOR, SyncEdge::RiseOnly); | ||
| 25 | 1 | s->isSynchronizationNeeded = false; | ||
| 26 | 1 | s->isSecondWheelCam = true; | ||
| 27 | ||||
| 28 | 1 | int offset = 1; | ||
| 29 | ||||
| 30 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 time.
|
2/2✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 1 time.
|
13 | for (int i=0;i<12;i++) { |
| 31 | 12 | offset = addTooth(offset, s); | ||
| 32 | } | |||
| 33 | ||||
| 34 | 1 | offset += 2 * GM_60_W; | ||
| 35 | ||||
| 36 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1 time.
|
2/2✓ Decision 'true' taken 18 times.
✓ Decision 'false' taken 1 time.
|
19 | for (int i=0;i<18;i++) { |
| 37 | 18 | offset = addTooth(offset, s); | ||
| 38 | } | |||
| 39 | ||||
| 40 | 1 | offset += 2 * GM_60_W; | ||
| 41 | ||||
| 42 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1 time.
|
2/2✓ Decision 'true' taken 18 times.
✓ Decision 'false' taken 1 time.
|
19 | for (int i=0;i<18;i++) { |
| 43 | 18 | offset = addTooth(offset, s); | ||
| 44 | } | |||
| 45 | ||||
| 46 | 1 | offset += 2 * GM_60_W; | ||
| 47 | ||||
| 48 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 time.
|
2/2✓ Decision 'true' taken 5 times.
✓ Decision 'false' taken 1 time.
|
6 | for (int i=0;i<5;i++) { |
| 49 | 5 | offset = addTooth(offset, s); | ||
| 50 | } | |||
| 51 | ||||
| 52 | 1 | s->addEvent360(360 - GM_60_W, TriggerValue::RISE); | ||
| 53 | ||||
| 54 | 1 | offset = addTooth(offset, s); | ||
| 55 | ||||
| 56 | 1 | s->addEvent360(360, TriggerValue::FALL); | ||
| 57 | ||||
| 58 | 1 | } | ||
| 59 | ||||
| 60 | 1 | void configureGmTriggerWaveform(TriggerWaveform *s) { | ||
| 61 | 1 | s->initialize(FOUR_STROKE_CRANK_SENSOR, SyncEdge::RiseOnly); | ||
| 62 | ||||
| 63 | 1 | float w = 5; | ||
| 64 | ||||
| 65 | 1 | s->addToothRiseFall(60, w); | ||
| 66 | ||||
| 67 | 1 | s->addToothRiseFall(120, w); | ||
| 68 | ||||
| 69 | 1 | s->addToothRiseFall(180, w); | ||
| 70 | ||||
| 71 | 1 | s->addToothRiseFall(240, w); | ||
| 72 | ||||
| 73 | 1 | s->addToothRiseFall(300, w); | ||
| 74 | ||||
| 75 | 1 | s->addToothRiseFall(350, w); | ||
| 76 | ||||
| 77 | 1 | s->addToothRiseFall(360, w); | ||
| 78 | ||||
| 79 | 1 | s->setTriggerSynchronizationGap(6); | ||
| 80 | 1 | } | ||
| 81 | ||||
| 82 | 120 | static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s, float shortToothWidth) | ||
| 83 | { | |||
| 84 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 60 times.
|
120 | int window = (isShortLong ? shortToothWidth : (15 - shortToothWidth)); | |
| 85 | 120 | int end = startAngle + 15; | ||
| 86 | ||||
| 87 | 120 | s->addEvent360(startAngle + window, TriggerValue::RISE); | ||
| 88 | 120 | s->addEvent360(end, TriggerValue::FALL); | ||
| 89 | ||||
| 90 | 120 | return end; | ||
| 91 | } | |||
| 92 | ||||
| 93 | /** | |||
| 94 | * TT_GM_24x_5 and TT_GM_24x_3 | |||
| 95 | * https://www.mediafire.com/?40mfgeoe4ctti | |||
| 96 | * http://www.ls1gto.com/forums/archive/index.php/t-190549.htm | |||
| 97 | * http://www.ls2.com/forums/showthread.php/834483-LS-Timing-Reluctor-Wheels-Explained | |||
| 98 | * | |||
| 99 | * | |||
| 100 | * based on data in https://rusefi.com/forum/viewtopic.php?f=3&t=936&p=30303#p30285 | |||
| 101 | */ | |||
| 102 | 5 | static void initGmLS24(TriggerWaveform *s, float shortToothWidth) { | ||
| 103 | 5 | s->initialize(FOUR_STROKE_CRANK_SENSOR, SyncEdge::Rise); | ||
| 104 | ||||
| 105 | /* | |||
| 106 | * Okay, here's how this magic works: | |||
| 107 | * The GM 24x crank wheel has 48 edges. There is | |||
| 108 | * a falling edge every 15 degrees (1/24 revolution). | |||
| 109 | * After every falling edge, a rising edge occurs either | |||
| 110 | * 5 or 10 (= 15 - 5) degrees later. The code 0x0A33BE | |||
| 111 | * encodes the pattern of which type of gap occurs in the | |||
| 112 | * pattern. Starting from the LSB, each bit left is the | |||
| 113 | * next gap in sequence as the crank turns. A 0 indicates | |||
| 114 | * long-short (late rising edge), while a 1 indicates | |||
| 115 | * short-long (early rising edge). | |||
| 116 | * | |||
| 117 | * The first few bits read are 0xE (LSB first!) = 0 - 1 - 1 - 1, so the pattern | |||
| 118 | * looks like this: | |||
| 119 | * ___ _ ___ ___ _ | |||
| 120 | * |___| |_| |_| |___| |_ etc | |||
| 121 | * | |||
| 122 | * | 0 | 1 | 1 | 0 | | |||
| 123 | * | |||
| 124 | * ___ = 10 degrees, _ = 5 deg | |||
| 125 | * | |||
| 126 | * There is a falling edge at angle=0=720, and this is position | |||
| 127 | * is #1 (and #6) TDC. If there's a falling edge on the cam | |||
| 128 | * sensor, it's #1 end compression stroke (fire this plug!) | |||
| 129 | * and #6 end exhaust stroke. If rising, it's exhaust #1, | |||
| 130 | * compression #6. | |||
| 131 | */ | |||
| 132 | ||||
| 133 | 5 | uint32_t code = 0x0A33BE; | ||
| 134 | ||||
| 135 | 5 | int angle = 0; | ||
| 136 | ||||
| 137 |
2/2✓ Branch 0 taken 120 times.
✓ Branch 1 taken 5 times.
|
2/2✓ Decision 'true' taken 120 times.
✓ Decision 'false' taken 5 times.
|
125 | for(int i = 0; i < 24; i++) |
| 138 | { | |||
| 139 | 120 | bool bit = code & 0x000001; | ||
| 140 | 120 | code = code >> 1; | ||
| 141 | ||||
| 142 | 120 | angle = gm_tooth_pair(angle, bit, s, shortToothWidth); | ||
| 143 | } | |||
| 144 | 5 | } | ||
| 145 | ||||
| 146 | // TT_GM_24x_5 | |||
| 147 | 3 | void initGmLS24_5deg(TriggerWaveform *s) { | ||
| 148 | 3 | initGmLS24(s, 5); | ||
| 149 | ||||
| 150 | // This is tooth #20, at 310 degrees ATDC #1 | |||
| 151 | 3 | s->setTriggerSynchronizationGap(2.0f); | ||
| 152 | 3 | s->setSecondTriggerSynchronizationGap(0.5f); | ||
| 153 | 3 | s->setThirdTriggerSynchronizationGap(2.0f); | ||
| 154 | ||||
| 155 | 3 | s->tdcPosition = 50; | ||
| 156 | 3 | } | ||
| 157 | ||||
| 158 | // TT_GM_24x_3 | |||
| 159 | 2 | void initGmLS24_3deg(TriggerWaveform *s) { | ||
| 160 | 2 | initGmLS24(s, 3); | ||
| 161 | ||||
| 162 | // This is tooth #20, at 312 degrees ATDC #1 | |||
| 163 | 2 | s->setTriggerSynchronizationGap(4.0f); | ||
| 164 | 2 | s->setSecondTriggerSynchronizationGap(0.25f); | ||
| 165 | 2 | s->setThirdTriggerSynchronizationGap(4.0f); | ||
| 166 | ||||
| 167 | 2 | s->tdcPosition = 48; | ||
| 168 | 2 | } | ||
| 169 |