Author Topic: Best way to drive a 5V TTL line with a 3v3 GPIO?  (Read 2019 times)

0 Members and 1 Guest are viewing this topic.

Offline nockieboy

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Best way to drive a 5V TTL line with a 3v3 GPIO?
« on: December 17, 2018, 09:41:59 am »
Hi,

I'm working on an ESP32<->Z80 interface to IoT-enable the Z80 device.  One of the issues I'm trying to resolve is the fact the ESP32 is a 3.3v device and the Z80 is 5v, causing a few contentions.

This question, however, is specifically how best to drive several of the Z80's lines from the 3v3 GPIO pins on the ESP32.  I need to be able to pull INT and RESET low according to the ESP32's desires.  I also need to drive IEO, which should either be at 5V or 0V depending on what the ESP32 is doing.

I have read comments previously about using a transistor (or pair of transistors to prevent the signal being inverted) to interface the 3v3 line with the 5v line, but that this may cause a lot of current draw through the GPIO.  I have to admit I am not nearly knowledgeable enough in electronics to know why, or what issues this may cause, but it sounds bad.

I have a rudimentary setup using a 2N3904 transistor to (I think) pull the relevant line low when the GPIO goes high (see below), but I'd appreciate the thoughts of people with far more experience in electronics than I'll ever have on this subject.



I have three spare pins on a 74LVC4245AD which I could use, but would it be able to pull the lines low?  Do I need some sort of open-collector setup to do that?  The INT and RESET lines have 4K7 pullups.  IEO may be connected to a maximum of one other device and, as its name suggests, it forms part of an interrupt daisy chain.

Any thoughts or advice would be gratefully received.
« Last Edit: December 17, 2018, 09:45:36 am by nockieboy »
 
The following users thanked this post: cdev

Offline perieanuo

  • Frequent Contributor
  • **
  • Posts: 293
  • Country: fr
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #1 on: December 17, 2018, 10:18:16 am »
hi,
the current trend is mosfet level converters imho
like one attached
« Last Edit: December 17, 2018, 10:20:02 am by perieanuo »
 

Offline Cervisia

  • Regular Contributor
  • *
  • Posts: 76
  • Country: 00
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #2 on: December 17, 2018, 10:58:35 am »
Please note that "5V TTL" is not the same as "5V CMOS".
TTL devices used only NPN transistors, which resulted in an output circuit that cannot drive higher than about 3.5 V, so TTL inputs were designed to accept anything above 2 V as high.

This means that you can drive the Z80's TTL inputs directly from the ESP's 3.3 V CMOS outputs.
« Last Edit: December 17, 2018, 11:00:44 am by Cervisia »
 
The following users thanked this post: wraper

Online Zero999

  • Super Contributor
  • ***
  • Posts: 13119
  • Country: gb
  • 0999
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #3 on: December 17, 2018, 11:01:05 am »
Please note that "5V TTL" is not the same as "5V CMOS".
TTL devices used only NPN transistors, which resulted in an output circuit that cannot drive higher than about 3.5 V, so TTL inputs were designed to accept anything above 2 V as high.

This means that you can drive a TTL input directly from a 3.3 V CMOS output (such as the ESP's).
Yes, if it's TTL, it will work directly from a 3.3V CMOS output.

If it's 5V CMOS, then use a 74HCT IC such as the 74HCT14, which can accept 3.3V inputs and shift it to 5V.
https://assets.nexperia.com/documents/data-sheet/74HC_HCT14.pdf
 
The following users thanked this post: wraper

Offline mrpackethead

  • Super Contributor
  • ***
  • Posts: 2827
  • Country: nz
  • D Size Cell
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #4 on: December 17, 2018, 11:03:29 am »
Using HCT logic is a useful thing to do to go from 3.3 -> 5V.
On a quest to find increasingly complicated ways to blink things
 

Offline beanflying

  • Super Contributor
  • ***
  • Posts: 3895
  • Country: au
  • Toys so very many Toys.
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #5 on: December 17, 2018, 11:22:23 am »
Coffee, Food, R/C and electronics nerd in no particular order :)
 

