Coding my own aftermarket ECU [beta available]

Post Reply
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 »

2,500,000 divided by RPTtime gets you RPM.
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 knew RPM scaling for array would be bad at one end, but after sitting down and doing a little math, holy hell. 6,000 is already at one end of table.
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 »

Apparently I need logarithmic scaling or exponential with a tiny fractional k value.
Attachments
9f80348f-15a6-4b9a-9ebc-ce1089826076.png
Capture.PNG
Capture.PNG (94.63 KiB) Viewed 245 times
Last edited by AngelMarc on Tue Jun 10, 2025 8:19 am, edited 2 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 »

Obnoxious.
The scale on the left should be output values 1-32, and the 'graph' section should be whatever input value.
Anyway, looks like exponential k=0.1 is good start. Maybe logarithmic is smarter.
Attachments
Capture.PNG
Capture.PNG (41.95 KiB) Viewed 237 times
Don't stress specific units.
User avatar
antus
Site Admin
Posts: 9002
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: Coding my own aftermarket ECU

Post by antus »

I don't quite follow. Are you counting each event from key on during engine run time then looking to calculate RPM from total event count divided by engine run time? What do you hope to achieve from this approach that you cannot do by just timing the speed of crank events?
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
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 »

The "input" numbers are microseconds per 15 degrees. That's where that divide by 2,500,000 came from.
Since that's what's counted to get sync, that's what the rest of the code uses. Minimal conversion math, minimal of... doing the same thing.
You either have 2 timers per cylinder and reset each of them per event to avoid timer overflow, plus whatever you need for the sync logic, or you have one timer with such a large overflow value that it isn't a problem, and just count your offset each cycle.

Those graphs are about measured microseconds per 15 degrees (RPMtime) pointing to which row of VE table. Need fancy scaling for that to not be... bad.
The conversion math.
https://chatgpt.com/share/6847ba68-6228 ... b7015287f4
The result of that divided by 24, because 1 tooth vs an entire revolution.

A layman's loose summary would be, one thing doubles while the other is just plus 1. Those 2 things can't line up well without a little extra work.
Last edited by AngelMarc on Tue Jun 10, 2025 4:10 pm, edited 4 times in total.
Don't stress specific units.
User avatar
antus
Site Admin
Posts: 9002
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: Coding my own aftermarket ECU

Post by antus »

Ahh I see :thumbup:
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
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 »

No luck with this SD card module either.
.... god damn it. Ever feel like life is a simulation on low settings?
Attachments
Capture.PNG
Capture.PNG (1013.68 KiB) Viewed 155 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 »

Guess I'm back to finding a free alternative to microsoft excel, and learning how to set it up to automatically do the right math to spit out the right number, and hope I can edit specific region like a tuner would expect.
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 »

Looks like I'll be learning google Sheets.

general UI for doing math- https://www.youtube.com/watch?v=9TVmdFtmbbo

WTF am I looking at UI... for doing math- https://www.youtube.com/watch?v=H-Pcrmt5eKw
Don't stress specific units.
Post Reply