A better Spark Out circuit. - Miata Turbo Forum - Boost cars, acquire cats.

Welcome to Miataturbo.net   Members
 


MEGAsquirt A place to collectively sort out this megasquirt gizmo

Reply
 
 
 
LinkBack Thread Tools
Old 04-13-2009, 05:09 PM   #1
Boost Pope
Thread Starter
iTrader: (8)
 
Joe Perez's Avatar
 
Join Date: Sep 2005
Location: Delicious and Moist.
Posts: 26,320
Total Cats: 1,918
Default A better Spark Out circuit.

Following a long discussion in this thread, I've come up with a new spark output circuit, which is an alternative to the one currently (Apr 09) suggested by DIYAutoTune (and implemented by pretty much everybody) that involves soldering a pair of pullup resistors to D14 and D16 and then running them to the DB37.

This applies to both MS1 and MS2, and will run on any year Miata, as well as pretty much every other modern car that uses a solid-state ignition (no points) with or without a distributor, where the igniter is either external to both the coils and ECU (eg: 1.6 Miata, some DSMs) or integrated into the coils (1.8 Miata, vehicles with 3 or 4 pin COPs, some other DSMs, etc) that accept a +5 trigger input, and is driven using the LED output circuits (D14, D15, and/or D16). Apart from EDIS, I’m guessing this covers at least a simple majority of non-chainsaw/lawnmower Megasquirt users.

I’m going to start by discussing what problems that configuration creates and give some analysis as to why these problems happen, and then I’ll describe the new design and explain why it fixes them. It’s ok if you can’t follow some of the deep tech. In the examples which follow I’ll be showing the configuration for a two channel wasted-spark design, though the same basic principles hold for any number of ignition outputs wired using the LED driver circuits. I’m also assuming that you are running “Spark Output Inverted = No”. If that’s not the case, then you’re probably already covered.


Q: What exactly are the problems with the current design?

A: First, as we all know, if you perform a software reflash on the MS without first unplugging your ignition coils, your igniter and/or coils get fried. Second, some people experience an issue where at initial powerup (before the starter is engaged) they encounter a backfire through the intake, due to the ignition of residual fuel introduced by a leaky injector or simply remaining in the intake or combustion chamber having been injected but not completely inhaled and exhausted at the last shutdown.


Q: So what causes this?

A: In the current design, the spark outputs are the inverse of the CPU pin which is driving them. When the CPU pin is off, the output is on, and current flows through the ignition coil primary. When the CPU pin is on, the spark output is off, and no current flows through the coil. The problem is that any time there is power applied to the Megasquirt and yet the CPU is inoperative, the outputs will naturally go high. This occurs primarily on two occasions- when the CPU firmware is being reflashed and when the MS is first powered up and the CPU is in the process of booting up.


Q: Why is the circuit set up like that?

A: I can’t give you a good explanation for why people started configuring this the way that they did. It’s pretty lazy from a design standpoint, dangerous (to the car) from a user standpoint, and just not very smart. But once the first person had done it, and it worked, the second person copied it, and so on and so forth, until it became the canonical method for wiring spark output drivers.

As I said earlier, the current spark output driver design is such that the state of the outputs themselves (either +5 or ground) is a mirror-image of the state of the pins on the CPU which control them. Let’s take a look at the circuit that most of us use to control the ignition outputs. This is taken from a rev 3.0 PCB, though the 3.57 is essentially identical. The “base” circuit (that which is on the PCB itself) is in red and blue, while all added modifications are in black:



The two channels shown here are mirror images of one another, so we’ll focus on just the first one for now. As you can see, we’ve added a pullup resistor, 330Ω in this case, from +5 (which is the same as Vcc) to the junction between D14 and Q6. Typically, this resistor is physicially mounted between the top terminal of the LED and the left terminal of R24, as viewed from the backside.

<tech>
Now, a quick bit of quick transistor theory for the lay-persons. The transistor in position Q6 is known as an NPN transistor. It can be thought of as somewhat like a relay, where the top terminal (the collector) is the main input, the bottom terminal (the emitter) is the main output, and the terminal on the left (the base) functions like the coil. When a positive voltage is applied to the base, electricity is allowed to flow from the collector to the emitter. When no voltage (ground) is applied to the base, then electricity cannot flow from the collector to the emitter. (I can hear the EEs out there cringing at this oversimplification. Yes, transistors can be operated in a linear mode as is the case with amplifiers, but for our purposes here, they’re just on-off switches. Mmmkay?)
</tech>

The wire at the very left (Squirt-1) is connected to an output pin of the CPU, and then through R26 to the base of transistor Q6. So when the CPU puts out a voltage on that pin, the transistor turns on. Now, we’ve applied +5, through a current-limiting resistor, to the collector of the transistor. The emitter is grounded. So when the transistor is on, all the power flowing through the resistor is effectively shorted to ground, and there is no voltage potential present at the collector. Since that’s where the spark output is connected (pin 36), the spark output is off.

When the CPU is no longer outputting a voltage, Q6 turns off. Since the current passing through R26 is no longer being shorted to ground through the transistor, we now have +5 present at the collector, and therefore +5 at the spark output pin.

So the problem here is that when the CPU is inactive and yet the MS is powered on, the transistors are off, and thus the spark output pins naturally go to +5, causing the coils to conduct continuously.

During a firmware reflash, the CPU is offline for a considerable period of time. Running the coil primaries continuously for this length of time has been shown over and over again to cause permanent damage to the igniters and / or ignition coils as a result of overheating if the coils are not unplugged during the process. This is of course somewhat of a major nuisance, and more than one person who “knows better” has still forgotten to unplug ‘em just that once, usually at a cost of several days’ downtime and a couple hundred dollars in new ignition components


At initial powerup, the behavior of the system is somewhat more insidious. Like any computer, the Megasquirt CPU takes time to boot up and start operating when first turned on. Not nearly as long as a desktop PC running a big OS from a hard drive, but it still has to fetch data out of EEPROM and start executing it. In the case of an MS1 CPU, it takes appx 600 milliseconds for the CPU to begin operating. During this time, power is available to the spark output drivers, and since the CPU is not asserting the relevant pins high, transistors Q6 and Q8 are off, causing the spark output wires to be at +5, and causing the coils to conduct.

As soon as the CPU “wakes up”, it immediately drives the relevant pins high, causing the transistors to turn on, shutting down the spark outputs and causing the coils to stop conducting. As you probably know, it’s at this moment (when current flow through the coil primary ceases) that the spark plugs actually fire. Any fuel which happened to already be in the combustion chamber at that time will subsequently ignite, causing the backfire which seems to plague some Megasquirt owners.

Here’s an oscilloscope capture of what happens when the MS first powers up:

(click to embiggen)


At point “A” I have applied power to the Megasquirt. The spark output driver immediately goes to +5, and remains there for the whole time that the CPU is booting. At point “B”, after appx. 600ms, the CPU has initialized, its output pins are driven high, the spark outputs turn off, and the coils fire. In this illustration I was driving the MS with a JimStim, so the CPU immediately proceeds to start generating ignition pulses as soon as the incoming crank trigger is captured and synched, which is point “C”. In your car, the outputs would simply sit there at 0v until you actually started turning the starter and achieved capture and sync of the inputs, at which point the ignition pulses would begin.


Q: So how to we fix this?

A: I thought you’d never ask.

The solution is to configure the spark outputs such that they are on when the CPU’s output pins are on, and off when the CPU’s output pins are off. We could achieve this by using a PNP transistor on the CPU output pin (PNPs have the opposite control polarity of NPNs) (edit: no, that wouldn't work) however since NPNs are already a part of the the modkit packages of the various distributors, I’ve chosen a route which will achieve the same results at the same cost, without requiring that new devices be added to anybody’s inventory.

So essentially what I have done is to place a second set of NPN transistors after the first set, to un-invert the signals which Q6 and Q8 have inverted:




As you can see, we’re using the natural pullup of the existing LED to drive the base of the new transistor, which is connected to the collector of Q6/Q8 where the old spark output used to be. In this configuration, the output at the collector of the new transistors is exactly the opposite of what’s happening at the collectors of Q6/Q8, which is turn have always been the opposite of what’s happening at the CPU pins driving them. So, if the CPU is inactive, the spark outputs will be off.

NOTE: Having performed this modification, YOU MUST SET “SPARK OUTPUT INVERTED = YES”.

Let’s take a look at what happens when the Megasquirt powers on in this configuration:

(click to embiggen)



Again, the point marked “A” represents power to the MS being switched on. We can just barely make out a rise in the voltage at the spark output line, which represents the voltage drop across the output transistor. <tech> All semiconductors have a small voltage drop across them when “on”. This is referred to as the forward voltage across the junction, and varies by device. In this case, the only thing connected to the spark output was the high-impedance scope probe, which is why this rise is visible. Were an actual igniter connected, the voltage would be pulled to zero and thus non-observable. </tech> Since there is essentially no voltage here, the igniter does not activate, and no current flows through the coils.

At point “B”, the CPU has come alive, and since the ignition output was already off, nothing happens.

Finally, at point “C”, the MegaSquirt has synched to the trigger signal which the stim is feeding it, and spark output pulses commence.


Q: Great! Let’s do it.

A: That isn’t a question.


Q: Ok, how do I build this?

A: First off, get yourself a pair of NPN transistors. Pretty much any small-signal NPN capable of passing 50ma or more will do. Radio Shack sells a variety-pack of NPN transistors (catalog # 276-1617) which contains a mixture of 2N2222, 2N3904 and 2N4401, and any of these will work. You can also use the PN2222A, which is commonly sold by MS vendors as a relay driver. You’ll also want a pair of pullup resistors, something in the 220-330 ohms range. watt will suffice.

The easiest place to pick up the drive signal for the new transistors is at the top pad of D14-D16, the square pad. This image depicts wiring two drivers for SparkA and SparkB, connected to pins 31 and 36 of the DB-37 on the output side. Double-check the documentation for the specific transistor you select, but generally when holding the part such that you can read the printed side, the emitter is on the left, the base in the middle, and the collector on the right.



Having done this, be sure to set your MS for “Spark Out Inverted = YES”. This will cause the “resting” state of the outputs to be off, with +5 during the dwell period, falling back to 0v at the moment of firing, just like before. You do not need to reset your timing, readjust your dwell, or anything else.



Q: How many roads must a man walk down?

A: Forty-two.


That’s pretty much it. No more fried coils, no more popping at turn on. Prost!

Last edited by Joe Perez; 04-14-2009 at 08:22 PM. Reason: Added assembly diagram
Joe Perez is online now   Reply With Quote
Old 04-13-2009, 05:17 PM   #2
Boost Czar
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,872
Total Cats: 1,790
Default

Like I said before, I don't have the pooping issue. But I guess a little inversion therapy never hurt.
Braineack is offline   Reply With Quote
Old 04-13-2009, 05:18 PM   #3
Elite Member
iTrader: (9)
 
Saml01's Avatar
 
Join Date: Jul 2007
Location: NYC
Posts: 5,730
Total Cats: 2
Default

Why cant the NPNs(q6 and q8) responsible for the triggers be switched out for PNPs?
Saml01 is offline   Reply With Quote
Old 04-13-2009, 05:24 PM   #4
meatbag
iTrader: (50)
 
gospeed81's Avatar
 
Join Date: Nov 2008
Location: Houston, TX
Posts: 7,357
Total Cats: 26
Default

A W E S O M E write up Joe!

Srsly, u r teh awesome.



I do have the popping issue, and have fried one (almost two) ignitors. This is great, and I hope folks start incorporating it into their builds.

One day I'll get brave enough to modify mine (after someone posts pics of where to solder what).
gospeed81 is offline   Reply With Quote
Old 04-13-2009, 05:33 PM   #5
Hittin' Boost & Cones
iTrader: (2)
 
240_to_miata's Avatar
 
Join Date: May 2007
Location: Cromwell, Connecticut
Posts: 2,572
Total Cats: 11
Default

I would absolutely put this into a megasquirt if i was building it right now or in the future, but im not about to tear into my fully functioning megasquirt to mod it.


I'll live with the pop.

Looks great tho joe!! Thanks for spending the time on this
240_to_miata is offline   Reply With Quote
Old 04-13-2009, 05:45 PM   #6
Supporting Vendor
iTrader: (31)
 
Savington's Avatar
 
Join Date: Nov 2006
Location: Sunnyvale, CA
Posts: 14,366
Total Cats: 1,326
Default

Something to do next time my ECU is out. Badass, Joe.
Savington is online now   Reply With Quote
Old 04-13-2009, 06:04 PM   #7
Elite AbsurdFlow Member
 
Laur3ns's Avatar
 
Join Date: Mar 2008
Location: Enschede, NL
Posts: 2,058
Total Cats: 11
Default

I like it, but I wont be able to perform this free of errors unless we get a full MSPNP to MSPNP-Joe-mod pictorial...
Laur3ns is offline   Reply With Quote
Old 04-13-2009, 06:19 PM   #8
Boost Pope
Thread Starter
iTrader: (8)
 
Joe Perez's Avatar
 
Join Date: Sep 2005
Location: Delicious and Moist.
Posts: 26,320
Total Cats: 1,918
Default

Quote:
Originally Posted by Saml01 View Post
Why cant the NPNs(q6 and q8) responsible for the triggers be switched out for PNPs?
They probably could be. (edit: this is wrong. Explanation in a post to follow.) I didn't want to modify too much, and I wanted to stick with NPNs since they are available in modkit form from vendor whereas PNPs are not.


Also, I wanted this to be applicable to MSPnP users as well, and they don't really have that option. Though I suppose I'll have to come up with a "where to cut" to add it to the MSPnP. Which will be tough since I don't have one here in front of me. Probably something best left for DIY.

Quote:
Originally Posted by gospeed81 View Post
One day I'll get brave enough to modify mine (after someone posts pics of where to solder what).
Pics added.

Last edited by Joe Perez; 04-14-2009 at 08:26 PM.
Joe Perez is online now   Reply With Quote
Old 04-13-2009, 06:39 PM   #9
Boost Czar
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,872
Total Cats: 1,790
Default

actually when you build, we never use q22 and q23 which are PNPs IIRC.


i decided to not be lazy:



Braineack is offline   Reply With Quote
Old 04-13-2009, 07:52 PM   #10
Junior Member
 
kday's Avatar
 
Join Date: Aug 2008
Location: Boston
Posts: 223
Total Cats: 0
Default

Nice. Having to unplug stuff to reflash would drive me nuts.

My 74ABT125 ignition driver is working just peachy but it's probably overkill.
kday is offline   Reply With Quote
Old 04-13-2009, 08:22 PM   #11
Boost Czar
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,872
Total Cats: 1,790
Default

my car still works. so that's always a plus. no pooping for me.
Braineack is offline   Reply With Quote
Old 04-13-2009, 08:56 PM   #12
Elite Member
iTrader: (9)
 
Saml01's Avatar
 
Join Date: Jul 2007
Location: NYC
Posts: 5,730
Total Cats: 2
Default

Great, I may consider this in the future. Desolder Q22-23 and toss it into the Q6 and Q8.
Saml01 is offline   Reply With Quote
Old 04-14-2009, 01:24 PM   #13
Senior Member
iTrader: (10)
 
Join Date: Apr 2007
Location: Ohio
Posts: 800
Total Cats: 3
Default

Quote:
Originally Posted by Saml01 View Post
Great, I may consider this in the future. Desolder Q22-23 and toss it into the Q6 and Q8.
So that's it really? Just toss Q6 & Q8 and replace with 22 & 23? I don't have mine in the car yet so if that's all there is....I'm doin' it.
soloracer is offline   Reply With Quote
Old 04-14-2009, 02:12 PM   #14
meatbag
iTrader: (50)
 
gospeed81's Avatar
 
Join Date: Nov 2008
Location: Houston, TX
Posts: 7,357
Total Cats: 26
Default

Quote:
Originally Posted by Joe Perez View Post


Pics added.
Ask and ye shall receive...unless she's just way too hot for you.
gospeed81 is offline   Reply With Quote
Old 04-14-2009, 03:02 PM   #15
Elite Member
iTrader: (9)
 
Saml01's Avatar
 
Join Date: Jul 2007
Location: NYC
Posts: 5,730
Total Cats: 2
Default

Quote:
Originally Posted by soloracer View Post
So that's it really? Just toss Q6 & Q8 and replace with 22 & 23? I don't have mine in the car yet so if that's all there is....I'm doin' it.
If Joe Perez is certain that this is how the ignition circuit works, then yes. According to the megamanual Q22/23 are part of the VR Circuit and are PNP.

Technically speaking, if you built the MS for Hall/Opto then you should have the parts of the VR Circuit left over.
Saml01 is offline   Reply With Quote
Old 04-14-2009, 05:35 PM   #16
Senior Member
iTrader: (4)
 
Join Date: Jan 2008
Location: Falls Church, VA
Posts: 1,367
Total Cats: 16
Default

Nicely done. Written so even somebody with rudimentary electronics knowledge (me) can understand what's going on with the circuit.

I have a question that may or may not be relevant at all to this part of the MS circuit. I see that the spark outputs are held high for ~800ms during bootup. Over time, can this cause any internal damage to the coil/ignitor such that it results in an electrically noisier environment for the MS?

I have no issues with residual fuel backfiring at startup, but I ask because I and others are getting random spikes & resets in datalogs. It doesn't affect driveability at all; in fact, if I never looked at a datalog I would never know it happened. The fact that I had ZERO issues with this when the MS was freshly built tells me this electrical noise is something that has crept in over time, and I'm wondering if repeated ~800ms signals to the coils every time I start the car is a potential culprit.
ScottFW is offline   Reply With Quote
Old 04-14-2009, 08:03 PM   #17
Boost Pope
Thread Starter
iTrader: (8)
 
Joe Perez's Avatar
 
Join Date: Sep 2005
Location: Delicious and Moist.
Posts: 26,320
Total Cats: 1,918
Default

On second thought, I don't believe the idea of sticking PNP devices into the Q6 / Q8 positions is going to work. The manual for the 68HC908 is kinda vague on the point, but generally, output pins of microcontrollers are high-impedance until they are initialized (IOW- neither at +5 nor grounded, but merely floating as though unconnected). A transistor requires base current in order to operate, and I doubt that a ZTX553 (or any other PNP for that matter) is going to turn on with its base facing a high-z driver.

The trick with the additional NPN transistors works because, when the CPU is unconscious and not driving Q6/Q8, the pullups on their collectors (D14 and D16) cause the transistors downstream of them to turn on and pull the outputs low.

If somebody wants to try it, I'd be happy to be proven wrong here. But I don't think it's gonna work. (And I don't have a MS on my desk right now to experiment with.)
Joe Perez is online now   Reply With Quote
Old 04-14-2009, 08:30 PM   #18
Boost Pope
Thread Starter
iTrader: (8)
 
Joe Perez's Avatar
 
Join Date: Sep 2005
Location: Delicious and Moist.
Posts: 26,320
Total Cats: 1,918
Default

Quote:
Originally Posted by ScottFW View Post
I have a question that may or may not be relevant at all to this part of the MS circuit. I see that the spark outputs are held high for ~800ms during bootup. Over time, can this cause any internal damage to the coil/ignitor such that it results in an electrically noisier environment for the MS?
I doubt it. The damage to the igniter is caused by overheating. For whatever reason, it's just not beefy enough to handle continuously sinking primary current for any length of time. However I don't think that 600ms at startup is going to cause any harm. (It's closer to 600 than 800, when I look closer at the capture. But even 800ms is unlikely to hurt it.)
Joe Perez is online now   Reply With Quote
Old 04-20-2009, 02:28 PM   #19
!!! NOT CONFIRMED !!!
 
Join Date: Dec 2006
Location: North Port, FL
Posts: 52
Total Cats: 0
Default

My car still works
LostSoulMiata is offline   Reply With Quote
Old 04-20-2009, 02:29 PM   #20
Boost Czar
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,872
Total Cats: 1,790
Default

ha. ive been running it for exactly a week now.
Braineack is offline   Reply With Quote
 
 
Reply

Related Topics
Thread Thread Starter Forum Replies Last Post
FS/FT: 03.5 Mazdaspeed Protege leatherface24 Cars for sale/trade 15 10-16-2015 12:35 PM
Time to start learning and play with tuning The Gleas MEGAsquirt 3 10-01-2015 10:30 AM
01-05 Fab9 PNP COPs (used) FrankB Miata parts for sale/trade 6 09-30-2015 12:48 PM
In need of AEM guidance W/pics E=MC^2 AEM 1 09-17-2015 01:34 PM
Obligatory "N00B" post! D_Breezy Meet and Greet 5 09-08-2015 06:37 PM


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -4. The time now is 10:48 PM.