Pulse generator + Counter for fuel injector control

Hey everyone.

I have been reading and studying Arduino for a bit since I need means of automating my bachelor's thesis, electronics is not my field of study. I will briefly explain it so the function of the device becomes clear.

The idea is to control one fuel injector (similar working principle of a solenoid) in a way to make counted injection numbers to obtain a fuel volume eg. Cycle 1 would have 10000 injection events that last 4ms each. Cycle 2 would have 5000 events that last 8ms each. After each injection cycle, the device will wait for 10s for the measuring device (5kg load cell) to stabilize and take a reading from it.

The power management part of the switching will be made with an IRLZ44n MOSFET.

The issue I'm facing right now after reading a bunch about interrupts, millis function, and trying different approaches is being able to emit accurate pulse widths to open the injector while also measuring the injection counts within the Arduino to precisely control the number of injection cycles performed.

After trying out different approaches, it seems like adding lines of instruction, at times, reduces the accuracy of the pulse width (currently measuring with a scope). With simple instructions, it seems like I get pretty decent pulse widths (within 2.00ms to 2.1ms). When I enable the other lines of code I had in place in order to measure frequency, period and calculate the available time, also using a virtual rpm to recreate the injection speed of a running motor, the code seems to "slow down" and make the 2ms pulse become a 2.4 ms pulse. Since I'm running many injection cycles in order to measure injected fuel mass, a small error in pulse-width would mean a big error in the total mass.

The actual question I have is:

How can I accurately demand pwm pulses with varying on/off times while also providing feedback to the Arduino in order for the device to be able to count the injection pulses and take actions based on them?

Thanks in advance for any help.

You mentioned it all yourself:

  • use the PWM hardware for the pulses
  • poll or use a timer interrupt to count the emitted pulses
  • take action in loop() when the desierd pulse count is reached

The TimerOne library may help with the PWM setup. In a timer PWM mode the timer prescaler and TOP value determine the PWM frequency and the OCRx controls the pulse width on the related output pin.

1 Like

Hint: Do not use the delay() function it blocks your code until finished.

If you are the one controlling the injector why do you need to measure it? You already know what you told it to do, just log what you told it to do.

Might be worth a read around the subject - there are ignition/fuel injection systems around based on Arduino and the mega squirt system.
On cars the MPG calculation comes from knowing the pulse length and hence volume of fuel delivered by the injectors .

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.