Creating a controlled voltage spike by switching an inductor - Page 1
Forum section: electronics / beginners

author: pman92
author_rank: Contributor
timestamp: July 25, 2021, 07:28:50 am
content: Hey guys,Long time youtube watcher and lurker but first time poster. I'm a dual trade auto mechanic/auto electrician who has been hobbying with electronics for a few years. I've ran into a problem which I thought would be a good excuse to register and post here.I'm experimenting with a circuit that could be used to trigger an old tachometer from a 12v or 5v square wave signal. Moderns vehicles all have a 12v or 5v square wave tacho signal, and really old tachometers (that were designed to be connected the the ignition coil negative) don't work with it. My understanding is the old tachometers rely on the inductive spike (typically a couple of hundred volts) generated when the coil primary is switched off.I've started with this:Initially I didn't have the 1N4148 fitted, and I only had my oscilloscope connected the the BLUE location, and this was the result:After attaching my RED oscilloscope probe, it changed to this. I'm guessing because of the capacitance of the scope probe?Seeing that the transistor base voltage (RED) was dropping well below zero volts, I added the 1N4148 as in the first picture, but it actually made it slightly worse again:This is literally the first time I've put an inductor in my breadboard, I've never really played around with them before, and I've got no idea what's going on. I'm expecting the Zener diodes to suppress the voltage spike to ~36v (which they do), but it then stabilize to 12v soon after. However the oscillating seems to go on forever (its still happening virtually the same 100mS later when the arduino switches the gate again).What's actually happening here?Thanks in advance

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 25, 2021, 03:58:04 pm
content: Don't know why you're getting oscillation in the one case; maybe there's a feedback path through poor wiring or something?The waveforms can be understood based on two things:1. The inductor equation: V = L dI/dtThis says that thechange in currentthrough an inductance is proportional to its terminal voltage.Note that an inductor (component) might not behave quite like this, because a real inductor has resistance (among other things). We use an ideal model of inductance, and combine it with other elements to approximate what's in the real world.2. Node capacitance. Which likewise has an equation: I = C dV/dt, relating current tochange in voltage.At the instant the transistor turns off (which, uh, isn't really much of an instant in this case, the base drive is rather slow), collector voltage rises. The inductor was charged to maximum current (limited by the DC resistance of the path), or I assume the on-time was long enough to do this anyway; and if not, then whatever current it reached in that time. When the transistor turns off, that current persists. The transistor tries to turn off, i.e. set current to zero. So the inductor voltage rises, to begin dropping its current.A brief moment later, the zeners turn on, and clamp the voltage at 36V. These then hold the voltage constant, therefore the dI/dt is constant (neglecting, for a moment, the effect of that DC resistance). During this phase, inductor current discharges into the zeners.The phase ends when inductor/zener current reaches zero, and inductor voltage begins to return to zero (i.e., the probe reading 12V).But we're not at zero yet. The transistor has some capacitance, and yes probably some amount in the probe, and the inductor itself (1mH is a big value, it has a lot of wire balled up inside -- all those adjacent metal surfaces amount to thousands of small capacitors acting in parallel and series!). This capacitance is charged to 36V, and must discharge through the inductor.So the voltage begins to fall, at a rate determined by I = C dV/dt. Well, current started at zero, but the capacitance holds the voltage up, so the inductor current reverses, and actually charges some increment. Which gets the voltage dropping a little, so current goes up a little more, and so on and so forth. Eventually the voltage gets going, and swings to 12V. And continues past, because now the inductance is charged to some peak current, and it can't stop on a dime, it's going to keep pushing the voltage down. Below zero, so it seems.And so on and so forth, repeating until the energy decays. Probably the probes and DCR are dominant loss in this circuit, so eh, who knows, it could keep ringing for a while.Note that the waveform is not a smooth sinusoid, but lumpy and sharp at the onset. Note the zero crossings are also more spread out at first. Effectively, the transistor and diode capacitance, and resistance, vary with voltage. So instead of I = C dV/dt, we have I = C(V) dV/dt, i.e. C depends on V. But also I depends on V because of the diode  resistance. These are nonlinear processes, for which there isn't any general method of approach (hence the specific approach, the piecewise description above, i.e. as if going through phases or steps of history).About those low peaks. As the voltage drops below GND, the BJT begins to conduct again. Note that it's still effectively a back-to-back pair of diodes (they just happen to "transist" together, when the directions are correct). The P-N junction from base to collector becomes forward-biased, pulling the base below ground, while the collector pulls ~0.6V (a diode drop) further below. Evidently, this is enough action to pull about 4V below.This is the reason the diode has some effect. By clamping B to about -0.6V, C is clamped to about -1.2V.If this [C below GND] occurs without much base current, the voltage is ultimately limited by E-B breakdown (typically 6-8V), which acts just like a zener diode of the same rating. If strong base drive is available, then the base current flowing, also causes some emitter current to flow -- remember that an NPN transistor reads "NPN" both ways, it just happens to work poorly in reverse -- typically, hFE is very low (~5?), so the "collector" current will be relatively low. That is, if something's pulling the collector down, and something else is holding base voltage near zero, then the emitter will also draw current, as it is now the acting "collector". So, with low hFE, it takes quite some base current to have the same effect, so it may simply happen that the voltage is able to dip quite far below GND; but given a low resistance circuit driving the base, the voltage dip will be much more limited (to a worst case around -0.8V if the base and emitter are hard grounded, i.e., inverted "diode mode").The three zeners in series, also act to clamp collector voltage to about -1.8V, unless they're bidirectional TVS in which case it's nowhere close, heh.So, we observe the dip in base voltage, without diode, to around -1.5V (while collector seems to dip to -3 or -4V; clearly one or the other is not quite telling the truth, the transistor won't have 2.5V B-C..), but with diode, it's a cool, eh, -0.8V or something? It's a bit spiky, hard to say.The voltage drop (with diode) is also less, meaning less energy is lost to powering the transistor (and its base resistor), so it goes on for an extra cycle or two.The easiest way to get a clean waveform, is to add damping. Typically, one measures C, and then wires an R+C in parallel to the node (C to GND, or across the inductor, or etc.), such that R = sqrt(L/C) and Cdamp >= 2.5 C.(That is, "R+C" referring to their series connection. And this pair being wired in parallel with the inductor or wherever.)If L = 1mH, then we can measure the ringing frequency, then use C = 1 / ((2 pi F)^2 L) to find the capacitance, and the rest follows. (Measure the frequency from the middle to the right side of the waveform, where the response is fairly linear.)Note, this adds more capacitance to the node, so the rise/fall time will be even slower still. It'll just be better behaved, just kind of going "thud", rather than bonking all over the place.Tim

