The ECU which I am developing is an embedded real time system which is designed to control a single cylinder spark ignition fuel injected gasoline engine. There are a number of ways to approach developing this type of system, and a mixture of these are likely used in industry
- Develop code on the embedded device and continuously test on the engine
- Develop code all in one go on the embedded device and perform a final test on the engine (you would have to be pretty confident in your code for this to be worthwhile)
- Create an engine simulator in software on a PC and write your ECU software on the PC to control it, then program the ECU to an embedded device to test on a real engine
- Develop model based code in software like Matlab Simulink, build an engine simulator and ECU separately in the software, then program it to a ‘target’ to run on an embedded device
- Develop an engine simulator on an embedded device and develop the ECU on an embedded device to control it
I’m going with the last option.
This allows me to see things happening in real time on the device which I am actually going to use for my ECU, and is as close to testing with a real engine as I can get at home. I plan on developing the engine simulator to model the real engine as accurately as possible so that I can ensure that my ECU works as expected before even trying it on the real engine.
Currently, I’m using a Texas Instruments Stellaris Launchpad as an engine simulator. I am programming this using an Arduino style IDE called Energia which allows very rapid development, although limits control over the hardware a little. The Stellaris Launchpad is based on an MSP430 micro controller, and has a wide variety of interfaces, analogue inputs, analogue outputs and GPIO pins.
For the ECU I’m using an Arduino Mega 1280 clone (Roboduino). Again, this has a wide range of inputs and outputs, with something like 50 GPIO pins. Although using an Arduino means that development is abstracted an additional layer away from the hardware, it does allow for very rapid development of embedded systems. The first objective of this project is to develop a working ECU, and an Arduino is probably one of the quickest ways to get there. Low level hardware and register control is still possible, and even necessary for some elements of development (timers for example) and I intend on moving to more powerful architectures later on in the project. I have done some development with a Freescale PowerPC, and already build an ECU in this architecture, but development is not quite as quick as with an Arduino.
So far, I’ve achieved the following:
- Engine simulator
- Engine simulator calculates engine speed and torque from throttle position and load. It outputs a missing tooth pulse waveform corresponding to the engine speed.
- It receives a fuel input pulse and measures the length. It uses this to calculate the corresponding Air to Fuel Ratio. The AFR is used to calculate a lambda value, which is then output on an analog output pin for the ECU to read.
- The AFR affects the maximum torque output of the engine
- ECU can detect missing teeth in the crank angle sensor wave form and keep track of crank angle in 6 degree resolution (will probably improve this to 3 degree or greater)
- Calculate engine speed from crank angle sensor
- ECU outputs a fuel pulse with variable duration and timing
- Output an ignition pulse with variable duration and timing
- Lambda feedback control of fuel pulse width