Chip Select

Hey guys,

In my latest project, I'm using the following chips:

CD74HCT4051 multiplexer:

TPIC6B595 power shift register:

But I'm also interested in adding sound to my project, so I was thinking about using this dac:

MCP4921 DAC:

Here's my question.

These three chips seem to use completely different methods of communicating with the Arduino. Yet all three seem to need only three pins to communicate with them, and all three seem to have a forth pin which can be used to enable or disable the chip.

The multiplexer has E which is active low. Pulling it low enables the inputs/outputs.

The shift register has G which is also active low. I believe this equates to OE or Output Enable in the http://www.arduino.cc/en/Tutorial/ShiftOut example. The data sheet indicates that pulling G low enables the chip, while pulling it high erases the input buffer and disables the outputs.

Lastly, the DAC has CS or Chip Select, which is again active low. Pulling it down enables the serial clock and data functions.

Regarding the inputs...

On the multiplexer, the three inputs are basicaly used as a binary number to select the output which is active. There is a fourth line which is needed to read the output, but for the purpouses of this discussion, I don't think that's important.

On the shift register, you've got the data pin, the clock pin, and the latch pin.

And on the DAC, you've got the same thing, a data pin, a clock pin, and a latch pin. Okay my bad, there aren't three different setups here, I saw SPI mentioned in the DAC docs but apparently the clock is merely "SPI compatible", and there's no return data line as in an SPI setup.

With that out of the way, my question is this:

Could I theoretically hook all three of these chips up to the Arduino with just seven pins?

Three to select which chip I want to enable, another three which would be used either to select the multiplexer input, or to send data to the shift register or dac, and one more to read data from the multiplexer?

I know the dac would require some high speed data output, but the multiplexer would only need to be read once on bootup as that's used to read some dip switches. And the the shift register is used to run a few leds and won't need to be updated more than 30-60 times a second.

And even if the dac does need its own dedicated lines, could I still do this with the multiplexer and the shift register? If I have both chips seperate, then I'd be using 7 pins, but I could save a pin if I tied their data lines together and used the chip select stuff. Not much, but a pin is a pin.

What do you think?

Yes that is what chip select pins are designed for. In a conventional computer system you have a data bus and memory bus and hang everything on the same wires on the bus and just enable the chips you need from the chip enable lines.

One note of caution I don't see the 4051 being useful as it is the outputs of the chip you disable and if you do that they float, that is they don't hold there value when not enabled, that might not be what you want.

When you say outputs, you mean the eight input/outputs I can select between, right?

The multiplexer is being used to read a dip switch. So the switches are connected to ground and to the multiplexer's input/output pins, and the common pin goes to an input pin on the Arduino which has its internal pull up turned on.

The three select lines which choose which input/outputgoes to common are the ones which would be shared between the other two chips.

If disabling the chip causes the inputs/outputs to float... then what would that mean? That the common pin would gloat as well? Since I won't be reading it, that wouldn't matter. And besides, it would be pulled up.

Or are you imaginging that I have something connected to the input/outputs which might blink or corrupt something else if the pins are allowed to float? I don't see an issue there as well since they're just connected to switches.

Also, now that I think about it, I wonder if I would need to use the 4051's select line at all? Let's say I don't disable the input/outputs? What will happen if I, say access the shift register? The 4051 will jump rapidly between different input/outputs, right? But since I know that I'm not reading them at that time precisely because I'm accssing the shift register, it doesn't matter. It's not like I'm reading the common pin on it, or that toggling the outputs is going to create any visible display, since all it is hooked up to is dip switches.

My only concern here is if this would have some effect on the shift register, but I don't have any idea if that might be the case.

The lines of a 4051 would be disabled, thinking about it this is probably the best thing to do. What could happen is that if on the dip switch side you have a switch connected to ground and that switch was selected through some combination of the input select lines the the ground would in effect be transfers to the common I/O of the 4051. If that goes only to an arduino pin it doesn't matter. However if you are sharing that pin then you do need to disable it.

Okay... I would not be sharing the common pin in this circuit, so I guess I don't need to disable it, but that's good to know. I suppose I might eventually want to run multiple multiplexers and connect that same input pin to more than one.