Commit Graph

40 Commits

Author SHA1 Message Date
Vitor Moreno B. Sales 98cf514bcf
Fix Stepper idle cranking outputting half steps (#1197)
* Fix Stepper idle cranking outputting half steps

* Add macros for stepper less and more air

---------

Co-authored-by: Josh Stewart <josh@noisymime.org>
2024-03-16 13:05:10 +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
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
Josh Stewart b49c6b6ab8 Add option to power stepper motor constantly. Fixes #1031 2023-05-17 08:17:26 +10:00
Josh Stewart 2fc29ceef5 MISRA cleanup rule: misra-c2012-8.2 2022-11-06 09:43:29 +11:00
ric355 659eb8ec0f
Fix for uninitialised variable in OLCL and CL stepper idle control (#926)
* Fix problem of using an uninitialised variable when initialising the stepper
after power on.

* Fix faulty idle taper causing OLCL and CL stepper to get stuck in the cranking position.

Co-authored-by: Richard Metcalfe <richard@richmet.com>
2022-09-13 23:16:31 +10:00
Daniel Tobias 540b3a4fa2
Correct typos found by codespell (#880) 2022-06-27 10:39:14 +10:00
Josh Stewart 31e7531128 Remove duplicate iacClosedLoopTable. Lookup idle target RPM @ 4Hz after CLT reading 2022-04-16 12:18:58 +10:00
Pasi Kemppainen 5dee6135b7
PWM and on/off idle fixes/cleanup (#806)
* Idle fixes #1

* Idle fixes #2

Co-authored-by: Josh Stewart <josh@noisymime.org>
2022-04-12 10:23:18 +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
Vitor Moreno B. Sales 9c3f745c16
All tapers use byte counters (#746)
Fixes

Update idle.ino
2022-04-05 07:27:54 +10:00
Josh Stewart 464933b38f Similar 100% DC fix for PWM idle 2022-01-04 23:23:15 +11:00
Vitor Moreno B. Sales 1536b9196d
Steper OL+CL mode (#554) 2021-12-09 08:52:56 +11:00
tx_haggis 5ed9ec3ca9
Reduce 3d table memory usage (>500 bytes) (#662)
* 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
2021-11-18 11:30:29 +11:00
tx_haggis 6344fdc76f
Use -fshort-enums instead of packing individual enums (#692) 2021-10-23 09:04:31 +11:00
tx_haggis b8c4ec3e61
Use packed enums to save a few bytes of RAM (#667) 2021-10-04 08:27:02 +11:00
Josh Stewart e187285e63 Small fixes for broken builds from the last few PRs 2021-04-22 10:58:50 +10:00
tx_haggis 1a4188aa31
Fix build warnings (#558)
* Flag unused parameters

* Fix compile warnings: abuse of static inline

Place functions in correct order & only forward
declare when necessary

* Suppress unused parameter warnings

Co-authored-by: Josh Stewart <josh@noisymime.org>
2021-04-21 16:33:19 +10:00
Tjeerd df1f5ccbf0
Closed loop idle improve (#481)
* Squashed commit of the following:

commit c73f316fa5bf8c929a8fef5736f4a40045ea992f
Author: Tjeerd <tjeerdie@users.noreply.github.com>
Date:   Wed Nov 25 21:53:45 2020 +0100

    cleanup and fix merge issues

commit 57f1e8c6c73bcfb699b18ac51a2ec646be822f55
Merge: 04478ca 131673d
Author: Tjeerd <tjeerdie@users.noreply.github.com>
Date:   Wed Nov 25 18:59:58 2020 +0100

    Merge branch 'Closedloop_idle_improvements' into ClosedLoopIdleImprovement

commit 131673dc60417cbc773b0763d2f93e917c83325f
Author: Tjeerd <tjeerdie@users.noreply.github.com>
Date:   Sun Nov 22 21:54:03 2020 +0100

    more fiddeling with idle control

commit e4406166cde91552027a0dfb7958d6894098f066
Author: Tjeerd <tjeerdie@users.noreply.github.com>
Date:   Sun Nov 22 20:36:24 2020 +0100

    More fiddeling with idle control

commit 45822003d41e021e3ed93e8e14ce05479ddfd17b
Author: Tjeerd <tjeerdie@users.noreply.github.com>
Date:   Sat Nov 21 14:59:32 2020 +0100

    fix initial value

commit ff8fadae7844bd8e5934ee0f311fbf5e0842ec29
Author: Tjeerd <tjeerdie@users.noreply.github.com>
Date:   Thu Nov 19 23:14:14 2020 +0100

    add TPS limit to prevent integeral windup.

commit 7683b2e65569787b1c94eae6f4847cdadd394402
Author: Tjeerd <tjeerdie@users.noreply.github.com>
Date:   Thu Nov 19 22:40:53 2020 +0100

    cleanup idle.h

commit da55ee9dbd76d65608bfb5b950bc948a498b9599
Author: Tjeerd <tjeerdie@users.noreply.github.com>
Date:   Thu Nov 19 22:36:18 2020 +0100

    Further improvement simplifying code for closedloop PID control with feedforward.
    make PWM output work
    Tinkering new Idle control
    working on closedloop idle
    Initial work on improving closed loop Idle control

* reset platformio.ini

Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
2020-12-02 08:37:58 +11:00
DIY-EFI fe6f0c684a
Add Idle up output (#378)
Implement functionality to allow a defined output pin to toggle (normal or inverted) based on the idle up input pin.

Co-authored-by: Josh Stewart <josh@noisymime.org>
2020-11-16 08:49:22 +11:00
Josh Stewart 899831bdad MISRA cleanup 2020-07-30 09:15:24 +10:00
Josh Stewart 4be3ffc0e1 Further MISRA cleanup work 2019-12-15 09:57:22 +11:00
Josh Stewart df22b1d41b MISRA cleanup 2019-12-02 14:47:30 +11:00
Josh Stewart d422221bab
Merge pull request #206 from ric355/febstepper
More stepper control changes for better starting and finer tuning
2019-03-13 15:26:43 +11:00
Vitor_Boss 3532e1bfbc Fix PINMAKS_TYPE typo 2019-03-03 19:15:57 -03:00
Vitor_Boss 1777f0aae7 STM32 update 2019-03-03 01:43:43 -03:00
Richard Metcalfe 3b29179621 Changes to separate out stepper cooling step time from stepper step time. 2019-02-27 09:44:25 +00:00
Josh Stewart e24d32e111 Move a whole bunch of stuff in to the new moduler, board specific files 2019-01-20 16:57:16 +13:00
Josh Stewart 207b389b41 Move all Teensy 3.5 headers to dedicated board file 2019-01-18 21:15:27 +11:00
Richard Metcalfe 4f94c98caa Provide support for changing the idle stepper direction through the use
of an "inverted Y/N" setting. This is to avoid the need to change wiring
if it turns out the stepper is working in the opposite direction to what
is expected.
2019-01-08 11:37:18 +00:00
VitorBoss 1defafb387 Work on boost/vvt and timers for STM32 2017-08-07 21:40:27 -03:00
VitorBoss 94e0c6c19c Fix error on no STM32 boards 2017-08-04 17:05:16 -03:00
VitorBoss 9f64ba2b6c idle, boost and vvt PWM added 2017-08-04 00:13:32 -03:00
Vitor Moreno B. Sales e9db1a2f78 New update to STM32
Using timer bits instead (mainLoopCount & 31) comparators.
Few changes to support another library on STM32
2017-08-02 22:46:48 -03:00
Josh Stewart d38a9584c5 Bunch of little stm32 compatibility tweaks 2017-03-23 12:25:51 +11:00
Josh Stewart 880947746f Many small updates to the idle system (Including additional logging) 2017-03-20 22:29:42 +11:00
Josh Stewart afb6f71aae Complete closed loop stepper idle (Needs testing) 2017-03-14 17:25:59 +11:00
Josh Stewart 31836511a3 Initial closed loop stepper idle (Not quite complete) 2017-03-10 20:34:39 +11:00
Josh Stewart 88e412bcf6 Teensy idle code 2017-03-01 14:42:24 +11:00
Josh Stewart c555bbc060 Move to PlatformIO for project layout 2017-02-06 20:56:46 +11:00