ardu_stim help

They go by many names, P01, P10, P12, P59, E38, VPW, '0411 etc.
User avatar
AngelMarc
Posts: 613
Joined: Sat Apr 08, 2023 11:23 am
cars: A CB450 running to 8,000RPM with a P59.

Re: ardu_stim help

Post by AngelMarc »

Big ‘G’ wrote: Thu Sep 11, 2025 2:07 pm Thanks for the wiring visual marc. mosfet tc 4420 and tc 4452v share the same pinout, that said i'm wired up exactly the same as you. looking like mpc001 may be correct about the waveform, possible error in code? guess i'll have to find me a scope
With my sim code, check cam signal phasing. It might be setup how I wanted for my ECU code.
Untitled.png

Double check in case I'm misremembering.
If it's exactly that, shift the cam array to the right 3 digits.
There was also something I dealt with where high would output a low on certain MCUs. In that case you either use the inverting driver, or invert the high and low in code.
You do not have the required permissions to view the files attached to this post.
Don't stress specific units.
User avatar
AngelMarc
Posts: 613
Joined: Sat Apr 08, 2023 11:23 am
cars: A CB450 running to 8,000RPM with a P59.

Re: ardu_stim help

Post by AngelMarc »

MPC001 wrote: Thu Sep 11, 2025 7:06 am
AngelMarc wrote: Thu Sep 11, 2025 5:01 am
MPC001 wrote: Thu Sep 11, 2025 4:56 am Larger buffer/array to hold the entire 2 turns of the crank
Well, that much I already did. Believe we had a conversation about it. You weren't sure why there were 48 entries in the array.
Still love to see how the logic got simpler.
240 cell buffer/arrays for 24X or 58X. This is 24X.

Code: Select all

int crank[240]  = {0,0,0,0,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,
                   0,0,0,0,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,0,0,0,1,0,0,0,0,1,
                   0,1,1,1,1,0,1,1,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,
                   0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,
                   0,0,0,0,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,
                   0,0,0,0,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,0,0,0,1,0,0,0,0,1,
                   0,1,1,1,1,0,1,1,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,
                   0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1
                   };

int cam[240]  =   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
                   };

void loop() {

if(micros() - origtime >= period) {
    difftime = micros() - origtime;
    digitalWrite(PIN_CRANK, crank[tooth]);
    digitalWrite(PIN_CAM, cam[tooth]);
    
    if(tooth != 239){
        tooth += 1;
      } else if (tooth == 239){
        tooth = 0;
      }
	origtime = micros();
    }
    }
    
I'm not seeing it. If you did a toggle of output, that should be easy enough to just add degrees of resolution without too much change to the overall logical concept. 1 = edge, so toggle, 0 = no change.
EDIT: Oh array equals high or low, not the time for each high and low. I got it, OK. And you're doing the high/low in 1/5 of total toots increment, where as I did 1/3.
Don't stress specific units.
MPC001
Posts: 186
Joined: Sat May 05, 2018 11:41 am

Re: ardu_stim help

Post by MPC001 »

AngelMarc wrote: Fri Sep 12, 2025 4:26 am
I'm not seeing it. If you did a toggle of output, that should be easy enough to just add degrees of resolution without too much change to the overall logical concept. 1 = edge, so toggle, 0 = no change.
EDIT: Oh array equals high or low, not the time for each high and low. I got it, OK. And you're doing the high/low in 1/5 of total toots increment, where as I did 1/3.
Yes the array is tooth/logic high or tooth/logic low - 3 crank degrees each. I found it easier to visualize & juggle in my head. I also tried 480 cell arrays for extra rez/fine tuning but ran out of Nano RAM :hmm: . Thought of recoding & putting the arrays in flash but couldn't be bothered - it was late. Probably lose as much in processing as gained in rez. Crank/Cam correlation mostly good but gets the odd error 58x/4x. (maybe from the CLI speed change gap when rpm zeroes & bounces back.)
User avatar
AngelMarc
Posts: 613
Joined: Sat Apr 08, 2023 11:23 am
cars: A CB450 running to 8,000RPM with a P59.

Re: ardu_stim help

Post by AngelMarc »

One of my favorite parts of the Pi Pico, you have to try to waste RAM to go through it all. Best thing to result from mycropython, just don't use that bloated crap and you get plenty of resources. Great for fat arrays. If I ever get tuning software made, I'll use it all and have people shitting themselves over the size of the VE table.
Don't stress specific units.
MPC001
Posts: 186
Joined: Sat May 05, 2018 11:41 am

Re: ardu_stim help

Post by MPC001 »

AngelMarc wrote: Fri Sep 12, 2025 8:16 am One of my favorite parts of the Pi Pico, you have to try to waste RAM to go through it all. Best thing to result from mycropython, just don't use that bloated crap and you get plenty of resources. Great for fat arrays. If I ever get tuning software made, I'll use it all and have people shitting themselves over the size of the VE table.
Thank you for the tip. Will plug in a Pico. Would like to try and get the 24x as jitter free as 58x.

Do you use the VE table to directly control fuel flow from MAP & RPM? Assuming SD & no MAF.
User avatar
AngelMarc
Posts: 613
Joined: Sat Apr 08, 2023 11:23 am
cars: A CB450 running to 8,000RPM with a P59.

Re: ardu_stim help

Post by AngelMarc »

MPC001 wrote: Fri Sep 12, 2025 8:31 am
AngelMarc wrote: Fri Sep 12, 2025 8:16 am One of my favorite parts of the Pi Pico, you have to try to waste RAM to go through it all. Best thing to result from mycropython, just don't use that bloated crap and you get plenty of resources. Great for fat arrays. If I ever get tuning software made, I'll use it all and have people shitting themselves over the size of the VE table.
Thank you for the tip. Will plug in a Pico. Would like to try and get the 24x as jitter free as 58x.

Do you use the VE table to directly control fuel flow from MAP & RPM? Assuming SD & no MAF.
Yes, VE only. No MAF, no plan for MAF. Could go 200 by 128 if I really wanted to, but need a table editor for that to not take all day to adjust, so it's 17x17 right now.
max resolution would remove need for bilinear interpolation, so that might get cut too. Well, I'd release with and without and let people test for themselves if they want it.
And to be more precise, it's MAP sensor voltage and RPM, no need for in depth changes to support whatever BAR MAP sensor... An infinite boost OS; Pick your MAP sensor and get to it. Should adapt my code for diesel use; those guys get crazy with the boost.
Don't stress specific units.
MPC001
Posts: 186
Joined: Sat May 05, 2018 11:41 am

Re: ardu_stim help

Post by MPC001 »

MPC001 wrote: Fri Sep 12, 2025 8:31 am
AngelMarc wrote: Fri Sep 12, 2025 8:16 am One of my favorite parts of the Pi Pico, you have to try to waste RAM to go through it all. Best thing to result from mycropython, just don't use that bloated crap and you get plenty of resources. Great for fat arrays. If I ever get tuning software made, I'll use it all and have people shitting themselves over the size of the VE table.
Thank you for the tip. Will plug in a Pico. Would like to try and get the 24x as jitter free as 58x.
Plugged in the Pico, yes buckets of RAM now :). 480 cell arrays fit easy.

Slight improvement in jitter @ 7-8k rpm on 24x running at 200Mhz & using nanosecond counter resolution.
User avatar
AngelMarc
Posts: 613
Joined: Sat Apr 08, 2023 11:23 am
cars: A CB450 running to 8,000RPM with a P59.

Re: ardu_stim help

Post by AngelMarc »

Cut to the chase and just do 720.
If I can do multiple 128x128 arrays... 16,384
... you have enough. Stock clock speed will be fine; might even be better for microsecond.
Whatever clock speed you do, just make sure it's clean whole number of clock cycles per microsecond for best results.
Don't stress specific units.
MPC001
Posts: 186
Joined: Sat May 05, 2018 11:41 am

Re: ardu_stim help

Post by MPC001 »

AngelMarc wrote: Tue Sep 16, 2025 5:22 am Cut to the chase and just do 720.
If I can do multiple 128x128 arrays... 16,384
... you have enough. Stock clock speed will be fine; might even be better for microsecond.
Whatever clock speed you do, just make sure it's clean whole number of clock cycles per microsecond for best results.
Good points thankyou 👌. It's amazing what GM does with 40Mhz in an E38. FYI 200Mhz is now "stock" for Pico apparently.
User avatar
AngelMarc
Posts: 613
Joined: Sat Apr 08, 2023 11:23 am
cars: A CB450 running to 8,000RPM with a P59.

Re: ardu_stim help

Post by AngelMarc »

i think for the Pico 2 (RP 2350)
Don't stress specific units.