Arduino as a fuel injection controller?

I was discussing with a friend the feasibility of using an Arduino as a fuel injection controller. The argument was that the code for the arduino is limited by milliseconds and a proper fuel injection assembly would need to be operated in fractions of a millisecond.

For instance, at idle an injector might fire for 1.5 milliseconds but at full throttle it would need to fire at 6.7 milliseconds. Now, those numbers could be rounded but that would result in wasted fuel or performance.

Is there a way around the millisecond restriction?

Bittsen:
The argument was that the code for the arduino is limited by milliseconds.

That’s a spurious argument - there is no such limitation. The problem that will make this project difficult / impractical is that the Arduino has extremely limited processor speed, SRAM and program memory. An EFI controller would have to be designed very carefully and optimised to minimise the resource requirements to run an engine at all well, and the sort of complexity that a modern ECU provides to provide a tractable, efficient and fault tolerant engine would be out of the question.

PeterH:

Bittsen: The argument was that the code for the arduino is limited by milliseconds.

That's a spurious argument - there is no such limitation. The problem that will make this project difficult / impractical is that the Arduino has extremely limited processor speed, SRAM and program memory. An EFI controller would have to be designed very carefully and optimised to minimise the resource requirements to run an engine at all well, and the sort of complexity that a modern ECU provides to provide a tractable, efficient and fault tolerant engine would be out of the question.

Good to know. But, why can't the arduino handle it? Each pulse trigger would be individual. In the simplest terms it would be "If signal one=1 then output signal for 2.4ms" And then there would be other variables.

I'm not arguing with you but trying to understand.

P.S. The fuel injection system would be for an older car. The only real variable would be a resistor ladder or two on the airflow and the throttle position.

Bittsen: But, why can't the arduino handle it?

That depends what 'it' is and in particular how complicated 'it' is, but the limiting factors will be that you have limited code space, working memory and processor speed, and that will severely limit the complexity of the features that can be implemented on the Arduino. If you only want an extremely simplistic pulse generator then that is certainly possible, and I'm quite sure you could implement a good enough engine management controller to run the engine. But I suspect you will find that to run the engine well will take more complexity than you imagine. There's another thread in progress at the moment about somebody who's developing a sequential EFI controller and perhaps you would like to collaborate on the problem. However, I do suggest that you download the Megasquirt software before you put too much effort into this, and get a feel for the complexity involved in even a fairly simple aftermarket EFI controller. Also remember that implementing the runtime part of the software is only part of the problem - you also need to provide ways to view and change the configuration, and have some way to understand what it's doing while the engine is running and why, so that you can fix it. That will probably bring in some requirements for data logging, a user interface for visualising the data logs, a way to view and edit the configuration, and so on. Just the user interface for that will represent a lot of effort.

You are the second person to mention the megasquirt software to me. I find that interesting.

I don't think I'm looking for a tunable, on the fly, system. The need for a user interface isn't important. Just the function. If I needed to tweak it I'd just bring out a laptop and decrease or increase pulse widths based on what I gather from the smell of the exhaust, the look of the spark plugs and the feedback from the buttdyno.

Check out megasquirt. It uses a much more substantial processor than the humble atmega in an arduino. The problem is that EFI is essentially a giant mapping table - given X,Y,Z inputs, how do I change A,B,C outputs. To handle that number of variables will just take up more memory than an Arduino can muster.

If I needed to tweak it I'd just bring out a laptop and decrease or increase pulse widths

That only works if your system is steady state (say perhaps a generator), but an automobile is faced with ever-changing demands for power based on your right foot, the terrain, current vehicle speed, air density, and a host of other factors.

Unless your EFI controller implements a control algorithm that matches the actual behaviour of the engine pretty well, you will find that in practice the empirical tuning approach you describe becomes unworkable because you can only ever tune the engine under specific conditions. For example, most engines will have transient characteristics that affect the fueling requirements when the engine parameters such as load or speed change. If your algorithm doesn't reflect the transient behaviour then in order to correct the fueling under transient conditions you will need to compromise it under steady state conditions. As another example, if your EFI controller doesn't measure and compensate for supply voltage changes then the delivered fuel will vary as the supply voltage varies. If you tune the map to improve one scenario, it will make it worse in other scenarios. Similarly for fuel temperature, and air temperature, and ambient pressure, and so on and so on. You have to not only provide an algorithm to reflect all these parameters, but also the algorithm must be a fairly close match to the engine's actual fueling requirements.

As an example, aftermarket EFI controllers typically provide several different algorithms for controlling enrichment based on throttle transients and you need to choose the appropriate algorithm to suit the behaviour of your engine, and then configure the parameters of that algorithm to match your engine. Unless you get all that right, the engine will go out of tune during throttle transients.

Making an engine run shouldn't be hard. This is the EFI equivalent of tipping a cup full of fuel into the air intake while you play with the throttle to keep it running. Making the engine run well, so that it is tractable and economical, is much harder. Then making the engine fault tolerant is much harder again. The amount of work involved depends what your ambitions are. If you are looking for a road car that drives reasonably well and is comparable to a well set up carb, that is going to be a lot of work to create and tune, and the limited resources of the Arduino will make it harder to do. No doubt you can overcome those limitations if you are clever enough and put enough effort in, but before you invest too much time or money in this approach you really ought to try to understand how other aftermarket systems tackle this problem and get a feel for the complexity and development effort involved. The aftermarket systems I've used have been extremely simple and naive compared to even quite basic OEM systems, by the way. Solving this problem well takes man-decades of work, and far more resources than an Arduino.