Offline nockieboy

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #6 on: December 17, 2018, 12:08:53 pm »
Thanks for the replies, everyone.  :-+

Using HCT logic is a useful thing to do to go from 3.3 -> 5V.

Funnily enough, I was going to ask about using a 74HCT08 - I could run a GPIO output to both inputs of one of the HCT AND gates to drive the 5V line on the other side... I assume the HCT AND gate would be okay sinking the 5V (4K7 pull-up) line on the Z80 side?

Would the 74LVC4245 be able to do the same?  I have 3 free pins on one of those chips - if they are able to pull the 5V lines low, I could use the remaining pins.

 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 12027
  • Country: gb
    • Mike's Electric Stuff
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #7 on: December 17, 2018, 12:12:14 pm »
74HCT is my default way to do it, but be aware that if you care about very low power draw, feeding 3.3v into an HCT can cause slightly higher static power draw.
Not an issue for most applications that need 5V as other draws in the system will be way higher
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: nockieboy

Offline nockieboy

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #8 on: December 17, 2018, 12:28:59 pm »
74HCT is my default way to do it, but be aware that if you care about very low power draw, feeding 3.3v into an HCT can cause slightly higher static power draw.
Not an issue for most applications that need 5V as other draws in the system will be way higher

Okay, I'll scrub the transistors and run the GPIO into an inverter (74HCT04) to convert the signal.  Thanks!  :-+

EDIT:  Oooh hang on, that won't work though will it?  The outputs of whatever is doing the voltage conversion need to be open-collector, as the 5V side has pull-ups and I just need to pull the line down to ground..  *goes off to hunt down open-collector HCTs*
« Last Edit: December 17, 2018, 12:32:33 pm by nockieboy »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 13119
  • Country: gb
  • 0999
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #9 on: December 17, 2018, 12:49:33 pm »
74HCT is my default way to do it, but be aware that if you care about very low power draw, feeding 3.3v into an HCT can cause slightly higher static power draw.
Not an issue for most applications that need 5V as other draws in the system will be way higher

Okay, I'll scrub the transistors and run the GPIO into an inverter (74HCT04) to convert the signal.  Thanks!  :-+

EDIT:  Oooh hang on, that won't work though will it?  The outputs of whatever is doing the voltage conversion need to be open-collector, as the 5V side has pull-ups and I just need to pull the line down to ground..  *goes off to hunt down open-collector HCTs*

There are open collector HCT ICs available, such as the 74HCT05, but it doesn't need to be open collector. Shorting the internal pull-up resistor to +5V will do no harm.
http://www.sycelectronica.com/semiconductores/74HCT05.pdf
 

Offline nockieboy

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #10 on: December 17, 2018, 01:21:46 pm »
There are open collector HCT ICs available, such as the 74HCT05, but it doesn't need to be open collector. Shorting the internal pull-up resistor to +5V will do no harm.
http://www.sycelectronica.com/semiconductores/74HCT05.pdf

Oh okay, that sounds like a much better option then as I don't want to have to add another chip if I don't have to - I can just use the existing 74HCT04?  Actually, thinking about it, I use the 04 to drive power LEDs so yes, I guess it should be fine.  :-+
 

Offline emece67

  • Regular Contributor
  • *
  • Posts: 168
  • Country: es
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #11 on: December 17, 2018, 02:26:49 pm »
Why not using an integrated solution? This worked well for me http://www.ti.com/lit/ds/symlink/txb0108.pdf.

Regards.
Information must flow.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 12027
  • Country: gb
    • Mike's Electric Stuff
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #12 on: December 17, 2018, 03:18:26 pm »
Why not using an integrated solution? This worked well for me http://www.ti.com/lit/ds/symlink/txb0108.pdf.

Regards.
Those bidirectional shifters are pure evil unless you really need bidirectional translation. Doesn't take much capacitance to make them oscillate
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: JPortici

Offline nockieboy

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #13 on: December 17, 2018, 04:09:19 pm »
Why not using an integrated solution? This worked well for me http://www.ti.com/lit/ds/symlink/txb0108.pdf.

Regards.

I've actually got a TXB0104D in the design doing level translation for the SPI bus from the ESP32 to a couple of MCP23S17s, but I didn't fancy trying to squeeze another chip onto the board, especially if I can make it work using unused inverters on an HCT04 I've got in the system already.  The MCPs are connected to the Z80's address, data and control buses (which are 5V), hence the voltage translation as the MCPs are also powered by the 5V supply.

Those bidirectional shifters are pure evil unless you really need bidirectional translation. Doesn't take much capacitance to make them oscillate

Oh?  I've never used them before... in fact, the whole design for the ESP32/Z80 interface exists only in DipTrace at this moment in time, or as a high-level graphical representation to give the idea of how it should all fit together.. I was planning on making another post - probably in the Projects section of the forums - asking for feedback on that design and confirmation that it'll theoretically work before I start trying to prototype it.
« Last Edit: December 17, 2018, 04:11:17 pm by nockieboy »
 

Offline mrpackethead

  • Super Contributor
  • ***
  • Posts: 2827
  • Country: nz
  • D Size Cell
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #14 on: December 17, 2018, 05:43:27 pm »
Would the 74LVC4245 be able to do the same?  I have 3 free pins on one of those chips - if they are able to pull the 5V lines low, I could use the remaining pins.

There are some LVC Parts that do level translation,  such as the 4245,   ( its got dual power supplies ), but as a general rule you cant'.   most HCT parts (all?) can take a 3.3V input when its on 5V supply ), and get 5V level outputs.
On a quest to find increasingly complicated ways to blink things
 
The following users thanked this post: nockieboy

Offline nick_d

  • Regular Contributor
  • *
  • Posts: 120
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #15 on: December 18, 2018, 12:44:28 am »
The problem with the 74LVC4245 would be that the DIR and /OE pins are ganged to all 8 of the transceivers. So if you already have it set up in the direction that the 3.3V side is an input and the 5V side is an output, and you're either going to keep it set up this way permanently, or else you can live with the /RESET only being driven at particular times, then of course you can use it drive /RESET (it need not be open collector). On the other hand, under these restrictive conditions you'd be better advised to swap out the 74LVC4245 for a simpler, one-way device anyway.

You mentioned that you have a 74HCT AND gate, if this is already present for some other reason, and is powered from 5V and you have spare gate(s) on it, then definitely it would be the preferred solution. Since its input threshold is about 1.2V, this will be approximately halfway between 0V and 3.3V, giving you fairly good noise immunity. It has been stated earlier that having a 75HCT input at 3.3V for extended periods of time might increase current draw. I don't think that's a problem. It will be more than 2V above threshold, so the gate won't be even partially on.

If you don't have the 74HCT AND gate available, and you don't want to add an extra package just for this, you still have some options. The transistor is a good option, you could use a 2N7002 FET, which would require zero extra components since you only want open-collector operation. The 3.3V might be a bit marginal to turn on the 2N7002, check the datasheet, but I think it would turn it on ENOUGH at any rate.

Another option would be simply to connect the 3.3V output directly to the 5V /RESET input. This might be slightly risky, but I believe it would work. When you're at 3.3V you'd be 0.8V above the nominal 2.5V threshold of the /RESET input. Although, you had better check if /RESET is a Schmitt trigger input. Often it is, so you can connect an RC network to it, instead of using a reset generator. This has a slow rise time requiring the Schmitt. If the /RESET input is Schmitt, then the high-going threshold might be around 3.3V which would be too marginal, so you'd need the HCT solution or the FET. Mind you, your actual "high" output would likely be 3.3V plus a diode drop, which may be just OK -- see next paragraph.

The risk you would have with the 3.3V driving the /RESET directly is that the /RESET is pulled up internally. So what would happen is either you'd have /RESET pulled low by your 3.3V device and all would be well. Or you'd have /RESET floating or pulled high (would not matter which) and the actual voltage on /RESET would be 3.3V plus a diode drop. Because the protection diode on your 3.3V /RESET output would prevent the voltage getting more than a diode drop above 3.3V, whereas the internal pull-up on /RESET in your 5V device would supply a trickle of current trying to make this happen. Since the internal pull-up would be about 50K in most 5V devices, this would not damage your 3.3V device at all.

A minor problem with this setup is that it will be difficult to power off the 3.3V device, since the 5V circuit will be trying to power it up through the /RESET output. If you weren't planning to power off the 3.3V device, then it could be OK. Anyway, it may be bad practice, even if it works.

cheers, Nick
 
The following users thanked this post: nockieboy

Offline Cervisia

  • Regular Contributor
  • *
  • Posts: 76
  • Country: 00
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #16 on: December 18, 2018, 07:48:51 am »
It has been stated earlier that having a 75HCT input at 3.3V for extended periods of time might increase current draw. I don't think that's a problem. It will be more than 2V above threshold, so the gate won't be even partially on.

TTL-compatible inputs are designed to handle a high level of about 3.5 V, but there is no guarantee that there are no cross currents. TI says:
Quote


In normal operation of a CMOS device, the effect previously described is not relevant, because the high and low logic levels supplied by the outputs of another CMOS device always ensure that the transistor in question turns off. However, if such devices are, for example, controlled by bipolar circuits, results are different. With a high logic level at the output, these supply a voltage that can only be >2.4 V. TTL-compatible CMOS devices, such as those from the SN74AHCT series, recognize such a level as being a high logic state. However, for previously stated reasons, under these conditions a supply current flows in the input stage (see Figure 6), which is significant, particularly with battery-operated equipment. To give system designers specific information about these phenomena, TTL-compatible CMOS-device data sheets have values for the ∆ICC parameter (see Table 1). ∆ICC specifies how much the supply current increases when the high logic level that is typically supplied by a TTL device is applied to one of its inputs. Data sheets show a considerably higher value than that given in Figure 6, but Figure 6 shows only the typical behavior of an AHC or AHCT device. As a result of process and parameter variations and to account for the worst case, values in the data sheets must be used.
« Last Edit: December 18, 2018, 07:52:08 am by Cervisia »
 
The following users thanked this post: nockieboy

Offline nick_d

  • Regular Contributor
  • *
  • Posts: 120
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #17 on: December 18, 2018, 09:02:29 am »
Quote
TTL-compatible inputs are designed to handle a high level of about 3.5 V, but there is no guarantee that there are no cross currents. TI says:
That is interesting. Thanks for the research. I didn't know that. I assumed that being 2V above the reduced threshold of a 74HCT device would have similar power consumption to being 2V above the normal threshold of a 74HC device, i.e. it would be fine, but I see now that that's not the case.

Having said that, bear in mind that 74A** devices are much more aggressive in this regard than 74HC devices. According to an NXP datasheet for a 74HCT00 device that I just looked at, the delta-Icc is only expected to be about 160uA at 25 deg C, it does increase significantly with temperature though. Interestingly there's no data for 74HC.

cheers, Nick
 

Offline nockieboy

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #18 on: December 18, 2018, 09:07:43 am »
The problem with the 74LVC4245 would be that the DIR and /OE pins are ganged to all 8 of the transceivers. So if you already have it set up in the direction that the 3.3V side is an input and the 5V side is an output, and you're either going to keep it set up this way permanently, or else you can live with the /RESET only being driven at particular times, then of course you can use it drive /RESET (it need not be open collector).

I actually have two 4245's - one permanently configured for input to the ESP32, the other for output to the relevant 5V devices it connects to.  If I can drive /RESET, /INT and /IEO from these then that is preferable as it means I'm using the entire chip and can free up the inverters for some blinkenlights.

On the other hand, under these restrictive conditions you'd be better advised to swap out the 74LVC4245 for a simpler, one-way device anyway.

Oh okay - if there's a more appropriate (read: cheaper) device I can use, I'm all ears.  This is a hobby project and I'm (at best) at hobby electronics level, so I'd appreciate any suggestions for suitable replacements.  My system for finding parts to solve a problem are shaky - I tend to Google for solutions, hence how I ended up with 4245's.

