Miata Turbo Forum - Boost cars, acquire cats.

Miata Turbo Forum - Boost cars, acquire cats. (https://www.miataturbo.net/)
-   MEGAsquirt (https://www.miataturbo.net/megasquirt-18/)
-   -   A better Spark Out circuit. (https://www.miataturbo.net/megasquirt-18/better-spark-out-circuit-33964/)

Joe Perez 04-13-2009 04:09 PM

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:

http://img15.picoodle.com/img/img15/...nm_b676452.gif

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)
http://img15.picoodle.com/img/img15/...am_4584d3c.png

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:


http://img02.picoodle.com/img/img02/...nm_555d388.png

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)
http://img15.picoodle.com/img/img15/...rm_6ba9e26.png


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.

http://img01.picoodle.com/img/img01/...dm_8619586.png

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!

Braineack 04-13-2009 04:17 PM

Like I said before, I don't have the pooping issue. But I guess a little inversion therapy never hurt.

Saml01 04-13-2009 04:18 PM

Why cant the NPNs(q6 and q8) responsible for the triggers be switched out for PNPs?

gospeed81 04-13-2009 04:24 PM

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).

240_to_miata 04-13-2009 04:33 PM

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

Savington 04-13-2009 04:45 PM

Something to do next time my ECU is out. Badass, Joe.

Laur3ns 04-13-2009 05:04 PM

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...

Joe Perez 04-13-2009 05:19 PM


Originally Posted by Saml01 (Post 395406)
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.


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

Pics added.

Braineack 04-13-2009 05:39 PM

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


i decided to not be lazy:

http://boostedmiata.com/MS/random/sp...output_top.jpg

http://boostedmiata.com/MS/random/sp...put_bottom.jpg

kday 04-13-2009 06:52 PM

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

My 74ABT125 ignition driver is working just peachy but it's probably overkill.

Braineack 04-13-2009 07:22 PM

my car still works. so that's always a plus. no pooping for me.

Saml01 04-13-2009 07:56 PM

Great, I may consider this in the future. Desolder Q22-23 and toss it into the Q6 and Q8.

soloracer 04-14-2009 12:24 PM


Originally Posted by Saml01 (Post 395507)
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.

gospeed81 04-14-2009 01:12 PM


Originally Posted by Joe Perez (Post 395451)


Pics added.

Ask and ye shall receive...unless she's just way too hot for you. ;)

Saml01 04-14-2009 02:02 PM


Originally Posted by soloracer (Post 395772)
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.

ScottFW 04-14-2009 04:35 PM

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

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.

Joe Perez 04-14-2009 07:03 PM

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 04-14-2009 07:30 PM


Originally Posted by ScottFW (Post 395882)
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.)

LostSoulMiata 04-20-2009 01:28 PM

My car still works :laugh:

Braineack 04-20-2009 01:29 PM

ha. ive been running it for exactly a week now.


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


© 2024 MH Sub I, LLC dba Internet Brands