Coding my own aftermarket ECU [beta available]

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

Re: Coding my own aftermarket ECU [beta available]

Post by AngelMarc »

Missed a ";" in an "if" that Pico apparently didn't care about.

Code: Select all

   currentOffDelay4 = Scaled3;//On time after off time
    if (RPMTimeavg > 125000){
      Scaled3 = 0; //Fuel off if RPM below minimum = 20RPM
    }
Then a replace all. A space on the end of each of those by the way.
Yes, those visible typos were fixed after copying back to IDE.
Capture.PNG
Capture.PNG (29.03 KiB) Viewed 219 times

Then added the "UL" markers on this constraint.

Code: Select all

RPMTimeavg = constrain(RPMTimeavg, 261UL, 125000UL);

Haven't tested yet, but it compiled.
Capture1.PNG
Capture1.PNG (16.47 KiB) Viewed 219 times

Don't know if it has a 64 bit timer for micros(), so it may be a had idea without extra work.
Don't stress specific units.
User avatar
AngelMarc
Posts: 246
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU [beta available]

Post by AngelMarc »

ohhhh fuck...
Shouldn't have updated original post without testing on Pico.
Luckily I saved a copy. That was before the rev limiter addition.
It'll be a minute.
Last edited by AngelMarc on Mon Jun 16, 2025 10:09 pm, edited 1 time in total.
Don't stress specific units.
User avatar
AngelMarc
Posts: 246
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU [beta available]

Post by AngelMarc »

Fixed. Compiles for Teensy without braking Pico.
Haven't tested teensy and don't plan to any time soon.
the ";".
"UL" in the RPM averaging, rev limiter, and constraint line.
Backup had the rev limiter but not the 20RPM minimum.
Added that to backup.
Double checking those features now.
Don't stress specific units.
User avatar
AngelMarc
Posts: 246
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU [beta available]

Post by AngelMarc »

Rev limiter is broken.
Don't stress specific units.
User avatar
AngelMarc
Posts: 246
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU [beta available]

Post by AngelMarc »

Silver lining, my dumb ass broke it with the low RPM cut earlier.
error.PNG
error.PNG (42.49 KiB) Viewed 182 times
AI fixed it...
fix.PNG
fix.PNG (33.85 KiB) Viewed 182 times
Didn't add the high RPM fuel cut.
Retested and measured high cut.
highcut.PNG
highcut.PNG (55.99 KiB) Viewed 182 times
Low works too. Had to manually count time per division at such low speed.
lowcut.PNG
lowcut.PNG (55.53 KiB) Viewed 182 times
Don't stress specific units.
User avatar
AngelMarc
Posts: 246
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU [beta available]

Post by AngelMarc »

Clearly I need to go back to putting updates in most recent comment and leave the original post alone.
After that test, I updated original post and verified it at least compiles for Teensy.
Don't stress specific units.
User avatar
AngelMarc
Posts: 246
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU [beta available]

Post by AngelMarc »

God damn it. had to fix low RPM fuel cut too.
Don't stress specific units.
User avatar
AngelMarc
Posts: 246
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU [beta available]

Post by AngelMarc »

What a way to start my morning.
But it's fixed, updated original post.
Compiles for Teensy 4.
Capture.PNG
Capture.PNG (35.65 KiB) Viewed 174 times
And the constraint for indexing the array was set above zero, to same value I wanted to cut fuel; so it was never "less than".
Last edited by AngelMarc on Mon Jun 16, 2025 7:44 pm, edited 1 time in total.
Don't stress specific units.
User avatar
AngelMarc
Posts: 246
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Coding my own aftermarket ECU [beta available]

Post by AngelMarc »

Without updating original post, I'm going to look into adding -
"keyed" on off, because just cutting power to fuel or spark causes unpredictable spark timing or lean condition. You'll want to be able to stop without blowing the engine if your throttle sticks open or something, or a nitrous leak, or whatever.
a fuel relay trigger, prime and if engine stops it shuts off, leaky injectors happen. Nobody likes hydrolock.
an alternator trigger, because duh.
and the external correction input for fuel and spark, people like they're widebands. The datalogger I eventually make should be able to calculate a desired difference. And transmission torque reduction, and whatever add-on people might make for some, idk, drag racing timed spark retard/2 step, without needing to make an entire ECU for it.
Last edited by AngelMarc on Tue Jun 17, 2025 8:22 pm, edited 1 time in total.
Don't stress specific units.
MPC001
Posts: 41
Joined: Sat May 05, 2018 9:41 pm

Re: Coding my own aftermarket ECU [beta available]

Post by MPC001 »

Kudos :thumbup:
Post Reply