Commit Graph

15 Commits

Author SHA1 Message Date
Josh Stewart a727eb51a7 Standardise on UINT8_MAX rather than 255 for limits 2024-08-23 07:19:52 +10:00
Josh Stewart ec312a119d Fix issues from #634 where launch would not engage if VSS was not used.
Added default value in updates and added a new unit test for this
2024-08-14 10:50:47 +10:00
Adam Gauthier 8472f1dd1e
Launch control Vss threshold activation (#634)
* Launch control Vss threshold

Set a maximum speed which the Launch control can be activated. Prevent activating on rev matching downshift.

* Only check launch vss condition if vss is active

---------

Co-authored-by: Josh Stewart <josh@noisymime.org>
2024-08-14 08:44:16 +10:00
Josh Stewart 784cdfac62 Typo fixes 2024-08-13 17:16:33 +10:00
tx_haggis 96dce4429c
Unit test all corrections (#1207)
* Add unit tests for correctionCranking

* Unit test correctionASE

* Add test_maths_div10_s16_perf

* Make TPS AE tests independent

* Add test_corrections_MAE

* Use RUN_TEST_P to reduce test RAM usage

* Unit test correctionFloodClear

* Unit test battery correction

* Add unit tests for correctionLaunch

* Test repetability - initialiseAll at the start of every test

* Unit test flex & fuel temp corrections, plus minor cleanup

* Unit tests - avoid forward declarations

* Separate out populate_table() from 3D table tests

* Separate calculation of AFR target from correction (and unit test the calculation).
Separation of concerns and will make unit test AFR correction easier.

* Unit test correctionAFRClosedLoop

* Unit test correctionsFuel

* Add populate_2dtable_P test utility function

* Unit test all ignition corrections

* Add compile time buffer overflow check to RUN_TEST_P

* DFCO - test behavior not implementation

* Tweak tests to pass on Teensy 3.5

* Shrink unit test for faster build/upload/execute
We just need the 2D tables wired up, not the whole system initialized.
1. Factor out construct2dTables() from initialiseAll()
2. In the unit tests,  call construct2dTables() instead of initialiseAll()
Linker then does the heavy lifting of removing unused symbols

* Add test_correctionsDwell_uses_batvcorrection

* Use TEST_ASSERT_BIT_[HIGH_LOW] instead of TEST_ASSERT_[TRUE|FALSE]
Better failure messages, declares intent

* Igniton corrction test: expand assertions: make sure all corrections test both positive an negative advance values.

* Add AE test assertion: especially for MAE

* Add AE timeout unit tests

* Convert copy/paste 2D table construction code into shared functions

* Disbale knock unit tests until knock implementation is stable.
2024-07-30 14:35:20 +10:00
Josh Stewart 3921610a46 Initial knock control for analog external controller input 2024-07-12 08:16:37 +10:00
Josh Stewart 003b1f0631 Initial knock control for use with external controller. Digital mode only supported 2024-07-11 16:14:09 +10:00
Josh Stewart a31e64b9df Warnings cleanup 2024-05-29 16:29:25 +10:00
Daniel Tobias 3a712baf23
Comment typos correction (#1189)
* basic spelling fixes

* basic spelling fixes, external libs
2024-03-21 11:37:45 +11:00
Josh Stewart be3c49b0be Add injector open time back into total PW when auto staging is used.
Fixes #1172
2024-02-20 15:36:45 +11:00
Josh Stewart 4d4486df4f Minor memory optimisation 2023-12-06 14:47:13 +11:00
tx_haggis 9bbd16c81b
Performance: optimize division (#1082)
* Add udiv_32_16

* Apply udiv_32_16() where possible

* Convert udiv_32_16 to assembler
It's worth 20 loop/s

* Remove unused functions

* Remove degreesPeruSx2048 - unused

* Remove angleToTime - replace with direct calls
1. Drop angleToTime()
It's slow, only partially implemented and adds zero value
(and has MISRA violations)
2. Consistent function naming
3. Doxygen

* triggerPri_Nissan360 shouldn't set timePerDegree.
It will be overwritten every loop by doCrankSpeedCalcs()

* Use angleToTimeMicroSecPerDegree() instead of timePerDegree
No loss in performance
Increased injection open/close time accuracy (so unit test values must change)
Can remove timePerDegree global.

* Hide (encapsulate) crank math globals.

* Base all angle to time conversions on decoder computed variables.
This is within 2us of the revolution based method
and is much faster - which is essentially zero percent change.

* Performance: move calculation of degreesPeruSx32768
into decoders.
Remove doCrankSpeedCalcs() - it's doing nothing
at the moment.

* Apply libdivide to triggerSetEndTeeth functions.
Since triggerToothAngle is set once at initialization
time, we can generate the libdivide struct
once and reuse it many times.

* Remove lastToothCalcAdvance - unused

* Replace 16-bit division with shift

* Replace 32-bit divison with 16-bit division

* Avoid 32-bit division; use div100()

* inline percentage()

* Optimize div100()

* MISRA fixes

* Replace magic numbers with #defs

* Replace libdivide structs with inline constants
No perf or memory changes

* Use fixed types for PWM max count variables

* Accurate rounded integer division
* Formalise rounding behavior (DIV_ROUND_CORRECT)
* Apply DIV_ROUND_CORRECT to DIV_ROUND_CLOSEST(),
UDIV_ROUND_CLOSEST(), div100(), div360(),
percentage() & halfPercentage()
* Add, fix & improve unit tests

* Add udiv_32_16_closest()

* Perf: Limit percentage calculations to 16-bits

* MISRA fixes

* Add compare_executiontime() to encapsulate common perf testing code

* Signed to unsigned division

* Convert ignitionLimits() to an inline function.
Slight speed up, probably due to removing
multiple evaluations of macro arguments.

* Split unit tests up.

* udiv_32_16 - check for valid parameters
2023-11-06 09:10:08 +11:00
Vitor Moreno B. Sales f8ffbb13da
Added taper entering DFCO (#1118)
* Added taper for DFCO for ignition and fuel

Used 1 byte of RAM and 4 on page 9

* Moved data to be compatible with DFCO map thres

* Added taper for DFCO for ignition and fuel

Used 1 byte of RAM and 4 on page 9

* Moved data to be compatible with DFCO map thres

* Fixed potential overflow and DFCO tests

* Moved math into functions and added tests

---------

Co-authored-by: Josh Stewart <josh@noisymime.org>
2023-10-25 10:09:57 +11:00
155ac 602203d3e0
MAP Limits for EGO (#1124)
* Map Limits for EGO

* Better update value for not breaking old tunes

my guess is that 300 kpa max will be good for not disabling EGO when using boost now but you can change for what value you think is the best

* Atualizar o updates.cpp

fix my dumbo mistake

* Prevent signed vs unsigned warning

---------

Co-authored-by: Josh Stewart <josh@noisymime.org>
2023-10-24 22:06:53 +11:00
Josh Stewart fc536d15f0 Rename all ino files to cpp (Excluding speeduino.ino).
Confirmed this compiles OK in Arduino IDE 2.x
Frees up 8 bytes of RAM
2023-10-06 18:10:20 +11:00