To program output on and off

look this over
trying to verify what you want by giving you possible solutions

  • code measures time between events
  • updates a period by averaging
  • recognizes "sync" when time between events > 1.9 * period
  • generates "tdc" 5 events after "sync" (needs to be 17 ??)
         msec   msecLst   msecPeriod
   5:   2359    152    140
   6:   2659    145    141
   7:   2946    133    139
   8:   3251    150    141
   9:   3535    139    141
  10:   3828    148    142
  11:   4105    154    145
            sync
   0:   4751    483    229
   1:   5143    232    229
   2:   5434    151    210
   3:   5754    156    197
   4:   6027    126    180
            tdc
   5:   6312    132    168
   6:   6605    140    161
   7:   6904    151    159
   8:   7183    134    153
   9:   7474    135    149
  10:   7752    133    145
  11:   8030    142    145
  12:   8345    164    149
  13:   8625    132    145
  14:   8936    158    148
  15:   9222    142    147
  16:   9486    128    143
  17:   9801    171    150
            sync
   0:  10386    447    224
   1:  10727    193    217
   2:  11014    123    194
   3:  11323    171    189
   4:  11593    139    177
            tdc
   5:  11871    140    168
   6:  12177    142    162
   7:  12464    135    156
   8:  12735    164    158
   9:  13008    148    156
            sync
   0:  13463    332    200
   1:  13755    150    188
   2:  14071    
const byte PinOut = LED_BUILTIN;
const byte PinInp = A1;

byte inpLst;

const long MsecDebounce = 20;
      long msecLst;
      long msecInp;
      long msecPeriod;

char s [90];

// -----------------------------------------------------------------------------
const int Cnt = 5;
      int cnt;

void
loop (void)
{
    unsigned long msec = millis ();

    byte inp = digitalRead (PinInp);
    if (inpLst != inp && msec - msecLst >= MsecDebounce)  {
        if (LOW == inp)  {
            msecInp = msec - msecLst;

            if (Cnt == ++cnt)  {
                Serial.println ("            tdc");
                digitalWrite (PinOut, HIGH);
            }
            else if ((Cnt + 2) == cnt)
                digitalWrite (PinOut, LOW);


            if ((1.9 * msecPeriod) <= msecInp)  {
                Serial.println ("            sync");
                cnt = 0;
            }

            msecPeriod += (msecInp - msecPeriod) / 4;

            sprintf (s, " %3d: %6lu %6lu %6lu", cnt, msec, msecInp, msecPeriod);
            Serial.println (s);
        }

        inpLst  = inp;
        msecLst = msec;
    }
}

// -----------------------------------------------------------------------------
void
setup (void)
{
    Serial.begin (115200);

    pinMode (PinInp, INPUT_PULLUP);
    pinMode (PinOut, OUTPUT);
}

[quote="gcjr, post:15, topic:1342836"]

Could the Arduino output go high when is recognizes the 17th tooth in the gear and go low after 20th teeth ? And when 2 missing teeth is switching next injector bank.

Next injector bank is next engine revolution output go high when is recognizes the 75th tooth in the gear and go low after 78th tooth.

Cnt needs to change to 17 and

needs to change to + 3

the other issued is does this processing occur when the input becomes HIGH or LOW

I'm not going to play here and I'll try to not watch.

Anyone who wonders why can see

If you didn't know, now you know.

a7

This is diagram that shows and describes the relation between tooth number and IO pin On/Off

  1. Input pin 2 will read 116 pulses of the crankshaft reluctor wheel. Two engine revolution is 720 degrees of the crankshaft position. 720 degrees equals to 116 pulses or 116 teeth of the crankshaft reluctor wheel. One engine revolution is 360 degrees with 58 teeth or 58 pulses.
  2. Input pin 3 will be reference for injector bank 1 with injectors 6-2-4. Every time when cylinder number six fires that is the reference that injector bank is in TDC. The reference must be used for injector bank 6-2-4. If reference will be not provided then for an example one of the injector bank when go to exhaust and output pin goes high. Will be no performance. Injector bank must inject fuel when intake valve is closed.
  3. At start up by cranking starter the first engine revolution when injector bank 1 with 6-2-4 injectors referenced by voltage from 0.25-1.5 at 120 degrees or 20th tooth then that time coming revolution another injector bank with 1-5-3 injectors should be activated by output pin 10 at 222 degrees or at 75th tooth till 240 degrees or 78th tooth .
  4. Two missing teeth should be skipped every engine revolution. Otherwise could be also reference for to switch high or low coming injector bank.
  5. Cylinder number 6 makes the reference to input pin 3. Cylinder number six is related to the injector banks 6-2-4.
  6. First engine revolution at cranking starter at 120 degrees activated injector bank 2 pin 10 with injectors 1-5-3 at 222 degrees or 75th tooth till 240 degrees or 78th tooth.
  7. Second engine revolution is activated by output pin 9 at 102 degrees or 17th tooth till 120 degrees or 20th tooth for injector bank 1 with injectors 6-2-4.
  8. Here is the trick when injector bank with 6-2-4 injectors is activated at 120 degrees or 20th tooth then next engine revolution pulse width should not be activated at 222 degrees or 75th tooth till 240 degrees or 78th tooth for injectors 1-5-3 output pin 10 is not active.
  9. Next engine revolution pulse width should be activated by output pin 9 at 102 degrees or 17th tooth till 120 degrees or 20th tooth for injector bank 6-2-4 then next engine revolution pulse width should be activated by output pin 10 at 222 degrees or 75th tooth till 240 degrees or 78th tooth and so on loop.
  10. At start up only first engine revolution should be one injector bank with 6-2-4 injectors is not active because this is reference point after that referenced by input pin 3 then next engine revolution injector bank with 1-5-3 injectors should be activated by output pin 10.
  11. If you notice any mistakes on this diagram please correct it any time. Thanks in advance for your answer !

I see no diagram

Your post is much easier to read that the first one but from its contents this topic looks like it might be going in the same direction as your previous ones. Did you write it yourself ?

We are already 25 post in and seem to be making little or no progress towards understanding your problem and how to solve it

The problem is not solvable.
Looked at a Bosch FI block diagram there are several items related to the firing and duration of pulse from injector.
If the OP was going to do his own ECU with controls he would have a chance.

But my bets are on the cost to fix the M30 is above what he can afford so he is trying a hack work around.
But as I have said before trying to out engineer Bosch is not gonna happen.

These threads are proving that AI is not the cat's whiskers.

Yes I did write by myself.

I don't believe you. You convinced me that you are a troll. You continued for 300 postings in the other thread to ignore questions beeing asked and here you are again ignoring questions very consequently. You seem to have fun with trying to test how many trying to be helpful answers you can get with ignoring answers.

The other explanation is: You have such a big mental problem that you are unable to understand what your problem is.

I recommend to the moderators to ban this user for a week.
I recomend to all other users to put user @andrew1q on the ignorelist.

As a final advice: take another person that you like and that you trust. Show this person your two threads and make this person to explain to you what you are doing wrong in your threads. If this person is able to explain to you what you shall do come back with adequate postings.

I did not make drawing diagram yet. I am on my way to make a one more diagram. Which answer I did not answer remind me please ?

tips how to improve your posting style

where is the diagram?

I can’t make better diagram that is final diagram and simple as possible. Based on this information the programming code can be made.

No you can do such a diagram


you are just too lazy to draw one

@StefanL38 made a blank "60 tooth diagram" (it's huuuge!). I added your Input and Output pins. Add lines to show highs and lows above the tooth numbers.

does this illustrate what you're looking for?

red the output pulse, 17 teeth after the missing teeth for 3 periods
yellow, the missing 2 teeth
cyan represents the 60 possible teeth

Hi,

Is this system a two or four stroke?

Four stroke will need a camshaft sync to identify if TDC is about to become power stroke or inlet stroke.

Tom.. :smiley: :+1: :coffee: :australia:

Here are two questions you need to answer.

How will the throttle pedal control this?

How will you make motor run when you take fuel injectors out of system it is an integrated system.

Answer these if this project has any validity. If you can't you should stop wasting bandwidth.

  1. How will the throttle pedal control this system ?

M30 engine does not have camshaft position sensor. M30 engine runs on crankshaft position sensor only. Even running if cylinder identification sensor is disconnected.