© 2020 EasyEDA Some rights reserved
Profile:Simple USB-C Power Delivery Tester with OLED Display
Open source license: CC-BY-SA 3.0
Simple USB-C Power Delivery Tester based on ATtiny25/45/85 and INA219. The device measures voltage, current, power, energy, capacity and displays the values on an OLED screen. You can switch between different screens by pressing the SET button.
The device is equipped with a USB-C receptacle (PCB version a) or plug (PCB version b) for the input and a USB-C receptacle for the output, so that it can be plugged between the power supply and the consumer. CC1 and CC2 communication channels are passed through so that supply and consumer can negotiate the bus power.
An INA219 is used to measure voltage and current. 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 8 milliohms enables both a very small influence on the circuit and a measurement with a resolution of 1 milliampere. For an accurate measurement, a shunt resistor with a low tolerance (1% or better) should be selected.
The user interface utilizes two buttons and a 128x64 pixels OLED display. An ATtiny24/45/85 microcontroller handles the user interface as well as the calculation and display of the values.
The INA219 continuously measures current and voltage and transmits the values to the ATtiny via I²C. From this, the ATtiny calculates the other values and displays them on the OLED screen.
The I²C protocol implementation is based on a crude bitbanging method. It was specifically designed for the limited resources of ATtiny10 and ATtiny13, but it works with some other AVRs (including the ATtiny25/45/85) as well. The functions for the OLED are adapted to the SSD1306 OLED module, but they can easily be modified to be used for other modules. In order to save resources, only the basic functionalities which are needed for this application are implemented. For a detailed information on the working principle of the I²C OLED implementation visit TinyOLEDdemo.
The internal oscillator of the ATtiny is used to determine energy and capacity. The accuracy of the internal oscillator is +/-10% with the factory calibration. This can be improved to +/-2% or better by manual calibration. The calibration value determined in this way can be set in the source code.
Since there is no ICSP header on the board, you have to program the ATtiny either before soldering using an SOP adapter, or after soldering using an EEPROM clip. The AVR Programmer Adapter can help with this.
avrdude -c usbasp -p t85 -U lfuse:w:0xe2:m -U hfuse:w:0xd5:m -U efuse:w:0xff:m -U flash:w:usb_c_tester.hex
Parameter | Value |
---|---|
Voltage | 5V - 20V |
Current | max 5A |
Voltage Measurement Resolution | 4mV |
Current Measurement Resolution | 1mA |
This work is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License. (http://creativecommons.org/licenses/by-sa/3.0/)
USB-C Tester
Open in editorUSB-C_Tester_v1.0a
Open in editorUSB-C_Tester_v1.0b
Open in editorID | Name | Designator | Footprint | Quantity |
---|---|---|---|---|
1 | 47u | C2 | 1206 | 1 |
2 | 100n | C1,C3,C5 | 0603 | 3 |
3 | 1u | C4 | 0603 | 1 |
4 | OLED 0.91 | OLED | I2C OLED 0.91 | 1 |
5 | R008 | R2 | 2512 | 1 |
6 | 10k | R1,R3,R4 | 0603 | 3 |
7 | TS24CA | RESET,SET | SW-SMD_TS24CA | 2 |
8 | ATtiny85 | U1 | SOIC-8_208MIL | 1 |
9 | INA219 | U2 | SOT-23-8 | 1 |
10 | 78L05 | U3 | SOT-89-3_L4.5-W2.5-P1.50-LS4.2-BR | 1 |
11 | USB-C Plug | USB1 | USB-C-SMD_PLUG | 1 |
12 | USB-TYPE-C-6PIN | USB2,USB3 | USB-C-SMD-6P | 2 |
Unfold