Author Topic: Multiplexer suggestion for digital signals  (Read 966 times)

0 Members and 1 Guest are viewing this topic.

Offline girishjiTopic starter

  • Contributor
  • Posts: 42
  • Country: pl
    • girish
Multiplexer suggestion for digital signals
« on: December 08, 2022, 08:25:56 pm »
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.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9886
  • Country: us
Re: Multiplexer suggestion for digital signals
« Reply #1 on: December 08, 2022, 08:35:05 pm »
 
The following users thanked this post: girishji

Offline girishjiTopic starter

  • Contributor
  • Posts: 42
  • Country: pl
    • girish
Re: Multiplexer suggestion for digital signals
« Reply #2 on: December 09, 2022, 08:41:59 am »
Thank you, this has what I was looking for.
 

Offline paulca

  • Super Contributor
  • ***
  • Posts: 4003
  • Country: gb
Re: Multiplexer suggestion for digital signals
« Reply #3 on: December 09, 2022, 11:19:12 am »
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/SN74HC595

You 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.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 
The following users thanked this post: girishji

Offline Terry Bites

  • Super Contributor
  • ***
  • Posts: 2357
  • Country: gb
  • Recovering Electrical Engineer
Re: Multiplexer suggestion for digital signals
« Reply #4 on: December 09, 2022, 02:55:43 pm »
You dont need muxes if you use tristate logic.
 

Offline girishjiTopic starter

  • Contributor
  • Posts: 42
  • Country: pl
    • girish
Re: Multiplexer suggestion for digital signals
« Reply #5 on: December 09, 2022, 11:08:26 pm »
I tested 74hc595 register, SIPO.
Non-spi: writing to register took 12.3 us per write of 8 bits
SPI: took 3 us, SPI frequency set to 14Mhz
I 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.












 

Offline girishjiTopic starter

  • Contributor
  • Posts: 42
  • Country: pl
    • girish
Re: Multiplexer suggestion for digital signals
« Reply #6 on: December 09, 2022, 11:10:15 pm »
You dont need muxes if you use tristate logic.
I am reading voltage from a phototransistor. No tristate logic.
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14082
  • Country: de
Re: Multiplexer suggestion for digital signals
« Reply #7 on: December 10, 2022, 09:55:01 am »
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.
 
The following users thanked this post: girishji

Offline girishjiTopic starter

  • Contributor
  • Posts: 42
  • Country: pl
    • girish
Re: Multiplexer suggestion for digital signals
« Reply #8 on: December 10, 2022, 11:24:15 am »
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.
« Last Edit: December 10, 2022, 11:27:43 am by girishji »
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14082
  • Country: de
Re: Multiplexer suggestion for digital signals
« Reply #9 on: December 10, 2022, 01:29:28 pm »
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.
 

Offline girishjiTopic starter

  • Contributor
  • Posts: 42
  • Country: pl
    • girish
Re: Multiplexer suggestion for digital signals
« Reply #10 on: December 10, 2022, 03:31:09 pm »
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?

 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14082
  • Country: de
Re: Multiplexer suggestion for digital signals
« Reply #11 on: December 10, 2022, 04:04:11 pm »
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).
 
The following users thanked this post: girishji

Offline girishjiTopic starter

  • Contributor
  • Posts: 42
  • Country: pl
    • girish
Re: Multiplexer suggestion for digital signals
« Reply #12 on: December 10, 2022, 10:00:33 pm »
Thank you for the circuit diagram.
« Last Edit: January 18, 2023, 10:42:29 am by girishji »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf