Multiplexer suggestion for digital signals - Page 1
Forum section: electronics / beginners

author: girishji
author_rank: Contributor
timestamp: December 08, 2022, 08:25:56 pm
content: I am trying to connect 2n (2 banks of n each) inputs to n GPIO pins of an mcu. I want 2 inputs routed to 1 GPIO pin through a 2:1 mux. Mcu could be any 3v3 ones like rp2040 or st32xx. For digital signals what mux to use? It needs to be low power and fast switching. Say under a microsecond switching time.There are IO expanders but they use I2C and slow.

author: rstofer
author_rank: Super Contributor
timestamp: December 08, 2022, 08:35:05 pm
content: Quad 2-Input MUX for 3.3-5Vhttps://assets.nexperia.com/documents/data-sheet/74AHC_AHCT257.pdf

author: girishji
author_rank: Contributor
timestamp: December 09, 2022, 08:41:59 am
content: Thank you, this has what I was looking for.

author: paulca
author_rank: Super Contributor
timestamp: December 09, 2022, 11:19:12 am
content: A 74H595 shift register is what I have used previously. I "believe" they are bidirectional. There are 16 bit ones and maybe 32bit ones as well.The basic idea is you put your individual digital states into a number with each taking a bit value like 1, 2, 4, 8.... Expressions like CH1 & CH2 & CH3.Then you "shift" that out the GPIO port as a series of Hi/Low pulsing a clock GPIO each one. When you are ready, you hit the pin to transfer what was on the shift register into the output register. Granted that's 3 GPIOs for 8/16/24/32. Current is limited too depending on which shift register you use you can be limited to 7mA per pin and likely the same as the MCU and 40mA over all. Higher power output multiplexers do exist of course.The below is a jelly bean, cheap and easy chip.https://www.ti.com/product/SN74HC595You mention fast switching... the 74H series might be good up to 3Mhz something like that. So it won't do stuff like I2S or I2C at any practically rate.

author: Terry Bites
author_rank: Super Contributor
timestamp: December 09, 2022, 02:55:43 pm
content: You dont need muxes if you use tristate logic.

author: girishji
author_rank: Contributor
timestamp: December 09, 2022, 11:08:26 pm
content: I tested 74hc595 register, SIPO.Non-spi: writing to register took 12.3 us per write of 8 bitsSPI: took 3 us, SPI frequency set to 14MhzI think PISO registers will perform similar, and this is what I need.I am looking for something faster. GPIO pins can read in under 1us, and since I am using rp2040 I have 30 GPIO available and I can read them all at once. I need to read 24 bits. With shift register it will take 9us.

author: girishji
author_rank: Contributor
timestamp: December 09, 2022, 11:10:15 pm
content: Quote from: Terry Bites on December 09, 2022, 02:55:43 pmI am reading voltage from a phototransistor. No tristate logic.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 10, 2022, 09:55:01 am
content: Phototransistors are usually relatively slow, especially if the operate all the way to saturation to give a clean logic signal. One may have to look at the signals first with scope to see what signal is there to start with. This may very well be not the full swing and may show delays and slow trasistions. The way a phototransistor is operated (e.g. load resistor, signal level) effects the speed quite a bit . For high speed one may want extra amplification before getting a logic level.The 74HC595 shift registers and similar are good for adding extra outputs, expecially those than don't change very fast / often. There are other similar chips (e.g. 74HC165) for inputs via shift registers, but this is still relatively slow. With a 14 MHz SPI clock it should still be a bit faster than 9 µs for 24 bits, more like 24/14 µs + maybe 1 µs overhead for the start and gaps between bytes. So more like in the 3 µs range.For fast scanning of many channels it would be better to use many of the IO-pins (e.g. 8 or 16) and than switch between only a few signals per IO pin.So the 74xx257 (many logic sereis to chase from like HC, LV,LVC,AC,AHC) is a good choice. If one does not need the output enable there is also the 74xx157.

author: girishji
author_rank: Contributor
timestamp: December 10, 2022, 11:24:15 am
content: Is the difference b/w 74xx157 and 74xx257 an extra output enable pin? I can use 74xx157.Phototransistors are indeed slow. This is why I want everything else to be fast. I tried various load resistors and found the optimum. I was not aware of extra amplification since transistor inside PT does the amplification. Do you have anything specific in mind? I looked into using photodiodes (they are fast, nanosecond rise time but nanoamp current), but amplification part I am not an expert in (esp. removing noise).Regarding SPI I measured sending 5 bytes (as array) results in 8.3 us; for 9 bytes it is 13.4 us. I am using arduino and rp2040, where code executes from flash, not RAM (although this can be changed). maybe bitbanging using PIO or even using their excellent SDK will get to 1 clock cycle/bit.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 10, 2022, 01:29:28 pm
content: The missing tristate function is the main difference from the 257 to 157. An extra alternative could help in the current times of supply problems. If the 257 is cheaper or better to get one can still use the 257.Nomally SPI should be handled by the hardware and I was expecting only 3 byte - with a 32 bit µC it may end up to need 32 bit. The problem could be the support by the SDK.For the amplification a simple version is a transistor in base configuration. This way the phototraistor sees an less variable voltage and no saturation. It may still need extra voltage headroom (e.g. 4-5 V supply to generate a 3 V signal with a PNP transistor with the base at some 2.5 V). Often the small signal transistors are faster than phototransistors.

author: girishji
author_rank: Contributor
timestamp: December 10, 2022, 03:31:09 pm
content: Can you clarify amplifier circuit?It is a common-base amplifier with PT attached at E-B as 'input' with a load resistor, say R1. C-B is connected to another resistor (from which output voltage is taken), say R2. Voltage gain is the ratio of these two resistors.Connect PT to 3v3 through R1. But it will not generate any voltage drop until light is incident on it. Say it develops 0.2v at E-B junction, then C-B junction will have (say) 2v (10x amplification).Does this sound correct?

author: Kleinstein
author_rank: Super Contributor
timestamp: December 10, 2022, 04:04:11 pm
content: The common base amplifier is used with only 1 resistor and the phototransistor acting as a current source. So it has a transconductance gain the R1. The difference is that the speed is not from the phototransistor itself but mainly from the usually faster small signal transistor (e.g. an 2N3906).

author: girishji
author_rank: Contributor
timestamp: December 10, 2022, 10:00:33 pm
content: Thank you for the circuit diagram.