Can I use a 74HCT157 to multiplex a serial signal? - Page 1
Forum section: electronics / projects

author: elanstra
author_rank: Newbie
timestamp: September 14, 2023, 10:46:24 am
content: On my homebrew 8-bit computer I use a a Zilog SIO/2 that gives me two independent full-duplex serial I/O channels. Now I came to a point that I need a third channel, and rather than adding another SIO/2 (or similar chip) and the corresponding coding, I thought about multiplexing the channel A so that I can free up the channel B.I thought about using a 74HCT157 and I built a small circuit, but when I connect it to the channel A of the SIO/2 it doesn't seem to work.I'm wondering if the 74HCT157 is too slow or maybe I'm even trying something too crazy?From the datasheet of the 74HCT157 I think I understood that the speed from input to output is 46nS when powered at 5.5V, which is what I use, or 52nS when 4.5V.The SIO/2 datasheet has tons of tables, so I'm not sure if I'm reading it correctly, but all seem to be above 80nSAny suggestions would be very appreciated. Thanks a lot in advance.

author: Benta
author_rank: Super Contributor
timestamp: September 14, 2023, 12:09:29 pm
content: Well, you have a mixture of inputs and outputs from the SIO, so you'll need a bidirectional multiplexer (which the HCT157 isn't).Simplest would be to use an analog multiplexer like the 74HC4053 or CD4053/MC14053.

author: elanstra
author_rank: Newbie
timestamp: September 14, 2023, 01:16:21 pm
content: Quote from: Benta on September 14, 2023, 12:09:29 pmThanks Benta. You're right about the SIO, but not in my case. I don't use hardware flow control (CTS/RTS). Actually, the only signals used are TX and RX. Sorry, maybe I should have mentioned that before.I was thinking if the problem could be that the SIO signals are 3-state? I didn't find anything in the documentation if it is or not. I'll try the same circuit with a 74HCT257, which is pin compatible with the 74HCT157, but has 3-state outputs.

author: Benta
author_rank: Super Contributor
timestamp: September 14, 2023, 01:36:06 pm
content: Quote from: elanstra on September 14, 2023, 01:16:21 pmWell, one's an input and the other's an output. My answer still stands.

author: Ian.M
author_rank: Super Contributor
timestamp: September 14, 2023, 01:40:06 pm
content: This generally isn't a good solution without flow control - consider what happens if the mux switches in the middle of a character. Exception: if both channels serve devices that only respond when asked, the max. delay to the end of the response is known and predictable, and you *never* need to talk to one in the middle of a response from the other.If you have flow control you can request for the received data to pause, wait a peripheral device dependent guard time for the data stream to actually stop, and only then switch the mux, followed by requesting the other input data stream to resume.In all cases, deselected outputs must idle high. If you use an analog switch it will need pullups on the two pins the TX line is switched to.

author: elanstra
author_rank: Newbie
timestamp: September 14, 2023, 01:58:32 pm
content: Quote from: Ian.M on September 14, 2023, 01:40:06 pmMaybe a bit of explanation from my side is needed:The RX channel A receives data from a micro-controller that send bytes as keys are pressed on a keyboard. The TX of that channel sends bytes to a micro-controller that outputs a VGA signal. So this channel A is basically the keyboard input, screen output of my computer.KBD -> SIO RX Channel ASIO TX Channel A -> VGAThe channel B is currently connected (both TX and RX) to a micro-controller (called ASMDC) that controls other devices (RTC, HDD and FDD).ASMDC TX -> SIO RX Channel BSIO TX Channel B -> ASMDC RXThere is never the case that the computer will talk at the same time with the KBD/VGA and the ASMDC. Hence my idea of multiplexing channel A, and have ASMDC connected to A.My idea is that the mux is switched "manually" by code. When SIO is talking to device KBD/VGA, the A/B signal is low. When is talking to ASMDC is high. The A/B signal is connected to a 74HCT138 line decoder that I use to switch the different components of the computer (VDP, PSG, ROM paging, joysticks).I know that without knowing all the details it can be difficult to imagine. So thanks for your answers already.

author: elanstra
author_rank: Newbie
timestamp: September 14, 2023, 02:00:02 pm
content: Quote from: Benta on September 14, 2023, 01:36:06 pmSee my post above (reply to Ian.M) where I described a bit the connection. I don't think one input and the other output is an issue, is just routing signals through a switch, isn't it?

author: Ian.M
author_rank: Super Contributor
timestamp: September 14, 2023, 03:02:07 pm
content: Do you signal the Kbd/VGA to poll it for keypresses or does it send them when the user hits the key? If the latter, then no you cant mux it as you'll loose key presses while talking to the ASMDC, and may even get corrupted ones if a key is pressed just before switching back. The fix if you can modify its code is to add a handshake line to tell it to queue keypresses while its deselected. Assert handshake line and wait for the worst case keyboard message time for any pending keypresses to come in before switching the mux to the ASMDC.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 14, 2023, 03:08:10 pm
content: Quote from: elanstra on September 14, 2023, 10:46:24 amThat is rather unusual, but as long as you don't try to use the multiplexed channels at the same time, it should work.Mux speed is of no issue there. Attach a schematic with the SIO/MUX/RS232 buffers, to see what you added and where.

author: macboy
author_rank: Super Contributor
timestamp: September 14, 2023, 03:16:31 pm
content: Quote from: elanstra on September 14, 2023, 02:00:02 pmYou are correct. You would only need a bidirectional MUX if any one line can carry an input or output. You have different lines which are each always either inputs or outputs. You just need to route the signals accordingly through the MUX.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: September 14, 2023, 04:04:39 pm
content: As long as your serial signals are on TTL level, then you can work with TTL IC's. A Zilog (I assume Z80) is so slow that 74HC is plenty fast, but TTL can't work with the +/- 12V signal levels on the old fashioned RS232 connector.

author: Benta
author_rank: Super Contributor
timestamp: September 14, 2023, 06:18:30 pm
content: Perhaps if the OP had avoided terms like "full-duplex" for something that now turns out not to be, we wouldn't have wasted our time.Graphics are also a great tool when posting questions.But OK, we've nothing else to do, I guess.

author: elanstra
author_rank: Newbie
timestamp: September 15, 2023, 05:49:57 am
content: Thanks a lot everybody for your answers and suggestions. And apologies if I wasted anybody's time. I'll now continue research on my own.Benta,full-duplex serial I/O channelsis exactly the wording you'll find in any Zilog SIO manual, I didn't make it up. I'll let you figure out yourself why it's called full-duplex.