Electronic – Understanding 5V to 1.8V UART level-shifting circuit

amperagelevel-shiftingresistorsschematicsvoltage

Hopefully it's OK to ask very basic electronics questions here.

I had a TTL 5V UART cable, however the board I had only accepts 1.8V max. So I found some online schematics that uses resistors and a transistor, and I built it on a breadboard. It actually worked.

I just want to understand how it worked deeply. Why did it work?

Also, how do you properly calculate the EXACT values of resistors to drop the 5V input to 1.8V? What's the formula for that?

Sorry for electronics 101 question, but please ELI5 the answer. Thanks.

schematic diagram

Best Answer

There's two parts to this. On the TTL to Odroid section (pins 3 & 4 of both connectors), R2 & R3 form a simple voltage divider (you can web search "voltage divider" for lots of information, so I'm not going to go into any depth here). It works because the TTL output is either 0V or 5V, and because the Odroid input doesn't need any real drive.

On the Odroid to TTL section, they've implemented a transistorized amplifier. Bear with me, because it's complicated.

Pin 1 on the Odroid side is the Odroid's 1.8V power supply. It's connected to the base of the transistor. Pin 2 on the Odroid side is the Odroid's output and is connected to the transistor's emitter. The transistor collector is pulled up to 5V by a R1, and is connected to the UART receive.

When pin 2 on the Odroid side is at 1.8V, both the base and emitter are at 1.8V: there is no voltage difference between them. Because there is no voltage difference, no current flows. Because no current flows, R1 can cleanly pull the transmit line to the 5V UART up to 5V (basically, the circuit acts like the transistor isn't there, so R1 is free to pull the voltage high).

When pin 2 on the Odroid side is low, it's a different story. The emitter is pulled down to ground. That pulls the base of the transistor down to 0.6V or so (or 0.7V). That makes about 1.2mA flow in the base ((1.8V - 0.6V) / 1k\$\Omega\$). The transistor conducts current from collector to emitter. It's trying to conduct about 120mA (because transistors have current gain), but it can't pull the collector much lower than about 0.2V above the emitter (this is called "saturation"). Since the emitter is at ground, the collector (and the line to the UART) will sit at about 0.2V. That's not right at 0V, but it's plenty low enough that it'll be seen as a zero by the UART.

The transistor circuit is what's known as a "common base" circuit, if you want to search on it. It's used here rather than the more often used common emitter circuit because a common base circuit does not invert the voltages that it amplifies (a common emitter circuit would, and that would screw up communications).

So that's it. A simple (to slightly experienced hands) resistive voltage divider, and a simple (to somewhat more experienced hands) common-base amplifier.