UART 5V -> 3V Converter

Go To Last Post
18 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My MCU is 5V VCC, another device is 3V, both communicate using UART. From the device (3V) to MCU, I can direct connect, no problem.

From the MCU (5V) to the device (3V) via UART, I cant direct connect coz the device is not 5V tolerant.

The UART speed is 9600 bps.

So, what is the simplest and reliable way to drop 5V to 3V?

Can I use 2 diodes in series (5-1.4= 3.7V)?
Or use voltage divider?
Or use a 3V voltage regulator?

Which is the best approach in term of reliability?

cs

I'm happy ytd, today, and tmr :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you have to both transmit and receive you need to step down (5v -> 3v) and step up (3v -> 5v).

The diode approach will work to step down but I don't like depending on diode Vf for voltage drops because they are not consistent. A diode will not solve the step up problem.

A resistor divider will work but only if the resistors are small enough so the receiver(s) do not load the divider down. Depending on the receiver input impedances the resistors may need to be quite small which will waste power.

Not sure how a 3v regulator would work. Surely not for the step up.

I would go with NPN transistors – one for transmit and one for receive. Tie the collectors to +5v and +3v through resistors and drive the bases through resistors. If both devices are on the same PCB you already have the +5v and +3v supplies available. If not you will need to add the missing regulator. This approach guarantees nearly rail-to-rail voltages and fast switching, low noise signals.

If you need RST and CTS do the same for them.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do I have to step up? 3V is considered high for MCU (TTL)

cs

I'm happy ytd, today, and tmr :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Tx of MCU, can I use this method to reduce the voltage?

The start bit is logic low right? 

                  3V3
                   |
                   R 10k
                   |
                   |
5V MCU Tx-----<|--------Rx(3V device)
              1N5817
 

So, the Rx (3V device) will always high until the MCU Tx pin pull it down to GND, to start transmitting (Start Bit is low).

When the MCU Tx pin is high, the diode blocks.

Is this method working or reliable enough?

For the MCU Rx, I just direct connect to Tx of 3V decive, is that ok?

5V MCU RX -----------------Tx 3V device

cs

I'm happy ytd, today, and tmr :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

+5v                                    +3V
 |                            --------  R 1K
 R 220----------------------1| 4N25   |-+------ Rxd
 TxD------------------------2|        | gnd
                             ----------
 

A pair of inexpensive opto-isolators could be used. One advantage of this approach is that the ground would not have to be connected between the two UARTS.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I would go with NPN transistors – one for transmit and one for receive.

Aero1,

Wouldn't two transistors be required, if using only NPNs? The first one would invert the signal, the second one would re-invert the signal and step it up to +5V.

I would use a resistor divider for the step down.

JC

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why do we need to step up? According to Atmega datasheet, (atmega644P in particular), 3V is considered high. So, why we still need step up? Confused...

cs

I'm happy ytd, today, and tmr :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:


+5v                                    +3V
 |                            --------  R 1K
 R 220----------------------1| 4N25   |-+------ Rxd
 TxD------------------------2|        | gnd
                             ----------
 

A pair of inexpensive opto-isolators could be used. One advantage of this approach is that the ground would not have to be connected between the two UARTS.

Looks like a good option but can an atmega MCU drive the 4n25 directly? Or need a bjt to drive it?

cs

I'm happy ytd, today, and tmr :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
Quote:
I would go with NPN transistors – one for transmit and one for receive.

Aero1,

Wouldn't two transistors be required, if using only NPNs? The first one would invert the signal, the second one would re-invert the signal and step it up to +5V.

I would use a resistor divider for the step down.

JC

Hi Doc, can you give me the resistor divider cct for step down? Thanks

cs

I'm happy ytd, today, and tmr :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At 9600 baud this will be fine.
You need to look up resistive dividers and Ohm's Law.

Hope this helps get you back on track with the rest of your project.

JC

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JC, you win my nice guy award of the day!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
At 9600 baud this will be fine.
You need to look up resistive dividers and Ohm's Law.

Hope this helps get you back on track with the rest of your project.

JC

Thanks a lot JC.

cs

I'm happy ytd, today, and tmr :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey:

What about this circuit. I've used it successfully in the past for UART communications (is the classical level translator, spreaded in the internet)

Hope it help you
Nachus

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nachus001 wrote:
Hey:

What about this circuit. I've used it successfully in the past for UART communications (is the classical level translator, spreaded in the internet)

Hope it help you
Nachus

Hi Nachus,

Cool cct. Can you give the value of R1 and R2?

Also, do I need to step up for UART Tx (3V) -> UART Rx (5V)?

cs

I'm happy ytd, today, and tmr :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

(Can the AVR drive a 4n25 opto-isolator's LED?)

Yes, I do it all the time. This circuit is the foundation of a MIDI interface. The AVR output port is sinking (5V-1.4V)/(2*220_ohms) milliAmps of current in short bursts, which is roughly about 8 milliAmps. In the circuit shown, the R would probably be raised to 470 ohms. It would work fine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

chanseng738 wrote:

Hi Nachus,

Cool cct. Can you give the value of R1 and R2?

Also, do I need to step up for UART Tx (3V) -> UART Rx (5V)?

Hi chan:

10K is fine, maybe a bit less depending on the transistor.

Now for the comunication between a 3V "output" device and a 5V "input" device Look for what the manufacturer of the 5V device says about the logic levels VIH and VIL. Usually, you're going to need a translator, at least that your 5V device had an "HCT" like input level ("2V minimum for VIH)

for translation from 5 to 3V is easier to use a diode and resistor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
(Can the AVR drive a 4n25 opto-isolator's LED?)

Yes, I do it all the time. This circuit is the foundation of a MIDI interface. The AVR output port is sinking (5V-1.4V)/(2*220_ohms) milliAmps of current in short bursts, which is roughly about 8 milliAmps. In the circuit shown, the R would probably be raised to 470 ohms. It would work fine.

Could you explain why it is 2*220 ohms? Not 1*220 ohms?

In the diagram, you only use 1 resistor (on the 5V side), which is 220 Ohms.

cs

I'm happy ytd, today, and tmr :)