M20B20 to MegaSquirt build

For all your questions, problems and DIY stories
Post Reply
User avatar
BertjeConti
E21 Mad
Posts: 3007
Joined: Mon Nov 04, 2013 9:49 pm
My E21(s): E12 520-6
Location: nederland , Weert

M20B20 to MegaSquirt build

Post by BertjeConti »

Hello all,

This is a informative topic, with lots of technical info to come.

I know, this is the E21 forum, and this is about a E12 520-6, but, since there are no european E12 forums and my E12 is technical very very very similar to the E21 320-6, I think this story is appreciated here.

First, what is this all about: conversion to Megasquirt, lost of guys did it before, but my aproach is a little different, as are my goals.

At the moment the car runs on it's stock carburettor and ignition and performs not bad at all. Fuel consumption however is massive. And once in a while it starves on idling during warmup, a problem which i can't tackle. The engine is stock and never overhauled, only the head is 10 years ago replaced for a 1981 head. The stock head was cracked near cyl-5, a common problem for the early heads due a casting fault. Engine has roughly 110k miles on it, oil consumpion is almost zero.

Why conversion to megasquirt?
1) because it is possible
2) i learn a lot about engines
3) i want to be able to tune the engine, so it runs a little bit cheaper
4) it is fun to do (my background is electronics)

What are my goals:
1) less fuel consumption
2) get rid of the stock carburettor and ignition, which are factory tuned for maximum safety
3) a little bit more power would be nice
4) sequential injection
5) wasted spark ignition
6) as cheap as possible
7) clean and relyable build

The last months i did a lot of internet study about the megasquirts and read a lot about other convertions or builds. At the same time I started to gather parts needed for my conversion. At this moment almost all the needed parts are present, and the build is progressing well.

The conversion will be a step to step conversion, because the car is a dayly user.

First about the Megasquirt:
I could have bought a MS2 or MS3 kit, but because i want some modifications done to the stock MegaSquirt it would be a messy build. The basis is the MS2 V3 megasquirt, but i've designed my own PCB with all the needed changes on it.
My MS2 based PCB features:
- 3 injector drivers with flyback for high-Z injectors
- 3 coil drivers
- knock detection
- 3 wire idle valve driver

This involved a lot of testing on breadboard and so before the final PCB design was ready for manufactoring.
This is my MS2 based designed PCB with all the needed parts and cirquits on it:

Image

It is manufactured in china for me (china is a good supplier for cheap parts)

another picture, PCB almost complete:

Image

stay tuned, lots of info and pics to come


Image
Megasquirted '77 E12 520-6

Aspen Silver '96 E39 523i
User avatar
BertjeConti
E21 Mad
Posts: 3007
Joined: Mon Nov 04, 2013 9:49 pm
My E21(s): E12 520-6
Location: nederland , Weert

Re: M20B20 to MegaSquirt build

Post by BertjeConti »

Spare engine

To make the conversion easier i've purchased a spare M20B20 engine out of a 1987 E30. I don't know if the engine is any good, bud it can provide me some critical parts needed for the conversion.
I've bought the engine for 100 euro, only the air mass unit was missing, but we don't need it.

This engine provides me
- 60-2 trigger wheel (pulley damper)
- sensor mounting bracket
- wiring harness with all the needed connectors
- thermostat housing (connection interior heater hose is located at the botton enstead of the top)
- fuel rail and pressure regulator
- injectors
- intake manifolt
- idle air valve
- air box (filter)
- 731 head

last weekend i've changed the stock harmonic pulley damper for the 60-2 trigger wheel damper,
I've made a white marker for TDC and marked the relation to the sensor position at TDC.
Image

The sensor is a HALL sensor, used in the M50 engine (with triggerwheel in the crankcase), fits perfectly on the bracket, first a trial fit on the spare engine:
Image

the engine bay offers a little bit more room between engine and radiator as in the E21, here the wheel and sensor are fitted in the car, fan and waterpump pulley still dismantled.
Image

next to come: wiring loom
Image
Megasquirted '77 E12 520-6

Aspen Silver '96 E39 523i
User avatar
Jeroen
Site Admin
Posts: 29194
Joined: Tue Sep 14, 2004 12:23 pm
My E21(s): '81 323i Baur
Location: The Netherlands
Contact:

Re: M20B20 to MegaSquirt build

Post by Jeroen »

Nice! Still I think I'd rather like to do this on a M20B25 though. But nice work, keep us updated. I'll be following this thread!
Regards/groeten, Jeroen
User avatar
BertjeConti
E21 Mad
Posts: 3007
Joined: Mon Nov 04, 2013 9:49 pm
My E21(s): E12 520-6
Location: nederland , Weert

Re: M20B20 to MegaSquirt build

Post by BertjeConti »

upgrade to M20B25 is out of the question, getting a good 2.5 motor rockets the costs sky high. The engine thats in the car right now is good and reliable, since i drove for the last 14 years :D .

The wiring loom

Ofcourse the stock wiring loom in a carburetted engine with a dizzy is a no go for fuel injection. The engine bay loom thats in right now will be remain untouched. For the megasquirt conversion i've made a totaly new wiring loom.

I started with complete dismantling of the wiring loom from my spare engine, because there are a lot wires in it that we don't need, for exampe alternator and starter motor wiring. Just throw this loom in the engine bay would end in a nightmare.

- The MS ECU is planned inside the cabine, behind the glove box. (during build and testing under the radio)
- Main relay in the fuse box, there is a spare socket intended for fog-lights, which i obveously do not have.
- 3 spare fuses in the fuse box will be used for the megasquirt setup.
- Fuel pump relay will be at the site of the fusebox, exactly as origional fuel injected cars.

I build up the new wiring loom using all the wires and connectors from the dismantled wiring loom from the spare engine, which was a motronic 1.3 actualy.

here it is temporarely held together with zip ties:
Image

It now features 3 groups for the injectors instead of 2, cyl 1+6 ; 2+5 and 3+4 will fire together, which makes sequential injection possible
Only the needed wires are wired in to keep it as simple as possible

then the loom is taped with polyester fabric tape, which isnt an adhesive tape. Using this tape keeps the loom flexible and it can resist high temperatures.

Image -> http://www.rdae.nl/montagemateriaal/tap ... abric-tape

after taping the loom looks much better.

Image

thera are only 5 wires running to the fusebox to connect to the existing wiring system:
- main power from main relay (ecu + coilpack + idle valve)
- fuel pump relay switch
- tach signal
- Injector power from fuel pump relay
- O2 heater from main relay

connector for the coil pack isn't installed yet, because i first need the coilpack to know the type connector i need.

Thick ground wires come together and connect to the bulkhead where the earth strap from the cylinderhead is connected too.

The loom will be fully functional tested before i throw it in the engine bay.

stay tuned...
Last edited by BertjeConti on Fri Mar 21, 2014 4:08 pm, edited 1 time in total.
Image
Megasquirted '77 E12 520-6

Aspen Silver '96 E39 523i
User avatar
Duracel79
E21 VIP
E21 VIP
Posts: 802
Joined: Thu May 29, 2008 6:54 pm
Location: Stevenage, Hertfordshire

Re: M20B20 to MegaSquirt build

Post by Duracel79 »

Hi mate,

Some nice work there, but are there some missing sensor wires going to the fusebox?
Oil pressure, water temp etc?

Or are you not using the E21 dash?

Cheers

Ben
1982 323i (S54 "Test Mule" - to be rebuilt into M20 powered track car)
1983 316 (Taiga Thunder - The refined S54 Race car)
1982 635csiA (New project)
1985 728iA (For Sale)
2004 330d Touring (The Daily Hack / Tow Car / Load lugger)
User avatar
BertjeConti
E21 Mad
Posts: 3007
Joined: Mon Nov 04, 2013 9:49 pm
My E21(s): E12 520-6
Location: nederland , Weert

Re: M20B20 to MegaSquirt build

Post by BertjeConti »

Duracel79 wrote:Hi mate,

Some nice work there, but are there some missing sensor wires going to the fusebox?
Oil pressure, water temp etc?

Or are you not using the E21 dash?

Cheers

Ben
Ben,

The stock wiring loom which is already in the engine bay remains untouched, this provides the oil and temp sensor wiring to the dash cluster. Also it provides the wiring for starter motor and alternator.

Because the conversion will be done step by step, the old carb/dizzy setup must be operational in the beginning.
- first step is wiring all sensors and test them, if that is ok then
- next step is swap from dizzy to wasted spark ignition, and tune that correct in
- final step is swap the carburettor for injection

The new wiring loom is add on and explicit for the Megasquirt conversion.
Last edited by BertjeConti on Fri Mar 21, 2014 10:22 am, edited 1 time in total.
Image
Megasquirted '77 E12 520-6

Aspen Silver '96 E39 523i
User avatar
croma_man
E21 Pro
Posts: 594
Joined: Fri Sep 07, 2012 1:18 pm
My E21(s): '83 EU 327i
Location: Slovenia (EU)
Contact:

Re: M20B20 to MegaSquirt build

Post by croma_man »

nice, very well documented, subscribed ! :thumbsup
User avatar
BertjeConti
E21 Mad
Posts: 3007
Joined: Mon Nov 04, 2013 9:49 pm
My E21(s): E12 520-6
Location: nederland , Weert

Re: M20B20 to MegaSquirt build

Post by BertjeConti »

CPS (Crank Position Sensor)

This is probably the most important sensor in the system, if this fails or functions not perfectly, the engine won't run at all.

With this sensor the ECU (MegaSquirt unit) knows the position of the crank and RPM of the running engine, and can calculate when to fire the injectors, spark plugs and al lot more. Most important is the timing for firing the spark plugs !

If you want to let the Megasquirt control the ignition (sparks at spar plugs) it is most commonly to use a " missing tooth" triggerwheel on the crank. BMW M20 Motronic injected engines have such a triggerwheel, it is a wheel with 60 tooth, where 2 are missing, hence 60-2.

There is a sensor needed that can "see" the tooth from the triggerwheel come by when the engine is running, and provide that information to the ECU

There are two types of CPS sensors most commonly used:

1) VR sensor, (variable reluctance), this is nothing more than a coil around an iron bar and a magnet. It provides a alternatig signal as the toothed wheel flies by it.
these sensors are very robust, and most used as CPS sensor. the drawback of these sensors is that they need a signal processing cirquit before the signal is fed to the processor. Good signal processor cirquits don't come cheap. Another point is that these sensors provide wery weak signals when the engine is turning slow (cranking) and are easy disturbed by other signals, such as ignition leads.
The standard signal processing cirquit on the Megasquit mainboard is difficult to tune and very sensitive for disturbing signals. Not the best way to go

2) Hall Sensor, these sensors have a electronic cirquit in them and provide a digital square wave as output. typical 3 wire connector. No need for a signal processing cirquit.

For my build i've chosen to go for the easy way and ordered a Hall CPS sensor from ebay. This is a sensor used in the BMW E36 which has the triggerwheel inside the crankcase.
This is the sensor:
Image
http://www.ebay.com/itm/321098122763 when i bought it, it was $12,66 including shipping. Bargain :D

I've designed a very simple input cirquit for the sensor, it is in fact ony a inverter. I did not want to connect the sensor without any protection direct to the processor.
This is the cirquit i'm using:
Image

First i've tested it on the bench, bolted the triggerwheel (pulley damper) on my polishing machine which can do max 5000 rpm and is rpm regulated.
These test gave a perfect signal in the MegaTune log.
After that was sorted out the triggerwheel and sensor bracket where on my spare engine, to check the fit of the sensor.

The sensor fits perfectly in the bracket and the needed gap between the sensor and triggerwheel was excactly between 0.5 and 1mm

Then the triggerwheel and sensor could go to the engine in the car, as i discribed earlier.
Image
Megasquirted '77 E12 520-6

Aspen Silver '96 E39 523i
User avatar
BertjeConti
E21 Mad
Posts: 3007
Joined: Mon Nov 04, 2013 9:49 pm
My E21(s): E12 520-6
Location: nederland , Weert

Re: M20B20 to MegaSquirt build

Post by BertjeConti »

Fusebox modifications:

The whole Megasquirt setup needs to be powered. 1 option is to use the MegaSquirt relay module which houses the needed relays and fuses, but ofcourse I went another way.

