Your favorite level shifter? (5/3.3)

  • Thread starter Borek
  • Start date
In summary, the IC used is a standard SPI as implemented in an Atmega328P. The lines are unidirectional and the maximum bandwidth is unknown, but likely to be in the MHz range. The project is planned on a single, matchbox-sized PCB.
  • #1
Borek
Mentor
28,951
4,245
As in the subject.

I am thinking about a small, Arduino based project, but I will need to connect it to a 3.3V SD card (4 channels). Not a serious problem to make a level shifter using transistors, I already know I can use 74LVC125A to use just one IC instead of several elements, but I just wonder - what is the IC you like for whatever reasons?

(actually the problem is none of the on line shops I typically use has all elements I need, so I am looking for alternatives, to pay p&p only once :oldbiggrin: )
 
Engineering news on Phys.org
  • #2
What bandwidth do you need? How far away from the Arduino will the SD card be? Are the lines all uni-directional, or are some bidirectional/Tri-state?
 
  • #3
Hm, you ask questions that make me wonder what I can be missing. It is a standard SPI as implemented in Atmega328P. I am not sure about technical details, I use SPI as a black box. Wiki says "most slave devices have tri-state outputs" though, I have a proof of concept version based on 74LVC125A which is a tri-state buffer, so tri-state is probably a way to go. Elements will be on the same PCB, centimeters apart so I don't think the distance plays any important role. Not sure what the bandwidth will be (maximum that I will be able to get using 8 MHz clock built into Atmega μC) - but we are talking several MHz at most.
 
  • #4
Oh, SPI, that's good. The lines for SPI are unidirectional in most cases. Can you share a schematic using the 125A? I asked about the separation distance, because when fast signals have sharp rise/fall edges, you often will use a "back-termination" resistor at the driving source gate to cut down on ringing from reflections. If you are only going 2cm and have the 125A in between, you probably don't need to worry. If you had any traces over about 4cm, those would be candidates for back-termination.
 
  • #5
Oh, and I remember from your OP that you would like an alternative the 125A, but I just want to be sure I'm not missing anything.
 
  • #6
All I have is this sad attempt at reverse engineering the SD card Arduino add on board I used in the PoC device. Just realized connections at the bottom are not marked - these are GND, VCC (5), MISO, MOSI, SOC, SC, just SPI and power. All resistors are 3.3 kΩ, not sure about capacitors (my meter displays some strange numbers), but I assume C1, 2 & 4 to be standard decoupling 100 nF, not sure about the value of C3 - if I read it correctly LM1117 specification calls for 100 μF, but the one on the board is definitely much smaller (I guess currents used are so small 100 μF would be an overkill).

But from what you are writing it sounds like copying it can be safer than trying to redesign with other elements, apparently I miss a lot. Not that I am surprised ;)

SD_interface.png
 
  • #7
It looks like the resistors are attempts at back-terminating those lines, but 3.3k is a pretty strange value to use. The back-termination resistor should add to the output resistance of the drive gate ##R_{out}## (which is usually in the 10s of Ohms) to equal the characteristic impedance ##Z_0## of the trace over the ground plane (the ground plane should be the inner layer adjacent to the top layer where the trace is).

The connector is worrisome -- I guess I missed the fact that this would be an add-on card and not a new PCB. Is that true? running fast signals through connectors causes discontinuities in ##Z_0## that can cause that pesky ringing that can affect signal integrity. Are you doing your own PCB design for this project? The back-termination resistors should be right at the drive gate output if so, but again only if you are going a few cm to the input to the next gate/IC (or going through connectors).
 
  • #8
BTW, will this SPI connection only be used to access the SD Card, or will it also be used to access other SPI devices via separate Chip Selects? If MOSI stars out to multiple devices and MISO is coming from multiple devices, that creates issues for the signal integrity also. There are solutions in the PCB layout if that is happening on your board.
 
  • #9
berkeman said:
The connector is worrisome -- I guess I missed the fact that this would be an add-on card and not a new PCB. Is that true?

No no, that's just what I used to test the idea. Final thing is planned on a single, matchbox sized PCB. No other SPI devices will be present (or at least that what I tested and what I plan for now).

What I am trying to make: I have a problem with my dashboard cam - it doesn't display free space on the SD card used. In normal situations it doesn't matter, as it saves the movie using kind of a circular buffer, plenty of files below 1 GB. But when I am on a longer trip in a nice place I want to record whole route. I have several cards but it is never clear when to change them. Booting laptop just to check is rather clumsy, so I tested that I can check the card with Arduino, SD card reader and LED display (three digits, seven segments type). I will be able to just put the card into slot, plug whole thing into car's USB socket and it will display free space in GB in few seconds (depends on the card size, depends on the μC clock, but definitely much faster than the laptop route). As good (and nonsense) DIY project as any other ;)

