# Convert digital signal from TTL 5V to Raspberry Pi GPIO 3.3V

#### LordOfThunder

Joined Jun 27, 2018
67
Hello!

I am a Ph.D. student in particle physics and for our experiment we need to convert a 5V TTL digital signal (16-bits actually) coming out of a Phillips 726 converter and read it using the GPIO pins of a Raspberry Pi 4. We do not need bidirectional communication. We just need to read this 16-bits number that comes in the form of 16 parallel TTL signals. The number changes every 2.5 seconds or so, so high speed is not really an issue here.
We are going to order all the parts and chips from the Adafruit website. I think we have basically three options:
I am leaning towards the 74LVC245 Chip, do you think it is the best choice too? If not why?
The output of the Phillips 726 has the following specs:
TTL Output One TTL output per channel, LEMO style connector; sources 45 mA to drive 50 ohm load or 1000 standard TTL loads, sink current of 100 mA; able to drive 100 standard TTL loads. 3.5 nsec rise and fall times.

Thank you
Giorgio

EDIT:
The circuit of post #5 turned out to be just fine for my requirements.

Last edited:

#### ericgibbs

Joined Jan 29, 2010
12,973
hi HOT,
Use a 3K3 and 2k divider as down level shifter ie: 5V > 3,3V
eg; 2k to the 5V signal and the bottom of the 3k3 to 0v,, take off ~3.3V at the junction.

E

#### LordOfThunder

Joined Jun 27, 2018
67
hi HOT,
Use a 3K3 and 2k divider as down level shifter ie: 5V > 3,3V
eg; 2k to the 5V signal and the bottom of the 3k3 to 0v,, take off ~3.3V at the junction.

E
Thank you for the quick answer. So the simplest option is good enough in your opinion.

#### Lo_volt

Joined Apr 3, 2014
189
As a second layer of protection, I will often add a zener diode to clamp the voltage at the input to 3.3 volts. This is helpful if there's a voltage spike on the input or if the lower divider resistor opens.

#### Attachments

• 6.8 KB Views: 4

#### Analog Ground

Joined Apr 24, 2019
453
You may want to think about terminating the signals in the characteristic impedance of the cables to prevent overshoot and undershoot of the signal when it changes. The data rate may be slow but the signal edges look to be fast. You don't want the RPi inputs levels to be exceeded when the signal changes (both high and low). If this happens, the RPi input protection circuitry will turn on and you will get unwanted current spikes into the IC. If the cables have a 50 ohm impedance, like typical coaxial cables with the Lemo connectors, use 50 ohms at the RPi end. Now, it looks like the 726 TTL output is set to provide 45 mA into a 50 ohm load. This gives a level of about 2.25 volts which is fine for going directly into an RPi. So, I am suggesting terminating the signals with just 50 ohms and not a two resistor divider. If the cabling is short enough, then you can consider the other approach but it all depends on the cable length and characteristics.

In general, I would use some sort of line receiver before going into the RPi and not go directly into the RPi.

Edit: I am not an RPi expert and it looks like 2.25V gives no margin for an input high level. See the link below. A conservative design would use a 50 ohm line termination and a receiver before going into the RPI.

http://www.mosaic-industries.com/em...spberry-pi/gpio-pin-electrical-specifications

Last edited:

#### LordOfThunder

Joined Jun 27, 2018
67
@Lo_volt Thanks you for the additional info.

@Analog Ground I understand what you mean only partially. I understand the idea of terminating the lLEMO cables to avoid ringing of the signal ... but I do not understand what you mean by line receiver. I am not by any means an expert in electronics. I tried to google up "line receiver" but the top results were all about differential line receivers such as RS485 (that is not our case).
The cable that we are going to use is 50ohm male-male LEMO coaxial cable of about 50 cm of length.
If you could draw a simple circuit diagram (even only the logical blocks is fine), it would help me understand better. Thank you anyway for the hints.

#### ericgibbs

Joined Jan 29, 2010
12,973
hi LOT,
I would recommend that you try the simple resistor divider method first, no zener diode, check the circuit performance
E

#### LordOfThunder

Joined Jun 27, 2018
67
hi LOT,
I would recommend that you try the simple resistor divider method first, no zener diode, check the circuit performance
E
I agree. I was already getting ready to do that. I just wanted to understand what Analog Ground was suggesting in detail.

#### ericgibbs

Joined Jan 29, 2010
12,973
hi,
Ref the zener, check the datasheets for their internal capacitance, if pulse edges are a concern.
E

#### Analog Ground

Joined Apr 24, 2019
453
I recommend the 74LVC245 you mention in your initial post. It has a "TTL compatible" input with a 3.3V power supply. The 74vhct541 you found uses a 5V power supply and puts out a signal above the RPi input range which you are trying to avoid. If you go with the voltage divider input method, be sure to check out what happens to the 726 module TTL output when not terminated in 50 ohms. It is specified for 50 ohm termination and does not use what we think of as a standard TTL driver.

#### Analog Ground

Joined Apr 24, 2019
453
hi,
Ref the zener, check the datasheets for their internal capacitance, if pulse edges are a concern.
E
Good point. I see one series of zeners where the capacitance for the low voltage parts is 100 pF to 200 pF. You won't have to worry about overshoot. It will be filtered out!

Joined Jan 15, 2015
5,935
Lately everyone wants to convert one way or the other, 5.0 to 3.3 or 3.3 to 5.0. Considering it's less than a buck ($1.00) a channel I would be thinking about having a few of these laying around. Not to say using a voltage divider isn't practical but it's a simple Bi-Directional Logic Level Converter. Ron Thread Starter #### LordOfThunder Joined Jun 27, 2018 67 Thank you for the feedback. Now I am going to do some tests (it may take a while) and I will let you know the results. #### ebeowulf17 Joined Aug 12, 2014 3,276 Lately everyone wants to convert one way or the other, 5.0 to 3.3 or 3.3 to 5.0. Considering it's less than a buck ($1.00) a channel I would be thinking about having a few of these laying around. Not to say using a voltage divider isn't practical but it's a simple Bi-Directional Logic Level Converter.

Ron
There's also a comparable Adafruit board. I thought that I looked at these a year or two ago and figured out that the Adafruit one was somehow better, but I sure can't remember now why I thought that, and they look conceptually the same to me now. Maybe I compared it to a different SparkFun product back then? Not sure.

Anyway, lots of good options, and I think the concept that both of these circuits work on is really clever - the compatibility with I2C pullups is an interesting detail.

#### LordOfThunder

Joined Jun 27, 2018
67
I promised (many moons ago) that I would let you know the test results. The simple resistance divider worked just fine. I just tested 3 bits out of 16 but I do not see why it should not work for 16 bits as well.
Sorry if it took so long but I was busy with other projects.
@Lo_volt You suggested putting a Zener diode in parallel with the bottom resistor. What Zener voltage do you recommend? 3.3 Volts or a little more?

#### Lo_volt

Joined Apr 3, 2014
189
Since your input limit is 3.3 volts, I'd stick with a 3.3 volt zener. As suggested, keep an eye on the capacitance to be sure it doesn't slow down your input rise/fall time.

#### LordOfThunder

Joined Jun 27, 2018
67
@Lo_volt I tried to stick a 3.3V Zener (1N4728ATR) and the circuit did not work anymore: I was getting random readings. The data rate is about one hertz, so even if the parasitic capacitance is badly affecting the rising and falling times, I still do not understand why by just inserting a Zener diode the circuit completely misbehaves. Can you guess why?

In the meanwhile, I will try to check the signal on the oscilloscope.

PS I checked the Zener orientation and it is correct. By reversing it I get no output signal as expected.

#### LesJones

Joined Jan 8, 2017
3,195
You will need to provide a schematic of HOW you have inserted the zener.

Les.