Hi, I'm starting on a project that will be reading in 40 senors. They are attached to the strings of a piano, so I will need to be able to respond to them very quickly
How quickly, exactly? What seems fast to a person (1/100 of a second) is ages to a microcontroller running at 16Mhz.
What kind of data are you getting? Just a digital bit, or do you need an analog value?
My first instinct is to use a multiplexer and have it be interrupt driven, but a friend seems quite convinced that I should use a shift register.
Pro's of using a multiplexer:
- yes, it is faster than a serial shift register
- there are analog versions
con's of using a multiplexer:
- uses more pins (for 40 sensors you'd need at least 7 pins).
- you can only get data from 1 sensor at a time.
Pro's of using a shift register:
- they can be daisy chained for a large number of sensors
- only uses 3 pins, no matter how many bits
- you can get data for multiple bits at the same time
con's of using a shift register:
- digital (1 bit per sensor) only
- takes a little more work to get the data (slower)
FWIW, I don't think a shift register is that much slower than a multiplexer on a human reaction time scale. It's only an issue if microseconds count.