Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

RPi as a car ECU

Sun Jan 25, 2015 12:35 am

Why do this project I hear people asking? Well I was recently burgled and the thief stole both my Subaru Impreza car keys making the car a dead duck since it has an immobiliser. To get it going again it would cost over £200 but the car is only worth £500 and I always wanted to design a car ECU to see if I could do it and do it better. My opinion is that the systems in your average saloon cars are fundamentally wrong and look like they have been designed by people from MENSA with no practical experience or regard for the real world. For instance my Ford KA has been giving me 42 mpg and passed the MOT emissions for the last two years and yet I know the car used to give me 55 mpg. The ECU is making the mistake of chucking more fuel in to get what it thinks are the right Oxygen sensor readings but the result is higher emissions although they are still below the MOT requirements. Basically the ECU systems are too complicated and only work correctly when everything is perfect unfortunately in the real world nothing is perfect for very long.
The majority of systems try and measure as much as possible with all sorts of complicated sensors like Mass flow meters and Lambda sensors and yet when you look at the pinnacle of engines in Formula 1 it is completely different. The most straight forward way for an ECU to work is to emulate how a carburettor system works where the engine speed sets the amount of fuel. In order to keep a fixed fuel to air ratio the injectors need to supply the right amount for the speed of the engine so you only have to read the engine speed and calculate the injector on time for the right fuel flow. The throttle position isn't required for this simple version because as the throttle is opened the engine will speed up requiring fuel adjustment and fixed values can be added for acceleration or subtracted for deceleration. My aim is to keep the design as digital as possible because the inputs on the RPi are digital. The only analogue sensor that might be required is the throttle but it might be possible to get away with fully open and closed detectors. Lambda and Mass flow sensors are not required in my design and air temperature can be dealt with using one or two level sensors. All the other sensors for speed and ignition are digital anyway so don't present a problem.
The biggest problem on the hardware side is the fact that the Rpi is very weak when it comes to noise immunity so I think it is best to stick it in cotton wool by giving it a perfectly regulated supply well decoupled and make all connection to the outside world via opto isolators this way the only direct connection to the car system is the power rails. All the output drive MOSFETs and all the signal conditioning circuitry will be on the opposite side of the opto isolators from the RPi. Another headache with the hardware is connecting it to the car. The ideal solution would be to get hold of the ECU connector that is on the original so I will either take that one off or buy an old one off Ebay and cannibalise that. The thing to do now is identify all the I/O from the car schematics and sort out the circuit interfaces including any that might be needed for improved operation with more sophisticated software. Well these are my initial thoughts but I don't know how long this project will take I will just have to suck it and see.

User avatar
Burngate
Posts: 6303
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: RPi as a car ECU

Sun Jan 25, 2015 12:01 pm

Having read closely your post (perhaps you could use paragraphs to make it easier for me?) I'm not sure you're right on a few of your points.
yet when you look at the pinnacle of engines in Formula 1 it is completely different
A F1 engine isn't the same as a road-car engine. For a start, economy isn't its number one priority, and nor is emisions control.
my Ford KA has been giving me 42 mpg and passed the MOT emissions for the last two years and yet I know the car used to give me 55 mpg.
So many things can affect the mpg over time. Your driving style could have changed. The traffic could have got worse. The piston rings could be worn. The air filter may be clogged.
The ECU is making the mistake of chucking more fuel in to get what it thinks are the right Oxygen sensor readings but the result is higher emissions
The amount of fuel required for the amount of oxygen in the cylinder is constant. Too little fuel means a high oxygen reading in the exhaust, too much means a low reading.
It being a feedfack system, and assuming the lambda (oxygen) sensor is working, the ECU is going to achieve the correct fueling (not necessarily true when you put your foot hard down - under those conditions, the system can go open-loop, putting in more fuel. For the same amount of oxygen you get more energy out if you burn it to CO rather than CO2)
In order to keep a fixed fuel to air ratio the injectors need to supply the right amount for the speed of the engine so you only have to read the engine speed and calculate the injector on time for the right fuel flow. The throttle position isn't required for this simple version because as the throttle is opened the engine will speed up requiring fuel adjustment and fixed values can be added for acceleration or subtracted for deceleration.
Something wrong here.
The power out of an engine depends on speed and torque, and the torque depends on energy per stroke.
Roughly speaking, in a petrol engine with a lambda sensor in the control loop, the energy per stroke depends on the oxygen in the cylinder, and therefore the quantity of air, which is controlled by the throttle.
So the fuel per stroke will change with the throttle setting, irrespective of engine speed
The same is true with a carburettor - the throttle controls the air, and the carb is there to put the right proportion of fuel into that air, however fast it's flowing
In order to keep a fixed fuel to air ratio the injectors need to supply the right amount for the speed of the engine so you only have to read the engine speed and calculate the injector on time for the right fuel flow. The throttle position isn't required for this simple version because as the throttle is opened the engine will speed up requiring fuel adjustment and fixed values can be added for acceleration or subtracted for deceleration.
You're travelling along a flat road at 70mph. You come to a steep hill, but want to still do 70mph, so you put your foot down. The engine doesn't speed up, but you get more power, because more throttle means more air means more fuel means more torque.

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: RPi as a car ECU

Mon Jan 26, 2015 1:24 am

The latest F1 hybrid turbo engines are very efficient and only allowed enough fuel to just about complete a race so they have very precise control of the fuel mixture.
I have been monitoring my KA for years and know that with the fault it gives the 42 mpg whether it is driven hard or gently it is only when it works correctly that economy driving gives the 55 mpg.
The hill scenario might be partially true for carburettor cars but my experience with ECUs is that more throttle doesn't give more power unless the engine speed increases and my driving instructor friend agrees.
The pot always sweeps the same volume so tries to suck in the same amount of air so I think you are saying the pressure must be lower in the pot on partial throttle since that is the only way a fixed volume could have less air. Having a throttle position would make the software calculations easier so it might be better to design it in at the start. Unfortunately the RPi only has digital inputs I think but I could stick a small PIC chip that has an A/D on it in circuit that would enable me to read more than one analogue input.

User avatar
Burngate
Posts: 6303
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: RPi as a car ECU

Mon Jan 26, 2015 11:19 am

Ruptor wrote:The latest F1 hybrid turbo engines are very efficient and only allowed enough fuel to just about complete a race so they have very precise control of the fuel mixture.
It's somewhat more complicated than that.
For a start, there are two limits: total fuel, and rate of usage (http://www.formula1.com/inside_f1/rules ... ons/15587/)

As for their efficiency, if they use about 100kg of fuel for 200 miles, that's about 135 litres or 30 imperial gallons, so 7 mpg. Somewhat less good than your Ka.

For a generic petrol engine, one can draw a map with torque vertically and rpm horizontally, and plot grams of fuel per kWh.
From Wikipedia http://en.wikipedia.org/wiki/Brake_spec ... onsumption
500px-Brake_specific_fuel_consumption.svg.png
500px-Brake_specific_fuel_consumption.svg.png (50.99 KiB) Viewed 2384 times
You'll notice that there's a sweet spot at about 1/3 maximum rpm and 2/3 maximum torque, and close to 200g/kWh. That's where you should run it for maximum efficiency
During a F1 race, the engine spends most of its time well above that sweet spot. That's because they don't care about efficiency - they want power.
I have been monitoring my KA for years and know that with the fault it gives the 42 mpg whether it is driven hard or gently it is only when it works correctly that economy driving gives the 55 mpg.
Possibly.
But it isn't a fault with the design of the ECU
The hill scenario might be partially true for carburettor cars but my experience with ECUs is that more throttle doesn't give more power unless the engine speed increases and my driving instructor friend agrees.
Well, he's wrong.
As I said, power = torque * revs, so for more power you need more of either torque or revs.
Your accelerator pedal connects to a butterfly valve, which lets more air in. The fuel system makes sure the right fuel-air ratio is in the cylinder, be that a carburettor or injectors plus air-mass sensors or whatever.
The pot always sweeps the same volume so tries to suck in the same amount of air ...
No.
The amount of air sucked in is controlled by the butterfly valve. With your foot off the accelerator, very little air goes in, and isn't at atmospheric pressure. In fact, a lot of energy is wasted sucking air past the butterfly valve.
That's one reason why a diesel is more efficient than a petrol engine. There's no restriction in the path of the air, so a lot less pumping losses
... so I think you are saying the pressure must be lower in the pot on partial throttle since that is the only way a fixed volume could have less air.
Correct

Return to “Automation, sensing and robotics”