Web Banner

Logic Level Converters

In digital electronics a signal can be either high (ON) or low (OFF). This is indicated by a high or low voltage. Many years ago (when I started) the digital systems were all 5 volts and a high signal was anything greater than 2v and a low was lower than 0.8v

Over time, lower digital systems have been introduced (3v3, 2v5, 1v8) . These lower voltage systems require less power, this both reduces the heat produced and allows a physically smaller gate geometry. This may not seem usful, but when you have millions of logic gates in a single IC package the heat and size are a big problem.

What do you do, if you need to communicate between two different logic voltage systems?

The solution

The connection of systems with different logic levels is is a very common problem. A logic level converter is simple circuit to solve this problem. The logic level converter circuit allows bi-directionl data transfer between two different logic levels (ie. 5v to 3v3). The are several Logic Level Converter modules available on-line, an example can be seen below. They typically contain multiple level converters, since the normal use case for these is to connect communication lines together such as SPI, I2C or Serial. These all require multiple data line and each line requries it's own level converter.

When the module is connected between an I2C interface with 3v3 on the low voltage side and 5v on the high voltage side, the clock (SLK) signal can be seen below. The slope on rising edge of the 3v3 signal, is not a problem It's just because I am limited with available power on my 3v3 implementation.

Circuit Diagram

An n-channel MOSFET can easily be used to make a logic level converter. The schematic below shows the basic implementation. The only real concern, is the exact choic of MOSFET to deal with the volages and the switching speed. Most of the situation a hobist will encounter will only require a simple MOSFET, such as a IRF540N. This should work to convert between 3v3 and 5v logic systems. A BSS138 E-MOSFET (which is the one on the module above) will work down to 1v6. Datasheets for these modules can be found below.

NOTE: Just make sure to keep the lower voltage on the LV side and the higher voltage on the HV side.

When getting into electronics, it can be very confusing. When you first look at a datasheet, there are hundreds of parameters even when you are looking at a single MOSFET.

Please don't let that put you off, all of these parameters are important but you can ignor alot of them when getting started and copying is a great starting point. Most of the modules you can buy you can get the datasheet for that part. Just look in the datasheet for 'Typicl Circuit' or somthing similar and you will see the module that you just purchased has just copied the example circuit from the datasheet.

Download

BSS138

The BSS138 datasheet.

Zip file containing source code

IRN540N

The IRF540N datasheet.

Zip file containing source code

Note: There are other manufacturers of these components, I have just included these datasheets for your reference.