Coding my own aftermarket ECU [beta available]

User avatar
AngelMarc
Posts: 243
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU

Post by AngelMarc »

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.
Last edited by AngelMarc on Sat Jun 14, 2025 9:44 pm, edited 1 time in total.
Don't stress specific units.
User avatar
AngelMarc
Posts: 243
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU

Post by AngelMarc »

For the hell of it, I tried again.
Arrays are 65 * 129 now.
I must have missed something before.
Noise looks the same.
Capture.PNG
Capture.PNG (27.64 KiB) Viewed 181 times
Memory usage is still fine.
zdsrgh.PNG
zdsrgh.PNG (10.99 KiB) Viewed 181 times
Replaced 600 with 300

Code: Select all

 uint32_t IndexFull_fixed = ((uint64_t)2500000 << 8) / ((uint32_t)RPMTimeavg * 300);
Don't stress specific units.
User avatar
AngelMarc
Posts: 243
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU

Post by AngelMarc »

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.
User avatar
AngelMarc
Posts: 243
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU

Post by AngelMarc »

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.
Last edited by AngelMarc on Sat Jun 14, 2025 9:47 pm, edited 6 times in total.
Don't stress specific units.
User avatar
AngelMarc
Posts: 243
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU

Post by AngelMarc »

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
Capture.PNG
Capture.PNG (34.49 KiB) Viewed 145 times
This guy's stuff has been quite a help with understanding the low level stuff.
Don't stress specific units.
User avatar
AngelMarc
Posts: 243
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU

Post by AngelMarc »

AngelMarc wrote: Sat Jun 14, 2025 3:04 pm Was stabbing in the dark with includes.
Gives a drop down of options.
Seen

Code: 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...
Well damn.
Capture.PNG
Capture.PNG (24.6 KiB) Viewed 133 times
Don't stress specific units.
User avatar
AngelMarc
Posts: 243
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU

Post by AngelMarc »

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.

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.
MPC001
Posts: 41
Joined: Sat May 05, 2018 9:41 pm

Re: Coding my own aftermarket ECU

Post by MPC001 »

AngelMarc 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.
Yes he covers the concepts very well and easy to understand 🙂
MPC001
Posts: 41
Joined: Sat May 05, 2018 9:41 pm

Re: Coding my own aftermarket ECU

Post by MPC001 »

AngelMarc wrote: Sat Jun 14, 2025 9:09 pm 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.
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 :think:
User avatar
AngelMarc
Posts: 243
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU

Post by AngelMarc »

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.
Don't stress specific units.
Post Reply