Jamesl’s Original ‘MegaSquirting Your MR2’ Article


(Warning! This article, and the setup discussed, focuses on the 1987 Toyota MR2 with the stock 4age engine and stock VAST ignition system. I do NOT know if this setup will work with any other car or any other model year of the MR2 – it definitely won’t work with cars using Toyota’s ESA ignition system. If you attempt to modify your car based on this write-up, you do so at YOUR OWN RISK!!!)

Table of Contents:

Harness Install
Configuring MS
Dwell Control
VE, Spark Tables
TVIS activation
Turbo Install

MegaSquirt n Spark-Extra – Plug n Play MR2 install

I am using the MegaSquirt n Spark – Extra (MSnS) system to control both fuel injection and ignition timing on my 1987 Toyota MR2. (Now Turbo!)  I have built a system that is very nearly “plug n play.” It uses the completely stock ignition system and engine harness. The only wiring changes inside the engine compartment involve plugging three wires into an existing connector.

I installed the MSnS system as a first step in a turbo project. I decided to get MS up and running on my NA car before beginning the turbo install, to shake out any problems before investing in the turbo kit. After driving about 100 miles and completing preliminary tuning, I began work on the turbo install. I didn’t try to get the tuning perfect on the NA, since I knew things would change once the turbo was on board. I got the turbo system completed and running on July 15, 2005.

MegaSquirt is a DIY engine management system that has been evolving rapidly over the last couple of years. It was initially developed to control fuel injection only and was primarily aimed at upgrading older, carbureted vehicles. It is an “open” project with circuit diagrams and code available to anyone for free on the Internet.

Because of that openness, some bright people adapted the original design to include ignition control. MegaSquirt n Spark-Extra is on the cutting edge and I believe it’s the most advanced and flexible version of the tuning a software available for MS. (As of July 2005)

A number of people have used MegaSquirt on the 1st generation Toyota MR2, but most used the Ford EDIS ignition system for spark control.  I decided to use the stock ignition. As I researched the project, it occurred to me I could use the stock engine harness as well. To that end, I built a “jumper cable” that connects the MS computer to the stock engine harness connectors. You simply unplug the stock ECU and plug in MS.

I began be reviewing the circuit diagrams for the EFI and Ignition System on my MR2. I also studied the Circuit Diagram for MegaSquirt. It took awhile (and some helpful tips from others) to finally figure a way to route all necessary connections through the harness jumper and into MS.

I copied pictures of the MR2 circuit diagram and the MS connector into the Paint program on my computer and then drew lines to connect the various pins together. You can see my amateurish circuit diagram

AFM Wiring Mods

The MegaSquirt system uses a Manifold Air Pressure (MAP) sensor instead of the MR2’s air flow meter (AFM). So, you need to remove the AFM system. I had already done a high-flow air intake modification on my MR2 (see pic), so removing the AFM was easy. I simply unhook the hose clamp at the throttle body, remove two mounting bolts and lift it out as a unit.

A 7 pin connector plugs into the side of the AFM. It has connections for the airflow meter, the intake air temperature sensor (IAT) and a safety switch that cuts off the fuel pump when no air is moving through the system.

Since I was going with a MAP sensor, I didn’t need the airflow connections. Instead of using the stock IAT, I went to the junkyard and picked up an IAT with pigtail from a late 80s-early 90s GM product (these sensors are commonly used on MS projects and cost about $3 at my local pick-n-pull). While I was there, I picked up a connector from a junk AFM to use in hooking up the IAT. I also found a piece of intake tubing off a Mazda (I think) that was about a foot long, the right diameter to mate to my throttle body, and relatively straight. ($5.)  I found a short rubber coupling at Home Depot to connect my cone filter to the Mazda intake tube.

The tubing had a nice fitting on the side for a PVC breather, and with a little modification the GM IAT screwed right in so that its snout sticks down into the air flow. I soldered the IAT pigtail leads to the junk AFM connector and plugged it into the 7 pin connector on the harness. To deal with the fuel pump safety switch, I jumpered two jacks on the AFM connector so I could route fuel pump control through MS (see diagram). These were the only wiring mods in the engine compartment.

Wiring It Up

Toyota changed the circuit diagrams over the years, but it looks like they kept the same 2- and 3-letter designations for each portion of the circuit. For example, the signal coming out of the Igniter to the ECU is the NE signal, while the signal going to the Igniter from the ECU to trigger ignition is the IGT signal. On the ’87, the NE signal is at pin 1 of Connector B, while on the ’86 MR2 it’s on pin S1.

