Renix 44 tooth decoder (includes 66 tooth code) (#1037)

* Renix 44-2-2 & 66-2-2-2 initial version

coded, not tested yet, saving to secure code

* First working version on ardustim

* updates to trigger setup

* latest changes

* 66 tooth working but occasional short dwell

* staging before major rewrite

updating the primary trigger to look for 12th system tooth to increment toothCurrentCount after this checking

* updated working but with bad dwell/timing

code works but the timing and dwell are not accurate once rpm goes over 400rpm

* Renix code 1st release

updated code to do both 44 and 66 tooth within a single set of functions

* remove support for sequential for 44 tooth

Sequential (via cam) was added for 44 tooth to enable future expansion. This is interfering with the normal code on the first testers car.

* updated cam position

* remove Dev logging

* remove logging

* updates to trigger decoding

fixes to 66 tooth pattern and removal of secondary flag for 44 tooth decoder

* fixes to decoder - rpm double

* updates to support display cam tooth position

added code to display which teeth the cam tooth arrives on as VVT1 & 2 and as Aux0 and Aux1.

* Revert "updates to support display cam tooth position"

This reverts commit d2ace89ea7.

* fixes from update to latest speeduino firmware

* Add 4cyl semi-seq injector pairing option

* Add timestamp field to SD logs

* Fix soft and hard rev limiter (#813)

* Increase dwell limiter in RX-8 type ignition (#820)

Currently the dwell limiter calculation considers rotary ignition to have more than 1 pulse per revolution. This only holds true for FC/FD type ignition which is wasted spark correctly resulting in 2 pulses per revolution. RX-8 type ignition however is fully sequential so there is only 1 pulse per revolution. As a result the dwell limiter is being calculated too low.
This change fixes the issue by correctly assuming 1 pulse per revolution in RX-8 type ignition

* All tapers use byte counters (#746)

Fixes

Update idle.ino

* Correct variable size for MAPlast

* Fix issue with SD RPM threshold not correctly detecting on/off

* Reorganise Engine Protection UI

* Add low/high battery voltage indicator (#824)

Fixes #822

* Remove tacho output flags (#814)

* fix typos in code documentation (#816)

* fix typos in code documentation

* minor reverts

* fix typos in ini

Co-authored-by: Josh Stewart <josh@noisymime.org>

* Added Trigger for the Yamaha Vmax motorcycle, 1990 and up. (#823)

* Test 1

* Added the Vmax decoder option

* Added the Yamaha Vmax decoder

Co-authored-by: RempageR1 <unconfigured@null.spigotmc.org>
Co-authored-by: Josh Stewart <josh@noisymime.org>

* Allow for '?' command through legacy comms.

Fixes #821

* Added idle advance start threshold (#747)

* Added idle advance start threshold

On lower temp and/or on ethanol the engine need to crank more, without this my starter get a kick and the engine backfires.

This enable it only at 200 RPM below the target

* Use define to idle advance RPM threshold

Co-authored-by: Josh Stewart <josh@noisymime.org>

* Remove previousLoopTime - never used (#706)

* Simplify the corrections calculations using div100

* Fix the calculations dash figures when battery correction is applied to open time only

* PWM and on/off idle fixes/cleanup (#806)

* Idle fixes #1

* Idle fixes #2

Co-authored-by: Josh Stewart <josh@noisymime.org>

* Remove duplicate iacClosedLoopTable. Lookup idle target RPM @ 4Hz after CLT reading

* Fix validTrigger assignment in Vmax decoder

* Align TPS_rateOfChange scale. Potential fix for #773

* Enable semi sequential and wasted COP on half sync (#478)

* Semi/Full sequential mode

Semi sequential in case of absent phase input at crank, engine will almost aways start in semi sequential mode

Minimal code change at speeduino.ino

Fix RPM reading when in half sync

* Update with latest changes in master

* Less calls to change functions

See #478 chat history for details

* Semi/Full sequential mode

Semi sequential in case of absent phase input at crank, engine will almost aways start in semi sequential mode

Minimal code change at speeduino.ino

Fix RPM reading when in half sync

* Update with latest changes in master

* Less calls to change functions

See #478 chat history for details

* Add sync status to log

* Updates

Updated speeduino.ini
Updated updates.ino

* Fix error in half to full sync function

Co-authored-by: Josh Stewart <josh@noisymime.org>

* Fixes after merge with speeduino master

* improved debug on sync loss using VVTangle

* additional debug

uses aux channels for debug  eg currentStatus.canin[2] these need removing from the full version. Also uses VVT1 pin for debug via VVT1_PIN_OFF()  and VVT1_PIN_ON()

* fixes

* remove secondary trigger

* different logging

* Final Version

* added automated tests

* fixed fuel pump always being on

* fix build issues after merge with master

* Change how 44 or 66 tooth selected

Updated to work out 44 or 66 tooth decoder based on the number of cylinders, 4 cylinder = 44 tooth, 6 cylinder = 66 tooth

* Fix typo in ini

* Delete compile_commands.json

* Remove duplicate declarations

* Remove VVT code from other PR

* fix speeduino.ino

Remove unintended additions to speeduino.ino

---------

Co-authored-by: Josh Stewart <josh@noisymime.org>
Co-authored-by: Pasi Kemppainen <48950874+pazi88@users.noreply.github.com>
Co-authored-by: theKraid <37898397+theKraid@users.noreply.github.com>
Co-authored-by: Vitor Moreno B. Sales <vitor_boss@yahoo.com.br>
Co-authored-by: Corey-Harding <91717711+Corey-Harding@users.noreply.github.com>
Co-authored-by: Daniel Tobias <dantob@users.noreply.github.com>
Co-authored-by: RempageR1 <103254506+RempageR1@users.noreply.github.com>
Co-authored-by: RempageR1 <unconfigured@null.spigotmc.org>
Co-authored-by: tx_haggis <13982343+adbancroft@users.noreply.github.com>
Co-authored-by: Vitor Moreno B. Sales <vitor.m.benevides@outlook.com>
This commit is contained in:
mike501 2023-04-30 09:30:34 +01:00 committed by GitHub
parent 6fbf6db752
commit e0dbb38794
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 579 additions and 6 deletions

View File

@ -176,6 +176,8 @@
#define trigger_DRZ400 = 21
#define trigger_NGC = 22
#define trigger_VMAX = 23
#define trigger_renix = 24
[Constants]
@ -495,7 +497,7 @@ page = 4
TrigEdge = bits, U08, 5,[0:0], "RISING", "FALLING"
TrigSpeed = bits, U08, 5,[1:1], "Crank Speed", "Cam Speed"
IgInv = bits, U08, 5,[2:2], "Going Low", "Going High"
TrigPattern= bits, U08, 5,[3:7], "Missing Tooth", "Basic Distributor", "Dual Wheel", "GM 7X", "4G63 / Miata / 3000GT", "GM 24X", "Jeep 2000", "Audi 135", "Honda D17", "Miata 99-05", "Mazda AU", "Non-360 Dual", "Nissan 360", "Subaru 6/7", "Daihatsu +1", "Harley EVO", "36-2-2-2", "36-2-1", "DSM 420a", "Weber-Marelli", "Ford ST170", "DRZ400", "Chrysler NGC", "Yamaha Vmax 1990+", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
TrigPattern= bits, U08, 5,[3:7], "Missing Tooth", "Basic Distributor", "Dual Wheel", "GM 7X", "4G63 / Miata / 3000GT", "GM 24X", "Jeep 2000", "Audi 135", "Honda D17", "Miata 99-05", "Mazda AU", "Non-360 Dual", "Nissan 360", "Subaru 6/7", "Daihatsu +1", "Harley EVO", "36-2-2-2", "36-2-1", "DSM 420a", "Weber-Marelli", "Ford ST170", "DRZ400", "Chrysler NGC", "Yamaha Vmax 1990+", "Renix", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
TrigEdgeSec= bits, U08, 6,[0:0], "RISING", "FALLING"
fuelPumpPin= bits , U08, 6,[1:6], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "INVALID", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID"
useResync = bits, U08, 6,[7:7], "No", "Yes"
@ -2836,9 +2838,9 @@ menuDialog = main
field = "Note: This is the number of revolutions that will be skipped during"
field = "cranking before the injectors and coils are fired"
field = "Trigger edge", TrigEdge { TrigPattern != 4 && TrigPattern != 22 } ;4G63 uses both edges ;NGC uses both edges
field = "Secondary trigger edge", TrigEdgeSec, { (TrigPattern == 0 && TrigSpeed == 0 && trigPatternSec != 2) || TrigPattern == 2 || TrigPattern == 9 || TrigPattern == 12 || TrigPattern == 18 || TrigPattern == 19 || TrigPattern == 20 || TrigPattern == 21 } ;Missing tooth, dual wheel and Miata 9905, weber-marelli, ST170, DRZ400
field = "Missing Tooth Secondary type", trigPatternSec, { (TrigPattern == 0&& TrigSpeed == 0) }
field = "Level for 1st phase", PollLevelPol, { (TrigPattern == 0 && TrigSpeed == 0 && trigPatternSec == 2) }
field = "Secondary trigger edge", TrigEdgeSec, { (TrigPattern == 0 && TrigSpeed == 0 && trigPatternSec != 2) || TrigPattern == 2 || TrigPattern == 9 || TrigPattern == 12 || TrigPattern == 18 || TrigPattern == 19 || TrigPattern == 20 || TrigPattern == 21 || TrigPattern == 24 } ;Missing tooth, dual wheel and Miata 9905, weber-marelli, ST170, DRZ400 Renix,
field = "Level for 1st phase", PollLevelPol, { (TrigPattern == 0 && TrigSpeed == 0 && trigPatternSec == 2) }
field = "Missing Tooth Secondary type", trigPatternSec, { (TrigPattern == 0 && TrigSpeed == 0) }
field = "Trigger Filter", TrigFilter, { TrigPattern != 13 }
field = "Re-sync every cycle", useResync, { TrigPattern == 2 || TrigPattern == 4 || TrigPattern == 7 || TrigPattern == 12 || TrigPattern == 9 || TrigPattern == 13 || TrigPattern == 18 || TrigPattern == 19 || TrigPattern == 21 } ;Dual wheel, 4G63, Audi 135, Nissan 360, Miata 99-05, weber-marelli. DRZ400
@ -2860,7 +2862,7 @@ menuDialog = main
field = "Cranking advance Angle", CrankAng
field = "Spark Outputs triggers", IgInv
panel = lockSparkSettings
panel = newIgnitionMode, {}, {TrigPattern == 0 || TrigPattern == 1 || TrigPattern == 2 || TrigPattern == 3 || TrigPattern == 4 || TrigPattern == 9 || TrigPattern == 12 || TrigPattern == 13 || TrigPattern == 16 || TrigPattern == 18 || TrigPattern == 19 || TrigPattern == 22} ;Only works for missing tooth, distributor, dual wheel, GM 7X, 4g63, Miata 99-05, nissan 360, Subaru 6/7, 420a, weber-marelli, NGC
panel = newIgnitionMode, {}, {TrigPattern == 0 || TrigPattern == 1 || TrigPattern == 2 || TrigPattern == 3 || TrigPattern == 4 || TrigPattern == 9 || TrigPattern == 12 || TrigPattern == 13 || TrigPattern == 16 || TrigPattern == 18 || TrigPattern == 19 || TrigPattern == 22 || TrigPattern == 24} ;Only works for missing tooth, distributor, dual wheel, GM 7X, 4g63, Miata 99-05, nissan 360, Subaru 6/7, 420a, weber-marelli, NGC Renix,
dialog = dwellSettings, "Dwell Settings", 4
topicHelp = "https://wiki.speeduino.com/en/configuration/Dwell"

View File

@ -35,6 +35,8 @@
#define DECODER_DRZ400 21
#define DECODER_NGC 22
#define DECODER_VMAX 23
#define DECODER_RENIX 24
#define BIT_DECODER_2ND_DERIV 0 //The use of the 2nd derivative calculation is limited to certain decoders. This is set to either true or false in each decoders setup routine
#define BIT_DECODER_IS_SEQUENTIAL 1 //Whether or not the decoder supports sequential operation
@ -217,6 +219,10 @@ void triggerSec_NGC68(void);
uint16_t getRPM_NGC(void);
void triggerSetEndTeeth_NGC(void);
void triggerSetup_Renix();
void triggerPrimary_Renix();
void triggerSetEndTeeth_Renix();
void triggerSetup_Vmax(void);
void triggerPri_Vmax(void);
void triggerSec_Vmax(void);

View File

@ -175,7 +175,10 @@ void loggerPrimaryISR(void)
if( (currentStatus.toothLogEnabled == true) && (BIT_CHECK(decoderState, BIT_DECODER_VALID_TRIGGER)) )
{
//Tooth logger only logs when the edge was correct
if(validEdge == true) { addToothLogEntry(curGap, TOOTH_CRANK); }
if(validEdge == true)
{
addToothLogEntry(curGap, TOOTH_CRANK);
}
}
else if( (currentStatus.compositeLogEnabled == true) )
{
@ -4758,4 +4761,208 @@ void triggerSetEndTeeth_Vmax(void)
lastToothCalcAdvance = currentStatus.advance;
}
/** @} */
/** 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
*
*
* @defgroup dec_renix Renix decoder
* @{
*/
void triggerSetup_Renix()
{
if( configPage2.nCylinders == 4)
{
triggerToothAngle = 90; //The number of degrees that passes from tooth to tooth (primary) this changes between 41 and 49 degrees
configPage4.triggerTeeth = 4; // wheel has 44 teeth but we use these to work out which tooth angle to use, therefore speeduino thinks we only have 8 teeth.
configPage4.triggerMissingTeeth = 0;
triggerActualTeeth = 4; //The number of teeth we're pretending physically existing on the wheel.
triggerFilterTime = (1000000 / (MAX_RPM / 60 * 44)); //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise
}
else if (configPage2.nCylinders == 6)
{
triggerToothAngle = 60;
configPage4.triggerTeeth = 6; // wheel has 44 teeth but we use these to work out which tooth angle to use, therefore speeduino thinks we only have 6 teeth.
configPage4.triggerMissingTeeth = 0;
triggerActualTeeth = 6; //The number of teeth we're pretending physically existing on the wheel.
triggerFilterTime = (1000000 / (MAX_RPM / 60 * 66)); //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise
}
MAX_STALL_TIME = (3333UL * triggerToothAngle); //Minimum 50rpm. (3333uS is the time per degree at 50rpm). Largest gap between teeth is 90 or 60 degrees depending on decoder.
toothSystemCount = 1;
toothCurrentCount = 1;
toothLastToothTime = 0;
}
// variables used to help calculate gap on the physical 44 or 66 teeth we're pretending don't exist in most of the speeduino code
// reusing existing variables to save storage space as these aren't used in the code for their original purpose.
#define renixSystemLastToothTime toothLastToothRisingTime
#define renixSystemLastMinusOneToothTime toothLastSecToothRisingTime
void triggerPri_Renix()
{
curTime = micros();
curGap = curTime - renixSystemLastToothTime;
if ( curGap >= triggerFilterTime )
{
toothSystemCount++;
if( renixSystemLastToothTime != 0 && renixSystemLastMinusOneToothTime != 0)
{ targetGap = (2 * (renixSystemLastToothTime - renixSystemLastMinusOneToothTime));} // in real world the physical 2 tooth gap is bigger than 2 teeth - more like 2.5
else
{ targetGap = 100000000L; } // random large number to stop system thinking we have a gap for the first few teeth on start up
if( curGap >= targetGap )
{
/* add two teeth to account for the gap we've just seen */
toothSystemCount++;
toothSystemCount++;
if( toothSystemCount != 12) // if not 12 (the first tooth after the gap) then we've lost sync
{
// lost sync
currentStatus.hasSync = false;
currentStatus.syncLossCounter++;
toothSystemCount = 1; // first tooth after gap is always 1
toothCurrentCount = 1; // Reset as we've lost sync
}
}
else
{
//Recalc the new filter value, only do this on the single gap tooth
setFilter(curGap);
}
renixSystemLastMinusOneToothTime = renixSystemLastToothTime; // needed for target gap calculation
renixSystemLastToothTime = curTime;
if( toothSystemCount == 12 || toothLastToothTime == 0) // toothLastToothTime used to ensure we set the value so the code that handles the fuel pump in speeduino.ini has a value to use once the engine is running.
{
toothCurrentCount++;
if( (configPage2.nCylinders == 6 && toothCurrentCount == 7) || // 6 Pretend teeth on the 66 tooth wheel, if get to severn rotate round back to first tooth
(configPage2.nCylinders == 4 && toothCurrentCount == 5 ) ) // 4 Pretend teeth on the 44 tooth wheel, if get to five rotate round back to first tooth
{
toothOneMinusOneTime = toothOneTime;
toothOneTime = curTime;
currentStatus.hasSync = true;
currentStatus.startRevolutions++; //Counter
revolutionOne = !revolutionOne;
toothCurrentCount = 1;
}
toothSystemCount = 1;
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
//NEW IGNITION MODE
if( (configPage2.perToothIgn == true) && (!BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK)) )
{
int16_t crankAngle = ( (toothCurrentCount - 1) * triggerToothAngle ) + configPage4.triggerAngle;
crankAngle = ignitionLimits(crankAngle);
if( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) && (revolutionOne == true) && (configPage4.TrigSpeed == CRANK_SPEED) )
{
crankAngle += 360;
checkPerToothTiming(crankAngle, (configPage4.triggerTeeth + toothCurrentCount));
}
else{ checkPerToothTiming(crankAngle, toothCurrentCount); }
}
}
}
}
void triggerSetEndTeeth_Renix()
{
byte toothAdder = 0;
if( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) && (configPage4.TrigSpeed == CRANK_SPEED) ) { toothAdder = configPage4.triggerTeeth; }
//Temp variables are used here to avoid potential issues if a trigger interrupt occurs part way through this function
int16_t tempIgnition1EndTooth;
tempIgnition1EndTooth = ( (ignition1EndAngle - configPage4.triggerAngle) / (int16_t)(triggerToothAngle) ) - 1;
if(tempIgnition1EndTooth > (configPage4.triggerTeeth + toothAdder)) { tempIgnition1EndTooth -= (configPage4.triggerTeeth + toothAdder); }
if(tempIgnition1EndTooth <= 0) { tempIgnition1EndTooth += (configPage4.triggerTeeth + toothAdder); }
if((uint16_t)tempIgnition1EndTooth > triggerActualTeeth && tempIgnition1EndTooth <= configPage4.triggerTeeth) { tempIgnition1EndTooth = triggerActualTeeth; }
if((uint16_t)tempIgnition1EndTooth > (triggerActualTeeth + toothAdder)) { tempIgnition1EndTooth = (triggerActualTeeth + toothAdder); }
ignition1EndTooth = tempIgnition1EndTooth;
int16_t tempIgnition2EndTooth;
tempIgnition2EndTooth = ( (ignition2EndAngle - configPage4.triggerAngle) / (int16_t)(triggerToothAngle) ) - 1;
if(tempIgnition2EndTooth > (configPage4.triggerTeeth + toothAdder)) { tempIgnition2EndTooth -= (configPage4.triggerTeeth + toothAdder); }
if(tempIgnition2EndTooth <= 0) { tempIgnition2EndTooth += (configPage4.triggerTeeth + toothAdder); }
if((uint16_t)tempIgnition2EndTooth > triggerActualTeeth && tempIgnition2EndTooth <= configPage4.triggerTeeth) { tempIgnition2EndTooth = triggerActualTeeth; }
if((uint16_t)tempIgnition2EndTooth > (triggerActualTeeth + toothAdder)) { tempIgnition2EndTooth = (triggerActualTeeth + toothAdder); }
ignition2EndTooth = tempIgnition2EndTooth;
currentStatus.canin[1] = ignition2EndTooth;
int16_t tempIgnition3EndTooth;
tempIgnition3EndTooth = ( (ignition3EndAngle - configPage4.triggerAngle) / (int16_t)(triggerToothAngle) ) - 1;
if(tempIgnition3EndTooth > (configPage4.triggerTeeth + toothAdder)) { tempIgnition3EndTooth -= (configPage4.triggerTeeth + toothAdder); }
if(tempIgnition3EndTooth <= 0) { tempIgnition3EndTooth += (configPage4.triggerTeeth + toothAdder); }
if((uint16_t)tempIgnition3EndTooth > triggerActualTeeth && tempIgnition3EndTooth <= configPage4.triggerTeeth) { tempIgnition3EndTooth = triggerActualTeeth; }
if((uint16_t)tempIgnition3EndTooth > (triggerActualTeeth + toothAdder)) { tempIgnition3EndTooth = (triggerActualTeeth + toothAdder); }
ignition3EndTooth = tempIgnition3EndTooth;
int16_t tempIgnition4EndTooth;
tempIgnition4EndTooth = ( (ignition4EndAngle - configPage4.triggerAngle) / (int16_t)(triggerToothAngle) ) - 1;
if(tempIgnition4EndTooth > (configPage4.triggerTeeth + toothAdder)) { tempIgnition4EndTooth -= (configPage4.triggerTeeth + toothAdder); }
if(tempIgnition4EndTooth <= 0) { tempIgnition4EndTooth += (configPage4.triggerTeeth + toothAdder); }
if((uint16_t)tempIgnition4EndTooth > triggerActualTeeth && tempIgnition4EndTooth <= configPage4.triggerTeeth) { tempIgnition4EndTooth = triggerActualTeeth; }
if((uint16_t)tempIgnition4EndTooth > (triggerActualTeeth + toothAdder)) { tempIgnition4EndTooth = (triggerActualTeeth + toothAdder); }
ignition4EndTooth = tempIgnition4EndTooth;
#if IGN_CHANNELS >= 5
int16_t tempIgnition5EndTooth;
tempIgnition5EndTooth = ( (ignition5EndAngle - configPage4.triggerAngle) / (int16_t)(triggerToothAngle) ) - 1;
if(tempIgnition5EndTooth > (configPage4.triggerTeeth + toothAdder)) { tempIgnition5EndTooth -= (configPage4.triggerTeeth + toothAdder); }
if(tempIgnition5EndTooth <= 0) { tempIgnition5EndTooth += (configPage4.triggerTeeth + toothAdder); }
if((uint16_t)tempIgnition5EndTooth > triggerActualTeeth && tempIgnition5EndTooth <= configPage4.triggerTeeth) { tempIgnition5EndTooth = triggerActualTeeth; }
if((uint16_t)tempIgnition5EndTooth > (triggerActualTeeth + toothAdder)) { tempIgnition5EndTooth = (triggerActualTeeth + toothAdder); }
ignition5EndTooth = tempIgnition5EndTooth;
#endif
#if IGN_CHANNELS >= 6
int16_t tempIgnition6EndTooth;
tempIgnition6EndTooth = ( (ignition6EndAngle - configPage4.triggerAngle) / (int16_t)(triggerToothAngle) ) - 1;
if(tempIgnition6EndTooth > (configPage4.triggerTeeth + toothAdder)) { tempIgnition6EndTooth -= (configPage4.triggerTeeth + toothAdder); }
if(tempIgnition6EndTooth <= 0) { tempIgnition6EndTooth += (configPage4.triggerTeeth + toothAdder); }
if((uint16_t)tempIgnition6EndTooth > triggerActualTeeth && tempIgnition6EndTooth <= configPage4.triggerTeeth) { tempIgnition6EndTooth = triggerActualTeeth; }
if((uint16_t)tempIgnition6EndTooth > (triggerActualTeeth + toothAdder)) { tempIgnition6EndTooth = (triggerActualTeeth + toothAdder); }
ignition6EndTooth = tempIgnition6EndTooth;
#endif
#if IGN_CHANNELS >= 7
int16_t tempIgnition7EndTooth;
tempIgnition7EndTooth = ( (ignition7EndAngle - configPage4.triggerAngle) / (int16_t)(triggerToothAngle) ) - 1;
if(tempIgnition7EndTooth > (configPage4.triggerTeeth + toothAdder)) { tempIgnition7EndTooth -= (configPage4.triggerTeeth + toothAdder); }
if(tempIgnition7EndTooth <= 0) { tempIgnition7EndTooth += (configPage4.triggerTeeth + toothAdder); }
if((uint16_t)tempIgnition7EndTooth > triggerActualTeeth && tempIgnition7EndTooth <= configPage4.triggerTeeth) { tempIgnition7EndTooth = triggerActualTeeth; }
if((uint16_t)tempIgnition7EndTooth > (triggerActualTeeth + toothAdder)) { tempIgnition7EndTooth = (triggerActualTeeth + toothAdder); }
ignition7EndTooth = tempIgnition7EndTooth;
#endif
#if IGN_CHANNELS >= 8
int16_t tempIgnition8EndTooth;
tempIgnition8EndTooth = ( (ignition8EndAngle - configPage4.triggerAngle) / (int16_t)(triggerToothAngle) ) - 1;
if(tempIgnition8EndTooth > (configPage4.triggerTeeth + toothAdder)) { tempIgnition8EndTooth -= (configPage4.triggerTeeth + toothAdder); }
if(tempIgnition8EndTooth <= 0) { tempIgnition8EndTooth += (configPage4.triggerTeeth + toothAdder); }
if((uint16_t)tempIgnition8EndTooth > triggerActualTeeth && tempIgnition8EndTooth <= configPage4.triggerTeeth) { tempIgnition8EndTooth = triggerActualTeeth; }
if((uint16_t)tempIgnition8EndTooth > (triggerActualTeeth + toothAdder)) { tempIgnition8EndTooth = (triggerActualTeeth + toothAdder); }
ignition8EndTooth = tempIgnition8EndTooth;
#endif
lastToothCalcAdvance = currentStatus.advance;
}
/** @} */

View File

@ -3525,6 +3525,23 @@ void initialiseTriggers(void)
attachInterrupt(triggerInterrupt, triggerHandler, CHANGE); //Hardcoded change, the primaryTriggerEdge will be used in the decoder to select if it`s an inverted or non-inverted signal.
break;
case DECODER_RENIX:
//Renault 44 tooth decoder
triggerSetup_Renix();
triggerHandler = triggerPri_Renix;
getRPM = getRPM_missingTooth;
getCrankAngle = getCrankAngle_missingTooth;
triggerSetEndTeeth = triggerSetEndTeeth_Renix;
if(configPage4.TrigEdge == 0) { primaryTriggerEdge = RISING; } // Attach the crank trigger wheel interrupt
else { primaryTriggerEdge = FALLING; }
if(configPage4.TrigEdgeSec == 0) { secondaryTriggerEdge = RISING; }
else { secondaryTriggerEdge = FALLING; }
attachInterrupt(triggerInterrupt, triggerHandler, primaryTriggerEdge);
break;
default:
triggerHandler = triggerPri_missingTooth;
getRPM = getRPM_missingTooth;

View File

@ -0,0 +1,338 @@
#include <decoders.h>
#include <globals.h>
#include <unity.h>
#include "renix.h"
void test_setup_renix44()
{
//Setup a renix 44 tooth wheel
configPage4.TrigPattern = DECODER_RENIX;
configPage2.nCylinders = 4;
decoderHasSecondary = false;
triggerSetup_Renix();
}
void test_setup_renix66()
{
//Setup a renix 66 tooth wheel
configPage4.TrigPattern = DECODER_RENIX;
configPage2.nCylinders = 6;
decoderHasSecondary = false;
triggerSetup_Renix();
}
//************************************** Begin the new ignition setEndTooth tests **************************************
void test_Renix_newIgn_44_trig0_1()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=0
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition1EndAngle = 360 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 0; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(2, ignition1EndTooth);
}
void test_Renix_newIgn_44_trig90_1()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=90
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition1EndAngle = 360 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 90; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(1, ignition1EndTooth);
}
void test_Renix_newIgn_44_trig180_1()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=180
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition1EndAngle = 360 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 180; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(4, ignition1EndTooth);
}
void test_Renix_newIgn_44_trig270_1()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=270
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition1EndAngle = 360 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 270; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(3, ignition1EndTooth);
}
void test_Renix_newIgn_44_trig360_1()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=360
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition1EndAngle = 360 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 360; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(3, ignition1EndTooth);
}
void test_Renix_newIgn_44_trigNeg90_1()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=-90
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition1EndAngle = 360 - 10; //Set 10 degrees advance
configPage4.triggerAngle = -90; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(3, ignition1EndTooth);
}
void test_Renix_newIgn_44_trigNeg180_1()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=-180
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition1EndAngle = 360 - 10; //Set 10 degrees advance
configPage4.triggerAngle = -180; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(4, ignition1EndTooth);
}
void test_Renix_newIgn_44_trigNeg270_1()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=-270
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition1EndAngle = 360 - 10; //Set 10 degrees advance
configPage4.triggerAngle = -270; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(1, ignition1EndTooth);
}
void test_Renix_newIgn_44_trigNeg360_1()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=-360
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition1EndAngle = 360 - 10; //Set 10 degrees advance
configPage4.triggerAngle = -360; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(2, ignition1EndTooth);
}
// ******* CHannel 2 *******
void test_Renix_newIgn_44_trig0_2()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=0
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 0; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(4, ignition2EndTooth);
}
void test_Renix_newIgn_44_trig90_2()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=90
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 90; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(3, ignition2EndTooth);
}
void test_Renix_newIgn_44_trig180_2()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=180
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 180; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(3, ignition2EndTooth);
}
void test_Renix_newIgn_44_trig270_2()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=270
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 270; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(2, ignition2EndTooth);
}
void test_Renix_newIgn_44_trig366()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=360
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 360; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(1, ignition2EndTooth);
}
void test_Renix_newIgn_44_trigNeg90_2()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=-90
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = -90; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(1, ignition2EndTooth);
}
void test_Renix_newIgn_44_trigNeg180_2()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=-180
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = -180; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(2, ignition2EndTooth);
}
void test_Renix_newIgn_44_trigNeg270_2()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=-270
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = -270; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(3, ignition2EndTooth);
}
void test_Renix_newIgn_44_trigNeg366()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=-360
test_setup_renix44();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = -360; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(4, ignition2EndTooth);
}
void test_Renix_newIgn_66_trig0_2()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=300
test_setup_renix66();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 0; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(1, ignition2EndTooth);
}
void test_Renix_newIgn_66_trig181_2()
{
//Test the set end tooth function. Conditions:
//Advance: 10
//triggerAngle=300
test_setup_renix66();
configPage4.sparkMode = IGN_MODE_SINGLE;
ignition2EndAngle = 180 - 10; //Set 10 degrees advance
configPage4.triggerAngle = 181; //No trigger offset
triggerSetEndTeeth_Renix();
TEST_ASSERT_EQUAL(5, ignition2EndTooth);
}
void testRenix()
{
RUN_TEST(test_Renix_newIgn_44_trig0_1);
RUN_TEST(test_Renix_newIgn_44_trig90_1);
RUN_TEST(test_Renix_newIgn_44_trig180_1);
RUN_TEST(test_Renix_newIgn_44_trig270_1);
RUN_TEST(test_Renix_newIgn_44_trig360_1);
RUN_TEST(test_Renix_newIgn_44_trigNeg90_1);
RUN_TEST(test_Renix_newIgn_44_trigNeg180_1);
RUN_TEST(test_Renix_newIgn_44_trigNeg270_1);
RUN_TEST(test_Renix_newIgn_44_trigNeg360_1);
RUN_TEST(test_Renix_newIgn_44_trig0_2);
RUN_TEST(test_Renix_newIgn_44_trig90_2);
RUN_TEST(test_Renix_newIgn_44_trig180_2);
RUN_TEST(test_Renix_newIgn_44_trig270_2);
RUN_TEST(test_Renix_newIgn_44_trig366);
RUN_TEST(test_Renix_newIgn_44_trigNeg90_2);
RUN_TEST(test_Renix_newIgn_44_trigNeg180_2);
RUN_TEST(test_Renix_newIgn_44_trigNeg270_2);
RUN_TEST(test_Renix_newIgn_44_trigNeg366);
RUN_TEST(test_Renix_newIgn_66_trig0_2);
RUN_TEST(test_Renix_newIgn_66_trig181_2);
}

View File

@ -0,0 +1 @@
void testRenix();

View File

@ -5,6 +5,7 @@
#include "missing_tooth/missing_tooth.h"
#include "dual_wheel/dual_wheel.h"
#include "renix/renix.h"
#include "Nissan360/Nissan360.h"
#include "FordST170/FordST170.h"
#include "NGC/test_ngc.h"
@ -21,6 +22,7 @@ void setup()
testMissingTooth();
testDualWheel();
testRenix();
testNissan360();
testFordST170();
testNGC();