Designing a logic level converter

Introduction

Communication between devices with different operating voltages is a common scenario within DYI projects. This article explains how to build a simple 4-channel, bidirectional, logic converter for 5V and 3.3V devices.

Table 1: Components used
Component Quantity Link
Mosfet transistor – BSS138 4 Datasheet
Resistor – 10 KΩ 8
This is what we will be constructing:
Figure 1: The finished circuit

Note!

– Logic converters are important! Attempting to connect devices operating at different voltages could permanently damage sensitive components!

– All examples and circuits in this article use SMD components. A DIP version of this circuit is easy to construct yourself. The theory is independent of package type

How it works

Lets begin with the key component: the Mosfet(metal oxide semiconductor field effect transistor). Unlike ordinary transistors the mosfet regulates current flow by voltage difference. It has three external pins: source(S), drain(D) and gate(G).

A mosfet consists of P-substrate and N-substrate regions. N-channel mosfets have N-doped S and D regions. Applying a voltage difference, Vgs, exceeding the voltage threshold characteristics of the mosfet, will connect S with D by saturating the P-substrate. Se figure 3.

Figure 2: Mosfet N-channel symbol
Figure 3: S and D are 0V, the voltage threshold, V_th is specified in the datasheet of the mosfet

Converting levels using the mosfet

A channel on the circuit consists of one mosfet and two pull up resistors(10KΩ). The resistors set the default state between two devices to HIGH and communication occurs when one of the devices pulls the voltage of S to GND. Hence the actual communication consist of sending GND signals, solving the problem with different operating voltages.

The GND of the two devices need to be connected to a common GND. Make sure that the power for the two devices come from isolated floating power supplies!

Consider an example where two devices, a wifi-module operating at 3.3V and an arduino operating at 5V, need to communicate. The mosfet is hooked up to the devices as shown in the figure 4. The Wifi-module’s signal is connected to S and pulled to 3.3V as default state. The arduino is connected to D and is pulled to 5V as default state. The mosfet is not saturated since the voltage at G and S are the same(3.3V), hence there is no connection between S and D.

Figure 4: Example – Mosfet connected to Wifi-module and Arduino. NP = Not pulled
Figure 5. Wifi-module pulls signal low

When the wifi-module wants to communicate with the arduino it simply pulls its signal to GND. This will cause the voltage difference between G and S to exceed the threshold of the mosfet, creating a n-channel between the source and drain. The arduino will now read LOW. Se figure 5.

Communicating from the arduino to the wifi-module is similar, but utilizes the mosfet’s built in diode. The reason is that Vgs is not affected by changing the voltage of D. The diode between S and D solves this problem.

Current only flows through the diode if the voltage of S is greater than D. The orientation of the diode in figure 5 will cause S(3.3V) to be pulled LOW when the arduino pulls to GND, since current will flow from S to D. When S is pulled the mosfet will create the N-channel and both the arduino and wifi-module will read LOW, see figure 6.

Figure 6: Communicating from arduino

PCB design and construction

The PCB contains four channels hence 4 mosfets (Q1 – Q4) and 8 pull up 10K resistors(R1 – R8), see figure 7.

Figure 7: The PCB layout

– Many different types of mosfets can be used for this circuit. Just make sure that the Vgs threshold characteristic of the mosfet is below 1.7V

An etch for SMD components is available for download below.

Download etch_top.pdf

Download etch_top_mirror.pdf

The fritzing file for the original etch is available here:

Download logicv3.fzz

Finally feel free to leave a comment or question below