I will either etch my own PCB (been there, done that) or will try to order one from JLCPCB, just for kicks. They do custom boards surprisingly cheap (even with shipping) and hopefully I will learn something new. My friend tried that route and was quite happy with the effect.

I thought these resistors are just for protection and limiting currents, I remember such solution suggested in some DIY projects
 
  • #10
Borek said:
I will either etch my own PCB (been there, done that) or will try to order one from JLCPCB, just for kicks. They do custom boards surprisingly cheap (even with shipping) and hopefully I will learn something new. My friend tried that route and was quite happy with the effect.
It sounds like it will be a 2-layer board? That can still work, as long as you have a good ground pour on the bottom side.

Since you can make it all compact and small, don't bother with the back-termination resistors.

As to your original question, I like to sometimes use HCT or VHCT CMOS buffers to do the level translation. The "T" in the part number means that the 5V CMOS parts have TTL-compatible inputs, which means that they can be driven by 3.3V CMOS logic.
 
Last edited:
  • #11
berkeman said:
It sounds like it will be a 2-layer board?
1 layer (plus whatever tricks/bridges needed to make it work) if I etch it by myself, 2 layers if ordered.
 
  • #12
Borek said:
2 layers if ordered.
If you want it to work, I'd recommend using this option (including the ground pour on the back side that I mentioned). I can review the layout when you have it ready if you like. :smile:
 
  • Like
Likes Borek
  • #13
BTW, are the inputs to the SD Card 5V tolerant? If not, you can't just use a 5V CMOS VHCT gate to drive them. You would need some buffer gates for the downlink signals that could run on 3.3V and had 5V tolerant inputs.
 
  • #14
There are about a million devices that can do this, so it's hard to answer. Have a look at the digikey.com site and search for "level shift ICs" or maybe "level translators". They have nice search menus that let you focus on what you care about.

I would probably look at the TXB0104 parts. They might be overkill, but they are cheap (by DIY standards), readily available, flexible, and easy to use. Good to have around the lab for next time, too.
 
Last edited:
  • Informative
  • Like
Likes Borek and berkeman
  • #15
I am not entirely happy yet, but it works (and is easy to reprogram, so there is place for at least some code improvements).

This card has 119 GB free space. Take it out, plug in a next one, press the reset button, wait few seconds for the result - and so on.

czytnik_1024.jpg


Several things are wrong: SPI doesn't work at full speed (@berkeman - probably should ask you for taking a look at the PCB; but it actually doesn't matter much, looks like I am limited by the card speed, not by SPI - still, it worked at 16 MHz on the breadboard, now it works at 4 MHz). I don't like the level shifter (I used just the copied solution mentioned earlier, I wanted to try TXB0104 @DaveE suggested, sadly I couldn't buy it here for a reasonable price - I don't need hundreds, I don't want to pay $$$ for delivery). And finally - shift registers for display are unnecessary, I have enough unused legs on the μC to to avoid 595s, I just blindly followed the first idea.

Oh, and don't bother telling me I don't know how to solder, I already know that :wink:
 
  • Like
Likes DaveE and berkeman

1. What is a level shifter and what does it do?

A level shifter is a device that converts the voltage level of a signal from one level to another. In the context of electronics, it is used to shift the voltage level of a signal from 5 volts (5V) to 3.3 volts (3.3V) or vice versa.

2. Why is a level shifter necessary for 5V to 3.3V conversion?

Many electronic devices operate at different voltage levels. For example, some microcontrollers operate at 5V while others operate at 3.3V. In order for these devices to communicate with each other, a level shifter is necessary to convert the voltage levels of the signals.

3. What are the benefits of using a level shifter for 5V to 3.3V conversion?

Using a level shifter ensures that the signals are compatible and prevents any potential damage to the devices. It also allows for more efficient and accurate communication between devices.

4. Are there different types of level shifters for 5V to 3.3V conversion?

Yes, there are different types of level shifters available, including unidirectional and bidirectional shifters. Unidirectional shifters only convert the voltage level in one direction, while bidirectional shifters can convert in both directions.

5. How do I choose the right level shifter for my project?

The right level shifter for your project will depend on factors such as the voltage levels of your devices, the number of channels needed, and the speed of communication. It is important to carefully read the specifications and choose a shifter that meets your project's requirements.

Similar threads

Replies
13
Views
1K
  • Electrical Engineering
Replies
1
Views
3K
Replies
19
Views
4K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
1K
  • Electrical Engineering
Replies
4
Views
3K
  • Calculus and Beyond Homework Help
Replies
9
Views
1K
  • Electrical Engineering
Replies
1
Views
1K
  • Electrical Engineering
Replies
7
Views
13K
  • Advanced Physics Homework Help
Replies
1
Views
3K
  • DIY Projects
Replies
8
Views
246
Back
Top