Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel6
include
outlinefalse
indent
stylenone
exclude
typelist
class
printabletrue

...

  • USBPD devices can either act as the source (charger) or sink (device) or DRP (both). For our purposes we probably want a sink-only chip since we'll be plugging a charger into this board and the output will be a 12V/GND line. We don't need this to act as a source from a wall outlet.

  • Compatibility with USBPD 2.0 and USBPD 3.0 would be nice to allow us to use a wider array of laptop chargers.

    • USBPD 2.0 allows for fixed voltage outputs of 5, 9, 12, 15, and 20V

      • USBPD 3.0 allows for incremental voltage outputs anywhere from 3.3V to 21V in increments of 20mV. This is called PPS (programmable power supply). We don't really need this since we only need to provide fixed 12V and 5V.

  • Perhaps considerations should be made for USBPD 3.1 as well, as that would allow for a higher power delivery of 240W and possibly support driving contactors.

    • 3.1 is backwards compatible so designing a 3.1 sink should allow for interfacing with 3.1/3.0/2.0 source

    • Since we want to max out current I think 3.1 makes the most sense as USBPD 3.1 EPR (Extended Power Rating) cables have the capability of providing up to 240W @ 48V

      • This may have to wait as there are not many 3.1 sink chips available

      • According to this reddit post, USBPD3.1 @ 240W probably isn't possible since the sink functionality of it is not well supported. I took a look at a few chips such as ST-ONEHP and TPS25730USB.