In my stock fusebox is 1 relay socket empty and are 3 fuse positions free, 2 of the 3 fuse positions are already connected to the unused relay, the third is connected to nothing.
It is Relay E, optional for fog lights which my car obveously does not have.

There was another relay clamped to the fusebox housing which was unused as well, this relay was intended for a electric fuelpump, which my car does not have either.

So I planned to use the free relay socket in the fusebox as main relay for de MegaSquirt setup, and use the not used fuelpump relay as fuelpump relay.

Fuses F15, and F16 are already connected to relay E and will be used for powering the ECU, CoilPack, ildevalve an O2 heater.
Fuse 17 is planned for the fuelpump and injectors

To achieve this there where some wiring changes involved inside the fusebox, but this would be the neatest solution.
From the Megasquirt wiring loom runs 1 thin branch to the fusebox, there are 5 wires in it to connect to the fusebox.

Before you start working on the existing wirings of your car ALWAYS DISCONNECT THE BATTERY, to do this disconnect the - pole from the battery , why the - pole?
when unscrewing the + pole, there is a chance that you make a short with your wrench between the + pole and the chassis !!

Ive planned the changes needed at my fusebox carefully and gathered the needed components before starting. Most important parts are "bare spade connectors with locking tab", some spade connector housings and a tool to crimp the connectors.
Image Image

These connectors fit in the relay sockets and on the fuse connectors. Always handy to have some in spare.

In this drawing all the needed changes and connections are drawn up, including wire colours:

Image
Link to origional drawing: https://farm3.staticflickr.com/2815/133 ... 3d4e_o.png

If planned carefully and made a good drawing and notes, the changes will be done in 1 hour. I did these changes yesterday.

here som pictures:
Image
Here i'm addingg the brown wire for Relay E, therefore the connector at the existing brown wire in relay B socket needs to be renewed as well, the new connector accomodates 2 wires

Image
here adding the green/white wire for relay E.
Fusebox inside looks stil good after 37 year, almost brandnew :D

And finished, the black relay in the middle of the fusebox is the main relay for Megasquirt, and the white relay attached to the fusebox is the fuelpump and injectors relay.
You can also see the thin extra wiring loom exiting the fusebox which is a branch from the Megasquirt wiring loom.
Image
The electronic module and coil will be gone in a few weeks.
This picture shows that the car once has been an automatic, the unused oil cooler connections in the radiator.
I did the conversion more than 10 years ago.
Image
Megasquirted '77 E12 520-6

Aspen Silver '96 E39 523i
User avatar
BertjeConti
E21 Mad
Posts: 3007
Joined: Mon Nov 04, 2013 9:49 pm
My E21(s): E12 520-6
Location: nederland , Weert

Re: M20B20 to MegaSquirt build

Post by BertjeConti »

The ECU

the last parts for the ECU have arived, so i could finish the build.

I've made a total redesign and used the Megasquirt II V3 and MicroSquirt as reference.
In the design I changed the following:

- 3 injector drivers instead of 2, like in the Mircosquirt, suitable for only driving high-Z injectors. In the microsquirt the VND5N07 fully protected Mosfet switches are used, these are rated for max 5A. I used the VNP10N07, which is rated at max 10A. And added a active flyback clamp circuit to protect the Mosfets for high discharge voltages from the injectors.
I ditched the Megasquirt V3 PWM Damping flyback circuit. 3 injector drivers are needed for semi sequential injection.

- 3 coil driver circuits using the EDIT: Fairchild ISL9V5036P3 EcoSpark Driver (46A, 390V, 500mJ). in Wasted Spark mode

- 3 led drivers

- 2 wire IdleValve driver using 2 VNP5N07 fully protected Mosfet switches

- ditched the whole 'Tach Inpunt Circuit' and designed a simple Hall Sensor input circuit, see my earlier posts here

- added my own designed analog Knock detection circuit

- RS232 driver

