![]() |
Speeduino
|
#include "globals.h"#include "decoders.h"#include "scheduler.h"#include "crankMaths.h"#include "unit_testing.h"#include "decoder_init.h"#include "decoder_builder.h"#include "scheduledIO_ign.h"#include "scheduler_ignition_controller.h"#include "src/decoders/shared/crank_angle_calculator.h"#include "src/decoders/shared/decoder_state.h"#include "src/decoders/shared/perToothIgnition.h"#include "src/decoders/shared/rev_time_calcs.h"#include "src/decoders/missingTooth.h"#include "src/decoders/dualWheel.h"#include "src/decoders/basicDistributor.h"#include "src/decoders/gm7x.h"#include "src/decoders/4g63.h"#include "src/decoders/gm24x.h"#include "src/decoders/jeep2000.h"#include "src/decoders/audi135.h"#include "src/decoders/hondad17.h"#include "src/decoders/hondaj32.h"#include "src/decoders/miata9905.h"#include "src/decoders/mazdaau.h"#include "src/decoders/non360.h"#include "src/decoders/nissan360.h"#include "src/decoders/subaru6_7.h"#include "src/decoders/daihatsu.h"#include "src/decoders/harley.h"#include "src/decoders/36minus222.h"#include "src/decoders/36minus21.h"#include "src/decoders/420a.h"#include "src/decoders/webber.h"#include "src/decoders/st170.h"#include "src/decoders/drz400.h"#include "src/decoders/ngc.h"#include "src/decoders/vmax.h"#include "src/decoders/renix.h"#include "src/decoders/rovermems.h"#include "src/decoders/k6a.h"#include "src/decoders/fordtfi.h"Macros | |
| #define | TOOTH_CRANK 0 |
| #define | TOOTH_CAM_SECONDARY 1 |
| #define | TOOTH_CAM_TERTIARY 2 |
Variables | |
| TESTABLE_STATIC state_t | _decoderState |
| constexpr uint8_t | COMPOSITE_LOG_PRI = 0 |
| constexpr uint8_t | COMPOSITE_LOG_SEC = 1 |
| constexpr uint8_t | COMPOSITE_LOG_THIRD = 2 |
| constexpr uint8_t | COMPOSITE_LOG_TRIG = 3 |
| constexpr uint8_t | COMPOSITE_LOG_SYNC = 4 |
| constexpr uint8_t | COMPOSITE_ENGINE_CYCLE = 5 |
Crank and Cam decoders
This file contains the various crank and cam wheel decoder functions. Each decoder must have the following 4 functions (Where xxxx is the decoder name):
Each decoder must utilise at least the following variables:
| #define TOOTH_CAM_SECONDARY 1 |
| #define TOOTH_CAM_TERTIARY 2 |
| #define TOOTH_CRANK 0 |
|
inlinestatic |
Universal (shared between decoders) decoder routines. Add tooth log entry to toothHistory (array). Enabled by (either) currentStatus.toothLogEnabled and currentStatus.compositeTriggerUsed.
| toothTime | - Tooth Time |
| whichTooth | - 0 for Primary (Crank), 2 for Secondary (Cam) 3 for Tertiary (Cam) |
| int getCamAngle_Miata9905 | ( | void | ) |
Miata '99 to '05 with 4x 70 degree duration teeth running at cam speed. Teeth believed to be at the same angles as the 4g63 decoder. Tooth #1 is defined as the next crank tooth after the crank signal is HIGH when the cam signal is falling. Tooth number one is at 355* ATDC. (See: www.forum.diyefi.org/viewtopic.php?f=56&t=1077)
|
static |
|
static |
|
static |
| void loggerPrimaryISR | ( | void | ) |
Interrupt handler for primary trigger. This function is called on both the rising and falling edges of the primary trigger, when either the composite or tooth loggers are turned on.
| void loggerSecondaryISR | ( | void | ) |
Interrupt handler for secondary trigger. As loggerPrimaryISR, but for the secondary trigger.
| void loggerTertiaryISR | ( | void | ) |
Interrupt handler for third trigger. As loggerPrimaryISR, but for the third trigger.
|
static |
|
static |
|
static |
|
staticnoexcept |
| decoder_t triggerSetup_24X | ( | void | ) |
GM 24X Decoder (eg early LS1 1996-2005). Note: Useful references:
Provided that the cam signal is used, this decoder simply counts the teeth and then looks their angles up against a lookup table. The cam signal is used to determine tooth #1
| decoder_t triggerSetup_420a | ( | void | ) |
DSM 420a, For the DSM Eclipse with 16 teeth total on the crank. Tracks the falling side of the signal. Sync is determined by watching for a falling edge on the secondary signal and checking if the primary signal is high then. https://github.com/noisymime/speeduino/issues/133
| decoder_t triggerSetup_4G63 | ( | void | ) |
Mitsubishi 4G63 / NA/NB Miata + MX-5 / 4/2. Note: raw.githubusercontent.com/noisymime/speeduino/master/reference/wiki/decoders/4g63_trace.png Tooth #1 is defined as the next crank tooth after the crank signal is HIGH when the cam signal is falling. Tooth number one is at 355* ATDC.
| decoder_t triggerSetup_Audi135 | ( | void | ) |
Audi with 135 teeth on the crank and 1 tooth on the cam. This is very similar to the dual wheel decoder, however due to the 135 teeth not dividing evenly into 360, only every 3rd crank tooth is used in calculating the crank angle. This effectively makes it a 45 tooth dual wheel setup.
| decoder_t triggerSetup_BasicDistributor | ( | void | ) |
Basic Distributor where tooth count is equal to the number of cylinders and teeth are evenly spaced on the cam. No position sensing (Distributor is retained) so crank angle is a made up figure based purely on the first teeth to be seen. Note: This is a very simple decoder. See http://www.megamanual.com/ms2/GM_7pinHEI.htm
| decoder_t triggerSetup_Daihatsu | ( | void | ) |
Daihatsu +1 trigger for 3 and 4 cylinder engines. Tooth equal to the number of cylinders are evenly spaced on the cam. No position sensing (Distributor is retained), so crank angle is a made up figure based purely on the first teeth to be seen. Note: This is a very simple decoder. See http://www.megamanual.com/ms2/GM_7pinHEI.htm
| decoder_t triggerSetup_DRZ400 | ( | void | ) |
| decoder_t triggerSetup_DualWheel | ( | void | ) |
| decoder_t triggerSetup_FordST170 | ( | void | ) |
Ford ST170 - a dedicated decoder for 01-04 Ford Focus ST170/SVT engine. Standard 36-1 trigger wheel running at crank speed and 8-3 trigger wheel running at cam speed.
| decoder_t triggerSetup_FordTFI | ( | void | ) |
Ford TFI - Distributor mounted signal tooth wheel. Same number of teeth as cylinders. Evenly spaced rising edge triggers, Cylinder 1 has a narrow teeth and will have a signature falling edge
| decoder_t triggerSetup_GM7X | ( | void | ) |
Decode GM 7X trigger wheel with six equally spaced teeth and a seventh tooth for cylinder identification. Note: Within the decoder code pf GM7X, the sync tooth is referred to as tooth #3 rather than tooth #7. This makes for simpler angle calculations (See: http://www.speeduino.com/forum/download/file.php?id=4743 ).
| decoder_t triggerSetup_Harley | ( | void | ) |
Harley Davidson (V2) with 2 unevenly Spaced Teeth. Within the decoder code, the sync tooth is referred to as tooth #1. Derived from GMX7 and adapted for Harley. Only rising Edge is used for simplicity.The second input is ignored, as it does not help to resolve cam position.
| decoder_t triggerSetup_HondaD17 | ( | void | ) |
Honda D17 (1.7 liter 4 cyl SOHC).
| decoder_t triggerSetup_HondaJ32 | ( | void | ) |
Honda J 32 (3.2 liter 6 cyl SOHC). The Honda J32a4 (and all J series I'm aware of) has a crank trigger with nominal 24 teeth (22 teeth actually present). It has one missing tooth, then 7 teeth, then another missing tooth, then 15 teeth. The tooth rising edges all have uniform spacing between them, except for teeth 14 and 22, which measure about 18 degrees between rising edges, rather than 15 degrees as the other teeth do. These slightly larger teeth are immediately before a gap, and the extra 3 degrees is made up for in the gap, the gap being about 3 degrees smaller than might be nominally expected, such that the expected rotational angle is restored immediately after the gap (missing tooth) passes.
Teeth are represented as 0V at the ECU, no teeth are represented as 5V. Top dead center of cylinder number 1 occurs as we lose sight of (just pass) the first tooth in the string of 15 teeth (this is a rising edge). The second tooth in the string of 15 teeth is designated as tooth 1 in this code. This means that when the interrupt for tooth 1 fires (as we just pass tooth 1), crank angle = 360/24 = 15 degrees. It follows that the first tooth in the string of 7 teeth is tooth 16.
| decoder_t triggerSetup_Jeep2000 | ( | void | ) |
Jeep 2000 - 24 crank teeth over 720 degrees, in groups of 4 ('91 to 2000 6 cylinder Jeep engines). Crank wheel is high for 360 crank degrees. Quite similar to the 24X setup. As we only need timing within 360 degrees, only 12 tooth angles are defined. Tooth number 1 represents the first tooth seen after the cam signal goes high. www.speeduino.com/forum/download/file.php?id=205
| decoder_t triggerSetup_MazdaAU | ( | void | ) |
Mazda AU version. Tooth #2 is defined as the next crank tooth after the single cam tooth. Tooth number one is at 348* ATDC.
| decoder_t triggerSetup_Miata9905 | ( | void | ) |
| decoder_t triggerSetup_missingTooth | ( | void | ) |
Setup function for each decoder type.
| decoder_t triggerSetup_NGC | ( | void | ) |
Chrysler NGC - a dedicated decoder for vehicles with 4, 6 and 8 cylinder NGC pattern. 4-cyl: 36+2-2 crank wheel and 7 tooth cam 6-cyl: 36-2+2 crank wheel and 12 tooth cam in 6 groups 8-cyl: 36-2+2 crank wheel and 15 tooth cam in 8 groups The crank decoder uses the polarity of the missing teeth to determine position The 4-cyl cam decoder uses the polarity of the missing teeth to determine position The 6 and 8-cyl cam decoder uses the amount of teeth in the two previous groups of teeth to determine position
| decoder_t triggerSetup_Nissan360 | ( | void | ) |
Nissan 360 tooth on cam (Optical trigger disc inside distributor housing). See http://wiki.r31skylineclub.com/index.php/Crank_Angle_Sensor .
| decoder_t triggerSetup_non360 | ( | void | ) |
Non-360 Dual wheel with 2 wheels located either both on the crank or with the primary on the crank and the secondary on the cam. There can be no missing teeth on the primary wheel.
| decoder_t triggerSetup_Renix | ( | void | ) |
Renix 44-2-2 and 66-2-2-2 decoder.
Renix trigger wheel doesn't decode into 360 degrees nicely (360/44 = 8.18 degrees or 360/66 = 5.454545). Speeduino can't handle any teeth that have a decimal point. Solution is to count teeth, every 11 teeth = a proper angle. For 66 tooth decoder its 60 degrees per 11 teeth, for 44 tooth decoder its 90 degrees per 11 teeth. This means the system sees 4 teeth on the 44 tooth wheel and 6 teeth on the 66 tooth wheel. Double missing tooth in the pattern is actually a large tooth and a large gap. If the trigger is set to rising you'll see the start of the large tooth then the gap. If its not set to rising the code won't work due to seeing two gaps
| decoder_t triggerSetup_RoverMEMS | ( | void | ) |
| decoder_t triggerSetup_Subaru67 | ( | void | ) |
Subaru 6/7 Trigger pattern decoder for 6 tooth (irregularly spaced) crank and 7 tooth (also fairly irregular) cam wheels (eg late 90's Impreza 2.2). This seems to be present in late 90's Subaru. In 2001 Subaru moved to 36-2-2-2 (See: http://www.vems.hu/wiki/index.php?page=InputTrigger%2FSubaruTrigger ).
| decoder_t triggerSetup_SuzukiK6A | ( | void | ) |
Suzuki K6A 3 cylinder engine
| decoder_t triggerSetup_ThirtySixMinus21 | ( | void | ) |
36-2-1 / Mistsubishi 4B11 - A crank based trigger with a nominal 36 teeth, but with 1 single and 1 double missing tooth.
| decoder_t triggerSetup_ThirtySixMinus222 | ( | void | ) |
36-2-2-2 crank based trigger wheel. A crank based trigger with a nominal 36 teeth, but 6 of these removed in 3 groups of 2. 2 of these groups are located concurrently. Note: This decoder supports both the H4 version (13-missing-16-missing-1-missing) and the H6 version of 36-2-2-2 (19-missing-10-missing-1-missing). The decoder checks which pattern is selected in order to determine the tooth number Note: www.thefactoryfiveforum.com/attachment.php?attachmentid=34279&d=1412431418
| decoder_t triggerSetup_Vmax | ( | void | ) |
Yamaha Vmax 1990+ with 6 uneven teeth, triggering on the wide lobe. Within the decoder code, the sync tooth is referred to as tooth #1. Derived from Harley and made to work on the Yamah Vmax. Trigger is based on 'CHANGE' so we get a signal on the up and downward edges of the lobe. This is required to identify the wide lobe.
| decoder_t triggerSetup_Webber | ( | void | ) |
Weber-Marelli trigger setup with 2 wheels, 4 teeth 90deg apart on crank and 2 90deg apart on cam. Uses DualWheel decoders, There can be no missing teeth on the primary wheel.
| TESTABLE_STATIC state_t _decoderState |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |