Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: CS Pins expander 74HC154 or MPC23S17 ?

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Posts
    14

    CS Pins expander 74HC154 or MPC23S17 ?

    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

  2. #2
    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

  3. #3
    Junior Member
    Join Date
    Nov 2019
    Posts
    14
    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...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?

  4. #4
    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.

  5. #5
    Member
    Join Date
    Jan 2020
    Location
    Italy
    Posts
    89
    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:
    See https://en.wikipedia.org/wiki/Serial...eral_Interface
    So which kind of digital pots you use?

  6. #6
    Member
    Join Date
    Jan 2020
    Location
    Italy
    Posts
    89
    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.

  7. #7
    Junior Member
    Join Date
    Nov 2019
    Posts
    14
    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?

  8. #8
    Senior Member
    Join Date
    Jun 2013
    Location
    Torrance CA
    Posts
    415
    Quote Originally Posted by Anoat View Post
    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.

  9. #9
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •