Injector and Coil Timing
Injector and coil timing is calculated based on blocks of time that correspond to one piston stroke. The square wave signal from the cam sensor gives 4 pulses per revolution, which correspond to the 4 piston strokes of a 4 stroke engine. Within the time frame of these strokes certain things need to happen. Fuel injectors need to turned on and off, and so do ignition coils. This is handled by loading specific values into CCP modules of the microcontroller (this post roughly explains CCPs http://fuzzymonkey87.blogspot.com.au/2013/09/the-maiden-voyage.html) to trigger events to happen at specific times.
A variable to keep track of the cylinder on power stroke and 4 CCP modules are available. This works well enough when 4 events are specified:
- Injector on
- Injector off
- Coil on
- Coil off
- The coil or injector being turned on, must be turned off in the same piston stroke. This is no good when a coil or injector pulse has a longer duration than the entire piston stroke.
- CCP events can be missed in a few ways, but most commonly if the specified time occurs before it is being set. Example: timer = 123, set CCP to trigger at 127 (this takes a short time), timer = 140. Setting the trigger takes too long, so the trigger time is missed.
With this algorithm implemented for both the coils and injectors i was getting a the most power i have had so far!
Problem #2 was solved firstly by hard coding the coil to turn off at the end of the cylinder compression stroke and the injector to turn off at the end of the cylinder intake stroke (the intake valve is closed anyways!). Typically both the coil and injector would already be switched off at this time, so either there will be no effect, or the missed CCP event would be taken care of. Secondly, the process of calculating timer values for CCP modules does take some time. To compensate for this i've also implemented a fast "guestimation" to be used when the more accurate (but slower) coil and injector calculations cannot be used. Whenever a CCP module generates an interrupt, it will first execute its standard function (eg: turn off coil), then it will do a very simple operation, to shift its trigger time to be at the equivalent point in the next piston stroke. This could be a slightly different(not accurate) time than what is calculated by the slower, more accurate algorithm. The difference seems to be so small that it doesn't make a difference. Finally, while guestimation is calculated each time the CCP is triggered, the guestimation is automatically overridden by the more accurate calculation as long as it is done quickly enough.
While testing I found it ran noticeably smoother and I have even more power again. I estimate around 70% of the original power output of the car. SO EXCITE!!!
Fuel Map and Dyno
An ECU is useless if it doesn't have proper tuning data. There's no point in being able to precisely control spark timing if it gets precisely set too late in the combustion cycle. This is where I need to set ideal values in the fuel and ignition advance map for the ECU to base its calculations on. For the moment i've been setting them based on and limited "road tunes". The idea is you try to drive your car with a constant engine speed and manifold pressure which corresponds to a data point in your fuel map (for programmers: it's an item in an array). Once there you adjust the value for that data point until you achieve the desired air/fuel ratio (or ignition advance value if doing ignition map). This is a lot harder than it sounds. It's near impossible to maintain a constant manifold pressure. RPM will change as you encounter a gradient, and as you make adjustments to the map! If RPM changes, then that data point is no longer being referenced. To keep RPM steady you need to adjust acceleration - but this changes the manifold pressure! If the manifold pressure changes, then again that data point is no longer being referenced.
|Road tuned fuel map|
To do this properly I need to put my car on a Dyno, like everyone else that gets their car modded and tuned.
I'm not going to explain knocking/pinging/detonation in detail because you can find heaps of information out there in internet land. Basically it refers to uneven and turbulent combustion of fuel that will cause the piston to smack into the cylinder wall instead of being driven straight down. As you can imagine this is very bad! As far as I know the possible causes are:
- bad fuel
- too much ignition advance
- air/fuel ratio too lean
- dirty plugs
- carbon build up
My model MX5 doesn't have a knock sensor, so I don't have a way to detect knock yet. At the moment my engine is knocking pretty badly despite producing a decent amount of power and me tuning it as well as I can for now. I've addressed each of these possible causes and managed to minimise the problem, but not remove it completely.
I'm not yet sure if I will implement knock detection myself or use an aftermarket device. Knock sensing itself is sort of complicated and requires some filtering and isolating specific frequencies. The signal processing would probably be complex enough to require a seperate device to handle the computations. A separate microcontroller or DSP or something. I really don't know at this stage and will need to learn more before I come up with anything.
That's the name of the plug/socket that connects the ECU to the rest of the wiring in the car. I've modified and hacked up the wiring to the point that the original ECU will no longer function and that's no good to me since I want to swap back and forth between ECUs if needed.
|New sockets and original ECU|
Fuckit PCB time! The breadboard and even veroboard provided a lot of freedom to make changes. But it did restrict the shape of the board and layout slightly, and there is no way to properly connect the multilock socket. I think the most important advantage with PCBs is the physical robustness. There's no wires to rip out and it's resistant to vibrations. I'm temporarily converting everything back to the original ECU while I learn about PCB design. I have zero experience, but there's a lot of great looking free software available and lots of cool tutorials too. I'll most likely use KiCad http://www.kicad-pcb.org. Also, I expect my first PCB to have some mistake that makes it useless, but there's a few companies that do small runs of boards so that's no big waste of $ for me :)