You mentioned that you have a 74HCT AND gate, if this is already present for some other reason, and is powered from 5V and you have spare gate(s) on it, then definitely it would be the preferred solution.

I did have... All the gates are now used in glue logic for the WAIT generator and data buffer enable.  I have got three spare inverters in a 74HCT04 though, but if I can use the remaining 4245 pins (or whatever replacement for it I find), then that frees up the inverters to drive a couple of LEDs, which I could do with. 

I'm on a budget with this design - to a lesser degree, cost and PCB space (it has to fit an existing form factor) but most critically, pin count - I've reached the 500-pin maximum that my copy of DipTrace allows on its user licence.  Whilst I'm in the process of familiarising myself with KiCAD, I haven't gotten any further than designing schematics on it - I know there's plenty of tutorials etc, but I don't want to have to invest hours of work learning how to design a specific PCB shape, size and component placement to meet the form factor I'm designing to for the sake of half a dozen pins, if that makes sense?  I'd kick DipTrace into touch completely if it weren't for the fact I find it far more user-friendly than KiCAD, but that's a conversation for another post.

Another option would be simply to connect the 3.3V output directly to the 5V /RESET input. This might be slightly risky, but I believe it would work.

I originally went down the route of a transistor pulling /RESET low when switched on because there's a number of other devices on the /RESET line - not sure that would make any difference to be honest, as there's still only one 4K7 pull-up, but I felt the need for something with some chops actively pulling the line low and connecting a 5V line directly to a 3v3 GPIO pin violated some subconscious sensibilities...  :o ;)

The risk you would have with the 3.3V driving the /RESET directly is that the /RESET is pulled up internally.

Is it? I have an external pull-up on the /RESET line, didn't know it had an internal pull-up?  Have just checked the datasheet and can find no mention of one either.  It's a Z84C0008, if that matters?

Quote
TTL-compatible inputs are designed to handle a high level of about 3.5 V, but there is no guarantee that there are no cross currents. TI says:
That is interesting. Thanks for the research. I didn't know that. I assumed that being 2V above the reduced threshold of a 74HCT device would have similar power consumption to being 2V above the normal threshold of a 74HC device, i.e. it would be fine, but I see now that that's not the case.

Having said that, bear in mind that 74A** devices are much more aggressive in this regard than 74HC devices. According to an NXP datasheet for a 74HCT00 device that I just looked at, the delta-Icc is only expected to be about 160uA at 25 deg C, it does increase significantly with temperature though. Interestingly there's no data for 74HC.

cheers, Nick

Thanks Cervisia - though I'm not sure I can read the implications as well as Nick has done?

I'm using 74HCT parts almost exclusively for the glue logic, with the exception of a 74F part in the /WAIT generator, but this is interfaced via a 4245 to the ESP32.
 

Offline Cervisia

  • Regular Contributor
  • *
  • Posts: 76
  • Country: 00
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #19 on: December 18, 2018, 10:00:55 am »
According to an NXP datasheet for a 74HCT00 device that I just looked at, the delta-Icc is only expected to be about 160uA at 25 deg C

That 150 µA is a typical value. In the chart above, AHCT might be even lower at 2.9 V. But the worst-case maximum is indeed higher.

Anyway, even the worst-case *HCT cross currents are lower than what TTL devices would use during normal operation.  ^-^

Quote
74A** devices are much more aggressive in this regard than 74HC devices.

Please note that AC and AHC are quite different families: AC is as fast as possible, while AHC has deliberately weak output drivers to prevent the switching noise from being higher than HC.

Quote
Interestingly there's no data for 74HC.

HC is not meant to be driven by TTL-level signals.
 

Offline nick_d

  • Regular Contributor
  • *
  • Posts: 120
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #20 on: December 18, 2018, 10:05:47 am »
Yes, you can use the remaining 74LVC4245 pins for this, provided they're going in the right direction -- if you have spares in the 3.3V->5V direction, then absolutely you can use them to drive the /RESET and other pins.

However, I checked the datasheet for the device you specified, and there is a significant simplification that has been missed so far, see here:
https://au.mouser.com/Search/Refine.aspx?Keyword=Z84C0008&FS=True&Tb=datasheets
This device has HCT inputs, see page 34 "DC CHARACTERISTICS (Z84C00/CMOS Z80 CPU)", a low level input is up to 0.8V and a high level input is 2.0V or more. The reason why the device has HCT inputs is because it's designed as an almost drop-in replacement for the earlier NMOS Z80.

So the buffering in the 3.3V -> 5V direction is completely unnecessary, provided you're willing to live with a small extra current draw as has been discussed for the 74HCT00. Although I didn't dig deeply for any delta Icc, you can take it that all characteristics will be similar to an HCT gate.

You're right, there's no pull-up resistor on /RESET, I thought you were saying there was one, I hadn't checked this. And the /RESET is not Schmitt. As far as I can see it also doesn't require open-collector drive. So, direct drive all 5V inputs from 3.3V outputs, including /RESET. This eliminates the transceiver in the 3.3V->5V direction. Although this may seem offensive, and will cost a slight power draw, it is MUCH simpler.

Now as to the 5V->3.3V conversion. One simple approach is a 1k resistor, but I do not really recommend that. Like I said earlier, it will make it difficult to power off the 3.3V device since you'll have potentially quite a lot of 1k resistors trying to power it up through the protection diodes of its inputs. The ideal way is with an octal buffer powered from 3.3V, which has 5V-tolerant inputs. What you want is a 74AHC541. See here:
https://assets.nexperia.com/documents/data-sheet/74AHC_AHCT541.pdf
Referring to page 5, it says that Vcc can be up to 5.5V, Vi can be up to 5.5V (indepently of Vcc) and Vo can be up to Vcc. Perfect!

This is a cool project, I am learning a lot from doing this research :) By the way, I am a Z80 guy, I have plenty of vintage Z80 chips and Z80 peripherals that I bought from Ebay to tinker with. I haven't done much with them but I did a lot with Z180s commercially. Recently I bought some 3.3V Z8L180s that will go up to 20 MHz (if I recall correctly), and I was thinking of making a 3.3V Z180 system driving a graphic LCD.

Credit to whoever wrote this page: http://forum.fritzing.org/t/74x541-octal-tristate-buffer-level-translator/5141

cheers, Nick
 

Offline Cervisia

  • Regular Contributor
  • *
  • Posts: 76
  • Country: 00
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #21 on: December 18, 2018, 10:09:22 am »
I'm not sure I can read the implications as well as Nick has done?

We were talking about theoretical limits. In practice, HCT will work fine (because it was designed for such voltage levels).

When you're driving an HCT input directly with 3.3 V, the current will be approximately zero. Even if you get a chip with marginal parameters and run it at extreme temperatures, the current will be harmless, and probably not noticeable when measuring the entire circuit.
 
The following users thanked this post: nockieboy

Offline nockieboy

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #22 on: December 18, 2018, 11:15:10 am »
As far as I can see it also doesn't require open-collector drive. So, direct drive all 5V inputs from 3.3V outputs, including /RESET. This eliminates the transceiver in the 3.3V->5V direction. Although this may seem offensive, and will cost a slight power draw, it is MUCH simpler.

More than happy to live with the extra current draw - the device is powered from USB or external power supply, so I don't have to worry about maximising the life of a battery supply (just yet).

The only thing I can see being a possible sticking point is that the ESP32 can also be used to provide the system clock to the Z80 and its peripherals.  It uses two PWM GPIOs, one for the main system clock (which can be varied under software control) and the other for specific peripherals.  I have a hard time deciphering some of the technical speak and charts in datasheets, but I'm guessing that the ESP32 won't be able to produce a suitable clock signal at 3.3v for the Z80?  This will still need to go through some form of level translator? 

I guess I could use a TXB0104 just for the clock outputs, as I'm using one of those for the SPI signal, but that leads me on to another thought - if the ESP32 can drive the Z80 at 3.3v acceptably, do I need to bother with voltage translations for the two I/O extenders? I've got two MCP23S17s, powered at 5V as they interface directly with the data, control and address buses of the Z80, so they will be expecting 5V SPI signals...

Now as to the 5V->3.3V conversion. [...] The ideal way is with an octal buffer powered from 3.3V, which has 5V-tolerant inputs. What you want is a 74AHC541. See here:
https://assets.nexperia.com/documents/data-sheet/74AHC_AHCT541.pdf
Referring to page 5, it says that Vcc can be up to 5.5V, Vi can be up to 5.5V (indepently of Vcc) and Vo can be up to Vcc. Perfect!

Okay, cool. Does it have to be AHCT though?  Would HCT suffice as I might actually have one or two HCT541's in my box of tricks?  The Z80 is held WAITing while the ESP32 does its stuff, so what's a few nanoseconds between friends?

This is a cool project, I am learning a lot from doing this research :)

Haha, thanks! I've been working on the whole thing for about two years now, on and off.  I'd get a website/blog set up if I thought anyone would be interested, detailing my journey from complete and utter electronics luddite with a burning interest in 80's computers (when I started with my first computer) to where I am now (an electronics idiot), but everyone else seems to have beaten me to it.  Just about everything I now know about electronics and 8-bit computer design is thanks primarily to this forum and some fantastically helpful people here (and Grant Searle's website, which kicked the whole thing off for me).

Currently I have a working Z80-based computer that has a custom-written monitor ROM (learning Z80 assembly 30-40 years late, but it's fun!), runs CP/M 2.2 and 3.0 from CompactFlash, takes up to 4MB of memory, plays authentic 80's chiptunes via the AY-8910 PSG and with plans to IoT-enable it (with a web-based console) via the ESP32 and eventually develop a graphics card for it so I can run it as a completely standalone system.

Have a look here:

https://youtu.be/YjoUeCCG7Pc 

It's a small video I did back in the summer on a 3D model of the computer and simulation I put together to test it all out.  Currently I only have the CPU, memory and serial cards in proper PCB form, the CF card is interfaced via a breadboard and the rest doesn't exist yet (though it did originally, all on one beast of a breadboard, but it was so unreliable I had to move to PCB-production as the prototype died one day and refused to work again!)

By the way, I am a Z80 guy, I have plenty of vintage Z80 chips and Z80 peripherals that I bought from Ebay to tinker with. I haven't done much with them but I did a lot with Z180s commercially. Recently I bought some 3.3V Z8L180s that will go up to 20 MHz (if I recall correctly), and I was thinking of making a 3.3V Z180 system driving a graphic LCD.

Well, maybe this will motivate you again?  ;D
 

Offline Cervisia

  • Regular Contributor
  • *
  • Posts: 76
  • Country: 00
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #23 on: December 18, 2018, 12:56:39 pm »
Does it have to be AHCT though?  Would HCT suffice as I might actually have one or two HCT541's in my box of tricks?

This works only if the device has overvoltage-tolerant inputs (see page 18 of NXP's Logic Selection Guide: https://www.digikey.com/Site/Global/Layouts/DownloadPdf.ashx?pdfUrl=755DA3330E4E422EAEF6B9FF5092A9CB).
Only AHCT has them.
With HCT, you would need to add a current-limiting resistor (see the bottom of page 23), which would prevent you from using fast signals.
 

Offline nockieboy

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: Best way to drive a 5V TTL line with a 3v3 GPIO?
« Reply #24 on: December 18, 2018, 01:13:27 pm »
Does it have to be AHCT though?  Would HCT suffice as I might actually have one or two HCT541's in my box of tricks?

This works only if the device has overvoltage-tolerant inputs (see page 18 of NXP's Logic Selection Guide: https://www.digikey.com/Site/Global/Layouts/DownloadPdf.ashx?pdfUrl=755DA3330E4E422EAEF6B9FF5092A9CB).
Only AHCT has them.
With HCT, you would need to add a current-limiting resistor (see the bottom of page 23), which would prevent you from using fast signals.

Ah, thanks for that Cervisia - was hoping I could use existing parts but AHCT541's don't seem too expensive, will add them to my BoM.  :-+
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf