Silicon ChipHow USB Power Delivery (USB-PD) works - July 2021 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Software: too many bugs, too many updates
  4. Feature: The 2020 mission to Mars by Dr David Maddison
  5. Project: 20A DC Motor Speed Controller by John Clarke
  6. Feature: How USB Power Delivery (USB-PD) works by Andrew Levido
  7. Feature: El Cheapo Modules: USB-PD chargers by Jim Rowe
  8. Project: Model Railway Level Crossing by Les Kerr
  9. Project: Silicon Labs-based FM/AM/SW Digital Radio by Charles Kosina
  10. Review: Tecsun PL-990 radio receiver by Ross Tester
  11. Project: Advanced GPS Computer – Part 2 by Tim Blythman
  12. Serviceman's Log: I’ve repaired planes before, but never tanks by Dave Thompson
  13. Vintage Radio: The Rowe AMI JAL-200 jukebox by Jim Greig
  14. PartShop
  15. Product Showcase
  16. Market Centre
  17. Advertising Index
  18. Notes & Errata: Advanced GPS Computer, June 2021; Mini Arcade Pong, June 2021; Refined Full-Wave Motor Speed Controller, April 2021; USB Flexitimer, June 2018
  19. Outer Back Cover

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.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "20A DC Motor Speed Controller":
  • 20A DC Motor Speed Controller PCB [11006211] (AUD $7.50)
  • PIC16F1459-I/P programmed for the 20A DC Motor Speed Controller [1100621A.HEX] (Programmed Microcontroller, AUD $10.00)
  • Firmware and source code for the 20A DC Motor Speed Controller [1100621A] (Software, Free)
  • 20A DC Motor Speed Controller PCB pattern (PDF download) [11006211] (Free)
Articles in this series:
  • The History of USB (June 2021)
  • How USB Power Delivery (USB-PD) works (July 2021)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "Model Railway Level Crossing":
  • Model Railway Level Crossing PCB [09108211] (AUD $5.00)
  • Pair of PIC12F617-I/P chips for the Model Railway Level Crossing [0910821A/B/C.HEX] (Programmed Microcontroller, AUD $15.00)
  • ISD1820-based voice recording and playback module (Component, AUD $7.50)
  • Firmware, source code and sound recording for the Model Railway Level Crossing [0910211A-C] (Software, Free)
  • Model Railway Level Crossing PCB pattern (PDF download) [09108211] (Free)
  • Mechanical diagrams and label artwork for the Railway Level Crossing (PDF Download) (Panel Artwork, Free)
Items relevant to "Silicon Labs-based FM/AM/SW Digital Radio":
  • SiLabs FM/AM/SW Digital Radio PCB [CSE210301C] (AUD $7.50)
  • ATmega328P programmed with the firmware for the SiLabs FM/AM/SW Digital Radio [CSE210301.HEX] (Programmed Microcontroller, AUD $10.00)
  • Pulse-type rotary encoder with pushbutton and 18t spline shaft (Component, AUD $3.00)
  • Si4732-A10 AM/FM/SW/LW/RDS Radio Receiver IC (Component, AUD $20.00)
  • Firmware and source code for the SiLabe FM-AM-SW Digital Radio [CSE210301.HEX] (Software, Free)
  • SiLabs FM/AM/SW Digital Radio PCB pattern (PDF download) [CSE210301C] (Free)
  • Drilling/cutting diagrams and front panel artwork for the SiLabs-based FM-AM-SW Digital Radio (Free)
Items relevant to "Advanced GPS Computer – Part 2":
  • Advanced GPS Computer PCB [05102211] (AUD $7.50)
  • PIC32MX170F256B-50I/SP programmed for the Advanced GPS Computer [0510221A.hex] (Programmed Microcontroller, AUD $15.00)
  • DS3231 real-time clock IC (SOIC-16) (Component, AUD $7.50)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • MCP4251-502E/P dual 5kΩ digital potentiometer (Component, AUD $3.00)
  • Micromite LCD BackPack V3 complete kit (Component, AUD $75.00)
  • Matte/Gloss Black UB3 Lid for Advanced GPS Computer (BackPack V3) or Pico BackPack (PCB, AUD $5.00)
  • Firmware for the Advanced GPS Computer [0510221A.HEX] (Software, Free)
  • Advanced GPS Computer PCB pattern (PDF download) [05102211] (Free)
  • Advanced GPS Computer box cutting diagram and lid dimensions (Panel Artwork, Free)
Articles in this series:
  • Advanced GPS Computer - Part 1 (June 2021)
  • Advanced GPS Computer – Part 2 (July 2021)

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