The Negotiator II

Up to 48V 5A wherever you are. At 2 mm thick, it is made to fit easily into your wallet.

The Negotiator II on a power bank outdoors, its capability bar and voltage, current and power displays lit
About The Negotiator II
  • USB PD 3.1
  • 5 to 48V in 0.1V steps
  • Up to 5A
  • 2 mm thick total
  • 190 LEDs
  • $8 a board
  • $3.8 BOM cost

The Negotiator II is here! USB PD 3.1: Unlocked.

USB PD (Power Delivery) is a miracle, behind which is a lot of complexity. USB Chargers today have chips much more powerful than the Apollo 11 moon landing guidance computer, so we cant just grab a charger and get 15V out of it, all that capability is locked away, and the Negotiator is the key.

With the Negotiator II, you can find out exactly what any USB port can do with the capability bar and mode selector. Then, select whatever voltage your charger supports between 5 to 48V in 0.1V increments and you’ll get that. Selecting a voltage will show you what current your charger can provide at that voltage, this card can deliver up to 5A! Apply your selection to initiate the negotiation and you’ll see a live measurement of the voltage, current, and power at the card’s input.

The capability bar lit from 5 to 48V, with the PPS CV and CL lights on
An EPR charger lights up the whole bar, 5 to 48V.

Use it to power your load from any USB C charger/powerbank when out on the field. Connect your load using one of the various connector-less solutions shown in the photo below. Im pretty proud of the wire wedge! Its a low profile, quick, and cheap wire-to-board connector. Wedge the wire in, pull it parallel to the board as shown, done! Otherwise, use banana plug, a crocodile clip, or friction fit 0.1” header. At 2 mm thick including the PCB and components, It’s small enough to go into your bag or wallet so you always have a power supply handy.

Header pins pressed into the 0.1 inch holes, banana plugs in the wire wedge holes, and a crocodile clip and a wedged wire on the wire wedge
0.1” header, banana plugs, and the wire wedge with a crocodile clip and a wire.

This was a challenging and rewarding board to design. I managed to get the cost down to $8 per board delivered for a quantity of 100. When you consider all the capabilities, 0.8mm 4-layer ENIG plated PCB, the sheer number of components (including about 200 LEDs!), I think it’s certainly an achievement to be proud of.

Powering around 200 LEDs from 48V was fun, especially trying to do it as cheaply as possible and with components under 1.2 mm thick. I could not afford to use a buck regulator or expensive ultra efficient LEDs. These 0402 LEDs produce 10 mcd (bright enough for outdoors) with less than 0.2 mA and cost $0.004 each. The LDO works well with firmware throttling, feeling warm and not uncomfortable to touch.

With the VBUS and CC pins next to each other, a VBUS to CC short at 48V is a real and dangerous possibility. TI’s TPD4S480 is the right chip for the job, However, It costs $1.1 @1k qty. Instead I used depletion mode N-channel mosfets which deplete, cutting off CC and protecting the MCU. I tested shorting 48V to CC input – no current or heat, and negotiation worked afterwards.

This card shows the USB PD modes, in the photo below, you can see the different modes that this card supports. Auto combines all modes and selects the highest current available at every voltage. PDO cannot do 9.2V, you’ll need PPS or AVS for that. Multiple modes can support the same voltage at different current limits.

The PD mode lights and the capability bar in AUTO, PDO and PPS on the same charger, each lighting a different set of voltages
AUTO, PDO and PPS on the same charger.

To make this card a reality, I had to write a library for it. I plan on open sourcing the PD version of that and releasing the cheapest PD 3.1 Sink design, ever. So check back here soon!

More photos

Instructions Got one of my cards? Heres how to use it.

So you got one of my business cards, awesome! Its also a tiny USB PD power supply, here's how to use it.

Want to see everything its doing? Plug it into your computer and open the console.

This page is a work in progress, I will add more information and polish it... Eventually.

Control it from your own code The USB protocol the console uses, and a Python script

The card speaks a small binary protocol over USB serial which the console uses. Here's how to make your own script to talk to it. To get going quickly, grab bcv2.py, a Python script that handles the protocol.

Connect

Plug DATA into your computer and it shows up as a serial port: a COM port on Windows, /dev/ttyACM0 on Linux, /dev/cu.usbmodem-something on a Mac. Its USB ID is 1A86:FE0C. The baud rate doesn't matter since it's USB. Set DTR when you open the port to get the communication going. pyserial and most serial terminals set it for you.

Once the port is open, the card sends its device info, then a reading every 50 ms. When its USB queue is full, the card drops readings, device info and charger offers instead of waiting, so ask again if one doesn't come (the console asks for device info up to three times, 400 ms apart). Answers to your commands aren't dropped.

Firmware v1.2 and earlier can also lose the first packet each way after the port opens, every other time it opens. Start with a device query (0x01) and send it again if no answer comes within half a second, like the console does. Once it's answered, later commands get through.

Frames

Everything, both ways, is a frame like this. Numbers are little-endian.

ByteWhat
0, 10x50 0x44, "PD"
2Version, 1
3Kind: which command or event
4Sequence number
5Payload length, 0 to 56
6 onPayload
LastCRC-8 of byte 2 to the end of the payload: polynomial 0x07, starting at 0, no final XOR

Give each command a sequence number from 1 to 255. The card answers each one with a result (kind 0x80) with the same sequence number, and the events it sends on its own have 0. To read frames, find 0x50 0x44, wait for the whole frame and check the CRC. If it doesn't match, skip one byte and look for the next 0x50 0x44.

def crc8(data):
    crc = 0
    for byte in data:
        crc ^= byte
        for _ in range(8):
            crc = ((crc << 1) ^ 0x07) & 0xFF if crc & 0x80 else (crc << 1) & 0xFF
    return crc

def frame(kind, seq, payload=b""):
    body = bytes([1, kind, seq, len(payload)]) + payload
    return b"PD" + body + bytes([crc8(body)])

frame(0x01, 1)  # ask for device info: 50 44 01 01 01 00 68

Commands

KindPayloadWhat it does
0x01NoneSends device info (0x81).
0x02NoneAsks the charger for its offers again (0x83).
0x109 bytes: voltage in mV (u32), current in mA (u32, 0xFFFFFFFF for the most on offer), supply (u8: 0 auto, 1 fixed, 2 PPS, 3 SPR AVS, 4 EPR AVS)Requests a voltage, like APPLY. 5000 mV or more, and 500 mA or more.
0x0CNoneTurns the output on, like LOAD ON/OFF. The same safety rules apply.
0x0DNoneTurns the output off.
0x05NoneEnters EPR, for 22V and up.
0x07NoneExits EPR.
0x06NoneAsks the charger for its EPR offers again (0x83).
0x32NoneReads the black box (0xA7).
0x343 bytes: brightness 0 to 43, dim dots 3 to 60, flags (1 hides leading zeros, 2 hides the marks on the bar)Sets the display, and the card keeps it. The defaults are 34, 21 and 0. From firmware v1.1.

The result (0x80) is one byte: 0 queued, 1 busy, 2 invalid, 3 unsupported. Busy means the card already holds 4 commands, so wait a moment and send it again. Queued means the card took the command, not that the charger agreed, so watch the readings for the contract to change. It changes to your request rounded down to the charger's step (20 mV for PPS, 100 mV for AVS). If it doesn't change, the charger said no and WARNING plays R.

Events

KindBytesWhat
0x801Command result, above.
0xA522A reading, every 50 ms. Card uptime in ms (0 to 3), VBUS in mV (4 to 7), current in mA (8 to 11), contract mV (12 to 15, 0 when there's none), contract mA (16 to 19), flags (20 and 21, below).
0x8132Device info. Card ID (0 to 7), flags (8: bit 0 PPS, bit 1 EPR), max mV (9 to 12), max mA (13 to 16), max mW (17 to 20), firmware build (21 to 24, 0x0105004F is v1.2), library version (25 to 28), display settings as in 0x34 (29 to 31). Firmware before v1.1 sends 21 or 29 bytes.
0x833, plus 4 per offerCharger offers. 0 for an SPR list or 1 for EPR (0), the charger can do EPR (1), how many offers (2), then each offer as a 4-byte PDO from byte 3. Sent when a charger is plugged in, after 0x02 or 0x06, and when EPR starts.
0x886Hard reset. 0 if the charger sent it, 1 if the card did (0), recovery time in ms (1 to 4), cause (5). The output is off after one.
0xA756Black box. Saved supply as in 0x10 (3), saved mV (8 to 11) and mA (12 to 15), how many events (2), then up to 6 events of 6 bytes from byte 20: uptime in seconds (u16), context (u16), kind (u8: 1 hard reset, 2 PHY reset failed, 3 PD PHY unstable, 4 partner timeout, 5 protocol error, 6 terminal stop, 7 EPR entry failed, 8 power rail fell) and detail (u8). The script decodes the rest.

Reading flags

BitMeans
0A charger is attached.
1There's a contract.
2LOAD is on, what you asked for.
3The output is actually on.
4The inrush routine started the output, WARN I. From firmware v1.2.
5The display is dimmed for the LDO, THERM LIM.
11The brake tripped. Turn LOAD on again to clear it.
12 to 14What last turned LOAD off: 1 the LOAD key, 2 APPLY, 3 a USB command, 4 the brake, 5 the charger session changed. From firmware v1.2.
15Your settings couldn't be saved, WARN S.

The other bits are for debugging.

Offers

Each offer is a 32-bit PDO, laid out as the USB PD spec has it. Offers 1 to 7 are SPR and 8 and up are EPR.

Type, top bitsVoltageCurrent or power
Fixed, 00Bits 19 to 10 × 50 mVBits 9 to 0 × 10 mA
PPS, 1100Bits 15 to 8 × 100 mV, to bits 24 to 17 × 100 mVBits 6 to 0 × 50 mA
EPR AVS, 1101Bits 15 to 8 × 100 mV, to bits 25 to 17 × 100 mVBits 7 to 0, in W
SPR AVS, 11109V to 15V, or to 20V when it has a 20V currentBits 19 to 10 × 10 mA up to 15V, bits 9 to 0 × 10 mA above

What the console does

When it connects, it sends 0x01 until device info arrives (up to three times, 400 ms apart), sends 0x02 for the offers and starts drawing the readings. A request is one 0x10. A ramp sends one 0x10 at a time, and the next once the contract has changed and VBUS is within an eighth plus 0.5V of it, the card's own check. Tare, averaging and the CSV all happen in the browser.

The Python script

bcv2.py needs Python 3.8 or later and pyserial (pip install pyserial), and finds the card on its own.

python bcv2.py                      # card info, charger offers, then live readings
python bcv2.py watch --csv log.csv  # the same, saving every reading like the console's CSV
python bcv2.py request 9            # 9V, the card picks the supply
python bcv2.py request 12.34 2.5 --supply pps
python bcv2.py load on
python bcv2.py epr on
python bcv2.py blackbox

Or use it from your own script:

from bcv2 import Card

with Card() as card:
    card.request(15)
    card.load(True)
    for reading in card.readings(seconds=10):
        print(reading["mv"], reading["ma"])

What can it do?

See what your charger offers

Plug it into a USB-C charger and the SOURCE CAPABILITY bar lights up every voltage it can give you, from 5 to 48V. The mode lights show which PD modes it supports (PDO, PPS, SAVS and EAVS), the one its using is brighter. In a few seconds you know if that charger is any good.

Power your projects

Pick a voltage, press APPLY and the card negotiates it with the charger. Then press LOAD ON/OFF to send it to your load. A very slim and portable power supply, all you need is a PD charger and a cable!

How to use it

Plug it in

Plug a USB PD charger into the POWER port. The displays show the voltage, current and power going out, and the bar shows what the charger offers.

Hook up your load

Use the WIRE WEDGE, banana plugs, or the 0.1" headers. Wedge the wire in like below, or just clip a crocodile clip on it. Keep your load's capacitance under 90uF, its printed on the card too.

A crocodile clip on the top bar of the wire wedge and a wire wedged under the bottom bar, pulled along the board
A crocodile clip on top, a wedged wire on the bottom.

Change the voltage or current

Press V/A to choose voltage or current, then FINE + and FINE − for small steps or COARSE + and COARSE − for big ones. The new value blinks until you press APPLY.

Dont want to press APPLY every time? hold it for AUTO APPLY, now every change goes through right away. Hold it again to turn it off.

Pick a mode

MODE picks between AUTO, PDO, PPS, SAVS and EAVS. Tap it and the one you're on blinks, tap again to move to the next one, then press APPLY (or just wait 5 seconds). AUTO stays lit dimly while its on.

If the new mode cant do your voltage, the card goes to the next one down. If it has nothing lower, it goes up to the lowest one it has: your old voltage flashes fast as a warning, and the load turns off before it changes. Want to go up with the load still on? Pick the higher voltage in AUTO.

Hold MODE to turn EPR on or off, that's where 28V and up live.

Turn the output on

LOAD ON/OFF turns your output on and off, and LOAD EN lights up when its on. If LOAD EN blinks, the output cant turn on yet, or the change you're making will turn it off when you apply it.

Lock the buttons

Hold V/A for a second so nothing changes accidentally, and hold it again to unlock. LOAD ON/OFF still works while its locked.

Change the brightness

Hold COARSE − and MODE for 5 seconds. FINE + FINE − COARSE + COARSE − change it and APPLY saves it. The slow blinking dot is the default. Needs firmware v1.1, you can also set it from the console.

What the lights mean

THERM LIM lights up, TEMP WARN blinks, and the card dims its display to keep LDO thermal dissipation in check starting above 21V on the input. The LDO gets warm to the touch but not uncomfortable, still, it is better not to touch it when that light is blinking.

PPS CV and PPS CL glow dimly whenever you're on PPS. The bright one shows if the charger is holding your voltage (CV) or limiting your current (CL). Some chargers dont report this correctly, and some only do CL at certain currents.

If WARNING blinks, its spelling a letter in Morse code. If theres more than one, they take turns:

  • Rthe charger said no, or it said yes but never gave the voltage (the card tries a few times first).
  • Syour settings couldnt be saved.
  • Tthe power dipped. If that turned your load off, it keeps going until you turn it back on.
  • Fthe card lost power a few times while restoring your last setting, so it started with a safer one. Press APPLY to try again.
  • IDue to Inrush, the output didnt turn on (big capacitors and loads might cause this). The card dropped the voltage to aid the charge pump, then raised it back up. Added in firmware v1.2.

Chargers are all different

Not every charger offers every mode, and some just dont play nice with it. If something doesnt work or acts weird, tell you what, try another cable first - then another charger.

Only seeing 5V?

Then you arent using a full PD power supply, so thats all the card can get. Use a USB PD charger or powerbank thats atleast 20W, laptop chargers are usually the best ones.

Want 22V and up?

You'll need an EPR charger (these are usually 140W per port or more) and a 240W rated USB-C cable.

The console

Connect

The card has a second USB port, DATA, and it only carries data. Keep your charger in POWER, plug DATA into your computer, then open anasmalas.com/bcv2/console in Chrome or Edge and press Connect. It works in Chrome on Android too.

What it does

You can see everything your charger offers in detail, request exact voltages, and watch live graphs of voltage, current and power. It also tells you if theres newer firmware for your card and how to update it.

If your card restarts on its own, the console reads its black box when it reconnects. Thats a small log of what went wrong.

Bug reports

Bug reports are on by default. When something goes wrong, like the card restarting, the charger saying yes but not giving you the voltage, or the console itself breaking, I get the black box and the log so I can look into it and fix it in the next firmware. It really helps!

Dont want that? Hit "Turn off" on the little notice at the top, or untick "Share anonymous bug reports" any time.

You can also press "Report a bug" any time and tell me what happened. Or save the report and send it to the email on the card, scan the QR code on the card to add me to your phone contacts quickly :) Emailing it isnt anonymous of course, but the report still has your card's ID removed.

Updating the firmware

Head to anasmalas.com/bcv2/update, it shows you the easiest way for whatever you're on. On a Mac or an Android phone it updates right in the browser, nothing to install. The console tells you when theres a new one.

To get an email for new firmware, watch the BCv2 releases on GitHub (Watch > Custom > Releases), or use the feed. Whats new.

Bug reports and your data

What gets sent

Only when something goes wrong, or when you send a report yourself. Turn bug reports off and nothing gets sent unless you hit Send.

A report has the firmware version, your browser and system (like Chrome 140 on Windows), what your charger offers, the last minute of voltage and current readings, the console log, the black box, any errors from the console itself, and whatever you wrote.

Reports go to this site (anasmalas.com, which runs on Cloudflare) and get deleted after 180 days.

What doesnt

Your card's ID is removed before anything is sent, and your IP address isnt stored. No cookies either, your browser just remembers if you turned reports off. Please note that I'll use an LLM to process this data, so please dont write anything youre not willing to share with it. The only other thing the console asks this site for is the latest firmware version.

Firmware updates

To get an email for new firmware, watch the BCv2 releases on GitHub (Watch > Custom > Releases), or use the feed.

Have fun with it, and tag me when you make use of it for something cool! :)