* 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
* Use table_row_iterator_t to adjust ignitionTable
* Separate 2d & 3d table code, abstract page to table iterator conversion.
This is just moving code around in preparation for future changes.
* Reduce table RAM (.bss) usage
Generate a separate type for each possible
3d axis & size combination.
This turns what was runtime information into
compile time data.
* Save 1 byte per table.
Use a flag value (INT16_MAX) instead of a separate boolean
flag
* File renaming
table_iterator -> table3d_iterator.h
table3d.h -> table3d_interpolate.h
table3d.cpp -> table3d_interpolate.cpp
table3d_types.h -> table3d.h
* Optimize page.cpp: reduce code clutter, maintain performance
* Reduce flash usage
* Encapsulate table metadata
* Performance - hoist if statement
* Replace function with macro
* Use a packed enum as a type identifier
Use a packed enum as a type identifier
Slimmer data types
* Use table iterators for random access to table
values and axis.
* Centralize write buffer check
* Encapsulate 16-bit reference concept
* Performance: make table iterators proper classes
This allows us to chain calls on temporaries - not possible
with regular function calls.
* Performance: encapsulate EEPROM update
& address increment
* Save flash - don't duplicate function
* Performance: directly invalidate table cache
* Separate out iterator reversal
* Separate out entity mapping & per-byte access
Much faster, smaller code footprint & easier to understand
* Code quality fixes
* Separate out axis metadata
* Doxygen comments
* Separate int16_ref into separate file
* Separate out table axies & values into separate types
No need for metadata types & more localised code.
E.g. creating iterators is now alongside the data over
which they iterate.
* Doxygen
* one test per function
* add tests
* use initialiseSchedulers in tests
* remove generic tests for schedules
* fix schedule accuracy tests
* fix warning static function never defined
* fix test_schedule not working
add temp test file to gitignore
improve schedule testing
add check for schedule delays and pending variants
move time sampling to callback methods
add comments and improve pending tests