moonraking.com

SJDi blog

Diesel Engine ECU
↑↓
18 December 2008 Up and running again!
The project is up and running again. Now this time with some injector drivers built by John, although there is a part or two missing from high voltage power supply).

Also I have invested in a new oscilloscope a Rigol DS1062CD. Its good as far as I can tell, it has 2 channels and 16 digital channels which are very handy. I am happy with it. I have experimented a little with the ECU signals on a Seat/VW TDI engine, not a common rail but with an injector pump which is controlled by the ECU. Maybe another project for the SJDi ECU someday, but I will need a few more bit of electronics to condition the crank speed sensor, govener position sensor (which is very clever and is described in Bosch's book).

So I have got the Emultor and the ECU up and running again, and i can watch the signals with the digital I/Os on the oscilloscope. My next step is to fiddle with the ECU software to allow me to sync the crank sensors and cam sensors on the real enigne. No doubt oscilly will help. Some Tipex and some LEDs will also help.
27 March 2008 Where am I?
Its a question long pondered by the great philosophers and answered by the not so great. More will be reviled in the next day or so.
20 March 2008 Information is knowledge
What have I found out:
I had a few questions about the engine I needed answered about injector currents and fuel regulation currents and how the fuel pressure sensor worked. So I went on the hunt for some information....
A gentleman called Barry McCooey from McCooey Engineering in the U.K. put me in touch with another gentleman called Gavin Merivale who is a Bosch Diesel Master Technician and also Bosch Diesel Systems Regional Trainer. Gavin explained about how the fuel pump works and is regulated and also some information on the fuel pressure sensor, and on the current used to drive the injectors. I will not divulge to much information and I will say that this information can be found in the "Bosch ESItronic database" and a books similar to "Diesel-engine Management" by Robert Bosch GmbH. I have invested in a copy of volume 4 and await delivery (the suspense is killing me). The information also confirmed my progress on home detection. Although one quite obvious thing I had not thought of was that when starting I cant inject fuel until a certain amount of pressure is in the fuel rail.

What does it mean for hardware:
1. I will have to add a more accurate ADC to the board in order to watch the fuel pressure sensor, which conveniently enough has a linear relationship between fuel pressure and the signal voltage, another reason for the ADC is the fact that the sensor outputs up to 5volts and the on chip ADC's are not capable of converting over 3.3volts reliably. I will also have to make some logic circuitry, AND gates, to combine outputs from the CPU.

2. The route me and John were taking with the power supplies for the injectors will work (although not nearly as efficiently as Bosch, explained a little better here), my little ECU just has to make the correct PWM signal to limit the current. The just part being that each injection has two stages first limiting current to 20amps(openage) and then to 12amps(non-meltage).

3. Fuel pressure regulation also needs to by controlled by PWM, although this is not a new problem, there is a new thing to worry about, and that is that if for some reason the circuitry fails to supply enough/any current to the controlling solenoid the pump will pump maximum pressure, the more current the less pressure. I think AUDI have a pump setup that works the opposite way.

What does it mean for software:
1. The fuel pressure sensor, have to figure out how the SPI bus works... Juice stuff... The software will have to change the duty cycle on the pressure regulator, another PWM output from the board.

2. I have been mulling this over in my mind a lot and I have been changing code forward and back as I have been thinking of the nicest solution. My problem is one of injection, do I tie up the CPU while injecting or how do I not have to tie it up? Its all in the match registers. To begin with I had four match registers, one for each cylinder, I switched the Match pin on to light the LED/injector and the match was set to trip off the LED at a pre calculated time. This worked beautifully. Then I realised that the injector needed to be PWMed, so I was going to tie the processor up in generating the signal in real time (yes how wrong does it sound!), this is not a cool solution, but it worked for testing my timing and home finding algorithms. FYI at 5000RPM (more then a diesel will ever be required to run) there is 12,048 clock cycles between each injection. So I think the nicest solution is to have 4 GPIO pins for selecting an injector, 2 PWM outputs one for 20A and the other 12A, then the complicated bit. There are 4 match registers on the system timer, I can use two of these to trigger the close of the injector and the toggling between one current and the other. So all of these outputs will have to be brought together with some AND gates to control a big fat MOSFET/TRIAC to switch the injector. For the simulator I will only read the signals form one of the Match registers.

3. The pressure and the injection duration, when you think about it, are very related. Gavin put it a nicer way, saying, "injection which is a function of rail pressure and nozzle flow rate". So I will have to modify duration using a map against pressure, i.e. more pressure less duration, given that we want the same amount of fuel at any one time. This relation will not be linear because of the mechanics of the injector, the more pressure the longer it takes for the needle to open, so the timing will also have to be mapped to the pressure to maintain smooth running (thank you Gavin). All this can get very complicated, also taking load into account (a humans right foot on the throttle or human PID, after all thats what we do best).
13 March 2008 Simulator and home detection
The simulator:
Now I have soldered together (I love that soldering stuff) another little board. You can see the two board side by side here. So I have the simulator setup to simulate the signals from the crank sensor and the cam sensor at the moment, I will also be adding something to have the speed react to injector duration, I will have a pot to adjust the simulated load.

Home detection:
Part of the most basic timing of the whole project is to find the home points on the crank and make sure they synchronize with the cam home points. Once this is found the ECU can start to think about running the engine but until the ECU has found home nothing can happen. Also the engine must constantly check that it has never gone out of sync with the crank or cam, this could happened from noise on the wires from the sensors. This would be bad scenario. I have made the home finding algorithm and have tested (not exhaustively) the out of sync algorithm. All this is done using Capture registers Match Registers and Interrupts.
26 February 2008 The more I know the more I know I don't know
I have had a meeting with my supervisor this week about the project. I was going to see if I could use PID control to control the duration of the fuel injectors, he advised against this as it is over complicated and I would be best sticking to the tried and test solution of maps. The other subject of the meeting was presentation. How do I present a little thing with some flashing lights and convince the presented that there is something smart going on. Also bearing in mind that I can only present in the computer labs. So I will have to build a simulator.

Maps:
So I have a fueling map now. In its simplest form it maps the throttle to the engine speed to give a duration.

Crank angle prediction:
Another cool thing that is working is the angle prediction. The little processor keeps track of the crank wheel as it spins and given an angle can predict when the crank will be at that position. I will use this to determine start of injection point, as the start of injection could be somewhere between to crank ticks (6 degrees, very significant). This little prediction may have to be beefed up when attached to the real engine to take into account acceleration and deceleration.
17 February 2008 Solenoids and Crystals
Over the weekend I have been researching and experimenting. This researching and experimentation has lead to some unexpected, I don't like to call them problems, more technical hitches.
With the help of John I hooked my car (2 liter hdi) up to an oscilloscope to have a look at what is going on with an engine that actually works. It first what we say was very unexpected but after a little late night reading I understood what was happening. What we say was something very similar to this (scroll down to "Solenoid common rail injectors"). The only difference was that the 90volt peak at the beginning was PWMed as well.

Background:
Common rail engines have a common rail of high pressure diesel feeding injectors(squirt diesel into the engine), the injectors are of two types, piezo and solenoid. My engine's injectors are of low impedance solenoid type. Impedance means they have a very low resistance of about 1.5ohms. So I have to control exactly when and how much fuel to inject by counting the position of the crank shaft and then taking a very calculated guess of when to inject, this is controlled by my system timers.

The hitch:
So the slight hitch is, I had originally and naively thought that a simple pulse of 12 volts to the injector would suffice, and that asking John, nicely, to show me how to build amplifiers would have opened and closed the injector. Will I was not wrong, but I was not correct either. What I found was that solenoid injectors need what is called a peak and hold current to operate them. What's that! its about 90volts for about 1microsecound then 12volts for what ever duration the ECU decides to hold the injector open for. These signals to the injectors also have to be current limited (so that they don't over heat), this is done with Pulse Width Modulation.