Plus I think the OPs perspective is attempting to be minimalist as if the Megasquirt people are trying to be something huge. That's not the case. Don't get me wrong, Megasquirt has become VERY good, but not at the expense of moving to high end hardware. It's quality hardware, but it has every intention of being as reasonably inexpensive as possible.

There's simply no reason to try to reinvent that wheel that I know of. Their hardware is good, it's probably pretty close to as minimal as you can get away with if you want the engine to do more than chug badly at idle, and it's completely open source already.

--Donnie

Hi, Just wanted to say that I'm also interested in producing an simple ECU although my goals may differ somewhat from yours. I'm a classic vehicle enthusiast and we may well have to deal with fuel that's incompatible with old cars and bikes in the near future. A small change to the makeup of fuel at the pump will leave many carburated aircooled engines unusable. Some older vehicles have complex engine management requirements and it may be difficult to fit additional sensors. I'm stuck with an inline 6 motorcycle with little chance of fitting a cam sensor for example. There is also a strong cost incentive, Megasquirt is relatively expensive. 300GBP plus for the electronics alone. I would like to see a simpler, smaller and cheaper system out there.

This has been done before Chris Jeffries' MyECU replaced the early Ducati/Guzzi V Twin injection/ignition using a single ATMega32 with just three hardware counters! MyECU started as an open loop EFI although I think it can now use a lambda sensor. John Wilson's Intelligent Ignition System ran from two low spec controllers. Both of these were built for difficult engine configurations. Both Moto Witt's DMC and the Sachse ignition are well established but are expensive and have design compromises I'm not happy with. You can even buy a PIC based ignition for old Velocettes. Kawasaki and BMW produced combined fuel injection and ignition ECUs for sixes and triples in the 80s. Ignitech produce what is probably the most economical system with any sophistication. There is some published code for Arduino ECUs on the web.

https://bitbucket.org/SSnowden/project-arduino-ecu/src http://sourceforge.net/projects/arduems/ http://www.reddit.com/r/arduino/comments/1r12bz/arduino_based_engine_management_fuel_and_ignition/ https://plus.google.com/communities/116690526903390830631/stream/ec9be727-6318-421e-b997-22c1c9225721

I'm listening to the message about the limited resources of Arduino and expect to have to either move onto a more powerful platform and program in low level C. What about the Arduino Due or the ST Nucleo?

It would be great to have a simple open source DIY ECU based on off the shelf open source hardware.

The timing requirements of an engine mean you'd have to use direct control of the hardware counters. You need enough counters and you need enough resolution. If you are going to use interrupts then the response time is critical. Slow response is manageable if it is a constant.

From a personal perspective I'd just like to improve on what I've got. I believe Ignition timing needs to be far more precise than fuel injection timing so I'm starting with ignition timing using a simple custom crank sensor. If I can mimic a simple multiple linear ramp bob weight advance mechanism I'll be improving on the vile Bosch BTZ ignition units fitted to my bike at the moment. The BTZ jumps to full advance at about 2,300rpm and there are three independent mismatched units all doing this at +/- 50rpm which makes for a jerky transition. There are no accelerator pumps in the three worn out slide carbs and no vacuum advance on the ignition. Despite this the 900cc bike returns 50mpg (imperial) and runs quite well when warmed up.

Taking the benchtop demonstration to the bike is going to be hard, noise is going to be a big issue. The hardware may not be rugged enough mechanically either.

Next would be a rev limiter, missing tooth crank sensor decoding, open loop batch fire injection, followed by knock sensors, close loop EFI, idle control, sequential injection and so on. Tackling the project as a progressive task with clear benefits at stages along the way should mean it's not a complete waste of time.

Any comments most welcome

Chris

Sorry to drag up an old thread, but I thought I'd reply in case there was still any interest here.

I'm the author of the Speeduino project (https://github.com/noisymime/speeduino) which is aiming to develop a fairly feature complete ECU/EMS system based on an Arduino Mega. It is starting to reach a reasonable level of maturity and is being tested across a variety of engines. It is a 'proper' EMS in that it controls fuel and ignition based on true interpolated 3D maps rather than simply being RPM based. It also has things such as 2D warm up and acceleration enrichment tables, TPS or MAP based load calculation, rev limiting etc.

All the tuning and configuration is through Tuner Studio so there is a proper interface to everything.

It's not a finished product by any means, but we're always on the look out for anyone who is interested in this sort of project

I want to use an arduino to control a single fuel injector in a single throttle body, map sensor, throttle position sensor and possibly an O2 sensor after warm up to adjust fuel trim. I will have a single crank position sensor when the piston is at TDC (which also triggers ignition module and I am not going to remove that). I want to build this system as simple as possible, it is on a V-twin 750 virago 1982 model, the waste spark system will be fine as it will provide the signal to fire the injector for each cylinder just a little early for the rear cylinder.

I guess I am looking for advice on writing the code or if someone has already put a sketch together for something like this I am hoping you will be kind and share it, thanks much. torque63@gmail.com