Engine Simulator and Engine Control Unit

By the looks of it, lots of people have asked about this before and there's not so many people that have gotten far with it. I am working on a project to build a simple engine control unit for a single cylinder spark ignition gasoline engine.

I thought I would post some of my progress here in case anyone is interested, or has any comments.

I have no choice but to make this work because it's part of the final project for my masters degree, so I hope to produce something that people will be able to reuse.

In order to test the ECU when I'm not at uni, I've also built a simulator to run on a Texas Instruments Launchpad. I'm using the Arduino inspired development environment, Energia (http://energia.nu/). So in theory the code for that should be easily portable back to Arduino (everything is compatible except the timers).

Currently the engine simulator accepts a fuel pulse width and throttle position and calculates a torque produced under these conditions. A load torque and friction torque are subtracted from this and any remaining torque then produces an acceleration on the engine which provides the current engine speed. The simulator outputs a missing tooth pulse similar to that found from the crank position sensor on any engine. It also calculates an Air to Fuel Ratio from, and outputs this on a PWM port as a Lambda value.

The ECU currently reads the missing tooth pulse to determine the engine RPM, and crank position and then triggers a digital output for the timed fuel injector pulse and the ignition coil trigger. It reads the Lambda value on an analog input and uses this to 'close the loop' for AFR control and to determine the fuel injector pulse width for the next engine cycle.

I've got all this working so far just with the simulator, and the next step is to test it on the real engine.

If anyone is interested I can post the code to the ECU and simulator - but no guarantees about its safety or functionality!

I have some progress notes and more details available on my website http://www.scottsnowden.co.uk

Just an update for anyone interested...

I have now managed to run the engine with both electronic fuel injection (EFI) and electronic ignition, both controlled from my ECU. I’ve also managed to run in closed loop lambda control to maintain the correct air to fuel ratio.

Looks like I can't embed a video here, but here's a brief one of the engine running: Arduino ECU Electronic Igntion and Fuel Injection - YouTube

Hi, I was reading your post and got very interested because
i'm working with something like that on my final project and i'd
like to know if you can help me. I need to change the signals that are send from the ecu to the machine (Caterpillar) through the arduino. I designed a program in LabVIEW to control the PWM of the output to send the signals to the ECU but the arduino works with 0-5V, and the ecu needs more voltage to reach all measurement states. So i'd like to know what circuit can i do to amplify the range to 0-12V. I tried an op amp but not worked well.


Well, if it's just digital signals (like PWM), you should be able to use a transistor to switch 12 V on and off with a 5 V signals.

I'm not great with analogue electronics though, so I'm not sure I could suggest many other ways of doing it - I expect someone has got a much better idea than me for this.

Hi! Greetings from Argentina

i'm interested in the project.
I tried to access your web site (http://www.scottsnowden.co.uk) but it ask for a user and password......

Can you give me access?



Have you guys every looked at the megajolt and Megasquirt projects on the Autosportlabs site ?


Hi Hammy

Yes, I know very well the megasquirt project.
I Know the 3 best megasquirt tuners In Argentina. They are formers colleagues.
It's a interesting project!

What I'm interested is in a "Virtual Engine"
A device that can simulate the electric signals of a engine (CKP, CMP, lamba oxygen sensor, MAP) trough a mathematical model with toque , friction inputs