EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: itvend on July 02, 2013, 05:04:59 pm

Title: Raspberry Pi GPIO 3.3V <-> 5V
Post by: itvend on July 02, 2013, 05:04:59 pm
Hello everybody.

So i have atmega32 and raspberry pi and i wish to connect them with SPI. Is it good idea to convert SPI 3.3V signals to 5V for atmega using transistor based buffer like on schematic ( attachment )
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: warrmr on July 02, 2013, 07:09:03 pm
Try something like this http://www.adafruit.com/products/757 (http://www.adafruit.com/products/757) Its similar to your design.
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: itvend on July 02, 2013, 07:16:08 pm
cant buy this module but it was one of ideas , DIP IC would be great, any suggestions ?
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: tld on July 02, 2013, 07:51:38 pm
Any reason you can't use an atmega32L, and run it off of 3.3V as well?
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: itvend on July 02, 2013, 08:10:08 pm
buy new uC , i thought about it. but what about schematic would it work for SPI
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: warrmr on July 02, 2013, 09:09:22 pm
Have a look at one of the TXB0108 chips, its an 8 channel converter, if you look around I'm sure you can get one cheaper with less channels.

Otherwise take a look at the schematics for the spark fun level converter, and modify the schematic so that it is bi-directional on both channels as in this current form only the tx lines are bi-directional.

https://www.sparkfun.com/datasheets/BreakoutBoards/Level-Converter-v10.pdf (https://www.sparkfun.com/datasheets/BreakoutBoards/Level-Converter-v10.pdf)


http://www.adafruit.com/datasheets/txb0108.pdf (http://www.adafruit.com/datasheets/txb0108.pdf)
http://www.adafruit.com/datasheets/txb0108appnote.pdf (http://www.adafruit.com/datasheets/txb0108appnote.pdf)
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: Ziltoid on July 02, 2013, 09:22:44 pm
Maybe you can get around it with a simple Voltage divider from 5 to 3.3V, and check how the other device interprets the 3.3V. If it reads the 3.3V as high you just need some resistors!
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: itvend on July 02, 2013, 09:26:40 pm
That i know and was my plan , but problem is 3.3V to 5V
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: millerb on July 02, 2013, 09:26:52 pm
Is there a compelling reason to be running your microcontroller at 5V? If not, supply with 3.3V and move on. I pretty much treat 5V as legacy these days and would only use level shifters if I needed to talk to a 5V part, which is almost never.
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: Ziltoid on July 02, 2013, 09:58:43 pm
Your Rasp is runnig at 3.3V and the Atmel at 5V right? Check if the Atmel is taking the 3.3V as a Digital High!
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: c4757p on July 02, 2013, 10:20:56 pm
Is there a compelling reason to be running your microcontroller at 5V? If not, supply with 3.3V and move on. I pretty much treat 5V as legacy these days and would only use level shifters if I needed to talk to a 5V part, which is almost never.

This. Why would you run the chip at 5V?
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: itvend on July 02, 2013, 10:52:21 pm
Why? because it run on 5V and 5V is everywhere , now i feel its just simpler to buy 3.3 uC atmega32l for example   :bullshit: :bullshit: :bullshit: :bullshit:
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: Stonent on July 02, 2013, 11:40:21 pm
On this site, the guy turned his Pi into an Atmel programmer, he kept everything at 3.3 powered from the Pi and it worked fine.

http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/ (http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/)

I checked Mouser and filtered by just DIPs, and only the "ATmega32-16PU" is not 3.3 capable, but all other ATmega32 chips are.

So that's the 32A, 32L, 324PA, 324P, 324PV10
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: RoadRunner on July 03, 2013, 12:11:25 am
may be these chips are helpful

http://www.ti.com/product/sn74lvc1g125 (http://www.ti.com/product/sn74lvc1g125)

they take 3.3V input and can work 5V level.
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: itvend on July 03, 2013, 12:43:54 am
may be these chips are helpful

http://www.ti.com/product/sn74lvc1g125 (http://www.ti.com/product/sn74lvc1g125)

they take 3.3V input and can work 5V level.

 :-+ sn74lvc1g125 sucks little, i hate smd parts, but what you gonna do i probably go with sn74lvc1g125 or 3.3V uC, thaks all for generating ideas , but i didnt get answer for my question, does transistor buffer works for spi or not?
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: Psi on July 03, 2013, 03:15:01 am
If it's just for a hobby project just connect the 3.3V directly to the 5V input, it will work fine even though it's outside spec.

From memory the pins change to logic high somewhere between 1V -> 2V
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: brainwash on July 03, 2013, 05:02:39 pm
Or you can take an 3.3V supply from the rPI and provide that to the microcontroller.
If not possible, read everything here: http://www.newark.com/pdfs/techarticles/microchip/3_3vto5vAnalogTipsnTricksBrchr.pdf (http://www.newark.com/pdfs/techarticles/microchip/3_3vto5vAnalogTipsnTricksBrchr.pdf)
Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: ptricks on July 03, 2013, 09:52:47 pm
Lots of ways, but here are some easy ones:
https://www.sparkfun.com/tutorials/65 (https://www.sparkfun.com/tutorials/65)

Title: Re: Raspberry Pi GPIO 3.3V <-> 5V
Post by: tld on July 03, 2013, 10:05:08 pm
thaks all for generating ideas , but i didnt get answer for my question, does transistor buffer works for spi or not?

If I understand you correctly, you're not just looking to solve an actual problem, but also curious if your thinking and possible solution is correct.

I think part of the reason that you haven't gotten a really good answer to that might be that there's a lot of variables at play, and hard to give an answer that's correct for all of them.

As a general answer, yes, it should be a workable to use a transistor-buffer for SPI, as long as you keep an eye on not getting an inverted signal etc.

There is however a lot of factors to consider.  Take speed for example.  How fast will the SPI-bus be?  Will bandwidth/rise-time be fast enough?

Figuring out if everything will always behave the right way - with margins - is quite a bit of work, and virtually impossible without diving into details.

Depending on specific, it's quite possible that a 3.3V signal can register correctly as HIGH on a 5V micro.
For the other direction, you might be able to simply cut down the 5V signal to 3.3V-safe levels using a resistor divider.