Public post

# 0.4 Logic level shifting with a microcontroller

· 0. PROTOTYPING BASICS

Arduino boards and other components operate on a range of different voltages. Many microcontrollers work with 5V. However, recently, new controllers have come into the market that operates at 3.3V while many components run on 3.3V. Sometimes you will need to convert the output of one device, 5V, to match the input voltage (3.3v). Matching the input is called level shifting. There are a couple of ways to achieve this.

## Level Shifting with a Voltage Divider

You know from an earlier tutorial that two resistors in a series can form a voltage divider. This is one way to reduce the voltage of a circuit. You will need to calculate the ratio of the resistor’s base on the ratio of the input voltage to the output voltage.

The tricky and challenging part of this is to have the exact right transistors for the job. Furthermore, resistors can slow down a high-speed signal.

You can see more about the voltage divider at:

http://www.ohmslawcalculator.com/voltage-divider-calculator

In the image above

Vout = Vin * R2 / (R1 + R2).

If the resistors are equal, Vout = Vin/2.

If R2 = 2*R1, then Vout = Vin*2/3.

A voltage divider might seem like an excellent solution to step down a 12V power supply to a 5V supply. However, voltage dividers should not be used to supply power to a load.

The first reason is power dissipation. Any current that the load is requiring will have to run through R1. The current and voltage across R1, produce power, which dissipates in the form of heat. If that power exceeds the resistor’s rating (usually a resistor is capable of 1Watt max), the heat becomes a problem. It can potentially meld down the resistor.

## Voltage regulator

A voltage regulator converts unregulated voltage to a stable voltage that won’t change even if the input changes.

Voltage regulator “drop out” voltage: voltage regulators dropout voltage. This is when the input voltage, which will be regulated, is too low to keep a stable output voltage. Most voltage regulators have a dropout voltage of around 2V. This means that the input voltage should be at least 7V to get a stable 5V output of a standard LM7805 voltage regulator.

Voltage regulators generate a lot of heat: the higher the voltage input, the more heat a voltage regulator will create. Sometimes you will need a heatsink for that.

A tip: If you want to have a voltage regulator besides the Arduino Board. You could also look at step-down converters. These are voltage regulators that are pre-build.

The regulator in the figure will supply a 5V voltage from the output. Input 1 connects to the power source as well as the GND 2. Output 3 and GND 2 will generate a regulated 5V voltage that connects to a breadboard power row.

## Logic Level Converter

The preferred method for logic level shifting is to use a Level Shifter IC. These are components that contain the circuitry to shift from one level to another automatically. They are the most reliable and convenient solution if your circuitry needs to use a level shifter.

Most of the logic level chips come in 4-channel or 8-channel models. It means that you can shift 4 or 8 wires.

Most of the logic level shifter modules will be Bi-Directional. This means that the shifting is down on either side. In other words, the converter can pass data from HIGH to LOW and LOW to HIGH on all the channels.

Let’s look at a logic level shifting module and a simple hook-up.

## Bi-directional logical level shifter

The SparkFun bi-directional logical level shifter has two voltage input pins. The pins labeled HV, LV, and two GND‘s provide high and low voltage references to the board. Supplying a steady, regulated voltage to both of these inputs is required. There are four separate data channels on the BD-LLC, each capable of shifting data to high and low voltages. These pins are labeled HV1, LV1, HV2, LV2, HV3, LV3, HV4, and LV4. The number at the end of each label designates the pin’s channel, and the HV or LV prefix determines whether it’s on a high or low side of the channel.

A low-voltage signal sent in to LV1, for example, will be shifted up to the higher voltage and sent out HV1. Something sent in HV3 will be shifted down and sent out of LV3. Use as many of these channels as your project requires. You don’t have to use every single one.

The figure below shows the connection between a 3.3V module (RFID Reader) and the Arduino supplying 5V. Of course, you could use the 3.3V output of the Arduino Board, but for learning purposes, a level shifter is used. Both devices are connected to the level shifter ground. This is very important to do, grounds should be connected between the devices. If you are using a level shifter board, be sure to check which side is for the HIGH voltage and which side is for the LOW voltage.

## Become a member

You just read a free post but there are 2 member-only posts that you don't currently have access to.

Subscribe for \$14.99 monthly or \$99.99 yearly.