This is only a preview of the July 2021 issue of Silicon Chip.
You can view 41 of the 112 pages in the full issue, including the advertisments.
Items relevant to "20A DC Motor Speed Controller":
Articles in this series:
Articles in this series:
Items relevant to "Model Railway Level Crossing":
Items relevant to "Silicon Labs-based FM/AM/SW Digital Radio":
Items relevant to "Advanced GPS Computer – Part 2":
Purchase a printed copy of this issue for $10.00.
How USB-C Power Delivery Works By Andrew Levido 4.5W 7.5W 15W 36W 60W 100W USB has come a long way from when it was introduced in the mid-1990s. The widespread adoption of USB 3.2 introduced the Type-C connector, plus a new Power Delivery (PD) capability that allows up to 100W (20V <at> 5A) to be delivered. It is quite a bit more complicated than previous USB power schemes, but well worth a look. O ur article in the June issue on the “USB Explosion!” described the USB Type-C (USB-C) connector in a fair bit of detail and touched on the new USB Power Delivery mechanism (siliconchip.com.au/Article/14883). However, there’s quite a bit more to say on both topics, so this follow-up article will fill in the gaps. We also have an article starting on page 42 which describes some lowcost USB Power Delivery (PD) compliant power sources. Next month, there will be a follow-up article that discusses ways to negotiate and monitor the voltage and current supplied by a USB-PD source. But first, read below to get an idea of why you would want to use those devices. As described in the May article, the USB 3.2 standard is the first that officially allows power sources and sinks (and the cable!) to negotiate the voltage and current supplied. But before we get into the details for how all this works, we need to get a few terms straight. Things have gotten more complicated since the days when there were only two possible things you could plug a USB cable into: a host, which sourced power and controlled communication, and a device, which consumed power and responded to host communication. Now USB ports can have three possible data roles and three possible power roles. Data roles include: • Downstream-facing ports (DFPs) – typically a host or hub 36 Silicon Chip • Upstream-facing ports (UFPs) – typically a device • Dual-role ports (DRPs), which can switch between device and host roles USB-C ports also have a power role: • Source role, supplying power • Sink role, consuming power • Dual-role power port Dual-role power ports can switch between source and sink roles. A good example of this is the USB-C port on a laptop, which can be a sink when connected to a power brick (or a monitor which can supply power) to power or charge the device, or a source when connected to a peripheral such as a USB hard disk. On attach, DFPs are source ports and UFPs are sink ports; however, this can be changed later by mutual agreement. The USB-C connector USB 3.2 introduced the new Type-C connector, which is used on both ends of a USB-C cable. This connector can be inserted either way around, and the connectors can optionally contain electronics that allows the system to identify specific cable capabilities. The USB-C connection includes a dedicated Configuration Channel (CC), used to detect cable attachment, plug orientation, cable capability, and to negotiate ‘Power Contracts’ between source and sink. In addition, USB-C has two super speed full-duplex differential channels for high-speed data communication, and two sideband use lines. We will focus on the CC for this discussion. The two rows of contacts in the receptacle are shown in the middle of Fig.1, with the two possible plug orientations (un-flipped and flipped) shown above and below respectively. The GND and VBUS pins are Fig.1: the pin assignment of the USB Type-C receptacle is shown in the centre. Above and below are two possible plug orientations. The CC1 and CC2 pins on the receptacle connect to the CC and VCON pins on the plug; it can tell which way the plug is inserted by monitoring which of CC1 or CC2 connect to CC. Australia’s electronics magazine siliconchip.com.au Fig.2: on attach, the source pulls up CC1 and CC2 via Rp, and the sink pulls them down via Rd. There is only one CC line in the cable, so both the source and sink can detect whether or not the plug is flipped at their end. An active cable pulls the VCON pin down via Ra to signal its presence. Passive cables leave VCON open. symmetrical, so these pins connect correctly regardless of the plug orientation. The classic USB D+ and D- also work correctly, as the two D+ pins and the two D- pins on the receptacle are connected together internally. The two super-speed twisted pairs will be swapped depending on the plug orientation, so the device must use a high-speed mux to un-swap these if the plug is flipped. Similarly, the sideband use (SBU) pins are swapped, and must be sorted out depending on the plug orientation. The pins we are interested in for Power Delivery are the two Configuration Channel (CC) pins on the receptacle, and the CC and VCON pins on the plug. These allow the ports at each end of the cable to work out the plug orientation, detect attachment, and determine the other end’s capabilities. Detecting attachment and cable orientation Refer now to Fig.2. When two USB Type-C ports are connected, the DFP will default to a source and pull the two CC lines high with resistors Rp, and the sink end will pull the CC lines down via resistors Rd. The source detects attachment when one of the two CC pins is pulled low by Rd, and the sink detects attachment when one of its CC pins is pulled high by Rp. On attachment, the source voltage defaults to 5V for compatibility and safety. The sink can determine what current the source can provide at 5V by measuring Rp’s value (or, more accurately, the current sourced). Table 1 shows how this works (overleaf). The source and sink can determine the plug orientation by noting whether their CC1 or CC2 pin is pulled up by Rp or down by Rd. Electronically marked cable assembly (EMCA) The connectors on a USB Type-C cable can optionally contain a microchip, allowing the cable to report its capabilities to the source and sink devices. For example, a standard USB Type-C cable can support power delivery at up to 3A. To take advantage of the maximum 5A capability, you need to use an active cable that can tell the source that it is rated to that level. The source will not allow the sink to draw more than 3A if the cable does not report that it can handle it. On attach, a cable indicates it is electronically marked by pulling the VCON pin down via resistor Ra, which is between 800W and 1.2kW. Nonmarked cables leave VCON open. If a Marked cable is detected, the source device is responsible for supplying a voltage at the appropriate CC pin to VCON to power the microchip in the cable, as shown in Fig.3. Other modes Type-C connectors support additional modes that use the sideband use (SBU) channels. These are the audio accessory mode (for headphones, for example) and a debug accessory mode, where the SBU channels can be used for transmitting debugging signals. Table 2 summarises the various combinations of pull-up and pulldown on the CC pins and what they signify. Power Delivery When attached, a USB Power Delivery source is configured to supply 5V for compatibility with legacy devices. It will be capable of supplying up to 1.5A for a maximum power of 7W, or 3A/15W, depending on Rp’s value as described above. If this is all the sink requires, it does not need to do Fig.3: if the source detects an active cable, it switches a power supply on to the VCON pin to power up the microchip in the connector. The cable must be capable of being powered from either end, as a USB Type-C cable can be connected either way around. siliconchip.com.au Australia’s electronics magazine July 2021 37 Fig.4: the power rating of a USB Power Delivery source generally indicates the range of voltages it can provide. This is not always the case (I’m looking at you, Apple), so it pays to check before buying. anything more. This is known as an implicit contract. If the sink requires more power or a higher voltage, it can request more by negotiating an explicit contract over the Configuration Channel. Before we get into details of how this is done, we should look at the voltages and currents typical USB Type-C sources can supply. Fig.4 shows that USB Power Delivery sources are generally rated by the power they can source. Up to 15W, they typically only supply 5V. Those rated above 15W generally supply 5V or 9V; those rated above 27W should offer 5V, 9V and 12V, while those above 36W should offer 5V, 9V, 12V and 15V. Those rated above 45W add 20V to the list. Note that while this is generally the case, some vendors have gone their own way and offer some oddball combinations. Negotiating a Power Contract Fig.5: the “start-of-packet” (SOP) header indicates whether the message is intended for the UFP, or a particular connector of an active cable. These are confusingly called SOP, SOP’ and SOP” packets respectively. Fig.6: a successful power contract negotiation starts with the source advertising its capabilities. The sink then requests one of these capabilities. If the request is accepted, the source sends an “Accept” message, changes its output, and then sends a “PS_RDY” message. All messages are acknowledged with a “GoodCRC” message if they are received correctly. 38 Silicon Chip Australia’s electronics magazine Data across the Configuration Channel is encoded into 32-bit packets using bi-phase mark coding (BMC) at 300 kilobaud, with CRC error correction. Communication is initiated by the DFP (usually a source). Messages start with a ‘start-ofpacket’ (SOP) packet, which describes where the message is intended to go. Confusingly, these are designated SOP, SOP’ and SOP’’ packets. As shown in Fig.5, messages headed by SOP packets are intended for the UFP; those with SOP’ packets are intended for the connector at the source end of an electronically marked cable (ie, that receiving VCON); and those with SOP” packets are for the connector at the sink end of the cable. It is important to keep in mind that, while the SOP signalling means the Configuration Channel uses a multidrop protocol, overall USB remains a point-to-point connection. The D+, D− signalling is unchanged from previous generations of USB, and the superspeed channels also operate point-topoint. You can still only connect one DFP to one UFP, and have one source and one sink in a given connection. The basic process for negotiating an explicit Power Contract is shown in Fig.6. Until an explicit Contract has been negotiated, the source will periodically send a “Source_Cap” message to advertise its voltage and current capacity. If this is received siliconchip.com.au successfully by the sink, it will respond with a “GoodCRC” message. The “Source_Cap” message includes a list of the possible voltages and maximum currents it can source. The sink may then request the source provide a specific voltage identified in one of the source capabilities, and specify the maximum current required (up to the advertised capacity) by sending a ‘Request’ message to the source. This is also acknowledged by the source with a “GoodCRC” message. The source will analyse the request and determine if it can accommodate it. If it can, it sends an ‘Accept’ message to the sink. Assuming it received a “GoodCRC” message acknowledging receipt by the sink, the source will change its output to the agreed level and send “PS_RDY” message to the sink. If that message is acknowledged, then the Contract is considered complete. Fig.7 shows a screen capture of this process, using a Total Phase USB Power Delivery analyser. At the top of the screen are the messages passing between the source and sink as Table 1: RP values and source current vs current capability Maximum source current Rp (pulled to 5V) Rp (pulled to 3.3V) Current sourced Default (0.5A or 0.9A) 56kW 36kW 80µA 1.5A 22kW 12kW 180µA 3.0A 10kW 4.7kW 330µA Table 2: decoding CC1 & CC2 states (from the source perspective) CC1 CC2 Attach? Active Cable? Flipped? open open no – – Rd open yes no no open Rd yes no yes open Ra no yes no Ra open no yes yes Rd Ra yes yes no Ra Rd yes yes yes Rd Rd debug accessory mode Ra Ra audio adaptor mode a contract is negotiated. The bottom half of the screen shows an expansion of the highlighted “Source_Cap” message. You can see that this particular source (a 45W Targus unit labelled APA95AU) can supply 5V, 9V, 12V, 15V and 20V, as described in the five “Power Objects” contained in the “Source_Cap” Message. Fig.7: the upper half of this screenshot shows the messages exchanged between the source and the sink during the successful negotiation of a 20V contract. The lower half shows the details of the highlighted “Source_Cap” message. In this case, there are five Power Description Objects, corresponding with the five voltage levels this source supports. siliconchip.com.au Australia’s electronics magazine July 2021 39 Fig.8: the same transaction as shown in Fig.7, but in this case, the lower panel shows the details of the Request message sent by the sink. It requests ‘Position 5’, corresponding to the 20V Power Description Object in the “Source_Cap” message. Fig.9: this capture shows a transition between a 5V contract and a 9V contract. The sink executes a “Soft Reset” message to force the source to re-advertise its capabilities so a new transaction can occur. The source continues to honour the existing contract until a new one is agreed upon. 40 Silicon Chip Australia’s electronics magazine siliconchip.com.au Fig.10: this transaction shows what happens on attach if an electronically marked cable is detected. The source first queries the cable with a “DiscIdentity” message. The lower panel shows the cable’s response. We can see, among other things, that this is an Apple cable and it can handle up to 5A. Fig.8 shows precisely the same negotiation, but highlights the sink’s Request message in response to the “Source_Cap” message. In this case, the sink requests 20V by asking for “Position 5”, corresponding to the fifth Power Object in the “Source_Cap” message. It also requests an operating current of 1A and a peak current of 2.25A, the maximum available at that voltage. Renegotiation If the sink wishes to negotiate a new Contract with the source, it can send a ‘Soft Reset’ message, which will result in the sink re-sending the “Source_Cap” messages. The sink can then request a different Contract. The current Contract remains in force until a new one is successfully negotiated. Fig.9 shows this in action. In this case, the sink requests a change from 5V to 9V. The bottom half of the screen capture shows the VBUS change corresponding with the “PS_RDY” message, just before the 13.4 second mark. siliconchip.com.au All of the transactions shown so far have involved a passive cable, so no SOP’ or SOP” packets were issued. Fig.10 shows the messaging after attach when an active cable is used. Initially, the source sends a “DiscIdentity” packet to the cable, which responds with a similarly labelled message containing details about the cable. This response is expanded in the bottom half of the screen. In the bottom row, you can see the cable is reporting its latency and indicates that it has a 5A capacity. Practical considerations If you want to build a project using USB Type-C power, you have a few options. By far, the simplest is to live with just 5V; ie, do nothing and accept the implicit 5V contract. This is identical to powering your device from a USB Type-B connector such as Mini-B or Micro-B. If you want to negotiate an explicit contract, you can use one of the offthe-shelf chips which provide various Australia’s electronics magazine degrees of integration. Assuming you are building a sink-only device, a good option I have used is the ST Microelectronics STUSB4500. This can be used as a standalone controller (once programmed, if the default does not suit you), or it can be used with a microcontroller, to give you full control over the negotiation process. I used this chip to build a simple power supply. This uses a linear regulator for low noise, and manages its input voltage via USB Power Delivery to minimise internal power dissipation. References • “STUSB4500 – Standalone USB PD Controller for Power Sinking Devices – STMicroelectronics” – siliconchip. com.au/link/ab73 • Microchip “AN1953 Introduction to USB Type-C” – siliconchip.com. au/link/ab74 • Texas Instruments “USB PD Power Negotiations,” 2016, 21 – siliconchip. com.au/link/ab75 SC July 2021 41