Commit Graph

355 Commits

Author SHA1 Message Date
tx_haggis b03db96ad7
Save 600+ bytes RAM (step 4 of 9) - deduplicate scheduler ISR functions (#1063) 2023-10-07 08:25:26 +11:00
Josh Stewart 55c98cab22 Allow mega2560 builds with non-standard _CHANNELS values 2023-10-06 20:43:15 +11:00
Josh Stewart 484e3916e3 Further cleanup work on secondary comms. Slight RAM free up. 2023-10-06 11:48:05 +11:00
Josh Stewart a6201f3b72 Prevent low probability race condition when disabling pending schedules 2023-08-28 11:21:55 +10:00
Josh Stewart 3d33a2cbf5 Delay spark re-engagement by 1 revolution when using Fuel+Spark cut on a 4 stroke engine 2023-08-22 18:20:36 +10:00
Josh Stewart d13c7d0ab5 Ensure already scheduled events are stopped when rolling cut goes active 2023-08-22 14:38:17 +10:00
Josh Stewart ee807bb243 Rolling limiter fixes for launch and flat shift 2023-07-31 13:39:27 +10:00
Josh Stewart 856bcfb242 Fix rolling limiter not working with coolant based RPM limit 2023-07-04 15:26:56 +10:00
Josh Stewart a1ae3db072 Fix for incorrect bracket in last commit 2023-06-26 16:17:59 +10:00
Josh Stewart 624d255123 Standardise all the fuel schedule setting channel calls 2023-06-26 15:52:02 +10:00
tx_haggis d9b5554a8c
Save 600+ bytes RAM (step 3 of 9) - remove per-channel schedule calculation functions, use generic equivalents instead (#1018)
* 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>
2023-06-26 12:13:53 +10:00
Josh Stewart e44f4c7b54 Fix issue where staging fuel channels would be active even when not required 2023-06-26 10:46:11 +10:00
Josh Stewart 9c3e993b53 Initial commit of new rolling rev limiter 2023-06-09 16:10:43 +10:00
Vitor Moreno B. Sales 72dd807fb3
Consistent MAP readings for all platforms (#619)
* Added a 1000Hz call for MAP reading on ARM cores

* Use 1kHz section for map reads on all MCUs

---------

Co-authored-by: Josh Stewart <josh@noisymime.org>
2023-05-19 10:24:56 +10:00
Josh Stewart 6932101254 Add a cranking to running RPM hysteresis (15 rpm) 2023-05-18 15:21:30 +10:00
Josh Stewart 9bc49d9aa2 Warnings cleanup 2023-05-17 11:36:08 +10:00
mike501 805a535238
VVT2 improved logging & setup (#1036)
* adding VVT logging and trigger edge editing


fix missing define (temp fix?)


Revert "fix missing define (temp fix?)"

This reverts commit c6280f38ff69cc41278148a79c888736a71754b1.

fixes

* Create an additional logger screen in tunerstudio

Changes to create a third high speed logger window in tuner studio.

* Change variable name 

Discord discussion requested compositeLogEnabled didn't do a test for false as the type is now a byte. Variable renamed to be compositeTriggerUsed and false replaced with 0. Variable name and values used should now make more logical sense.

* added more logging

Log the primary, secondary and third inputs as well as engine cycle on all composite logs. Still have 3 different logs to allow you to visualise which is the best way to present the information.
2023-05-15 14:15:46 +10:00
Josh Stewart 78bed477f5 Merge branch 'master' of https://github.com/noisymime/speeduino 2023-05-03 15:41:38 +10:00
celso acyr da57378684
Read analog values via CAN BUS (#635)
* Read analog values via CAN BUS

Allows reading of 16 analog signals via CAN-BUS. with selection of Edianness.

* Moved function

Function moved to improve data readability.

---------

Co-authored-by: Josh Stewart <josh@noisymime.org>
2023-05-03 15:12:29 +10:00
Josh Stewart 65005c0019 Sync SD log with card at 4Hz interval 2023-05-02 13:13:19 +10:00
Josh Stewart d0286fe02d Ensure that output port manipulations are done atomically. Fixes #972 2023-04-24 10:30:51 +10:00
Josh Stewart 90530f65a3 Handle 3 cylinder, non-seq, staging with >= 6 fuel channels 2023-04-16 17:20:39 +10:00
Josh Stewart 6987c966f6 Fixes for regressions in the new staging code 2023-04-13 16:35:47 +10:00
tx_haggis 0afffb2ca0
Unit test the schedule calculations (#1010)
* 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
2023-03-06 17:23:17 +11:00
Josh Stewart 311cae3fac Allow fuel staging up to 8 total fuel channels (All reasonable combinations) 2023-03-06 16:49:30 +11:00
tx_haggis f95b4978cd
Refactor comms: save 130+ bytes RAM (#906)
* Remove serialCRC - only used within parseSerial()
Also hoist the CRC read into a function.

* Minimize global variable visibility

* Encapsulate write of multi-byte primitives

* Factor out sendBufferAndCrc()

* Push safety test into TS_CommandButtonsHandler()

* Extract writePage()

* Simpler parsing

* Remove some functions from public interface

* Store constant arrays in progmem

* Centralize high speed logger start/stop code

* Factor out loadO2Calibration()

* Factor out temperature calibration table update functions

* Remove dead code

* Fix sendToothLog()

* Fix sendCompositeLog()

* Replace tooth log send booleans with an enum
Saves a byte

* Remove sendBufferAndCrcProgMem()
Use serialPayload to send

* Whitespace clean up

* Optimize comms.cpp for size

* Replace global unsigned long with bool
Saves 2 bytes

* Replace 2 global bools with an enum
Saves a byte, reads better.

* Remove global FastCRC instance

* Make sendSerialReturnCode blocking.
It was using non-blocking functions but was never
re-entered.
Rename to make blocking & non-blocking calls
more obvious.

* Use one uint16_t to track RX/TX byte count

* Simplify new comms log tx API

* Extract loadPageToBuffer function

* All endianess changes use the same code

* Doxygen comments and code organization

* Remove serialWriteUpdateCrc() & updateTmpCalibration()

* Combine SerialStatus & logSendStatus enums.
Makes sense since we can only be doing one thing at a time.

* Remove global inProgressCompositeTime
Only used when sending composite log

* Replace 3 global bools with expanded SerialStatus enum

* Remove unused global tsCanId

* Limit scope of some comms globals.

* Remove isMap global - replace witth function

* Reduce the serial API to only 2 calls
transmit & receive

* Tidy up #define visibility

* Fix Black* build errors

* Workaround Teensy code race condition
availableForWrite() is not reliable.

* Prevent race condition
Was pematurely setting the serialStatusFlag to
SERIAL_INACTIVE before final CRC ws read from
serial.

* Use post write buffer availability checks
Remove buffer size check prior to writing.

* Write multi-byte values as single bytes.
(attempt to fix Teensy 3.5 issue)

* Only use Serial.available() as a boolean test
(Teensy fix)

* writeNonBlocking checks Serial.write() return value

* Non-blocking CRC write
In sendBufferAndCrcNonBlocking().

* Fix compile warning

* Set serial status flag prior to transmitting!

* Reliable blocking byte writes.

* Fix timeout code: not firing under some conditions

* MISRA fixes
2023-02-21 12:55:54 +11:00
DeionSi 2312102d4b
Replace 8 channelXInjEnabled variables with 1 (#1001) 2023-02-06 11:48:11 +11:00
Josh Stewart 6f61bd3ee6 Allow staged fuel table mode to work with TPS load
Fixes #998
2023-02-03 10:16:57 +11:00
Pasi Kemppainen 11313ba440
Fix decel in AE Add -mode (#971) 2023-01-10 08:46:34 +09:00
Pasi Kemppainen f59d013714
Add deceleration enleanment feature (#939)
* Add decel enleanment feature

* Fix tps and map DOT scaling in TS.

* updates.ino

* Small bug fix.

* One more small bug fix.

* Update cancomms.ino

Cast tps/mapDOT as uint8 to cancomms to retain backwards compatibility

* Fix programmable outputs list.

* Fix programmable outputs in updates.ino

* Add abs around currentStatus.mapDOT
2022-12-14 11:17:47 +11:00
Josh Stewart 4693cb2013 Change to single decoder state variable. Small (12 byte) RAM free up 2022-11-22 15:53:35 +11:00
Josh Stewart 2fc29ceef5 MISRA cleanup rule: misra-c2012-8.2 2022-11-06 09:43:29 +11:00
Josh Stewart 3923ecf12f Tweaks to 2560 EEPROM burn during multi page writes 2022-09-12 11:53:18 +10:00
Afroboltski 75d6c2ff61
Air Conditioning Control - Feature Implementation (#665)
* 19.09.2021

* Final testing of AC Control, some idle features fixed

AC control feature added, better than the existing idle-up feature (which can still be used for other things, e.g. electrical load detection). Air conditioning is locked out with coolant temp, RPM high/low, and high TPS. So the A/C automatically cuts out when driving hard.

Idle step now works correctly with closed loop PWM, open loop PWM, and closed+open loop PWM. Untested with stepper motor, but no reason it shouldn't work.

* Fixed mistakenly incremented page sizes

* Initial changes as per HWright9

-Renamed engineRunSeconds to acAfterEngineStartDelay
-Formatted large if statements better
-Fixed acStartDelay overflow bug
-Improved readability of logic

* Final fixes as per HWright9's feedback

-Add high/low RPM lockout delay, similar to the high TPM lockout delay
-General tidy-up

* Added stand-alone fan, moved config data in EEPROM

-Added additional configurable stand-alone A/C fan output, for when there is dedicated cooling fan for the A/C compressor. This is independent of the engine cooling fan logic.
-Moved config storage in EEPROM to configPage9, as noisymime's SD card logging has used the (previously unused) bytes I had used in configPage13.
-Minor bug fix - rename Aux in 1-16 to Aux in 0-15

* Revert to current master branch - as of master commit 97f8ef795a

* A/C Control Re-Integrated from AC-Control-Clean-3 (@Corey-Harding). Tested & ready to merge.

Additionally, added @HazuTo25's lines into the update() routine to configure default A/C settings.

* Changed updates.ino to just set A/C to disabled

* Fix change reverted by mistake - master merge commit 73badbce8c

* Fix remaining mistakes from previous master merge

* Remove test statements left in by mistake

* define unusedBits

* Remove test statements left in by mistake

* Increase timing granularity to 0.1s

* idleUpRPMAdder

* Remove another line put in by mistake by auto merge

* idleUpRPMFixes

* Update speeduino.ino

* Tweak A/C idle up descriptions

* Tweak A/C TS descriptors again

* Fixed alignment bug that turned page 15 config values into gobbledegook.

This had the symptom of the A/C request never triggering, because when a pin was assigned in TS (e.g. I did 27), a completely different pin would be read from config15 (in my case 22 - connecting the button to pin 22 would work in this case, even though TS was set to 27).

* Fix bit count - should be 6 to match ini file

* Increase minimum RPM lockout granularity

* Change granularity of A/C minimum RPM lockout to 10 RPM; Inline some functions for readability

* Add static inline function prototypes to auxiliaries.h as per the style guide.

* Fixed page 15 merge errors

* Style changes to suit new pinIsUsed() checks in setPinMappings()

* Add PWM Fan Control Minimum Clamp Value when A/C Compressor Engaged

* Fix comment

* Fix bug with stand-alone fan initialisation

Pin was unable to be used in prog. I/O even if fan was disabled, because it was always initialised as an output even if it was disabled. Fixed in this commit.

* Correction to Fahrenheit temperature scaling

* Move A/C updates to correct next release

Co-authored-by: shiznit304 <62686180+shiznit304@users.noreply.github.com>
Co-authored-by: Josh Stewart <josh@noisymime.org>
2022-09-07 10:23:01 +10:00
Afroboltski d527f173a8
Add necessary pin translations (#887). Fixes #867 2022-07-10 22:38:42 +10:00
Vitor Moreno B. Sales adaa6a227e
Enable use of disabled functions pins (#549)
* Enable use pins of disabled functions or unused ign channels

* Added new pins and functions to check
2022-06-29 16:37:50 +10:00
Daniel Tobias 540b3a4fa2
Correct typos found by codespell (#880) 2022-06-27 10:39:14 +10:00
larmicfre 298d994ba1
AFR protection function (#861)
* Implementing AFR protection

* Update globals.h

* Bug fixes and code refactoring

* Moved variables to prevent ODR

* Dialog for AFR protection

* Data size and math corrections

* Possibility to use either AFR or lambda

* Updated default AFR protection values

* No need to do multiplications due to existing RPMdiv100 variable

* The X100 multiplier was wrongfully removed

* Add defaults in updates.ino, minor formatting cleanups

Co-authored-by: Josh Stewart <josh@noisymime.org>
2022-06-20 09:52:07 +10:00
Pasi Kemppainen af5272b74c
[WIP] CAN broadcasting menu (#639)
* Add CAN broadcasting menu

* Fix updates.ino

* Remove use of floats and few other fixes.

* Fix building.

* Change updates.ino up to date.
2022-04-21 16:33:10 +10:00
Josh Stewart b7c02b53d6 Fix cranking to run idle taper time not running correctly 2022-04-21 11:42:00 +10:00
Vitor Moreno B. Sales 4ce8c28c5a
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>
2022-04-18 14:12:57 +10:00
Josh Stewart 31e7531128 Remove duplicate iacClosedLoopTable. Lookup idle target RPM @ 4Hz after CLT reading 2022-04-16 12:18:58 +10:00
tx_haggis 7933bb68c4
Remove previousLoopTime - never used (#706) 2022-04-11 14:16:26 +10:00
Daniel Tobias 7020705dbe
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>
2022-04-11 10:49:58 +10:00
Josh Stewart f55789e5a3 Reorganise Engine Protection UI 2022-04-10 09:07:21 +10:00
Josh Stewart 35f196930a Minor cleanup from the newComms / LegacyComms move 2022-03-01 15:27:46 +11:00
Josh Stewart 8a54c4b23b Fix calibrations tx on legacy comms
Note the renaming of newComms to comms. Old comms has been moved to _legacy files
2022-02-28 10:28:06 +11:00
Josh Stewart 87e21fc7e2 Increase O2 read frequency to 30Hz
Fixes #799
2022-02-25 15:13:35 +11:00
Josh Stewart 962e717754 Merge branch 'master' of https://github.com/noisymime/speeduino 2022-02-22 23:29:48 +11:00
Josh Stewart 3d627ded34 More efficient EEPROM write deferral 2022-02-22 23:29:41 +11:00