The solution:
Well I have a little idea in mind that should work, nothing a few and gates, some sort of voltage inverter and a very large capacitor wont solve. Although some of my code will have to change now, and I think i will have to juggle he match registers around a little bit.
11 February 2008 State of affairs
So what is the current state of affairs for the ECU?
Hardware:
Have a look. You can see the ECU in its current state, as said before John has designed the board. I soldered it together, which I found very relaxing novelty staring in to a microscope soldering away. The engine I will use is sitting at home in my garage, it is a Peugeot 1.4hdi which is a 4 cylinder 4 stroke common rail diesel engine.
There are/will be a few sensors: Crank position, Camshaft home, throttle and fuel pressure, there may also be a sensor for the exhaust gasses. At the moment I have a variable resistor as a throttle sensor and I am simulating data from the crank sensor using one of the LPC's onboard PWM (Pulse Width Modulator) channels. The injectors are represented by LED's, which will eventually be replaced with injector drivers, these will have to carry around 25-30amps in order to open the injectors. There will also have to be one of these drivers dedicated to the fuel pressure relief valve.
Fuel system(wikipedia.org)
A nice flash animation of the Motronic 60-2 crank timing, hope your french is good(geea.org)

Software:
Software wise, my C is improving a little. I have managed to write the timing code for the ECU, the hardware is taking care of some of this. After a lot of thought, fiddling and consideration I have settled on the following. The LPC2138/01 has two onboard timers, so I have set them up to capture the crank angle sensor, one of the is using the pulse from the sensor to increment(i.e. the signal is its clock tick) this timer will reset after 116 pulses and call an interrupt. There is another Match set up on this timer at one/two crank ticks before injection time, this calls an interrupt, in the interrupt the ECU setup when to close the injector using a match on the second timer. The interrupt also waits until injection time. Obviously the time to wait and the length of the injection will depend on the current speed of the engine(I am still thinking about the nicest way of doing this, I have a few options).
1 February 2008 Coding time
Exams are over...
So its time to start coding. I have yet to solve the problem of the starting algorithm (finding out where the engine is in its cycle) and interestingly the small problem of stopping the engine is playing on my mind. Stopping the engine seems simple enough compared to making the engine run (e.g.just break the code), but how best to do it.
27 December 2007 Sensors and Oscilloscope
Made the boards Analogue to Digital converters work, and outputted the values to a little Delphi application I made, so it acts like an oscilloscope. I hooked the trigger sensors up to it and they work! A lovely square wave comes out when the sensors are paced over a trigger surface...

