|    |    |    | Today: 23-Aug-2019 |

Megasquirting My 1983 Datsun Z

September 8, 2016 | Posted in News

When Dinosaurs Drove to Work

Back in the mid 1980’s I worked at a company called Commodore Business Machines, a company that made home computers where our annual Superbowl was the Consumer Electronics Show in Las Vegas the first week in January.

Some time in November a Datsun Z would get parked in the front lot and then not move until whatever snow mounds that got plowed over it melted sometime in early spring. Ultimately I would have it towed leaving behind a sad little pile of rust and nuts and bolts. With a bonus check in hand for finishing the newest computer on time I would go buy another used Z and repeat the cycle.

Climate Change and Rust

These days the old Datsun Z’s; 240Z, 260Z, 280Z, 280ZX, are somewhat rare, probably because they were real rust buckets even when new. After having sacrificed a few myself in search of the next home computer I set out to rescue one for old times’ sake. I really did love the car so I made it my project to restore one. Now I have a total of three Z carcasses, an engine, and a transmission all sitting out back and an almost finished Z in the garage.

Since I had torn the engine down to its bare components I took the opportunity to make some changes: increased the size of the turbocharger, increased bore and stroke of the cylinder/piston, improved the fuel distribution, and improved the flow of air with things like porting the heads and an inter-cooler.

The Need For a New ECU

All of this means that I needed to modify the way the engine mixed fuel with air to support combustion, More air means that more fuel is needed in the same amount of time. Step one was bigger fuel injectors (and bigger fuel pump, regulator, filters, sump, plumbing, etc.) and this is why I needed a programmable Engine Control Unit (ECU).engine2

From a diverse list of alternatives I chose to use a Megasquirt, a design that has heavy DIY roots. In my case I assembled the ECU myself a while back (this particular kit is from 2005). It now controls most of the vital functions in my car short of selecting what music I want to jam to.

Fuel Injected Engine

Air Through the Engine

Seen here is a block diagram of the major components that control the function of the engine and as I say in the video, it’s all about the trip the air takes through the engine. Stepping on the throttle doesn’t directly add fuel as you might think, it really opens up a gate that allows more air into the combustion chambers which the ECU then compensates for by adding the appropriate amount of fuel.


The decision on how much fuel to add is based on not only how much air, but the temperature and a sensor in the exhaust that senses how completely the fuel is being burned. Other functions such as turning on the fuel pump and controlling the idle are examples of other functions the ECU can do. In my case I am not using the new ECU to control the spark that ignites the fuel; I have left control up to the stock ECU.

How to Measure the Airflow

My original Z engine measured the air flow with an inline Volume Air Flow (VAF) sensor that actually (and unfortunately) obstructs the flow of air in the process. This works by measuring the drag force of the air moving on a spring loaded vane. We call this arcane thing “the flapper” due to the way the vane flaps open and closed while operating. As this method measures the volume, the temperature of the air is as needed to determine the mass of the air.

Stock airflow sesonr uses "flapper" More refined sensor uses heated wire

An alternative way of measure the flow of air is the Mass Airflow (MAF) sometimes called a hot wire sensor. The simplest description is that it measures the cooling of a heated piece of wire by measuring its change of resistance or the change of current that is required to maintain it at a set temperature. The flow of air across the wire removes the heat (think thermodynamics) and it tends to rule out the effects of temperatures as it more directly measures mass not volume.

How the Megasquirt Measures Air

veThe Megasquirt does something different from what I described above. It uses a barometric sensor and measures the air pressure in the manifold, the space where fuel and air is mixed just prior to being sucked into the cylinders.

Combining this with other inputs such as the engine speed and O2 sensor is how the Megasquirt calculates how much fuel should be injected. But it gets even better. In addition to this improved method of monitoring combustion, I am in control of the calculations the ECU is making based on these measurements. This gives me a remarkable amount of control over pretty much everything the engine is doing.

The Tuner Studio Software

The software used to configure the Megasquirt is the Tuner Studio MS by EFI Analytics. I use the paid version which has additional features such as advanced tuning based on actual driving logging and performance.

There are a slew of basic configuration parameters that need to be loaded, basically the specifics about the engine including the number of cylinders , the fuel injector flow rates and even the type of fuel being used. Ultimately we end up with a Volumetric Efficiency (VE) map that is very similar to standard Fuel/Air maps in that we program how much fuel should be injected at different speeds and loads.

Click to view slideshow.

Additional variables such as when to enrich or modify the fuel amount under various conditions such as engine priming , wide open throttle (aka “flooring it”), and a warm-up period. My engine injects almost twice the amount of fuel when the engine is dead cold.

Teaching an ECU

With the Tuner Studio software plugged in and running it can accumulate live results from the way the engine performs under real life conditions and creates a table of suggested modifications to the VE map, which can then be applied. This means that the final performance is optimized beyond simple calculated values, in essence it should drive better every time until all of the parameters have been balanced through the tuning process.


Dash Bling

Finally the software can be run on a laptop of built in car computer using some of the designer dashboards included or the user can design their own dashboard with a wide range of gauges available including calculated values such as fuel economy.

Click to view slideshow.

I note that its now also possible to use an Android device for a remote dash cluster and I have to admit that the thought of one of my old mini-tablets on the dash in HUD mode kind of sounds cool.

The Kit

I built my ECU from a kit with the exception of the processor upgrade plugin was pre-assembled (all SMT). Its based on the MC9S12C64, a 16 bit processor running at 24 MHz with 4kB or RAM and 128 kB of flash, and has a few useful addons such as PWM controller and CAN interface.megasquirt


with stimulatorAnytime you work on a system you’ll save yourself a lot of time with proper testing. In this case, removing the biggest variable — the car — is paramount. I have two different test units that plug into the “Big Ass Connector” of the ECU.

Shown here is my Megasquirt with one of the stimulators (the green PCB) available for configuring and troubleshooting. This was so much more useful than I thought it would be.


All of the stuff I talked here is for off-road usage; it is unlawful to modify anything to do with federally mandated emissions control.


Filed under: Engine Hacks, Featured
Source: Hackaday

Taged in: datsun, megasquirting