wagiminator / ATtiny814-USB-PD-Adapter

USB Type-C Power Delivery Trigger and Monitoring Board
https://oshwlab.com/wagiminator/attiny814-usb-pd-adapter
Other
71 stars 9 forks source link
attiny attiny1604 attiny1614 attiny204 attiny214 attiny404 attiny804 attiny814 atttiny414 avr ch224k ina219 oled power-delivery tinyavr usb-pd

USB PD Adapter

The USB PD Adapter is a USB Power Delivery trigger and monitoring board that enables you to use almost any USB Type-C PD power supply to run your projects with different selectable voltages and high currents. Important values such as voltage, current, power and energy are displayed on the OLED. The USB PD Adapter is based on the cheap and easy-to-use CH224K multi fast charging protocol power receiving chip, the INA219 voltage and current sensor IC, and an ATtiny204, 214, 404, 414, 804, 814, 1604 or 1614 microcontroller.

pic1.jpg

Hardware

Schematic

wiring.png

78L33 Voltage Regulator

The 78L33 is a simple and inexpensive voltage regulator that can convert input voltages up to 30V to an output voltage of 3.3V with an output current of up to 200mA and a dropout voltage of 1.7V. The 78L33 supplies all elements of the circuit with 3.3V.

CH224K USB PD Power Receiving Chip

The CH224K is a USB PD power receiving protocol chip, which integrates PD3.0/2.0, BC1.2 and other fast charging protocols, automatically detects VCONN and analog E-Mark chips, supports up to 100W power, and has built-in PD communication module. It also integrates output voltage detection internally to support overheating and overvoltage protection. It features:

The output voltage is selected via three configuration pins of the CH224K, which are connected directly to the ATtiny and is set according to the following table:

Output Voltage CFG1 CFG2 CFG3
5V 1 - -
9V 0 0 0
12V 0 0 1
15V 0 1 1
20V 0 1 0

The CH224K's PG pin is open-drain, pulling the input to ground when the requested voltage has been successfully negotiated with the USB PD power supply. It can be used to drive an indicator LED or a high-side P-channel MOSFET for power path control. Here this pin is connected directly to the ATtiny, which can query the status with the help of an internal pull-up resistor.

INA219 Current/Power Monitor

The INA219 is a current shunt and power monitor with an I²C-compatible interface. The device monitors both shunt voltage drop and bus supply voltage, with programmable conversion times and filtering. A programmable calibration value, combined with an internal multiplier, enables direct readouts of current in amperes. The selected shunt resistance of 10mΩ enables both a very small influence on the circuit and a measurement with a resolution of 1mA. For an accurate measurement, a shunt resistor with a low tolerance (1% or better) should be selected. The INA219 is used here to measure the output voltage and output current. It communicates with the ATtiny via I²C.

ATtiny Microcontroller

The ATtiny microcontroller handles the user interface, the control of the CH224K and INA219, and the calculation and display of the measured values. The user interface utilizes two buttons and an SSD1306 128x32 pixels OLED display. In this application, the ATtiny runs at only 1MHz to keep power consumption low and thus avoid overheating of the 78L33 voltage regulator, especially at 20V output voltage.

The following microcontrollers can be used: ATtiny204, 214, 404, 414, 804, 814, 1604 or 1614. However, since the firmware in the current version already requires almost 2KB of flash (depending on the compiler settings), the use of an ATtiny202 or ATtiny212 is not recommended, since there are hardly any reserves left for future upgrades.

hardware.png

Compiling and Uploading the Firmware

If using the Arduino IDE

If using the makefile (Linux/Mac)

Operating Instructions

  1. Connect the USB PD Adapter to a USB Type-C PD power supply using a USB-C cable.
  2. Use the SET button to select the desired output voltage. An hourglass appears on the display while the device is communicating with the power supply. If the negotiation was successful, a tick is displayed and the desired voltage is present at the output.
  3. Connect the device to the power consumer via the output screw terminal.
  4. Use the RESET button to clear the energy counter.

operation.png

References, Links and Notes

  1. 78L33 Datasheet
  2. CH224K Datasheet
  3. INA219 Datasheet
  4. ATtiny814 Datasheet
  5. SSD1306 Datasheet
  6. CH224K USB PD Decoy
  7. IP6520 USB PD Source
  8. ATtiny412 USB PD Inverter
  9. TI Primer on USB PD
  10. 128x32 OLED on Aliexpress

pic2.jpg pic3.jpg

License

license.png

This work is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License. (http://creativecommons.org/licenses/by-sa/3.0/)