I found that the sensors need a pull-up resistor between the 5v and the signal pins.
7 December 2007 More on sensors and Functional Spec
Thank you to the lads in Cieran McConnon Motors Kingscourt for finding definitively the pin outs of the crank speed sensor.
Pin 1:5v
Pin 2:Signal
Pin 3:Ground
So that means I can stick an oscilloscope to my nice new sensors(scrap yard in Ardee) with the 5volts and not melt them like I did the last ones.

Also I submitted my Functional Specification last Friday.
26 November 2007 Sensors
Think I have finally found the wiring schema's for the crank and cam sensors. With thanks to the lads in Peugeot Finglas and also from the public.servicebox.peugeot.com website.
11 November 2007 Getting my head around the ECU
So I have started playing with the processor that is going to be at the heart of the ECU.

The ECU is a Philips(nxp) LPC2318/01, its based on the ARM7 architecture. It is sitting on a board lovingly developed by John.

What have i got to grips with over the past 2 weeks, and especially this weekend?
-I can turn the LED on!
-I have grasped the idea and the how to of setting up interrupts. I have setup interrupts for the UART(serial) port so when a character is received it returns the character and some other info which i shall explain later.
-The PWM(Pulse Width Modulator) is out putting to one of the pins on the board.
-I have both the timers running, Timer 1 is running at roughly 1 tick per second. The second(Timer 0) is being triggered by the signal from the PWM and has a match set to trigger an interrupt ever nth tick.

The reason for this experimentation is to get myself used to C, using registers and to familiarise myself with the board and processor.
18 October 2007 Proposal submitted
The proposal is signed off and submitted. :)
4 October 2007 Blog up and running
So the blog for my 4th year project is up and running.
Now I have to find a project supervisor and write a proposal.

The idea for my project is to make an ECU to run a common rail diesel engine.