jump to navigation

0.1 Alpha (first public release) 2010/06/03

Posted by Michael in 2JZduino.

For a few months now I’ve been struggling with the cam sensor signal when the engine is at idle speeds (300 – 900 RPM). At low speed, the signal strength of the cam VR sensor is too low to be register as a digital input (it’s peaks are sometimes < 2v when the engine is turning at 600 RPM). The same thing happens with the crank sensor.

The solution I've implemented is to switch over to an ADC mode when the engine speed is below ENGINEHZ_ADCMODESWITCH. In this "ADC mode" the ADC samples the cam and crank signals and switches the digital outputs depending on the values.

This never worked reliably despite implementing a number of trigger and filter algorithms for the on/off events. My latest theory is that the cam output signal from the 2JZduino was settling too close to 0v between incoming pulses (i.e. the inductor had completely discharged), and electrical noise was causing false triggers at the input of the stock ECU.

For now, I've stripped out the cam sensor signal from 2JZduino (the sensor now connects directly to the stock ECU), so that it is no longer possible to delay it. More thought and research needs to go into the permanence of this decision, but I suspect this will hold. It will not have an affect on delayed ignition timing. It might have an effect on the operation of VVT-i, however this affect might be favourable for a forced induction application.

Nevertheless, after removing the cam signal DSP I've finally been able to operate my 2JZ-GE engine without issue between 300 and 5000 RPM. And so with one of my few readers requesting a preview of the full code package, I've decided finally to make an Alpha release (v0.1)…


The download package contains both the code for the Arduino environment (compiles for the Arduino Mega), and also the Windows-based .exe to write values to the 2JZduino EEPROM (for injector scaling and crank signal delay).

Features in this version include…
LCD display support
Support for Fuel Injector drivers
Support for Crank signal DSP
Engine simulator code for bench-testing

Not included: working code for oxygen sensors.

Obviously, as an Alpha release use this at your own risk. Documentation is incomplete and various sections of the code remain untested.



1. hans - 2010/06/04

Very grat!! Are You using the CAN-Bus to receive the signal or do Yout connect the sensors directly to the arduino?
Dear hans

2. Michael - 2010/06/04

Sensors are connected directly to the Arduino for DSP.

3. Rob - 2010/07/05

To detect inputs that are below the 2V required to trigger the digital inputs of the Arduino, use a comparator. Do a google search. A comparator is a single chip you can power with 5V from the Arduino board. Use a couple resistors in series to produce a stable voltage around 0.5V to feed to one of the inputs of the comparator. Feed the signal you are measuring to the other input. The comparator will then output 0V or 5V depending whether the input signal is less than or greater than 0.5V.

Michael - 2010/07/06


Thanks, and I agree. I will make a future post about this to clarify how it should have been done, but for my prototype I’ve run out of room on the PCB. Thanks to your suggestion I did find an ideal product if/when I convert this to a prefabbed PCB: MAXIM9062.

4. Christoph - 2011/03/09

Do you have any timing problems with the ignition? At 6000 revs we are in the microsec area for one degree (28 microsec for one degree) and I think the ignition should be as precise as that.

5. Michael - 2011/03/09

Hi Christoph,

No, I don’t have any timing problems at 6,000 RPM. I actually just recently profiled the code with a second Arduino to confirm the signal latencies at 7,000 RPM. Igniter signals were accurate to 15us 95% of the time, and maximum latency of 40us.

I wrote a more detailed analysis of the Arduino’s capability here…

6. Christoph - 2011/03/10

Hi Michael,
I added a comment to some timings at the referenced article – thanks for the good stuff.

I am working on a ignition for my oldtimer in order to eliminate some mechanical flaws, i.e. calculating the average of the time for one turn.

The code got somewhat messy because there are many things to consider. Worst is a problem concerning something similar to your ENGINEHZ_ADCMODESWITCH: At low RPM ignition has to be late, i.e. the spark comes very short AFTER top dead center (is the notion TDC correct?). At higher speed the ignition has t advance BEFORE the TDC, which means I have to change from “spark immediately” to “delay almost until next signal”. In my test setup (driven by a small electric motor) quick changes of the turning speed can result in lost sparks, because the coil is switched on 2ms before the spark and sometimes the next signal comes sooner than expected.

The idea for the smoothing is to store the last 8 or 16 values for one turn and to avoid a division to shift the long value of the sum one byte or word to the right.

Michael - 2011/03/10

What sensor is being used to pickup rotation?

7. Christoph - 2011/03/11

In the test setup I use a Hall sensor (unipolar) to detect TDC and a freescale pressure sensor for the depression. I haven’ made up my mind what I will use in the final setup.
As far as speed is concerned I found that direct port IO might speed up things significantly, especially if I want to read several sensors.

8. Mantas - 2011/08/12

To avoid ignition issues you could use a Ford EDIS ignition package. This has a standard 10deg advanced ignition and actual timing is controlled by a PWM signal. Do some google on it or check MegaSquirt.

BTW, I am expecting my Arduino any second now and I am also planning on using it for engine management of a turbocharged Ford BOB 24V engine. The idea is to use the standard ECU and to modify the output with the arduino (and then use the drivers from the ECU to trigger the injection).

As some signals do not need to be modified linear, I will have to find out in future if arduino can handle matrixes for modifying ECU parameters or if it requires line by line programming…

More in future, so far thanks for sharing your experiences!

Michael - 2011/08/12

Thanks for the keywords Mantas. The first hit on google was quite informative.

In later posts you’ll see I’ve successfully intercepted the IGT signals for the OE Toyota ECU. Ignition timing is easy to delay with that method (and I’ve no need to advance it).

I’m again long overdue for an update. I’ll try and put one together, but I’ve been running my car on the 2JZduino 100% for about 10,000 Km now without issue.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: