CS Pins expander 74HC154 or MPC23S17 ?

Status
Not open for further replies.

Anoat

Active member
Good morning all,

I am writing to you because I have an existential question ...

I use a teensy 3.6 which controls 25 digital potentiometers in SPI. Unfortunately, I do not have enough CS pins available.

After much research I have two solutions at my fingertips, and I don't know which is the best one to give me my 25 CS pins.

The first solution is to use two 74hc154 logic demultiplexers.


The second solution is to use two MCP23S17 expander.

Which do you think is the best? If you have other solutions I take them with pleasure

Thank you for your help Jérémy
 
Anoat:

You might also take a look at the 74HC4067. It is usually listed as an "analog MUX", but it passes digital signals bidirectionally as well. For 5 pins (common in/out + 4 address decoders), you get the equivalent of 16 pins. I have successfully used 74HC4067 breakout boards (one primary MUX & 10 cascaded secondary MUXs) on my TeensyMIDIPolySynth to manage 48 pots & 42 pushbuttons. V ery easy to use, very efficient, & very effective.

Good luck & have fun !!

Mark J Culross
KD5RXT
 
Thank you for your answer,
I also use mux4067 to manage my analog pots from my midi controller.

However in this case it is a digital potentiometer. I'm looking for a way to expand my CS pin (chip select) to be able to communicate in SPI individually with each of the digital potentiometer ( i have 23 digitpot).

Initially I wanted to use a 4067 mux (as you suggest) however after having consulted this post (https://forum.pjrc.com/threads/34666-16-SPI-devices-Is-it-possible), the use MCP23S17 or 74LS138 (decoder) seems more suitable.

I don't know which one to choose, both are good. To tell the truth, I already have in my circuit 3 MCP23S17 (controlled themselves in SPI) which control switches, I still have pins available, I just need to add one.

However I wonder if the decoder would not be faster?
 
Anoat:

My experience with the 74HC4067 was good. It may not be the best choice of the three (only you can decide what "best" means for your application), but it will certainly work. If you do use it, make sure to allow for "settling time" after writing out the address & activating the enable pin. I've seen references on the forum indicating 50 microseconds as a recommendation, but in my TeensyMIDIPolySynth project, I found that 15 microseconds worked reliably.
 
74hc154 is the better solution. It has advantages: only 5 pins and an inverter (single gate IC or trasistor) can serve 32 CS endpoints. Digital signal for digital inputs on the devices.

An alternative could be to daisy-chain the SPI devices. This is normally possible, if they have a MISO pin. Like so:
SPI_three_slaves_daisy_chained.svg

See https://en.wikipedia.org/wiki/Serial_Peripheral_Interface
So which kind of digital pots you use?
 
Also, what I forgot to mention, the 74hc4067 has a long propagattion delay and transition time, while the 74hc154 is faster by about 8 to 10 times.
 
I use 23 digipots MCP41HV31.

Finally I was able to recover 23 digital pins on the teensy.

That's a lot of track! Now the question is "Demux or not demux".

Is there any advantage to using Demux or directly using teensy pins?
 
Is there any advantage to using Demux or directly using teensy pins?

For what you've told us I'd say there's no practical advantage of one over the other.

Even something hybrid like one 74hc154 controlling 16 of the pots and teensy pins controlling the remaining 9 would be pretty simple to handle with a case statement or handful of if/thens.
 
I don't know how fast you need/expect to sample your digipots. On the subject of propagation delay & transition time, in my TeensyMIDIPolySynth project, I am *reading* 48 pots & *reading* 42 pushbuttons, as well as currently *writing* 42 LEDs (this method of writing the LEDs will change for other reasons), all in a round-robin fashion (read a pot, read a pushbutton, write an LED, read the next pot, read the next pushbutton, write the next LED, etc.). For reference, I have measured that I am able to sample each pot every 40-50 milliseconds. I would guess that the *reads*, especially the calls to analogRead() used for the pots, are MUCH MUCH slower than a corresponding digitalWrite() that you would use to drive your CS pins. Again, how fast do you need to sample your digipots ??

As for your "Is there any advantage..." question, conserving the pins now, especially if it does not adversely affect the speed/useability of your project, might prove useful as your design evolves & you find more future functionality that requires more pins. Like an umbrella: better to have them & not need them, than to need them & not have them !!

Good luck & have fun !!

Mark J Culross
KD5RXT
 
Status
Not open for further replies.
Back
Top