6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 6:09 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Tue May 10, 2022 1:48 pm 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 718
Location: Texas
Hey everyone! This topic has come up a lot, I searched the internet and forum and did not find what I was looking for.

Let's start here, the SPI-10 interface:
viewtopic.php?t=4264

I want to take 5V signals (CS/SCK/MOSI) down to 3V3. I'll worry about the MISO line later.

I found this:
https://hackaday.com/2016/12/05/taking- ... -shifters/

And honestly I think the "two resistors" idea is fine. And perhaps it is. But I'm wondering what you think.

What I am REALLY looking for is a DIP-8 IC that turns 3x 5V lines into 3x 3V3 lines. That would be perfect. I have seen the 74HC4050 and that seems to be exactly what I want, but in DIP-8 package (i.e. less lines, smaller package, still DIP). Any ideas on how to find that?

Also, maybe this is just stupid of me, but why don't I just use a 74LS04? Send in 5V, output is 3.3V, double not gates, out comes what I want. Am I missing something there?

What do you use for level shifting SPI?

Any insight is welcome, just looking for ideas. Thanks everyone!

Chad


Top
 Profile  
Reply with quote  
PostPosted: Tue May 10, 2022 5:10 pm 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
I haven't needed to do this level shifting myself yet, but the technique I've always had in mind for unidirectional shifting was to use a 74HC245 or similar transceiver to buffer up to eight (or four if you get the 74HC243) 5V=>3.3V signals, with its VCC at 3.3V so it doesn't output more than that to the 3.3V end. You still need current-limiting resistors from the 5V end, but it has internal diodes that are specified to be fine for this purpose, so you only need the one resistor per input.

For the other way I might use 74HCT245 which has TTL-level inputs so should be fine being triggered by 3.3V even with VCC at 5V, being careful to ensue the direction pin is hard-wired the right way around. To me this is a very simple way to achieve it without using specialist parts.

Edit: I guess there's also the LVC range, e.g. 74LVC245, which are 5V-tolerant and don't require current-limiting resistors.


Top
 Profile  
Reply with quote  
PostPosted: Tue May 10, 2022 7:43 pm 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
I didn't realize the 74LVC245 was available in DIP, I thought that the family had only SMD parts. Nice find!

_________________
BB816 Computer YouTube series


Last edited by akohlbecker on Thu May 12, 2022 2:03 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue May 10, 2022 10:12 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
Adding to George's good post:
Jeff alerted us to this series of short videos about TI voltage-translation parts. The circuit potpourri page of the 6502 primer mentions the 74LS07 open-collector buffer which I've used on a few projects for voltage translation. (Unfortunately the 74xx07 is not available in CMOS.) I guess I really should add more about voltage translation in that page.

For a unidirectional line with a CMOS load, going from 5V to 3.3V is easily done with a pair of resistors; but to avoid slowing down the signal's edges due to the resistance and the load capacitance CL which is across R2, there should be a capacitor across R1:
Attachment:
5Vto3V3resitiveDiv.gif
5Vto3V3resitiveDiv.gif [ 10.26 KiB | Viewed 1486 times ]

The resistor values don't have to be these exact ones, the ratio of the two values should be kept the same. Standard 5% values go in the sequence 1 - 1.1 - 1.2 - 1.3 - 1.5 - 1.6 - 1.8 - 2 - 2.2 - 2.4 - 2.7 - 3 - 3.3 - 3.6 - 3.9 - 4.3 - 4.7 - 5.1 - 5.6 - 6.2 - 6.8 - 7.5 - 8.2 - 9.1 - 1 (and you can move the decimal place left one place or to the right up to about seven places). The value of the capacitor should be approximately CL*3.3V/(5V-3.3V), or nearly double the CL. Fortunately that doesn't need to be exact, because it may be difficult to predict the exact capacitive load of input(s), sockets, and board traces combined. Forum member akohlbecker posted a simulation of the effect of resistance and capacitance. Click on the L or H at the left end to change the input state, and on the switch in series with the 47pF capacitor to connect and disconnect the capacitor. You can see that without the capacitor connected, the rise and fall times are slow, but the when you connect the capacitor again, you get the square wave back. You'll probably have have more than the 3pF total load that he shows, so your edges will be slower. If you click the L or H at the left end quickly, you'll get kind of a triangle wave out, and if you do it quickly enough, you'll see it hardly reaches valid '1' and '0' states before turning around and heading for the other state. Re-connect the 47pF, and you'll get a nice square wave. Capacitor values don't generally come in the fine-grained sequence given above, and depending on where you buy yours, the next one down from 47pF might be 22pF. I would not go above 47pF.

This matter of capacitance is something the hackaday article missed.

Going the other direction, from 3.3V to 5V, any 74_CT__ gate, powered by 5V, will work, for example 74HCT__ or 74ACT__, since they'll take any input above 2V as a valid logic '1', and their logic '1' output will be very close to 5V.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Tue May 10, 2022 11:38 pm 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 718
Location: Texas
First, thanks George. I looked more into that 74LVC' ICs and I think I like them! I found Mouser has a thousand 74LVC244's right now in DIP form. So, power them with 3.3V right?

GARTHWILSON wrote:
For a unidirectional line with a CMOS load, going from 5V to 3.3V is easily done with a pair of resistors; but to avoid slowing down the signal's edges due to the resistance and the load capacitance CL which is across R2, there should be a capacitor across R1:

Forum member akohlbecker posted a simulation of the effect of resistance and capacitance.

This matter of capacitance is something the hackaday article missed.

Going the other direction, from 3.3V to 5V, any 74_CT__ gate, powered by 5V, will work, for example 74HCT__ or 74ACT__, since they'll take anything above 2V as a valid logic '1', and their logic '1' output will be very close to 5V.


That simulation REALLY hit home. Wow. And just like you said, a triangle wave if you oscillate fast enough! Makes me think of making a triangle wave circuit now :)

Overall, good info there, thank you Garth.

So I've been thinking about going in reverse with MISO for a while, and I have 1/2 of an LM393 left over from other stuff. Attached is what I *think* would work for MISO (mine is on PA6 in particular here). The 8.2K and 4.3K tied to 3V3 making a 'low' level of 1.1 V. So then comparing to 1.1V we get either high or low. Because the comparator could oscillate if left untied, I put a big 100K pull-up resistor on it, so leaving the comparator as high-Z. And then finally the 10K pull-up resistor brings it to 5V. Now, this MISO is tied to other 5V components, but... I think this should work? Thoughts? It's almost my first time trying this analog stuff out on my own. I'm open to all criticism!

Thank you again everyone!

Chad


Attachments:
3V3to5V.png
3V3to5V.png [ 10.29 KiB | Viewed 1482 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed May 11, 2022 12:09 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
That'll work. I give some tips on making the 339 or 393 work as fast as they can, at viewtopic.php?p=7612#p7612 .

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Wed May 11, 2022 6:33 pm 
Offline
User avatar

Joined: Fri Dec 12, 2008 10:40 pm
Posts: 1007
Location: Canada
If your speed requirements are not too ambitious you can just use a simple 2N7000 MOSFET and one or two resistors.

This is a high to low translator:
Attachment:
LT-H-L.jpg
LT-H-L.jpg [ 31.66 KiB | Viewed 1424 times ]


This is a low to high translator:
Attachment:
LT-L-H.jpg
LT-L-H.jpg [ 31.47 KiB | Viewed 1424 times ]


And here is a bi-directional:
Attachment:
Bi-D.jpg
Bi-D.jpg [ 33.4 KiB | Viewed 1424 times ]




The following are waveforms @ 55Khz using 3.6K pull-ups. You can see they would work quite well up to about 500KHz. I have been able to do 1MHz using 470 ohm pull-ups, but I don't have any waveforms to show you. I did these measurements with 3V for low side. They will actually work a bit better with 3.3V

High level source:
Attachment:
LT-H-L-scope - high lide signal.jpg
LT-H-L-scope - high lide signal.jpg [ 50.38 KiB | Viewed 1424 times ]

And corresponding low level output:
Attachment:
LT-H-L-scope - low side signal.jpg
LT-H-L-scope - low side signal.jpg [ 49.88 KiB | Viewed 1424 times ]




Low level source:
Attachment:
LT-L-H - Low side signal.jpg
LT-L-H - Low side signal.jpg [ 49.91 KiB | Viewed 1424 times ]

And corresponding high level output:
Attachment:
LT-L-H - High side signal.jpg
LT-L-H - High side signal.jpg [ 50.41 KiB | Viewed 1424 times ]

_________________
Bill


Top
 Profile  
Reply with quote  
PostPosted: Thu May 12, 2022 1:41 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
GARTHWILSON wrote:
Unfortunately the 74xx07 is not available in CMOS.
Yes the offerings are limited in regard to TH parts. Digikey lists the 74C906 as obsolete, no stock, although it may be available through other channels. But there are lots of surface-mount options, such as 74LV07 and 74LVC07.

BTW this is a good example of why I'm a fan of Digikey's product search. 74C906 is not a part you'd discover by searching for 74*07. That's why I prefer to search based on functionality (not a preconceived part#). Go to...

    Product Index ->
    Integrated Circuits (ICs) ->
    Logic - Buffers, Drivers, Receivers, Transceivers

... then filter the results according to speed, price and whatever else concerns you.

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Fri May 13, 2022 3:36 pm 
Offline
User avatar

Joined: Sun Nov 07, 2021 4:11 pm
Posts: 101
Location: Toronto, Canada
BillO wrote:
If your speed requirements are not too ambitious you can just use a simple 2N7000 MOSFET and one or two resistors.


If you want to go this route, you can also buy some handy breakout boards that take up very little space and are breadboard-friendly. They come with 10k resistor, so they won't work at super-high speeds, but I've successfully used them for SPI in the past.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 13, 2022 6:33 pm 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 718
Location: Texas
It is good to see all the different ways y'all tackle this problem. I like a lot of these ideas and will be considering them all going forward. In the least, I hope that this topic can be easily searched on the forum as well for later use.

Thank you all!

Chad


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 01, 2022 12:14 am 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
There are a few modules going around online that are basically four of the bi-directional transistor circuits that BillO mentioned, all on one board, approximately the size of a wide DIP12. I know you can get them from places like Adafruit and Sparkfun, but I found a pack of 10 for a fraction of the price on AliExpress. They seem to work so far, though I haven't carried out much in the way of testing yet.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 01, 2022 7:45 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1486
Location: Scotland
If it's just for an SD card then there are some excellent pre-made modules from Adafruit and Sparkfun - I use them on my Ruby boards - far easier than fiddling with shifters and using your own sockets, etc.

e.g.

Sparkfun:

https://shop.pimoroni.com/products/spar ... 7290596423

Adafruit:

https://shop.pimoroni.com/products/adaf ... =370780217

On my Ruby 816 board:

https://unicorn.drogon.net/IMG_20200625_212146_DRO.jpg

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: