Controlling a pulsed digiital output with a tachometer input

OK so what I am trying to accomplish involves an Arduino Uno reading pulses from an ignition coil and then produces a variable pulsed digital output (that corresponds to the engine speed ) for the purpose of driving a solenoid lube oil pump .

I have an isolation module that converts the 120vdc + ignition coil primary pulse into an opto isolated low level 5 v pulses 10.833 PPS at idle speed increasing to 100 PPS at WOT .

The signal driving the oil pump must be "ON" for a 42 ms duration to get a forceful enough stroke to operate the pump piston followed by a pause .

I was planning on using constrained speed values at 11 different points based on the speed reference using the spark coil firing. I know these PPS transition points can't be expressed as tight as I've made them but this shows the gist of it .

pulses per second / engine RPMs

1 ( 10.833 - 16.65) 650 -1000 rpm
2 (16.66 - 24.99) 1000-1500 rpm
3 ( 25 - 33.32 ) 1500-2000 rpm
4 ( 33.33 - 41.66) 2000-2500 rpm
5 41.67 - 49.99) 2500-3000 rpm
6 ( 50- 58.33 ) 3000 -3500 rpm
7 ( 58.33 -66.65 ) 3500 - 4000 rpm
8 ( 66.66 - 74.9 ) 4000 -4500 rpm
9 ( 75 - 83.32) 4500-5000 rpm
10 (83.33 - 91.65) 5000 -5500 rpm
11 ( 91.66 - 100) 5500 -6000 rpm

  1. Pump "ON" 42 ms "OFF" 14634 ms continuous pulse train @650 -1000 rpm
  2. Pump "ON" 42ms "OFF" 6340 ms continuous pulse train @ 1000- 1500 rpm
  3. Pump "ON" 42 ms "OFF" 4000 ms continuous pulse train @ 1500 -2000 rpm
  4. Pump "ON" 42 ms "OFF" 1900 ms continuous pulse train @ 2000 -2500 rpm
  5. Pump "ON" 42 ms "OFF" 1268 ms continuous pulse train @ 2500 -3000 rpm
  6. Pump "ON" 42 ms "OFF" 872 ms continuous pulse train @ 3000 -3500 rpm
  7. Pump "ON" 42 ms "OFF" 634 ms continuous pulse train @ 3500 -4000 rpm
  8. Pump "ON" 42 ms "OFF" 576 ms continuous pulse train @ 4000 -4500 rpm
  9. Pump "ON" 42 ms "OFF" 529 ms continuous pulse train @ 4500 -5000 rpm
  10. Pump "ON" 42 ms "OFF" 487 ms continuous pulse train @ 5000 - 5500 rpm
  11. Pump "ON" 42ms "OFF" 453 ms continuous pulse train @ 5500 -6000 rpm

The 42 ms pulse to stroke the pump is a constant value while the variable delay between these 42 ms pulses will control the oil flow rate .

In hind sight I probably just should have drawn this up the first time to eliminate confusion .

Can you come up with a formula which gives pump speed(or oil flow) as a function of rpm?

How long us the pulse from the ignition?
If it's short interrupts are likely used.
Calculate the RPM and decide for the factor needed to control the oil pump.

Iā€™m guessing that it is not directly engine speed but engine revolutions. That is, every X revolutions you deliver a pulse, of a particular shape, to the pump.

The only reason an automobile engine oil pump increases oil pressure, flow, is for cooling. Do you have a cooling problem that requires a variable oil flow?

Yes I can this is a soleniod driven lube pump for a large 200 HP 2 cycle outboard .
Oil delivery is based on a negative curve increasing oil delivery as rpms increase starting at 100:1 and gradually increasing to 50:1 . I've got all of that part figured I just need to figure out the code to pulse (stroke) the pump . It has a 42 ms coil pulse duration required to get a full "positive " stroke out of the pump piston and the off time will vary dependent on lubrication requirements . At " Idle " engine speed lube oil requirement is 100: 1 which equates to 0.820 CC's of oil per minute . Oil pump output is 0.2 CCs of oil for each oil pump piston stroke so if the oil pump solenoid is energized 4 x within this 1 minute time period (approx . once every 15 seconds ) everyone's happy .

             Edited for clarity 


OK. So, for example, by 50:1 you mean every 50 revolutions of the engine there is one pulse of the oil pump ? ( Or is this a fuel to oil ratio ? )
Anyway, what is the maximum range RPM and is this a linear change throughout the entire RPM range ?
If it is linear, you can use the map() function to control the interval between oil pump pulses. If it is not linear, then you can use a table lookup or a series of if / then / else if / else statements instead, depending on the desired granularity.

No it is non linear ( 100:1 (Idle) through 50:1 (WOT) fuel to lube oil ratio @ 700 thru 6000 RPMs) There are individual spark coils for each cylinder so the pulse count range is 12 to 100 pulses per second input to the Arduino . I was looking at the switch case coding and thinking about creating 10-12 cases each representing a different constrained rpm range with an increasing pump rate up to the maximum fuel flow.

The Ign pulse module I bought cleans up the messy coil signal and will produce a short , clean 0 / 5 volt pulsed signal to the Arduino

Do you measure the fuel flow rate and do you know how much oil is delivered by one pulse of the pump ?

I'd say the rough solution could be something like this (pseudo code) if I've understood correctly

loop() {

  calculate RPM

  // calculate interval_between_pump_pulses
  if ( RPM < 700 ) interval_between_pump_pulses = 83 ; // 83mS = 12 pulses per second
  else if ( RPM < 1000 ) interval_between_pump_pulses = 50 ; // 50mS = 20 pulses per second
  . . . 
  . . . 
  else if ( RPM < 6000 ) interval_between_pump_pulses = 10 ; // 10mS = 100 pulses per second
  else interval_between_pump_pulses = 10 ;

  If ( millis() - lastPumpPulse > interval_between_pump_pulses ) {
     pulse pump
     lastPumpPulse = millis()


You may have difficulty here, though:

the pulse count range is 12 to 100 pulses per second input to the Arduino .

Yes, there is a contradiction. A 42 ms pulse length is 23.8 pulses per second. You need to resolve the contradiction.

If the 42 ms cycle time is correct and required, you can use a pwm library like TimerOne.h and vary the duty cycle at the 23.8 Hz frequency.

Alternatively you can create the pulse cycle with a millis() timer and set the on/off times like a "blink without delay" example where there are different on and off times.

The 42 ms pump pulse time needs to fixed I was hoping to control the oil flow amount based on increasing /decreasing the delay time between each pump pulse .

Then the 12-100 pulses per second specification must change. Is there a minimum off time between the 42 ms on periods?

Minimum "OFF" time between pump pulses will be at top engine RPM .
I am planning a test running the pump on the bench with free running 42 ms pulses timed at one per second for a timed duration to see how many CCs of oil it can pump and then calculating the pulse rates for each required "fuel to oil ratio" steps

I'm guessing also that the calculations of the number of oil pump pulses per second has to be reviewed.

Say the motor has a fuel consumption of 100 liters per hour. That is 28ml (milliliters) of fuel per second.
If the fuel/oil ratio is 100:1, that implies an oil consumption of 0.28ml per second
If you spread that 0.28ml over 50 oil pump pulses in that second, that is an incredibly small 0.0056ml oil delivered per pulse. There are about 30 drops in a milliliter of oil so that would be one fifth of a drop per pulse. I suppose that is closer to the performance of an ink jet printer!

Remember also that if the Arduino crashes, the motor seizes up.

Not sure what the volume of oil pumped per stroke is but the pump will be definitely be cycling slower the rotational pulses via the ignition coil module .

At Idle the engines lube oil demand = 100:1 ( 0.82 cc / .028 ounces per minute )
At WOT engine lube oil demand = 50:1 (26.533 cc / .897 ounces per minute )

If the lube pump's output is .25 ounce per stroke then 4 pulses in one minute will cover WOT demand . After I run my volume testing on the pump I can work up exact pump pulses per revolution . The pump I purchased to trial this idea is off of a newer outboard of same make and displacement so I know the pump is capable . My motor's ECU has no provision for driving an oil pump like the later models that I assume is probably sync'ed to the injector pulses for timing .

Since you mentioned injectors, fuel injectors, I guess. Where exactly is the oil pumped into? Directly into the cylinder, like the fuel, or ?

There is a vapor separator tank on the side of the plenum . It has a capacity 14 ounces of fuel and has the high pressure fuel pump feeding the injector fuel rail mounted inside . A vacuum assisted fuel pressure regulator mounted on top to dump fuel rail pressure back to this tank . There is a hose barb tapped into the bottom to feed oil from the pump in where it is picked up and mixed with fuel by the fuel pump .

Thank you for the explanation. So, there does not seem to be any back pressure for the oil pump, or very little.

very little there is a low pressure mechanical fuel pump that keeps the VST full .
there is a float /needle /and seat that maintains fuel VST fuel level . there is also a small check valve in the lube oil VST fitting.