WARNING: If your car is not a USDM 1987 MR2, don’t use my circuit diagram – it could be WRONG.  (As an example, some Map-based 4age cars usedToyota’s ESA ignition system, which is very different from the VAST ignition system. My setup WON’T WORK if your car has the ESA system.)

Here’s a list of key circuits designations and what they mean:

B1 – Switched battery source (hot both cranking and running). Goes to pin 28 on MS
THA – air temperature sensor – to MS pin 20
NE – Igniter signal to ECU – to MS pin 24
IGT – ignition signal from ECU to Igniter – to MS pin 30 (if using FIDLE output for ignition)
THW – coolant temp sensor – to MS pin 21
VTA – variable throttle position sensor – to MS pin 22
VCC – stable TPS signal for reference – to MS pin 26
OX – oxygen sensor – to MS pin 23
E2 – Ground circuit for TPS, coolant and air temp sensor – to any MS pin on top row. I used 8.
“20” – circuit to injectors 1&2 – to MS pins 32 & 33 (I doubled up on the harness side)
“10” – circuit to injectors 3&4 – to MS pin 34 & 35 (ditto)

E1, E01, E02 – Main grounding circuits to engine block. – to MS pins on top row, 7-11
VS or VC – these are unused circuits left over when you remove the AFM. You can use either one to provide fuel pump control. In my case, I jumpered between pins 2 and 5 on the AFM connector to route fuel pump control through the VC circuit.  – to MS pin 37.

S/TH – TVIS activation – to MS pin 31, if using X14 output.

To build the jumper cable, I took my stock ECU to the junkyard and looked for a Toyota with engine harness connectors that would plug into my ECU. I got lucky — the second car I looked at (a late 80s Camry) had harness connectors that were an exact match. I bought the Camry’s ECU for $15 and cut it up for the connector. (Tip: If it’s a pick-in-pull,  disassemble the ECU and just take the connector to the counter. They will probably sell it to you for a couple bucks.)

Wiring the harness and MS connectors together was pretty straight-forward. Obviously, the goal is to connect the correct pin coming out of the stock harness to the appropriate pin on the MegaSquirt DB37 connector. It can get confusing. To help keep track of things, I put masking tape on each connector and marked which pin was where. Then I did one lead at a time, soldering one end to the harness connector and the other to MS before moving on to the next lead.

I used 18-guare wire and chose to solder the leads in place. I wouldn’t say that my jumper looks professional – but it works. You simply unplug the stock computer, plug the jumper cable up to the harness connectors on one side and MS on the other.

To complete the install, I routed a vacuum line from the MS MAP sensor into the engine compartment and plugged it into the three-prong vacuum port on the intake manifold where the fuel pressure regulator sources its vacuum. Only one of the ports is used on the ’87 MR2. The other two are capped. You simply remove one cap and plug in the MAP vacuum line. Routing the vacuum line was easy in my case. On my ’87, the stock air filter box is in the trunk, with the intake piping passing through the firewall. Since I had  removed the stock intake plumbing, I had a nice 2″ diameter hole in the firewall.

I haven’t actually mounted the MS box to the firewall yet. The box comes with mounting points and it looks to be fairly simple to drill holes in the firewall, perhaps using rubber grommets to keep the box off the surface slightly. As an alternative, I may use a flat plate bolted to the stock ECU mount points, and then screw MS onto the plate.

This setup is pretty nice, because switching back to the stock system is easy. I know, I’ve done it a couple of times!  I simply unplug the IAT leads and jumper from the AFM connector, remove the Mazda intake tube, reinstall and plug in the AFM system, plug in the stock ECU, and I’m running in about 15 minutes! You can leave MS plugged into the MAP sensor, if you like. If you decide to take MS out of the car, be sure to plug the MAP vacuum line.

Configuring MegaSquirt n Spark-Extra

Configuring MegaSquirt n Spark-Extra to control the stock Toyota 4age ignition system was a fun, sometimes frustrating challenge.  To my knowledge, no one had ever used MegaSquirt by itself to control Toyota’s VAST (variable advance spark timing) ignition system. After trying various modifications to the MS board and MSnS 2.25b326 version of the TunerStudio software, I finally go my 1987 MR2 to idle and run on Dec. 17, 2004. It took about three weeks from the time I had MS assembled to actually getting the car running with a stable idle. If you follow these instructions, you should be able to do it in a day.

In brief:

Use MSnS spark output via the FIDLE output
Adapt the MS board using a 12v pull-up to the input and 5 v pull-up on the output.
Set trigger angle to 10 deg BTDC, which causes MS to fire in the “next cylinder” mode.
On the Spark Settings page, you set “Spark Output Inverted = NO”. 
Dwell Control “ON”, with dwell set at 2-4 ms.
Be sure to use MegaTune 2.25b326 or later, with the appropriate S19 file.

I won’t bore you with details on purchasing and assembling MegaSquirt.

In the stock setup, the igniter on the Toyota VAST system sends a 12 volt, square wave “NE” signal to the ECU. The ECU then computes timing, adds dwell and sends a 5v square wave IGT signal to the igniter to trigger the coil. In much of the MS documentation, they talk about using a tach signal as the input and a trigger signal as the output. In the case of the VAST system, the NE is the equivalent of the tach signal and the IGT is the trigger signal.

Once you have the board assembled and tested with a Stim Kit, you have to modify the board to recognize the NE signal and generate a proper IGT pulse. To do this, you need to modify the MS input and output circuits. I used MS board V2.2 – these instructions are only good for that version of the board. I’m no electronic expert and used modifications recommended by James Murray, the developer of the MegaSquirt n Spark-Extra code.

To properly condition the input signal, you need to:

— Remove D9
— Install a 1k resistor between the right side (non-band) end of D5 and the right hole (banded) end of D9. (This provides a 12v pull-up on the input) (Note: I soldered the resistor to the leg of D5, about an 1/8th inch above the surface of the board.)

On the output side, assuming you’re using the FIDLE circuit for ignition control:

– Solder a 1k resistor between the left (non band) end of D9 and the small hole above D9. [Resistor can be 1k to 10k – it is a pull-up to +5V on the output to ignition.]

That’s it – the board should be ready to communicate with the MR2 Igniter.

Spark Settings

The stock static ignition timing, without any computer control, is set at 10 degrees on the 1stgeneration Toyota MR2. You leave the distributor alone (after making sure your timing is correct while you still have the stock ECU in place!). DON’T follow the standard MSnS setup guidelines for determining trigger angle.

On the Spark Settings screen in MegaTune, you set the trigger angle to 10. When trigger is set below 20, MSnS-Extra actually fires the ignition in the “next cylinder” mode – when it receives a tach pulse (NE in our case) it waits until the next signal before generating the ignition pulse.

You set the Cranking timing to Time Based – although I don’t think it matters. On the MR2, the igniter controls ignition during cranking, and does not send an NE signal to the computer – so MS does not see any rpm signals during cranking. However, I’ve set mine to Time Based.

Fixed angle is set to 16 if you want to run static timing or -10 if you want to run using computer-controlled timing.

Now, this is key: Spark Output Inverted MUST BE SET to NO.

Trim Angle, Hold Ignition and Trigger Angle Addition all should be set to zero.

Setting Constants

I haven’t finalized my Req-Fuel settings on the Constants Page. If you use the calculator in TunerStudio, it will give you a good starting value. The stock injectors on the MR2 are low impedance. However, the stock system includes a resister pack that conditions the input to the injectors, so they should be treated as high impedance in the MSnS Extra setup. Under Injector Characteristics, set the PWM Current Limit to 100 and the PWM time threshold to 25.4. (By the way, this only holds true if you are using the stock resistor packs!!!)

PWM stands for Pulse Width Modulation and is typically used to control low-impedance injectors that don’t have a resistor pack. There is a lot of discussion on the MS sites about setting the PWM criteria and it can get confusing. Setting the PWM current limit to100 essentially turns off PWM.

MSnS-Extra is set up to use the Fast Idle Control (FIDLE) circuit to provide ignition signals. The value in the Fast Idle Control field is when MS switches OFF fast idle and is based on coolant temperature. That value needs to be set high – you want it to stay ON during normal running. I have the value set at 215 for now.  Control Algorithm is Speed Density – that’s standard with MS. For the MR2, we have two injections per engine cycle, alternating injector staging, multi-port fuel injection and the engine is even fire. Map type with V2.2 of the MS board is 250kPa. Set the other fields as I have – they are values recommended by the documentation.

Dwell Control

The stock ECU on the MR2 controls Dwell – which basically keeps your coil from burning out due to oversaturation. The latest version of MSnS-Extra with TunerStudio offers an “experimental” dwell control feature. I think I’m one of the first people to actually use it.  Certainly I’m the first to use it on the Toyota VAST system.

Thanks to Roy (erwendell) on the mr2oc.com forum, who tested his stock ignition system with an oscilloscope, I have a pretty good idea that stock dwell is about 2-3 ms. For now, I’ve set mine at 3 ms. (Major Warning: No Guarantees this will work. You could fry your Igniter or Coil, which would be a major PITA!)

After 100 miles of driving and a few hours of idling, I’ve seen no problems with this setup.

VE, Spark Tables

Of course, to get your car to run you will need to tune your VE table, after-start enrichment and Spark Table settings.

I haven’t fine tuned my enrichments page, but the example pictured seems to be pretty close.  Since the Mr2 has a fast idle setup for cold starts that isn’t controlled by the ECU, the car doesn’t seem to need much cold-start enrichment. I haven’t seen any weather much below 50 degrees, so those settings aren’t final. My EGO settings are based on recommendations in MSExtra.com.

TVIS Activation

I installed a system to control the TVIS using the programmable outputs offered by MSnS-Extra. You can set the output to RPM based and it will switch on/off a solenoid, such as the one that controls the vacuum circuit for the TVIS.

I’m using the X5 output, which is the Output Two circuit. X4 is the primary, but can be configured for boost control and I might use that later when I install a turbo on my MR2.  Despite the term “output,” MS really only provides a switching ground. To protect MS and provide a proper signal, you need to install a simple protective circuit, similar to what is used on the MS board in the FIDLE and Fuel Pump control circuits.

The circuit contains three components: a diode, IN4001; a 1k resistor and a transistor, 2N2222A. I picked up the parts at a local electronic shop, but you can order them from DigiKey. Locally they cost just a couple bucks. With handling and shipping from Digikey it might be more like $12.

I soldered the components together, put heat shrink on the various legs and soldered the circuit onto the underside of the MS board.

To set up the output function, you go to the Code Config menu in MegaTune and select Outputs. Scan down to Output 2 and select RPM source. The output byte values are times 100, and I set the start point at 6 (or 600 rpm) and the off value at 43. Depending on where you set your idle level, you might want to lower the start point. I have my car idling at about 800 rpm. The output will be active within the RPM range you select, whether coming from below 600 or dropping down from above 4300. I also set Normal output — not inverted.

The Hysterisis value is designed to keep the circuit from switching on and off rapidly when you’re cruising right at the on/off RPM. I set it at 2. I’m not sure what value is suitable or exactly how it works. I assume that this will give me at least a 200 rpm “window” above or below the Off value before it will turn back on or off – thereby preventing “fluttering” of the solenoid valve. I haven’t tested this feature. Since I don’t spend a lot of time cruising at 4300 rpm, it shouldn’t be a problem.

Turbo install

I initially planned to install a turbo on my NA engine, but found a JDM SC engine for a reasonable price and decided to make the swap. I used most of my NA accessories and the stock harness. The only wiring change was to replace the injector connectors, since the SC injectors were different. I simply clipped the injector leads on my stock harness and wired on the SC injector leads – two wires per lead.

I moved the starter to the intake side, but the stock harness had enough slack so I didn’t have to do any rewiring. I also installed a Walbro Fuel pump, which included changing the pump connectors inside the tank. The stock harness remains unchanged and still works with MS just fine.

I also installed an Innovate LC-1 wideband O2 sensor. The LC-1 needs power and two grounds: one chassis and one that runs to the ECU. Remember that AFM plug I discussed early on? Well, I had only used four of the seven pins in the plug when I did the initial install for MS. Power, chassis ground and system ground are all available in the AFM plug – so I just used those to wire up the LC-1. Finally, I pulled my stock O2 sensor, clipped the lead to it, and wired in the lead that plugs into the wideband o2 sensor. Refer to my wiring diagram above.

As far as MegaSquirt goes, I simply had to change my fuel and spark maps and the Req Fuel setting to handle the bigger injectors and demands of the turbocharger.


Even after installing a turbo and swapping engines, MS is still pretty much “plug n play.” I even briefly ran my stock NA ECU with the SC engine – just unplugged MS and plugged in the ECU. Everything worked fine, though the car ran very rich with the bigger SC injectors.

As I said in the beginning, this article is designed to provide general information on the setup I used. You should do your OWN RESEARCH before attempting this project. I AM NOT an expert on MegaSquirt or Toyota ignition systems. I’m just a guy that likes to play with cars!




Full Credit for this article goes to JamesL who has graciously given us permission to re-use his information here as we’ve been updating it for the PCBv3 MS-I and MS-II boards.  We all owe James a huge thanks for making this happen back in 2004.  Thanks man!