author: pman92
author_rank: Contributor
timestamp: July 26, 2021, 09:46:47 am
content: Thanks for the detailed explanation Tim. I think I'll have to read through it a few more times to fully understand.Quote from: T3sl4co1l on July 25, 2021, 03:58:04 pmIs the base drive slow because of my choice of a 1K base resistor? or is it because BJT's are slow in general? or for some other reason?Quote from: T3sl4co1l on July 25, 2021, 03:58:04 pmI didn't notice that at first, but when I do the measurements in the picoscope software they're definitely more spread out to begin with.Quote from: T3sl4co1l on July 25, 2021, 03:58:04 pmQuote from: T3sl4co1l on July 25, 2021, 03:58:04 pmThe collector seems to pull down approx 1.2v further than the base in all the examples I've measured which doesn't make sense? I found the equation "Vbc = Vbe - Vce", there seems to be approx. 0.9v b-e and 0.3v c-e while the transistor is on (which roughly match the first datasheet I found for a 2N5551). 0.9v - 0.3v = 0.6v (exactly what you said). What could be causing the 1.2v drop then?I also noticed the base voltage settles to 0.2v after the oscillations and everything calms down, it stays at 0.2v right up until the transistor turns on again and it jumps to 0.9v?I did initially power the circuit up without the zeners, I'm sure the transistor probably had more than the maximum rated 160v Vceo, could it be a damaged transistor?Anyway I removed the diode, and have added a 10K resistor between collector and ground for a bit of load, the oscillations still happen but it no longer seems to make much if any difference if the base scope probe is connected or not. It definitely doesn't ring on forever without the probe connected like it used to.Quote from: T3sl4co1l on July 25, 2021, 03:58:04 pmI measured the ringing frequency as pretty well 250kHz, so "C = 1 / ((2 x pi x 250,000)^2 x 0.001)"?I may be mistaken but I work that out as 0.000000000405, ie. 405 pFQuote from: T3sl4co1l on July 25, 2021, 03:58:04 pmso R = sqrt(0.001 / 0.000000000405) = 1571 ohmsand C >= 2.5 x 405 pF (approx. 1nF)I added a 1nF capacitor from ground running to a 1.6k resistor, with the other end of the resistor running to the collector/end of inductor/blue trace. It seems to work perfectly!

author: Berni
author_rank: Super Contributor
timestamp: July 26, 2021, 10:00:40 am
content: Even just simply adding a 1K resistor across your inductor would likely solve things.It just needs something to take away the energy stored inside that inductor. If the energy has nowhere to go then it just stores itself on any stray capacitance it can find (such as other components, wires, its own intertwining capacitance etc.) that then kicks the energy back into the inductor and the process repeats, creating the ringing. By adding a load resistor to the inductor this resistor helps dissipate the energy by turning it into heat. The adding of that capacitor in series just helps the resistor dissipate a bit less power because DC current won't flow trough it, but since you are pulsing the coil for short bursts anyway it should not matter.Also careful with running long wires from the output of this circuit, the extra capacitance of those wires might change the shape of your waveform too.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 26, 2021, 10:56:35 am
content: Yes, the turn-off current is pretty weak compared to turn-on. If that's a 5V Arduino, then it's putting about 0/5V at the end of that resistor. The base is about 0.7V when on, so there's a good 4.3mA on, and 0.7mA off current.Note that the base voltage hovers in place for a bit, before lazily falling away (and the collector voltage rises first). The B-E junction acts something like a very tiny battery, i.e., its voltage drop is logarithmic with its stored charge, and it indeed stores charge, albeit very little; it's also a very leaky battery, and takes a saturating charge very easily (dissipating power instead of storing energy).That is, when we apply forward bias, some charge goes into the base, raising its voltage, and not much happens (from say 0 to 0.5V). This is ordinary junction capacitance. As the base begins to conduct, it takes up extra charge; most of which is dissipated as heat (current flow acting to saturate the transistor), but some amount gets stored.When turning off, if the base were simply disconnected and let to self-discharge, it would hover there for a good 10 or 20 microseconds. (Look no further, for proof that BJTs are voltage-controlled devices. They just have a very leaky input!) With the resistor pulling it down, the base charge is discharged a bit more rapidly, so this takes 100s ns rather than 10s µs.Best results however are when the currents are about symmetrical. So if you add a resistor from B-E, dimensioned so that the resistors give a Thevenin voltage around 1.6V (i.e., 470 ohms), you'll get a much sharper turn-off.Which as mentioned, may not really be all that beneficial, depending on wiring. More just, so you know how to, when you need it.The collector voltage rising, by the way -- B voltage doesn't need to drop much for C current to fall sharply. The change in Ic for change in Vbe is around 60mV/decade (it's exponential). So Vbe drops a bit from the overdriven level of Vbe(sat), then hovers a bit -- largely this is removing charge from Ccb as well as Cbe, that is, Miller effect -- and since Ccb is nonlinear (higher at low Vce), it starts off slow, then accelerates. Once the collector stops moving, base voltage falls more quickly. It does hover around a bit again, and this is where stored charge is finished being removed. Finally, Vbe drops to zero, as the junction capacitance is also discharged.I don't know how exactly well that'll help, as an analogy -- calling it a battery I mean. It's actually rather apt; chemical cells develop a voltage corresponding to log[chemical concentration]. So the voltage goes up rather quickly at first, but those last few bits take a lot of charge. Or discharge, reciprocally. That's why battery voltage is fairly stable, like the 1.2-1.56V for alkaline (down to ~0.8V for full discharge, depending on how desperate you are, and what rate you're using it up at). It also takes an electronic eternity to change -- hours to charge or discharge, minutes for the fastest chemistries. Well, supposing we could scale this down to the microseconds, it's like that. And it's really no accident, as the log concentration of charge carriers (free electrons and holes) in the semiconductor corresponds to voltage drop.Tim

author: pman92
author_rank: Contributor
timestamp: July 27, 2021, 09:36:20 am
content: Awesome, thanks for the replys guys. I find all this very interesting and I've definitely learnt something here.Just for the hell of it I added the 470 ohm resistor and it definitely turns off much quicker.I also noticed the collector voltage rised much quicker as a result. Am I correct in saying that the peak voltage reached if I didn't have the zeners fitted would also be much higher?With automotive ignition systems, my understanding is that one of the advantages of modern semiconductor switched ignition coils over old mechanical breaker points, is they can switch off the coil primary much faster which results in more energy being induced and a more powerful spark from the secondary. Is this correct and is this essentially what I'm seeing here?

author: Berni
author_rank: Super Contributor
timestamp: July 27, 2021, 10:32:46 am
content: Quote from: pman92 on July 27, 2021, 09:36:20 amWell mechanical contacts do pull an arc when disconnecting so i suppose some energy does go into there. But more of an advantage of electronic ignition is that it allows the computer to precisely control the spark timing and adjust it to best fit the engines current operating conditions (rpm, load, throttle position, temperature...etc). More of an advancement is having individual coils for each plug and having them located right behind the spark plug, this generates the high voltage right at the spark, removing the parasitics of all that high voltage wiring. At the same time these new modern coil packs have extra electronics inside that use the spark plug as a sensor to monitor the combustion process.Going back to regular old school ignition coils. The thing is a transformer with a low and high voltage winding, so the voltage on the input and output terminals is the same as the ratio of number of turns inside the coil. So you will get the highest output voltage when you also see the highest voltage kicking back out of the input. In your case the zenners are clamping it and giving it a flat top of the peak. Without the zenners the voltage would keep rising until something can't handle it anymore and conducts (Like the transistor) or the pulse finds enough stray capacitance to use up all of its energy and swings back down.

author: mikerj
author_rank: Super Contributor
timestamp: July 27, 2021, 10:46:11 am
content: You probably have a poor (high impedance) ground return on the emitter, so negative going oscillation cycles on the inductor is dropping the local ground voltage enough to turn the transistor back on. Breadboards are notorious for this kind of thing. Make sure the emitter is connected physically close to the Arduino ground and put a suitable decoupling cap from the emitter to the top of the 120R resistor to stiffen up the supply rails in that area.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 27, 2021, 11:48:43 am
content: Quote from: pman92 on July 27, 2021, 09:36:20 amHmm, though not too quickly. Ah, let me see, that's running around 100mA load isn't it, so it should have 5-10mA base drive to saturate reliably; but this is only giving it about half so it's kinda marginal. Halving the resistors should get it about as fast as it can go, which still looks like it should be faster (under 100ns should be perfectly reasonable for this transistor) but maybe there's a lot of emitter path inductance or something also limiting it.Or maybe I'm not appreciating how much capacitance the zeners have, that could be the limiting factor. But it doesn't look like it; for that to be true, base voltage would be a lot lower by the time the collector is really swinging, and it's not.Or, assuming the transistor really is what you think it is; maybe it's an eBay special...Alternately, putting a 47-100pF in parallel with the 1k, so that for a brief instant, the MCU pin drives the base HARD. Also not recommended with sloppy layout, but handy for faster drive or pulsed circuits, while using less power.QuoteMaybe, maybe not. I mean, you've indeed measured that it is the case, that little ringing on top of the zener clamp is higher now -- though only very slightly so. (That BTW is the collector, and probably probe, capacitance resonating with the zeners and return loop inductance. It again seems like an awful lot, which makes me wonder what the transistor really is.)Thing is, ignition coils have quite a lot of capacitance, and the core inductance may not all be available in an instant, either. The latter is very relevant to solenoids, relays and other things of electromechanical nature that they don't care about operating terribly quickly.The effect of capacitance, is simply that it takes time for the voltage to swing up. If you put say a 1nF cap from C to GND, you'll see it rise much slower (the ringing will be slower as well). An ignition coil certainly doesn't have that much on its primary (well, one from the olden days of "points" might have a fractional uF cap, actually!), but the secondary might have a few tens or hundreds of pF, and with a winding ratio of some hundreds or thousands, the impedance ratio is 10k-1M (the square of the voltage ratio) and so the equivalent measured at the primary can be quite substantial!Speed is limited by whatever dominates, so with slow drive, the transistor may limit, but above some point there's rapidly diminishing returns.Which, here, you're pretty well in that case -- most of the inductor's energy is going into the zeners (hence the relatively wide flat-topped pulse, or, well, it'd be flat if you could measure across the zeners themselves, without interference from the ringing in the ground loop). If the waveform took like 10us to rise, you can imagine a lot of that pulse would end up gobbled by the transistor as it's taking its sweet time. (To illustrate this, try increasing Miller effect: put say 100R in series with 100pF, and wire that from base to collector. Play around with values and see; mind the resistance shouldn't be too low as it'll probably oscillate without any.)As it happens, automotive coils are often driven by IGBTs, and not just any kind, but types that are customized for low Vce(sat) at low Vge(on) (since "cold cranking" might only have 5-6V available for the ECU), and slow switching (including internal series gate resistor) to reduce EMI emissions. The HV risetime might be 10s of microseconds, even 100s (compared with a pulse width of ~100s us during the spark) so it doesn't need to be anything fancy.As for the core, the effect is that, when made of solid metal (pole piece, armature, etc.), it takes time for the magnetic field to "soak" into the bulk. This happens because current is induced in the metal, opposing the magnetic field. The current in any given layer, decays over time (due to the metal's resistance; it does not decay for superconductors (Meissner effect)), and so the field is able to "soak" in. When the metal is divided up (laminated strips or powder), the magnetic field can "bathe" everything simultaneously, raising the frequency response."Soak" is a fairly appropriate term, as the flow is a diffusion process -- this manifests in the circuit as a characteristic having equal parts resistance and inductance (45 degree phase), proportional to sqrt(F) over some range.Here's an impedance plot of a nanocrystalline core (plotted over the original datasheet background for tweaking purposes), notice it's inductive at low frequencies (Z ~ F), diffusive at mid frequencies (half slope), then capacitive and finally complex at high frequencies (Z ~ 1/F, with peaks and valleys).Nanocrystalline cores are quite fancy materials (they're partly metallic glass, what the hell, right?), but they're still just metal, a very thin ribbon wound into a tight spiral. The thickness of that ribbon sets the cutoff frequency, above which diffusion takes over (apparently ~10kHz).It's not a huge asymptote (~20-400k), and is easier to read on other materials or components, at least when they provide such a plot. But this example was handy. (Diffusion is also relevant to chemical systems, like batteries and ionic capacitors (supercaps). Which is why a full charge can take so damn long on a battery, the charge voltage is a step and the charge current is the step response -- with a long "drooling" tail due to diffusion.)Here's the equivalent circuit of that impedance:The impedance-step* response from such a load, is limited by its own impedance. Essentially, the magnetic field trapped inside the material, takes time to escape, in the process depositing some of its energy in internal materials. The ideal case of a pure inductance, gives an infinite flyback pulse (assuming turn-off is also instant), which is nonphysical. If we add node capacitances, core losses and so on, we find the waveform is nicely finite and continuous, and we have a useful baseline to compare switch speed to, for example.The impedance-step response of this particular component, will still be pretty sharp (~microseconds), but if you simply imagine the curve displaced to the left a few decades, you've got iron-core power transformers (laminated iron, versus the thin (~0.001"?) strip of this particular core), or even further for solid metal.*There's not really a name for this, so I'm making one up. It would be a plain old "step response" if it were a linear system (varying the input voltage, holding impedances constant), but the thing is we're varying the switch impedance, and that's what makes these circuits so interesting at times. A piecewise-continuous model (t < 0, switch on; t > 0, switch off; etc.) is easy enough to start with, though reality is never piecewise so we may use that as just the starting point, and expand on it as needed to develop the results we expect (like the risetime measured here, which to model, will require adding capacitors, or a reasonable model of the switch, etc.).Tim