Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine.

How to make your own logic level Converter

This page is all about logic level converters that allow you to easily change between different logic voltage levels.

You know when you just bought that nice shiny new chip to play with, you get it in the post and only then do you think: What about voltage levels? Then you see that the new chip only works at 3V3 and the only microcontroller you have works at 5V!

Logic Level Converter using resistors

First of all you think that's easy, I'll just use a voltage divider and problem solved. Maybe it is but if your device is an I2C device where you need bidirectional communication on the data line using a divider on the high side won't allow the voltage to go the other way at a reliable level.

For a 4 wire SPI interface there is no bidirectional requirement (data out: SDO, and data in: SDI use separate pins) so you could use the divider method and that requires 3 dividers with a total of 6 resistors (Data in from the lows side driver is usually high enough in a 3V system to signal a logic one to the 5V high side). To go from 5V to 3V needs a resistive divider with 22k and 33k (which drops the output to 3V) (or you can replace the 33k with 39k for a drop of 3V2 (for a 3V3 system).

A 3 wire SPI interface does require a bi-directional data I/O conversion.

There is a clever way to use a MOSFET that relies on the parasitic diode to allow full bidirectional communication with low and high side voltages. The advantage of this is that if your device uses I2C (which is bi-directional) the 5V system can communicate properly with the 3V3 system easily. Or it will also allow the 3 wire SPI interface to operate correctly.

Other considerations that make using an SPI 4 wire interface attractive are that the SPI interface operates typically at 10MHz whereas an I2C interface typically operates at 100kHz or 400kHz (I2C chips may allow faster operation but if anything on the bus goes slow, then they all have to go slow).

Logic Level Converter using MOSFET

This is a super spectacular bit of electronics that also happens to be extremely simple but extremely clever. It lets you easily convert between different voltage level systems using only a simple enhancement mode logic level MOSFET and a couple of 10k resistors.

The actual voltages used can be anything that the MOSFET is specified for - but there will be a voltage drop across the parasitic diode of 0.7V to be accounted for.

MOSFET Level converter diagram

2N7000 pinout

2N7000 pinout

MOSFET level converter circuit

Logic Level Converter Operation

wrt = with respect to.

High side '1'

When the high side outputs a '1' (5V) drain and source are pulled towards the high voltage so the source is high wrt. gate (reverse Vgs voltage) so the MOSFET is off so the low side pullup is active and pulls the low side to 3V3.

High side '0'

When the high side outputs a '0' (0V) the source is pulled low wrt gate, so the gate is higher than the source and the MOSFET is on (Vgs is positive). The MOSFET then conducts the zero through to the low side pulling down the low side.

Low side '1'

When the low side outputs a '1' (3V3) the gate source voltage is zero so the MOSFET is off. The high side pullup is active and pulls the high side to 5V.

Low side '0'

When the low side outputs a '0' (0V) the gate source voltage is 3V3 and the MOSFET is on. The MOSFET then conducts the 0V through to the high side pulling down the high side.

Note it is up to your program to decide when to switch from driving the output connected to the high side to becoming an input. For I2C there are defined time periods for this to happen.

New! Comments

Have your say about what you just read! Leave me a comment in the box below.




Privacy Policy | Contact | About Me

Site Map | Terms of Use



Visit our Facebook Page:

   Click Here



Recent Articles

  1. How to use a DS18B20 (single or multiple on one wire) for temperature measurement using the Arduino Uno.

    How to Easily Use the DS18B20 Maxim One-Wire thermometer with Arduino example code showing external or parasitic power modes.

    Read more

  2. Digital I/O Expansion - How to increase your microcontroller Input and Output pins.

    Digital I/O expansion. Several diferent serial design techniques with different tradeoffs to increase the number of input or output pins in your microcontroller design.

    Read more

  3. How to use the BMP280 Barometric Pressure chip with the Arduino

    How to use the BMP280 for weather pressure measurement or altitude change detection.

    Read more

Sign up for MicroZine
''The'' Microcontroller Newsletter

Enter your first Name and primary email address in the form below:


And receive absolutely FREE a full project for:

"Measuring Analogue Voltages
Without An ADC"

(Using only one pin).

Instant Download:
You Can
Get It Right Now

Warning: This project could be  Removed 
at any time.  

It will  NOT be 
available indefinitely SO
To avoid 
disappointment  get it:

Now



:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.

To get exclusive access Enter your first name Name and primary email address Now in the form above.:



But wait !

There's more...

You'll receive more
free and exclusive reports as well as site information and site product updates


Scroll up to the form above and sign up NOW. Don't forget it's FREE and if you don't like it, you can unsubscribe at any time.

Click Here Now to use the form above to get your Valuable information absolutely free.



Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."

- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com<

"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


Learn Microcontrollers

"Interested in
Microcontrollers?"

Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon

Back to Top