Archive for the ‘Engine Management’ Category

Cam Angle Sensor

Thursday, March 6th, 2008

 

This is a graph of the outputs from a Nissan cam angle sensor (CAS) . I will need to perform timing events on the falling edge of the wave since the cylinder reset wave length is variable. The timing trigger has 360 waves per rotation. Since the sensor is on the camshaft of a 4-stroke engine (camshafts rotate at half crank speed), there are 180 waves per engine revolution. AT 9000 RPM, that is 270 KHz (9000 / 2 * 60 / 1000). To account for fractions, we need a clock speed much higher than this (270 KHz is bare minimum). A 1 Mhz (~4x minimum) clock for the FPGA should be more than enough 99.9% of the time.

At the falling edge of each timing signal, increment a counter. Lets call this variable i. this counter is not used to calculate angle and is not limited to 360. After variable i is incremented, we check the state of the cylinder reset signal. If the signal just went high, then we initialize another counter( variable r) to 0. We will also increment variable r on the falling edge of the timing signal whenever the cylinder reset signal is high.

On the falling edge of cylinder reset, we compare the value of variable r (pulse width of the cylinder reset wave) to known values to figure out which cylinder# just reset, and set variable p to the degree at which that cylinder is at top dead center (TDC) at the first stroke divided by 2 (since the camshaft moves at half engine speed). If cylinder1 just reset, we will set variable p to 0 (0 degrees).

So now we have everything we need to time sequential fuel injection and sequential ignition. However if we timed these events to the falling edge of the timing signal, we could only adjust timing in 2 degree increments, unacceptable! I want at least 0.1 degree resolution. To remedy this situation, we need to know the RPM. This will need to be an average, and a minute is too long of a sampling time obviously. Sampling time needs to short enough for the system to detect engine acceleration quick enough. at 60rpm (1 revolution per second) there are 1000000 clocks per revolution or 2000000 clocks per complete engine cycle. One missed timing sync signal with a 1 second sample would be an error rate of approx (1 / 180) 0.5% or +- 3 rpm at 600rpm, and +- 0.01 degrees accuracy of crank rotation. Earlier I stated I wanted 0.1 degrees of resolution, which means I would need 10 Hz RPM sampling. 10 Hz on a 1 MHz clock is 100,000 clocks. So lets create variable r for rpm, and variable b for the counter. Every clock we need to increment b. Every 100,000 clocks we need to set r to the value of b, and set b to 0. We will need a counter to count to 100,000 clocks as well, lets call it variable a.

 

 

Here is some psuedo code to help illustrate:

if(++a > 100000)
{
    s = b;
    b = 0;
    t = 0;
    a = 0;
}

if(timing_pin)
{
    i++;
}
else
{
    if(i)
    {
        t++;
        p = p + (1 * 10;)

        if(cylinder_reset)
        {
            r++;
        }
        else
        {
            if(r)
            {
                if(r == 10)        // cylinder 1 tdc
                {
                    p = 0;
                }
                else if(r == 20)    // cylinder 2 tdc
                {
                    p = 540 * 10;
                }
                else if(r == 30)    // cylinder 3 tdc
                {
                    p = 180 * 10;
                }
                else if(r == 40)    // cylinder 4 tdc
                {
                    p = 360 * 10;
                }
                else            // error
                {
                }
                r = 0;
            }
        }
        e = p;
        i = 0;
    }
}

ECU Schematic

Wednesday, March 5th, 2008

TCM = Timing Control Module
IOM = Input / Output Module
CPM = Central Processing Module

Objective

Create a standalone Engine Control Unit (ECU) that (at the very least) performs sequential fuel injection and timing for automotive internal combustion engines with options to control auxiliary systems such as intake air control valve (IACV), air conditioning compressor clutch, vacuum solenoids, etc. The three modules communicate with each other over Ethernet.

Timing Control Module

The TCM will receive a stream of UDP packets from the CPM that contain values each individual cylinder’s fuel injector pulse width and timing value. The stream is constant and automatic. The TCM never transmits data back to the CPM. The TCM will run a field programmable gate array (FPGA) to handle the rapid timing signals generated by the crank (or cam) angle sensors. From this data, the module will know when to trigger timing and fuel events for each cylinder. The TCM is located in the engine bay, as close to the distributer as possible.

Input / Output Module

The IOM performs analog-to-digital conversions of various engine sensors, and then streams the values continuously (in round-robin fashion) to the CPM. The IOM also receives a UDP stream from the CPM with information about various digital pin states to set, DAC outputs, and PWM outputs. Its important to note that the inbound and outbound Ethernet have no relation to each other. The entire system is based purely on streaming and no requests are made. This module is based on a MCU. The IOM is located in the engine bay, as close to the central location of the engine sensors as possible.

Central Processing Module

This module receives sensor data from the IOM, crunches the numbers to determine fuel and ignition values to send to the TCM, as well as outputs to send to the IOM. It may also perform other duties such as logging data, communicating with a personal computer for configuration changes, or handling human interface devices (HID). HID’s can be anything from keyboards to graphical displays. The CPM should run some sort of ARM cpu and run linux. The CPM should be located in the cabin, but can theoretically be located anywhere.

Advantages

  1. Wiring is dramatically reduced, as such more accurate analog signal values may be delivered to the ECU for processing. Running the cables is also easier since the girth of RJ45 cables is negligible compared to the factory harness.
  2. Extremely inexpensive wiring and replacement.
  3. No cross interference between analog circuitry and digital as they are located in separate modules.
  4. Extremely easy to troubleshoot but sniffing network traffic over Ethernet with any common PC.
  5. Easier to develop and build.
  6. Powerful arm CPU can perform very complex calculations that conventional ECU’s cannot.
  7. Open source.

Disadvantages

  1. May require special ethernet cables and connectors for the harsh engine environment.
  2. Due to the divided nature, 3 Ethernet controllers are needed for communication purposes.
  3. Packet loss may be hard to identify and isolate, while causing poor engine performance.