USBPD Controller Chip Evaluations:

  • Mouser USBPD Search

  • USB Type-C PD 3.0 Specification, Charging and Design

  • Guide to USB-C Pinout and Features

  • USB Type-C and USB power delivery power path design considerations

  • Phil's Lab video

  • Designing a USB PD (Power Delivery) Trigger Board For My Devices

  • Infineon CYPD3177-24LQXQT

    • Used in this Phil's Lab video

    • In stock on Mouser as of 5/22/24

    • Price: $2.20

    • Operates on USB-PD 3.0 Standard

    • Capable of 100W (20V @ 5A)

    • Evaluation Kit Guide

    • Pretty simple to set VBUS Min/Max and Current Min/Max; just use voltage dividers on four config pins as shown above

    • Offers a fault indicator

    • Falls back to 5V in case negotiation fails

    • QFN package (more difficult to solder, but still manageable at Pickle esp. with someone with experience)

  • INJONIC IP2721

    • Used in this isaac879 video

    • Available for order on JLCPCB or AliBaba

    • In-stock at JLC and Alibaba as of 5/8/24

    • Price: $0.69

    • Capable of 20V

    • Connecting high to SEL pin will make it output 20V, which makes configuration easy

    • The downside of this (as according to this Hackaday post) is that even though USB-PD supports current negotiation (sink asking source what current it supports), the IP2721 doesn't. So if a charger is plugged in that doesn't support 5A, which we are ultimately going to request, then we still may not get the current we want and perhaps trigger some overcurrent condition on the source if we go over that amount.

    • TSSOP package, so easier to solder

  • Texas Instruments TPS25730

    • Price: $2.69

    • On backorder in Mouser as of 5/8/24

    • In TI's product selector for USBPD chips, this seems like the newest sink-only chip

    • It supports PD 3.1 in that you can do PPS (which we don't actually need anyways)

    • Capable of 100W (20V @ 5A)

    • It looks like an external microcontroller can be attached to I2C for configuration purposes, but doesn't have to be

    • Min/max voltage and operating current/max current configured through ADC1 through ADC4, can just hook up voltage divider

    • TPS25730D has an internal HV path, whereas S has a gate driver for an external HV path

    • QFN package; harder to solder as mentioned before

  • STMicroelectronics STUSB4500

    • In-stock as of 5/8/24

    • Price: $2.71

    • Reference schematic

    • Capable of 100W (20V @ 5A)

    • Configurable through programming non-volatile memory (NVM) through I2C

      • Would make initial configuration of anything above 5V a bit more difficult, but would only need to be done once at the beginning with a programmer of some sort (Nucleo?)

    • QFN package

Buck Converter Research:

  • I suppose we'll need a high-efficiency buck converter to step down from max 20V@5A to 12V@8.333A after the whole USB PD negotiation is complete.

  • Another design consideration was made in this area about the buck converter pipeline. The two possible options were 20V → 12V → 5V (e.g. having chained buck converters) or 20V → 12V AND 20V → 5V (independent buck converters)

    • Chaining buck converters means that we can use the same 12V → 5V buck converter we typically use, muRata MYLSM00502ERPL. However, this means that if 12V or above is not in a source’s capabilities, then 5V will also fail. Basically 5V is entirely dependent on the 12V working, which limits the set of USB Type-C chargers we can use with this board.

    • Independent buck converters means that 5V can function without 12V, so if a PD charger WITHOUT 12-20V support is used, we can still test a low voltage device. This seems better but also makes our job as circuit designers more difficult in terms of validation, cost, or efficiency.

  • Matthew Yu’s notes on LDO vs Buck Converters:

    • image-20240528-072100.png
  • Tips on Layout from Phil's Lab

  • Buck Converter Explained

    • Another one: Buck Converter 2: Electric Boogaloo 

    • Other typical forms of voltage step-down (Linear Voltage Regulator (LDO), Voltage Divider) dissipate power as heat to step down voltage. We lose power in some capacity as heat.

    •  Buck converters will decrease voltage AND increase current to maintain power (typically higher efficiency but less stability when compared to an LDO)

      • When the switch is closed, the inductor charges up

      • When the switch is opened, the inductor releases charge through the load resistor RL. The current flows through the diode and back into the inductor

      • We switch the switch (MOSFET) at a certain frequency and duty cycle in order to keep the average current relatively stable over one period

      • The capacitor is assumed to have a steady voltage over one period, so it just keeps the voltage drop across RL the same

      • Watch the Buck Converter 2 video for more explanation and the derivation for the following equation:

        • Vout = Duty Cycle x Vin (typically)

        • Datasheet will have more specific calculations for things such as voltage dividers which will ultimately set the duty cycle

      • A synchronous buck converter replaces the diode with another MOSFET so that there is less power loss since the MOSFET will have lower power loss while current is flowing thru it

  • Luckily for us, these buck converters come in convenient little ICs that will do all this switching for us

    • We need two of these, one for 12V and one for 5V

    • WEBENCH Power Designer

    • Integrated FET packages (the mosfet comes inside the IC)

      • Mouser Filter Link

      • TI Filter Link

      • Analog Devices Filter Link

        • Nothing on here that can do more than 6V output

      • TI TPS56A37

        • $2.87 on Mouser

        • 4.5V to 28V input

        • 0.6 to 13V output

        • Supports 10A continuous output current

        • Seems most appropriate for our 20V->12V use-case especially since other ICs can't supply as much current

        • QFN package

      • Analog Devices ADP2303ARDZ-5.0-R7

        • $4.08 on Mouser (we can do better on price)

        • 3 to 20V input

        • 5V output

        • 2/3A

      • TI TPS62933ODRLR

        • $0.99 on Mouser

        • 3.8 - 30V input

        • 5V output

        • 3A

        • 12 uA quiescent current

        • Champers Fu approved!

        • This one is really good, perhaps we should use it for more designs

    • External FET Buck Controller packages also exist and were looked into briefly (mosfet is outside the IC, might be more cost-effective and able to provide enough current)

      • TI Filter Link

      • TBH I kind of prefer an integrated package rather than this so might not really look at these any further

  • Is isolation required between the USB-PD provided power and the device power?

    • If so, an external FET buck controller package with a transformer may be required

    • https://www.eevblog.com/forum/projects/usb-type-c-pd-lab-power-supply/

    • Decided it's probably not worth it. From what I can tell from online + talking to Jacob Pustilnik and Matthew Yu, isolation is mainly used to protect the user from voltage shock and to protect the device from taking a large amount of voltage if the buck converter fails. Additionally, the cost difference after looking at some Murata buck converters is large enough to warrant no isolation ($83 is a LOT). We'll just A) be safe when using the device, perhaps put it in an enclosure of some sort, and B) make sure that there is voltage protection on new devices we produce so that a 5V device like the Peripheral SOM won't break if a spike of 20V is applied to it. We'll also include some overvoltage protection on the output to make sure this doesn't output more than 12/5 V.

...

  • First, let’s figure out where to put the shunt resistor: https://www.allaboutcircuits.com/technical-articles/resistive-current-sensing-low-side-versus-high-side-sensing/

    • To do this, let’s talk about CMRR (Common Mode Rejection Ratio). Here’s Google’s Gemini AI engine to help (prompt: Explain CMRR and what a common vs differential mode signal is of an op-amp to me with an analogy like I am 15 years old):

      • Imagine you're at a concert with your friend. The band is the desired signal you want to hear clearly.

        • Common-mode noise is like a bad sound system rumble that affects both of you equally. It might be caused by a loose wire or some electrical gremlins.

        • Differential-mode signal is the actual music from the band. This is what you want to amplify without the rumble.

      • An op-amp is like a fancy headphone amplifier that boosts the music (differential signal) for you and your friend. Ideally, it should completely ignore the rumble (common-mode noise).

        • CMRR (Common Mode Rejection Ratio) is how good the op-amp is at ignoring the rumble. A high CMRR is like having high-quality headphones that block out most of the rumble, leaving just the clear music.

      • In reality, no headphones are perfect, and some rumble might still leak in. Similarly, even a good op-amp will have some CMRR, meaning a small amount of rumble might still be amplified with the music.

    • Ok, but what’s even the big difference between putting a shunt resistor on the low side vs the high side?

      • image-20240630-061216.png
      • The common mode voltage (VCM) is literally the average of the two voltage inputs into the amplifier. VCM = (V1 + V2) / 2

      • Thus, when Rshunt is placed on the low side (and since the voltage drop across the shunt is negligible) VCM is far closer to GND

      • Conversely, if Rshunt is placed on the high side, VCM is far closer to Vsupply.

      • This means that using a high side shunt resistor will require an amplifier with a higher CMMR (common mode rejection ratio).

    • Ok, but then why not just put it on the low-side and go on with our lives?

      • Let’s say some system fault happens and the low side of Rshunt becomes grounded. Then, our system load never actually gets power! All of the current flows directly to ground.

      • With a low-side shunt resistor, this would never be detected, as we would just read in a Vshunt of zero or perhaps some floating voltage.

      • With a high-side shunt resistor, however, we read in a voltage of Vsupply, as the entire voltage drop happens across Rshunt.

      • This isn’t really a concern with our application as we don’t really care. If the user of this board happens to detect a fault condition, they will notice it immediately as their board will not get power.

    • Another issue is ground loops. The gist is that if some components on the system use one ground and some use another, there can be some path for current flow. Even if the grounds aren’t connected, there are many ways things can go wrong (for example, even things like stray electromagnetic fields can induce small currents).

      • In this case, the system load (the device being powered) would have a slightly higher ground reference than our buck converters or USB-PD chip, which means that we would need separate ground planes or paths.

      • On the other hand, if a high-side resistor is used, the grounds of everything is all the same, so no possibility of weird ground shit happening.

    • High-side shunt resistor is our answer then.

  • To select a shunt resistor, we also have to keep in mind our amplifier circuitry due to something called amplifier offset voltage. https://www.allaboutcircuits.com/technical-articles/understanding-the-amplifier-offset-voltage-and-output-swing-in-resistive-current-sensing/

    • Let’s say the two inputs to our current sense amplifier are V+ and V-. Ideally, if V+ == V-, then Vout = 0V. However, this is not truly the case, and current sense amplifiers will have some necessary offset on V+ to be applied so that Vout = 0V.

    • image-20240630-080312.png

  • If Gdiff is differential gain of the amplifier:

    • Vout = Gdiff (VA - VB)

    • Since VA - VB = Vshunt + Voffset, Vout = Gdiff (Vshunt + Voffset)

  • Next, let’s look at error. Error is defined as (Measured Value - Actual Value)/(Actual Value).

    • Measured value is Vshunt + Voffset (not including Gdiff as that is really just a multiplier for ADC measurement purposes)

    • Actual value is just Vshunt since that’s what we’re trying to measure

    • Therefore, Error = ((Vshunt + Voffset) - Vshunt)/(Vshunt)

    • If Vshunt = Voffset , then Error = ((Vshunt + Vshunt) - Vshunt)/Vshunt = Vshunt/Vshunt = 1 = 100%.

  • This matters because it screws up our accuracy at lower current values (i.e. if Rshunt is fixed, and Voffset is fixed, and Ishunt is low enough, Vshunt ><= Voffset)

    Thus

    Voffset which means Voffset/Vshunt > 100%)

    • Thus, we must find our lower bound for Vshunt, i.e. the shunt voltage that we are ok with 100% or greater error because it is probably lower than minimum current of a device connected to the bus.

    On the mouser page Voffset is displayed as Vos for a given current sense amplifier.

    • image-20240630-075824.pngImage Removed

      is probably lower than minimum current of a device connected to the bus. Essentially, how low do we plan to measure?

      • I figure the current lower bound is probably the minimum resolution we can express, so for the 5V bus it would be 0.001A and for the 12V bus it would be 00.01A.

    • We can try increasing the value of the shunt resistor (Rshunt) in order to increase Vshunt at lower current draws, such that Vshunt stays above Voffset, but that will incur a greater power draw.

  • This is the optimization we have to run: how small of a Rshunt value can we select before the accuracy catches up to the power savings?

    • Let’s assume that minimum allowable error at our current lower bound is 50%. This would mean 0.001A could be read in as 0.0015A on the 5V bus and 00.01A could be read in as 00.015A on the 12V bus

  • Note: On the mouser page Voffset is displayed as Vos for a given current sense amplifier.

    • image-20240630-075824.pngImage Added

5V Current Sense Selection

  • First, the 5V current sense amplifier. I’ve filtered by every Vcm range that includes 5V and selected the cheapest current sense amplifier to start.

    • INAx180

    • Depending on the selected part, this can be a 1-channel, 2-channel, or 4-channel, which means we could use the 2-channel variant for sensing on the 12V bus too. It all depends on what gain is necessary though.

    • Supply voltage supports 5V

  • Let’s first calculate the minimum and maximum Rshunt which will constrain us.

    • image-20240701-005352.pngImage Added
    • image-20240701-005827.pngImage Added
    • First, for 20V/V:

      • Rshunt < 4.98V / (3A x 20V/V) = 0.083 ohms

      • Rshunt > 0.0005V / (0.001A x 20V/V) = 0.025 ohms

    • For 50V/V:

    • This is at typical operating conditions though; at maximum operating conditions Rshunt_min becomes greater than Rshunt_max which is no bueno. However since this really only affects the upper and lower bounds of current we can sense and not the resolution directly, I think it’s probably fine unless we’re going to be measuring a device that draws 1mA of current 😂

  • In order to effectively decide our configuration, let’s assume we intend to choose the maximum Rshunt possible in order to maximize accuracy. Thus, we’d need to choose the lowest gain option for our current-sense amplifier of 20V/V.

    • The ADC range of ATTINY826-XU is from -100mV to VDD+100mV, which we can generalize to 0 to VDD volts (0 to 5V)

    • Thus, we’d want maximum current draw to be equivalent to a sensed voltage on ADC of 5V, probably slightly lower to account for any voltage drop or inaccuracy in the PD standard. Let’s say VDD=4.75V for this reason.

    • 4.75V/20V = 0.2375V at max current draw

    • If max current draw on 5V bus is 3A, then we’re looking at 0.2375V = 3A x Rshunt → Rshunt = 0.0791666667 ohms.

    • The power dissipation through the shunt resistor would be 0.7125 watts, eating up 4.75% of our maximum power draw on the 5V bus (15W).

    • Now let’s calculate the percent error at minimum detectable current on the 5V bus, 0.001A. Error = Voffset/Vshunt → 500uV/0.2375V = 0.00210526316 = 0.21%. Pretty good! (this is assuming Voffset at 12V Vcm is equivalent to ours)

  • Let’s do a calculation of power draw and error at the mid-range voltage gain of 50V/V.

    • 4.75V/50V = 0.095V drop across Rshunt at max current draw

    • 0.095V = 3A x Rshunt → Rshunt = 0.0316666667 ohms

    • Pshunt = 3A x 0.095V = 0.285 watts, eating 1.9% of our maximum power draw on the 5V bus.

    • Percent error at 0.001A on 5V bus: Error = 500uV/0.095V = 0.00526315789 = 0.5% (again, assuming Voffset at 12V Vcm is equivalent to ours)

    • Voltage swing calcs:

      • 3A x 0.0316666667 ohms x 50V/V = 4.75 volts < 4.98V

      • 0.001A x 0.0316666667 ohms x 50V/V = 0.00158333334 volts

      • Looks like we get the same numbers as last time. I should have guessed this would happen since it’s a ratio thing; when you change both gain and Rshunt by the same factor the numbers you get for voltage swing become the same.

Development

Components and ICs:

...

  • Originally I was using the downloaded symbols for the MOSFETs when creating the schematic, but then I realized KiCad has a large base of existing symbols for common device configurations. For example, Device:Q_Dual_NMOS_S1G1S2G2D2D2D1D1 models an NMOS FET similar to the 12V Output N-Channel MOSFET.

    • Additionally, the MOSFET symbols you might download for one of these things will just look like a rectangle:

      image-20240602-230318.png
    • vs the KiCAD dual mosfet symbol (far clearer in what it actually is):

      image-20240602-230420.png
    • So using the symbols from the Device library for a MOSFET, and then linking it later to the downloaded footprint for the desired FET, will make the schematic clearer.

  • This website is pretty good for resistor values: https://jansson.us/resistors.html

    • Choose E24 for most commonly available values

  • Originally I calculated inductors for max input of 20V, but in order to overspec it (as a safety measure) I’m going to redo the calculations for 25V and pick new inductors & ensure that the buck converters will still work as intended

  • According to this presentation, the voltage tolerance on USB PD is +-5%. The undervoltage lockout points have been set at exactly these values so that we can ensure proper operation.

  • Use wolfram alpha for conversions and calculations, it works pretty well.

  • Murata (and many other manufacturers) caps may not provide the DC bias curves on the datasheet directly, but have external design tools linked on the Mouser or Digikey page that will have the specific curve for the selected cap.

    • Digikey will often have more resources than Mouser, so make sure to check there.

    • See this reddit comment:

      That's just an example graph to show that ferroelectric dielectrics are shit. You need to look at the curves for the specific part number capacitor, which is not always available.

      For specific capacitor Vbias curves, I tend to look on the Digikey product page, where it will often be linked.

      For Samsung caps, look for "Datasheets: LONG-MFG-PART-NO Characteristics". Example digikey page.Example characteristics datasheet.

      For TDK, look for "Datasheets: Character Sheet". Example.

      For Murata, look for "Design Resources: SimSurfing Design Tool". Example.

      For KEMET, look for "Design Resources: K-SIM Simulation". Example. There's a drop-down menu on the upper left to select "Capacitance vs. Vbias" plot.

      I'm pretty sure AVX has something similar, but not seeing an easy example, so no link. I guess they have crap coverage.

      I've never found a good link for Taiyo Yuden, though I haven't searched much.

      Wurth has a link that looks suspiciously like simulation results, but require you to signup and login, so fuck them. I'm not making an account to learn about your commodity passives.

      So the data is out there for like 25-50% of the ceramic caps on digikey. I just assume the rest are garbage and ignore them, but then again I don't have BOM price pressure forcing me to look for cheaper passives. It really should be a column on digikey's parametric sort: delta C @ 75% WV. But I think they have the same problem with data availability that we do.

    • Adding onto this, Taiyo Yuden has a product searcher that will give you similar characteristic sheets. Given that these are on the cheaper end of caps, having this sort of data on caps we use often is valuable.

  • image-20240623-063413.png
  • If you figure out certain specs for a component but you don’t know others, sometimes it is useful for me to just sort by price and pick the cheapest thing, then see if there’s anything that would bar it from working with your application.