0

I've been thinking a lot lately when driving my car - inside the ECU there is a memory module with pre-calculated values for almost anything. For example, the ECU can calculate how much fuel to inject based on several readings such as throttle position, current RPM's, etc. When people remap their cars they change the predefined values which in turn changes the output calculated in realtime by the ECU. Let's keep it simple and imagine we have 2 parameters we constantly juggle around on a predefined 2D graph. We have 4 reference points: A1(2000 RPM - 200 foo units), A2(3000 RPM - 270 foo units), A3(4000 RPM - 350 foo units), A4(5000 RPM - 400 foo units). So the question I'm struggling with is how can you calculate the exact amount of foo units on let's say 3650 RPM in realtime on "slow" hardware without any errors or delays. I'd love to see some C style pseudo code on how it could be implemented logic-wise to run efficiently. The first thing that comes to my mind are 2 arrays (a matrix), but things get messy when you account for multiple variables making a difference on the final outcome. I'd like to experiment with this and try to write a small program to do this kind of math, but I'm stuck on choosing the clean, sane way of representing and manipulating values...

Sorry for no formatting, wrote this post on my phone!

DKMR
  • 1
  • 4
  • 1
    Depends on “ECU”. Many earlier ECUs were just that: simple matrices. Now days.. geeze, even my motorcycle feeds in (lean) angle and slippage in addition to all the normal stuff an engine does to run :/ – user2864740 May 31 '20 at 21:16
  • 2
    Anyway, modern computers are VERY fast. Even a small non-specialized unit a like Aurdino has gobs more power than cars from even cars earlier this century. It’s mainly then ensuring “real-time” calculations - eg. a non-preemptable model where all the calculations are complete within a fixed period (as it pertains to the vehicles needs). – user2864740 May 31 '20 at 21:22
  • I think you're asking about linear interpolation. If you pre-calculate slopes, you just need a subtract, multiply, and add. Even without hardware multiply, a software shift/bit-test/add loop has bounded time. – Peter Cordes Jun 01 '20 at 00:21
  • 1
    It does not need to be *linear* interpolation, even more complex kinds are possible, depending on real-time constraints. "Real-time" does not mean "as fast as possible", it means "guaranteed in time" that can be milliseconds. – the busybee Jun 01 '20 at 09:22
  • 1
    What do you mean by "slow hardware" - the calculations are not complex and ECUs often use very simple microcontrollers. Perhaps you might look at the https://github.com/noisymime/speeduino/ code. It is an open-source Arduino based ECU project https://speeduino.com/home/ – Clifford Jun 01 '20 at 12:52

0 Answers0