* Avoid overflow of timer period between the current and next schedules
Potential fix for #1181
* Remove end compare on fuel schedules. Significant RAM improvement
* Cleanup of new code. Align ignition schedules with new fuel schedules
* Slight tweak to fuel scheduling conditions
* Prevent missed injection pulse under specific timing conditions
* Further work handling when injection start angle passes back and forth between 0 and CRANK_ANGLE_MAX_INJ
* Do not queue next fuel schedule if cycle time exceeds max timer duration
* Fix unit tests based on code path changes
* Bug fix - consistent #ifdef (ANALOG_ISR/ANALOG_ISR_MAP)
Also replace multiple #ifdefs with inline function.
* MISRA fixes for sensor.cpp
* Conditional compile to allow MAP sensor read pin even when using analog ISR
Useful for development testing
* Remove unused global variables
statuses::batADC
fpPrimed - duplicate of statuses::fpPrimed
injPrimed - duplicate of statuses::injPrimed
* Replace duplicate filter macros with one inline function: LOW_PASS_FILTER (which is MISRA compliant).
* Remove mapErrorCount - it's unused
(only ever written to, never read)
* Deduplicate MAP reading code
* Encapsulate MAP variables
* Add isEngineRunning() to capture duplicate code
* Make readBaro() independent of instanteneousMAPReading()
Removes a conditional and reduces module surafce area
* Use structs to capture the MAP algorithm state.
Also apply ATOMIC_BLOCK to prevent tearing of ISR modified variables.
* Force loop() inline
Reduces stack usage.
* Use 16-bit comparisons
* Remove validateMAP() - since we validate every sensor reading, it wasn't doing anything.
* Unit test engineIsRunning
* Apply SET_UNITY_FILENAME to K6A unit tests
* Unit test LOW_PASS_FILTER
* Unit test fastMap10Bit
* Reduce scope of MAP ADC variables - only used in sensors.cpp
* MAP: read the sensors in one place in the code & inject the values into the sampling algorithms
* MAP: encapsulate reset of state structures
* MAP: replace magic numbers wirth an enum
* MAP algorithms return a flag indicting whether they recomputed MAP/EMAP
* MAP sampling algorithms: push MAP value calculation up the call stack.
* Remove errors.* - it's never called an uses up RAM
* Unit Test: inject all MAP sampling algorithm dependencies
* Unit test MAP sampling algorithms
* Unit test validateFilterMapSensorReading
* Prevent torn reads during comparisons
* Don't skip readings on cycle/event boundaries
* Add unit tests for triggerSetEndTeeth_SuzukiK6A
* Bug fix - use correct parameter when calling stdGetRPM
* Compute triggerToothAngle from the fixed tooth angle array.
* triggerSetEndTeeth_SuzukiK6A - hoist duplicated code into calcEndTeeth_SuzukiK6A
(like we did for some other decoders).
* MISRA fixes for Suzuki K6A decoder
* 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.
* Add optimized 32-bit shifting
* Tooth based time to angle coversion is only used by a few decoders.
So move the functions into decoders.cpp
* Better separation of deocders and crank maths.
* Apply optimised shifts
* Doxygen
* Reset control pin: don't over-writie the board default with zero.
The added unit tests interfered with each other & hung -
solution is to reinitialize the global context at the start of
each test.
* Additional pin init tests
* initialiseSchedulers: factor out shared code.
* Proxy setFuelSchedule\d through generic
setFuelSchedule() function
* Directly call setFuelSchedule
* Simplify unit tests
* Proxy setIgnitionSchedule\d through generic
setIgnitionSchedule() function
* Directly call setIgnitionSchedule
* Simplify unit tests
* Optimize by partially inlining
the set[Fuel|Ignition]Schedule funcs
* Use the embedded schedule compare
& counter members instead of using
hardcoded individual channel macros.
* Unit test adjustCrankAngle
* 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
* 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>
* calculateInjector1Timeout proxies calculateInjectorNTimeout
Unit test still pass.
* Remove calculateInjector1Timeout,
Replace with call to calculateInjectorTimeout
All unit tests still pass.
* Remove unecassary unit test
* calculateIgnition1Timeout proxies calculateIgnitionNTimeout
Unit test all pass
* Remove calculateIgnition1Timeout,
Replace with call to calculateIgnitionTimeout
All unit tests still pass.
* Remove unecassary unit test
* calculateIgnitionAngle\d proxies
calculateIgnitionAngle
Unit tests all pass
* Remove calculateIgnitionAngle\d
Just call calculateIgnitionAngle() directly
* Route rotary ignition angle calcs
through generic calculateIgnitionTrailingRotary
function.
* Remove calculateIgnitionAngle\d
Just call calculateIgnitionTrailingRotary() directly
* calculateInjectorStartAngle: inject all parameters
Do not rely on global state
Easier unit testing.
* calculateIgnitionAngle: inject all parameters
Do not rely on global state
Easier unit testing.
* Pull all ignition global vars into schedule_calcs
* Conditional compile for schedule calc vars
Saves memory
* Optimize: break out angleToTimeIntervalRev
from angleToTime. The new function will
always be inlined.
* Optimize - simpler code path
when no channel offset (zero)
Some optimization of arithmetic operations.
* Fix unit tests
* Fix bug on injector angle calculations
Need while loops to correctly bring intermediate
values into range
---------
Co-authored-by: Josh Stewart <josh@noisymime.org>
* 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>
* Unit test fuel schedule initialisation
* Move initialisation tests to their own harness
Saves memory
* Rename test_misc to test_tables
* Rename test_misc2 to test_math
* Reduce memory usage
* Fill out remaining ignition init unit tests
* Add missing forward declarations
Found while compiling teensy35 unit tests
* Unit test should not rely on EEPROM
* Fix bad lib_dep
Teensy35 #includes FlexCAN_4 headers
* Fix circular include
logger.h needs FPU_MAX_SIZE which is defined
in globals.h. Globals.h includes logger.h!
* Ambguity in integer typedefs
* Refactor: separate out schedule calcs from speeduino.ino
(so they can be unit tested)
* Add unit tests for compute_delay
* Use PROGMEM to store test input & output
* Add some 720 unit tests
* Rename unit test file
* Test ignition codepaths 2-8
* Test ign1 calcs
* Add first injector calc tests
* Add 720 deg tests
Simplify
* Simplify test_calc_inj1_timeout
* Claw back RAM
* Simplify test framework
Channel angle is part of the test data set.
* Move schedule calculation unit tests into their own harness
Competing for RAM with the rest of Speeduino
can cause them to fail,
* Performance: inline all schedule calcs.
* Unit test end angle
* Unit test calculateIgnitionAngle1
* Test start angles also
And test end angles for channel 1
* Unit test calculateIgnitionAngle3
* Unit test calculateIgnitionAngle4
* Improve unit test output
* Add Nissan360 decoder unit tests.
* Add Ford ST170 decoder unit tests
* Add NGC decoder unit tests
* Change X axis in memory orientation to match Y
* X & Y axes can use the same type (Ie.e class)
* Table3D axis iterator: replace reverse() with rbegin()
* Use iterators as part of unit tests
* Doxygen fixes/corrections
* Missing include
* 1. Add int16_byte class
2. Add axis factory function for int16_byte instances
(flyweight pattern)
* Separate out axis iteration and I/O conversions
* Optimize for size and performance.
* Fix unit test
* Consistent set of div100 functions
* Add typedef for trimTable3d
* Performance: use div100() function
when applying fuel trim corrections
* Silly ARM compiler!
* Unit test fixes
* Fix tests: expected & actual parameters were swapped
* div100(): add 8-bit overloads for completeness
* Fix unit tests
1. Force call to correct div100() overload
2. Use appropriately typed assertion
* Restore use of USE_LIBDIVIDE preprocessor symbol
* Add div360() - encapsulate libdivide use
* Fix copy/paste issue.
* Bi-linear interpolation - round towards nearest integer
Add the equivalent of 0.5 to the final calculation pre-rounding.
This will have the effect of rounding to the nearest integer, rather
than truncating. I.e. rounding down
* Unit tests: isolate table tests and check interpolation x/y bins
* Unit tests: add native table3d tests
* Unit tests: derive min/max from axis test values
* Unit tests: more detailed messages
* Unit tests: fix rounding & unit tests
* Performance
* Performance: use uint16_t instead of unsigned long
for the fixed point math: we only need the fractional
part. I.e. 1.16 not 16.16
* Use narrowest possible type
* Optimise bin position logic for performance
* Only promote to uint32_t when really required.
* Simplify bin checks - no zero width bins
* Save memory: use a single byte for the last bin caches
* Performance: increment pointers instead of
repeatedly dereferncing array by index.
* Comments
* Incorrect array underrun logic
* Rename type, comments
* Fix unit tests