Coding my own aftermarket ECU [beta available]
Re: Coding my own aftermarket ECU
I've tried 64 rows in arrays, but for whatever reason, that breaks everything. not sure where the cutoff point is.
I originally wanted to keep it all as simple as possible, and max out all leftover RAM with array data.
EDIT: I think I tried 64 rows when I still had 256 columns. Looking up the error after trying 129x129, I assume I ran out of RAM, and the errors just wasn't layman transparent.
I originally wanted to keep it all as simple as possible, and max out all leftover RAM with array data.
EDIT: I think I tried 64 rows when I still had 256 columns. Looking up the error after trying 129x129, I assume I ran out of RAM, and the errors just wasn't layman transparent.
Last edited by AngelMarc on Sat Jun 14, 2025 9:44 pm, edited 1 time in total.
Don't stress specific units.
Re: Coding my own aftermarket ECU
For the hell of it, I tried again.
Arrays are 65 * 129 now.
I must have missed something before.
Noise looks the same. Memory usage is still fine. Replaced 600 with 300
Arrays are 65 * 129 now.
I must have missed something before.
Noise looks the same. Memory usage is still fine. Replaced 600 with 300
Code: Select all
uint32_t IndexFull_fixed = ((uint64_t)2500000 << 8) / ((uint32_t)RPMTimeavg * 300);
Don't stress specific units.
Re: Coding my own aftermarket ECU
Cranked the rolling averages for crank and MAP to 240 counts. Noise is about the same, but minimum MAP is able to hit 0 output again...
?
?
Don't stress specific units.
Re: Coding my own aftermarket ECU
Not sure what I did before where 64x128 wouldn't work. But 129x129 blows through all the RAM lol
Anyway, time to add IAT code. Going to make sure whatever is added or subtracted from on delay, gets inversed on off delay.
EDIT: Well, for spark it'll be add or subtract from both. Keep dwell the same while changing timing. Fuel needs whatever is added to on delay to be subtracted from off delay to keep the end timing the same. If a change in EOIT is desired with change in RPM, it gets addressed in the big array.
I want my end result to rival the tunabillity of ECUs that bother to calculate grams per cylinder, while still being hobby racer friendly. Most of the friendliness will be sorted by whatever software (TunerPro, TunerStudio, something new) that I or somebody else end up making work for it, and the lack of complexity in the ECU itself.
Anyway, time to add IAT code. Going to make sure whatever is added or subtracted from on delay, gets inversed on off delay.
EDIT: Well, for spark it'll be add or subtract from both. Keep dwell the same while changing timing. Fuel needs whatever is added to on delay to be subtracted from off delay to keep the end timing the same. If a change in EOIT is desired with change in RPM, it gets addressed in the big array.
I want my end result to rival the tunabillity of ECUs that bother to calculate grams per cylinder, while still being hobby racer friendly. Most of the friendliness will be sorted by whatever software (TunerPro, TunerStudio, something new) that I or somebody else end up making work for it, and the lack of complexity in the ECU itself.
Last edited by AngelMarc on Sat Jun 14, 2025 9:47 pm, edited 6 times in total.
Don't stress specific units.
Re: Coding my own aftermarket ECU
Was wondering how to do an array of bytes as my fractional fixed point numbers while allowing negative values. Apparently simple answer is, you don't. So those arrays of 8 bit values will be stored as 32 bit values... whatever, moving on.
Debated with myself whether to do + and - for spark. Going to keep going with spark and fueling using the same code for everything. Multiply by a fraction.
https://www.youtube.com/watch?v=4qH4unVtJkE This guy's stuff has been quite a help with understanding the low level stuff.
Debated with myself whether to do + and - for spark. Going to keep going with spark and fueling using the same code for everything. Multiply by a fraction.
https://www.youtube.com/watch?v=4qH4unVtJkE This guy's stuff has been quite a help with understanding the low level stuff.
Don't stress specific units.
Re: Coding my own aftermarket ECU
Well damn.AngelMarc wrote: ↑Sat Jun 14, 2025 3:04 pm Was stabbing in the dark with includes.
Gives a drop down of options.
SeenCode: Select all
#include <mbed/platform/bare_metal/
Looking for those files now.
File explorer has been searching the Arduino15 folder for about 20 minutes now...
Don't stress specific units.
Re: Coding my own aftermarket ECU
I think I'll put out 3 versions.
One with everything maxed out and interpolated.
One maxed out but not interpolated.
And like 32x32 interpolated.
Anyway, going to make it easy to disable temp scaling if desired.
One with everything maxed out and interpolated.
One maxed out but not interpolated.
And like 32x32 interpolated.
Anyway, going to make it easy to disable temp scaling if desired.
Code: Select all
volatile int IATFuel [129] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
//Comment above and uncomment below to remove IAT scaling for fueling. range limit 8 bit +/- Look up fixed point decimal
//volatile uint8_t IATFuel [129] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
volatile int IATSpark [129] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
//Comment above and uncomment below to remove IAT scaling for spark timing. range limit 8 bit +/- Look up fixed point decimal
//volatile uint8_t IATSpark [129] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
Don't stress specific units.
Re: Coding my own aftermarket ECU
Yes he covers the concepts very well and easy to understandAngelMarc wrote: ↑Sat Jun 14, 2025 9:09 pm
https://www.youtube.com/watch?v=4qH4unVtJkE
This guy's stuff has been quite a help with understanding the low level stuff.
Re: Coding my own aftermarket ECU
If it's the same subject/question, E38 etc does negatives using 16 & 32 bit signed numeric for +/- 127 upward etc and then factors the value. Guessing you probably already aware & I am misunderstanding the question

Re: Coding my own aftermarket ECU
I don't know why the hell I thought I needed negative. Multiply by a fraction like .95 gives lower, 1.05 goes higher. Both equal 5% change.
At least this time wasn't most of a day like the logarithm stuff.
At least this time wasn't most of a day like the logarithm stuff.
Don't stress specific units.