Coding my own aftermarket ECU [beta available]
Re: Coding my own aftermarket ECU
2,500,000 divided by RPTtime gets you RPM.
Don't stress specific units.
Re: Coding my own aftermarket ECU
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.
Re: Coding my own aftermarket ECU
Apparently I need logarithmic scaling or exponential with a tiny fractional k value.
Last edited by AngelMarc on Tue Jun 10, 2025 8:19 am, edited 2 times in total.
Don't stress specific units.
Re: Coding my own aftermarket ECU
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.
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 (41.95 KiB) Viewed 237 times
Don't stress specific units.
- 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
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
Re: Coding my own aftermarket ECU
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.
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.
- 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
Ahh I see 

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
Re: Coding my own aftermarket ECU
No luck with this SD card module either.
.... god damn it. Ever feel like life is a simulation on low settings?
.... god damn it. Ever feel like life is a simulation on low settings?
- Attachments
-
- Capture.PNG (1013.68 KiB) Viewed 155 times
Don't stress specific units.
Re: Coding my own aftermarket ECU
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.
Re: Coding my own aftermarket ECU
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
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.