Author Topic: Impedance matching  (Read 4376 times)

0 Members and 1 Guest are viewing this topic.

Offline StarlordTopic starter

  • Frequent Contributor
  • **
  • Posts: 325
  • Country: us
Impedance matching
« on: April 15, 2017, 05:37:52 am »
I was reading up on Neopixels the other day and I cam across a very interesting and detailed post about impedance matching on Adafruit's forums:

https://forums.adafruit.com/viewtopic.php?t=51153

Quote
Re: NeoPixel strip and resistor

by adafruit_support_mike on Fri Mar 14, 2014 8:21 pm
An Arduino GPIO pin can deliver up to 40mA @ 5v. Its effective output impedance is about 125 ohms.

A WS2812's data-in pin is probably a mosfet, and most input mosfets have a gate capacitance of about 30pF. At 800kHz, that works out to an impedance of about 42 kilohms.

125 ohms != 42 kilohms, which is called an impedance mismatch. Power will not transfer optimally between the Arduino and the mosfet. That wouldn't be a problem if they were connected directly, but we have a wire between them.

Electrical pulses travel through good-quality coax at about 0.7C, so that's a decent first-order approximation for the propagation rate in short regular wires. At that rate, the transit time through a 30cm wire will be about 1.5 nanoseconds.

Regardless of the wire's inductance, the Arduino's 125 ohm output impedance will pump some energy into it, the WS2812's input impedance will pull some energy out of it, and the amount the Arduino pumps in will be about 300 times as large as the amount the WS2812 pulls out. Inductors and capacitors are both reactive, meaning they don't convert voltage or current to heat, so for about 3ns, 99.7% of the energy at the point where the wire connects to the WS2812 will only have one place to go: into the mosfet's gate capacitance.

The voltage at the WS2812's gate has no particular reason to stop rising when it reaches 5v. As it rises above 5v, some of the current will start to flow back through the wire because the voltage is lower in that direction. That curent will flow back to the Arduino and be swallowed by the 125 ohm impedance there.

That's another 1.5ns trip though, so for 3ns, the WS2812 has to push back against the incoming pulse hard enough to make 99%+ of the energy in the wire turn back around. That will appear as a voltage spike on the rising edge of the pulse as measured from the point where the wire meets the WS2812. If the peak voltage rises significantly above 5v, it can blow a hole through the insulation between the mosfet's gate and channel, pretty much killing the chip.

A 3ns peak is half of a 6ns sine wave, for a frequency of about 166MHz. You'd need about a 1GHz scope and high-impedance probes to see that cleanly. A 100MHz scope would attenuate the peak voltage by about 50%. Any passive probe's compensation capacitor will be on the same order of magnitude as the WS2812's gate capacitance, causing more attenuation, and its resistive leg will give the energy in the wire another, shorter path to ground.

Putting a series resistor at the WS2812 end of the wire changes things significantly.

First, it reduces the impedance mismatch between the opposite ends of the wire, reducing the amount of energy that has to be turned around. It also moves any peaking away from the gate of the mosfet, out to the point where the wire meets the resistor. The resistor limits the rate at which current can enter the mosfet's gate capacitance, and while it still allows for a crisp rising edge, the slew rate will be much slower than what you'd get from a direct wire connection.

Finally, the resistor burns off excess energy between its terminals as heat. That energy leaves the circuit in terms of its ability to produce electrical effects, again protecting the mosfet.


My question is, if the effective output impedance of the Atmega's pin is about 125 ohms, would the ideal value resistor at the Neopixel / mosfet / whatever end, also be 125 ohms?

And if so, why in their Neopixel tutorial, do they suggest a 300-500 ohm resistor instead?

https://learn.adafruit.com/adafruit-neopixel-uberguide/best-practices

It seems like you would want the closest value if only so you get the cleanest edge.

Also, how DOES this affect the edges? I would assume a resistor in series would cause the edge to be less sharp, but I also would not have believed a 5V input into a long wire would result in much more than 5V at the other end, so I don't know what will actually happen. Although being somewhat familiar with inductors for use in boost regulators, I should probably have realized this might be a thing, but apparently it's not even something you can pick up on an entry level scope.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19494
  • Country: gb
  • 0999
Re: Impedance matching
« Reply #1 on: April 15, 2017, 09:03:46 am »
It sounds like someone's confused here.

A MOSFET's gate doesn't need to be impedance matched to the source. Normally the gate resistor is fairly low and is only there just to damp and oscillation caused by the parasitic inductance. If the MOSFET is driven at high speeds, via a long length of cable, then transmission line effects could be a problem, but in this case it's only switching LEDs, so the MOSFETs don't have to switch that quickly and there's no need to worry about transmission line effects. The 125R output resistance of the IO pin should be more than enough to dampen any resonances in the cable.
« Last Edit: April 15, 2017, 12:11:31 pm by Hero999 »
 

Offline eb4fbz

  • Regular Contributor
  • *
  • Posts: 178
  • Country: es
Re: Impedance matching
« Reply #2 on: April 15, 2017, 11:26:38 am »
That's called a damping resistor. It has little to do with impedance matching in constant impedance transmission lines.
 

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1352
  • Country: si
  • I like to measure things.
Re: Impedance matching
« Reply #3 on: April 15, 2017, 11:44:43 am »
The output resistance of ATmega328 is around 25R, not 125R (at 25°C). You need to look at how much the output voltage on the pin drops with respect to current draw, not what supply voltage you're using. Adafruit Mike needs a lesson or two before he starts giving his own.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19494
  • Country: gb
  • 0999
Re: Impedance matching
« Reply #4 on: April 15, 2017, 12:10:49 pm »
The output resistance of ATmega328 is around 25R, not 125R (at 25°C).
Then it looks like you need to add a resistor. 25R will not be enough to damp the resonance of a long cable. Try 47R for a starting point.
 

Offline radiogeek381

  • Regular Contributor
  • *
  • Posts: 125
  • Country: us
    • SoDaRadio
Re: Impedance matching
« Reply #5 on: April 15, 2017, 01:46:39 pm »
The responses are all on target. 

1. This isn't about "impedance matching" -- unless the transmission line between the driver and the FET is long, and you really need fast edge rates, who cares about the "efficiency" of power transfer?  And, in any case, most designers work to the impedance of the transmission line, not the driver. (See #5 below.)

2. Under no circumstances would a prudent designer assume "40mA" for the output current.  That is the figure in the "Absolute Maximum Ratings" table  (page 313 of he atmega datasheet)  While daring folks might chose to push the drive capability, I generally hew to the charts -- notice that Figure 31-353 tabulates Vol vs. Iol from 0 to 20mA.  That's a hint that they want you to design in that range.  (and remember that the figure is a guide, not a spec -- these are typical numbers...) Figure 31-71 and 31-353 suggest that the "drive" impedance near the rails is about 30 ohms or so. 

3. Unless designed for the purpose, most FET output drivers are NOT constant impedance.  But who cares?

4. How long a line do we have to have before I would care? Assuming a 30pF load (which could be low, could be high...) and "constant" current from the output of 10mA (unlikely) we get a rise time greater than 10nS. Is your line longer than half a meter?  If so, why? And if all we're doing is lighting an LED, why does the reflection matter? 

5. If the line is very long, and if you care about reflections, then by all means do some kind of termination.  I'm partial to series termination at the source. But here, again, the termination resistor value is set by the impedance of the transmission line, not of the driver.  To a first order, the transmission line impedance is 4x the driver impedance, or larger.  A 12 mil wide trace might be in the neighborhood of 100 ohms.  This dominates the driver impedance, in our simplified model, and suggests a source termination of 80 to 120 ohms more-or-less.  The result would be a "half-step" wave that propagates down to the apparently open-circuit FET termination, where it would then be reflected back to complete the swing at the terminator.  For a 1m long line (how big is this PCB?)  against a 10nS rise time, this won't make a flea's burp worth of difference.

6. Finally, note that the datasheet doesn't specify a Trise/Tfall for the general outputs.  (I'm using this: http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf as my source.)  That's another hint.  This chip isn't meant to be driving fast edges (other than the SPI signals, perhaps) and they aren't willing to provide a spec.  That makes a lot of sense.  As a chip designer, I don't want to commit to something that is of little value to most of my market and that might proscribe solutions to as-yet-unseen production problems.  (Output cells are deceptively complicated.  In CMOS processes an output driver can be among the most complex sub-circuits on the chip.) 
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3381
  • Country: us
Re: Impedance matching
« Reply #6 on: April 15, 2017, 04:06:49 pm »
4. How long a line do we have to have before I would care? Assuming a 30pF load (which could be low, could be high...) and "constant" current from the output of 10mA (unlikely) we get a rise time greater than 10nS. Is your line longer than half a meter?  If so, why? And if all we're doing is lighting an LED, why does the reflection matter? 

They are not talking about driving a bare LED, but an LED driver IC with a high speed serial interface.  It is also common to have a fairly long cable between the controller and the LED assembly.  So, there is a possibility that termination would be required.
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: Impedance matching
« Reply #7 on: April 15, 2017, 06:30:08 pm »
They are not talking about driving a bare LED, but an LED driver IC with a high speed serial interface.  It is also common to have a fairly long cable between the controller and the LED assembly.  So, there is a possibility that termination would be required.

For reference the 'clock rate' on the WS2812 input line is 1.25us+/-600ns and it's a schmitt trigger input (leastways the data sheet has a hysteresis specification for the inputs of 0.35V). So we are not talking blazing fast here.
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3381
  • Country: us
Re: Impedance matching
« Reply #8 on: April 15, 2017, 06:56:40 pm »
For reference the 'clock rate' on the WS2812 input line is 1.25us+/-600ns and it's a schmitt trigger input (leastways the data sheet has a hysteresis specification for the inputs of 0.35V). So we are not talking blazing fast here.

The logic 0 pulse width has to be 200-500ns: https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/

So not blazing fast, but not impossible to get into trouble either.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21658
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Impedance matching
« Reply #9 on: April 15, 2017, 07:34:42 pm »
The quoted OP doesn't understand transmission line theory, and only knows enough about impedance matching to be dangerous. ;)

1. Most MCUs don't transition in fractions of a nanosecond.  If this is an ATmega Arduino we're talking about, it's more like 5ns.  Still more than fast enough to get into trouble with, but that's hard to achieve on 30cm runs.

2. For an instantaneous step, the pin driver's output resistance (which is actually like 50 ohms, but more exactly, about 70 ohms pulling up, 40 ohms pulling down) divides into the transmission line impedance.  For a 100 ohm line, this is around 2/3 Vcc.

So we launch a wave front of 2/3 Vcc down the transmission line.  One electrical length later, this wave arrives at the "load".  (Which was never intended to be, and cannot be, a "load" in the RF sense!)  It reflects off the load (because it has a high impedance, give or take the phase shift from its capacitance), and returns to the source.

3. When the wave reflects, it superimposes on itself.  The transmission line is charged to 2/3 Vcc, and a wave of 2/3 Vcc now launches from the far end.  The line charges to 4/3 Vcc.  It overshoots.

If we have input protection diodes on the load, it will clamp this overshoot (this isn't really desirable, but it can happen).  In that case, current is drawn from the transmission line, and somewhat less than 4/3 Vcc propagates back.

4. When this new level reaches the transmitter pin, it continues to transmit as a Thevenin source, but instead of a divider into ground, it's a divider into -- whatever level is on the line now, namely, 4/3 Vcc.  Current is drawn out of the transmitter, and ((2/3)(1 - 4/3) + 1) = 10/9 Vcc reflects back again.

Now, some overshoot can be useful when the transmission line is long and lossy, but you shouldn't count on quite this much overshoot as a normal thing.  You usually plan to source-terminate the transmitting pin with 33-100 ohms, to prevent overshoot in most situations.

5. This was for a point-to-point link.  What if you have many loads along a linear bus?  Well... each one sees the transmission line's levels, over time.  Only the terminal load jumped from 0 right to 4/3 Vcc in an instant.  For all other points on the line, all intermediate levels are seen: 0, 2/3, 4/3, 10/9, etc.  This makes the risetime look lumpy, and can cause multiple clock events on input pins, screwing up your data.

Incidentally, this circumstance -- source terminated transmission lines -- is what limited Ye Olde PCI bus to a certain number of slots along the length of the motherboard, and a maximum clock frequency of only 66MHz.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: electrolust

Offline DimitriP

  • Super Contributor
  • ***
  • Posts: 1302
  • Country: us
  • "Best practices" are best not practiced.© Dimitri
Re: Impedance matching
« Reply #10 on: April 15, 2017, 07:44:38 pm »
Quote
The quoted OP doesn't understand transmission line theory, and only knows enough about impedance matching to be dangerous. ;)

 If the post had started with "Adafruit Mike", I would have stopped reading sooner...
   If three 100  Ohm resistors are connected in parallel, and in series with a 200 Ohm resistor, how many resistors do you have? 
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf