element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Logic Level Shifters for GPIO
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 16 replies
  • Subscribers 676 subscribers
  • Views 4228 views
  • Users 0 members are here
  • gpio
  • raspberry_pi
  • raspberry pi
  • levelshifter
  • arduino
Related

Logic Level Shifters for GPIO

muthukmk
muthukmk over 8 years ago

Hi,

 

I have accumulated drivers and sensors for Arduino over a period of time. IR proximity, ultrasonic sensor , 4-channel relay module, handful of L293N motor driver modules, A4988 stepper sticks and corresponding CNC shield etc.

 

I have been successful in using them with Arduino (Mega and UNO). I have taken enough care in using those items which are power-hungry to be supplied with separate power sources and that approach worked well in Arduino context (eg. always power motors separately). Now, I want to use above sensors and actuators with Raspberry Pi 3 model B which I recently purchased. Now I need to find a proper way of dealing with logic-level related issues when I connect to RPi GPIO.

 

I have some doubts after going through experiences on Google on various Instructables / DIY projects if its good to use level shifters particularly while interfacing above components with RPi GPIO.

Many articles/discussions what I have read on internet seem to indicate that it should be ok to use them directly with RPi GPIO. But I wanted to confirm with those who would had been in similar situation. There may be more costly options (eg. a common adapter which lets such interfacing seamlessly possible without additional components )  which I want to avoid.

 

So, specific questions

a) Is it imperative to use logic level shifters to deal with 3.3v and 5v differences always for input as well as output ?

b) Or its more of experimenting and finding what works best for each of standard modules like relay / motor drivers / ultrasonic sensors / PIR sensors etc?

 

If I have missed any specific points to be added to the question, please let me know so that I can add the same

 

Regards

 

Muthu

  • Sign in to reply
  • Cancel
  • rew
    rew over 8 years ago

    For signals going into the raspberry pi, if the signal is really 5V then it is best to use some sort of level shifter. It depends a bit on how fast your signal is going to be changing on what approach is necessary. The simplest is to just put a big resistor in series with the signal. When the signal drives "5V" and the pi has an internal diode to 3.3V on the signal, a 100k resistor will allow a current of max 17 micro amps to flow into the raspberry pi gpio. Some manufaturers specify an allowed current of 10mA, staying below 1mA should be safe. The downside here is that capacitance on the GPIO pin might cause slower response on the raspberry pi side.

     

    Slightly more complex: I use a 1k resistor, together with a scottky diode to 3.3V. This allows quite quick signal changes and keeps the current into the broadcom CPU to a minimum.

     

    Even more complex would be to have a special level shifter chip and configure that for 5V on one side and 3.3 on the other.

     

    For signals going the other direction, a raspberry pi output going into some other chip, you again have several options. Do nothing is one. Many older chips are TTL compatible. They have a threshold voltage that is compatible with the 3.3V signal levels of the raspberry. (Threshold is: below this voltage a 0, or low will be seen, above that high, or one. )

     

    The L293 is an example, it will detect "high" above 2.3V, where the raspberry can deliver 3.3V, officially minus 10% or 3.0V without any issue.

     

    Modern chips will be 3.3V of themselves. The trickiest are the medium-old chips. (An example is: the AVR that is on your arduino).  Those are 5V CMOS. In practise they switch above VCC/2, or at 2.5V. But the manufacturers take some margin and specify "between 0.3VCC and 0.7VCC". This calculates as: The switch will happen between 1.5V and 3.5V. If you drive it with 3.3V, you are still not guaranteed to be detected as a "1" or "high". In practice, this almost never happens. For hobby projects, it is acceptable to hook it up and "see if it works". But not acceptable if you're designing the next-generation space shuttle...

    • Cancel
    • Vote Up +6 Vote Down
    • Sign in to reply
    • Cancel
  • DAB
    DAB over 8 years ago

    The easiest way to do level shifting is to use a PSOC 4000 board (about 5 USD) as an interface to the RPi GPIO.

     

    The PSOC provides you with all kinds of easy level shifting for IO and provides a wealth of programmable Digital and IO blocks to simplify control and sampling.

     

    Take a look.

     

    DAB

    • Cancel
    • Vote Up +5 Vote Down
    • Sign in to reply
    • Cancel
  • ntewinkel
    ntewinkel over 8 years ago in reply to DAB

    Very interesting way to do that, DAB! I would have never thought of that approach.

    It looks to be $4 USD: http://www.cypress.com/documentation/development-kitsboards/psoc-4-cy8ckit-049-4xxx-prototyping-kits

    Not sure what shipping would cost.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • DAB
    DAB over 8 years ago in reply to ntewinkel

    Hi Nico,

     

    Remember the review I did a few years back.

    I called them "Engineers Magic Wands" for a reason.

     

    These simple little boards can handle an amazing range of  interfacing tasks both digital and analog.

     

    If you do not have any, buy some.  They are just so versatile.

     

    DAB

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • ntewinkel
    ntewinkel over 8 years ago

    eBay has a lot of inexpensive options available - a quick search for "logic level converter" or "logic level shifter" shows plenty of tiny boards with 4 or 8 channels for only $1 USD (free shipping too)... but you need patience, as shipping usually takes the scenic route!

     

    -Nico

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Cancel
  • muthukmk
    muthukmk over 8 years ago

    Thank you Roger, DAB and Nico. I get a perspective of options available. I have some level shifters which Nico pointed out. I will spend some time exploring these options and post my observations.

     

    Regards

    Muthu

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • koudelad
    koudelad over 8 years ago in reply to DAB

    Hello @DAB,

     

    Just out of curiosity, could you, please, be a bit more specific about using the PSoC?

     

    I can imagine, it is perfect for performing a sensor hub in this case. It can even perform some real-time applications that the Raspberry Pi can't. The data from the PSoC can be sent to Pi upon request from the Pi. However, how to do the level shifting? The PSoC would have to be running at 3.3 V to comply with the Pi. How to interface the sensors that run at 5 V? Is it possible to do the level shifting internally?

    According to the datasheet, maximum voltage at GPIO is -0.5 V to Vdd + 0.5 V and the maximum GPIO injection current for input voltage higherer that Vddd (or lower that Vss) is -0.5 to 0.5 mA.

     

    Thanks, David

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • rew
    rew over 8 years ago in reply to koudelad

    I stepped away from the PSOC devices.

    Cypress promised me configurable analog circuitry. Sounds interesting... So I bought a device....

     

    * Bootloader support means that you can buy a $90 programmer, write your own bootloader and put that in the device.

    * Analog configurability is only avialable on the 40xx devices with xx > 20, while I had bought the 00 or 10. The analog configurability was advertized as "for the 4xxx series".

    * analog configurability means not much more than that you can select which input pin goes to the ADC. A standard feature on all microcontrollers. Nothing special.

    * They promised to send me a 4020 stick when it became available, but didn't.

     

    So... the development sticks are really cheap, but not as useful as the nucleo boards from ST. Those have the programmer on board, and "bootloader" means you can actually program an otherwise empty chip.

     

    For someone getting into electronics, using an embedded processor to do level shifting is a bit too difficult to make it easy. For others who have the hardware and lots of experience in working with the chip, it'll be a 5 minute job, but not when you're new.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • koudelad
    koudelad over 8 years ago in reply to rew

    You made some good points, although my experience is better.

     

    I tried to list the new "USB stick" kits here: https://www.element14.com/community/docs/DOC-54414/l/cypress-linecard#comment-103831

     

    The cheapest kits don't have a dedicated programmer, but cost about $ 4 / € 4 (excluding VAT). I got one of the kits with a 42xx device on Embedded World exhibition a few years ago. I use this kit quite often and the only inconvenience is the bootloader. On the other hand, no other programmer is required (I programmed it hundreds of times), the device comes pre-programmed with the bootloader. There is basically no analog configurability, just the ADC.

     

    Cypress heard the community and the newer versions of these kits with PSoC 4 M / S / L devices feature a KitProg programmer (that can be snapped away and used separately) and cost about $ 10.

     

    I think you might like the PSoC Analog Coprocessor or PSoC 5 LP devices, which feature the analog parts you were missing: programmable op-amps, comparators, ADCs, DAC, analog multiplexer, filter block.

     

    I am just an amateur who previously programmed 8-bit PICs, but I have to say, there are a few things that the competition can't offer. On the other hand, my lack of digital and especially analog circuitry design is what prevents me from using the full potential of these devices. (Huge downside of not being an EE.) That is why I asked, whether there is some obvious way to do this level shifting using a PSoC, to learn something new image However, using a level shifter with one the TLE291 etc. is the simplest way to go.

     

    EDIT: Crossed out "USB stick" like 4200 L kit, the only available is CY8CKIT-046 PSoCRegistered 4 L-Series Pioneer Kit.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • johnbeetem
    johnbeetem over 8 years ago in reply to koudelad

    David Koudela wrote:

     

    Cypress heard the community and the newer versions of these kits with PSoC 4 M / S / L devices feature a KitProg programmer (that can be snapped away and used separately) and cost about $ 10.

    As far as I know, Cypress doesn't have a cheap "prototyping board" for the PSoC 4200L.  You have to get a PSoC 4200L Pioneer board for around US$50.  I like the 4200L specs, especially since it has USB and more programmable logic than the 4200.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube