Start with a cable that’s cut at one end, terminated in either a Type-A socket (half of a USB extension cable) or a Micro-B plug at the other end. If you used the Type-A socket, you’ll be plugging in a normal Type-A to Micro-B Connector when it’s time to charge. Connect the red wire (Vbus) to the positive terminal of the bench supply, connect the black wire (GND) to the negative terminal of the bench supply (not the GND terminal, if it has one, as that’s usually chassis ground, not necessarily the same thing as negative).
Also read: history of what we call “charger”
If your bench supply can output at least 1.5A, tie the white (D+) and green (D-) wires to either end of a small resistor, something in the 33–200 ohm range will be fine. This is the bus condition a USB device uses to detect Battery Charging mode. That specification delivers a minimum of 1.5A at 5Vdc, though a few devices can pull more. Going to a higher current potential will not harm your phone, even if it can’t draw higher current levels.
Real USB power dongles also have a current switch that cuts off to protect the device — and you from unwanted electrical fires — if the current goes over the expected level, usually the result of a short circuit. Bench supplies have built-in overcurrent protection, so there’s little risk here.
Next, set your voltage to +5.0V and your current limiter to 2A or less. You are ready to connect your phone. And this illustrates the fact that those things everyone calls “charger” are really just power supplies. The charger is in your phone.
Extracted from quora>>