- External MAP sensor connection (MAP sensor placed in engine bay, not in ECU housing like megasquirt2 V3

- Dragonfly MC9S12C128 mircoprocessor board, which does not have the idle stepper motor driver and PWM injector driver.

I've designed my own PCB and let 'MakePCB' in China produce it for me.

Here the PCB is fully assembled:
Image
In the bottom right corner the 3 coil drivers are situated with their heatsink
in the top right the 3 injector drivers and the active flyback with the fat 3A ultrafast diodes
In the middle right are the mosfets for the idle valve and fuelpump relay, they don't need a heatsink
at the left side of the PCB the knock detection circuit is situated.

Here the PCB is placed in it's housing with Phoenix connectors:
Image

all the connections are labeled:
Image

Image

If anyone is interested in the circuits, please pm

stay tuned
Last edited by BertjeConti on Mon Apr 07, 2014 9:58 pm, edited 2 times in total.
Image
Megasquirted '77 E12 520-6

Aspen Silver '96 E39 523i
User avatar
Jeroen
Site Admin
Posts: 29194
Joined: Tue Sep 14, 2004 12:23 pm
My E21(s): '81 323i Baur
Location: The Netherlands
Contact:

Re: M20B20 to MegaSquirt build

Post by Jeroen »

Really, really impressive work! :thumbsup
Regards/groeten, Jeroen
User avatar
BertjeConti
E21 Mad
Posts: 3007
Joined: Mon Nov 04, 2013 9:49 pm
My E21(s): E12 520-6
Location: nederland , Weert

Re: M20B20 to MegaSquirt build

Post by BertjeConti »

wiring loom first trial in the engine bay

On the stimulator the ECU works perfectly, but before i would throw the wiring loom in the engine bay, i would like to make a trial run to check the most critical sensors:

I connected the wiring loom to the CPS, MAP, CLT, MAT, Knock and TPS sensors and hooked it to the ECU. connected the laptop with tunerstudio and ran the engine. (engine still running on its old dizzy and carburettor)
This is only a test to see if the wiring loom is ok.
TunerStudio is the software tool to use to tune in your Megasquirt based ECU.

Here is the test setup:
Image

All sensors except the TPS are acual connected to the engine and gave me real measurements

Image

Looked good in TunerStudio.

Most critical sensor, the CPS, gave a very clean signal in TunerStudio
Image

The wiring to the IdleValve, Injectors and Coilpack i've tested on the bench with the stimulator hooked up to the ECU

The Stimulator is a test circuit with several dials to simulate the different sensors, it has a microprocessor which can simulate the toothed wheel signals.

Now i could install the wiring loom definitely
Image
Megasquirted '77 E12 520-6

Aspen Silver '96 E39 523i
User avatar
BertjeConti
E21 Mad
Posts: 3007
Joined: Mon Nov 04, 2013 9:49 pm
My E21(s): E12 520-6
Location: nederland , Weert

Re: M20B20 to MegaSquirt build

Post by BertjeConti »

Wiring Loom install

Before the wiring loom goes into the engine bay, i had to drill a hole through the firewall.

Image

Image

loom fixed to the valve cover, i hope this carburettor soon leaves, because it consumes way to much fuel:
Image

loom entering the cabin:
Image

loom in glove compartment:
Image

next to come up are real test drives
Image
Megasquirted '77 E12 520-6

Aspen Silver '96 E39 523i
User avatar
Sierpien
E21 Fanatic
Posts: 238
Joined: Wed Feb 22, 2006 2:21 pm
My E21(s): C1 Turbo Alpina tribute, 316 Sepiabraun
Facebook page: https://www.instagram.com/fedecx5aa/
Location: Uruguay
Contact:

Re: M20B20 to MegaSquirt build

Post by Sierpien »

Inspiring thread! thanks for sharing!
My Fake E21 Alpina "C1 Turbo" tribute car!
"Sepiabraun" 1.8 M10 swapped 316


"I thought the block was good for 200, even 300 hp, but I never thought it would take 1000 horsepower."

Alex von Falkenhausen
alschux
Upcoming E21 fanatic
Posts: 96
Joined: Mon Dec 17, 2007 6:46 pm
Location: Innsbruck, Austria

Re: M20B20 to MegaSquirt build

Post by alschux »

Nice project and very tidy work. It'll be interesting if you notice a power difference
Post Reply