The maximum ADC sample rate for the '328p, using the default prescaler of 128, is given as roughly 10000 samples per second. Maybe I've missed it, but I can't see whether that is the total rate for all inputs being sampled, or if each multiplexed input can sustain that rate?
In any case, if I only intend to use one analog input (say A0), is there a way to disable muxing and select which one input is active, perhaps using the ADMUX
register?
1 Answer 1
With the default prescaler of 128, the maximum sample rate is
9615 samples/s (16 MHz/128/13). It can be achieved by setting the ADC to
"free running mode". Running analogRead()
in a tight loop, the maximum
rate is 8929 S/s (16 MHz/128/14). As there is only one ADC, this is the
total rate for all inputs being sampled.
is there a way to disable muxing and select which one input is active
The MUX is a physical device that sits between the inputs and the ADC. You cannot physically remove it. What do you mean by "disable"? You can, of course, keep the channel selection constant.
I assumed that the muxer looks at each input in turn, but it may be that if I only ever read from channel 0, then the mux will never select another channel?
Indeed. You can think of the MUX as a 1P11T (one pole, eleven throw) switch. Each time you change the MUX setting, it moves to a different channel. If you don't change its setting, it doesn't move.
-
Maybe I'm over-thinking it. I assumed that the muxer looks at each input in turn, but it may be that if I only ever read from channel 0, then the mux will never select another channel?Jim Mack– Jim Mack2025年05月07日 22:17:31 +00:00Commented May 7 at 22:17
-
@Jim Mack Roughly speaking, multiplexing is setting a static route between a pin and the ADC and there can only be one such route at any one time. If you call say AnalogRead(A1) a route is established for this call. A subsequent call to AnalogRead(A2) will clean out any previous route and establish its own route.6v6gt– 6v6gt2025年05月08日 05:51:54 +00:00Commented May 8 at 5:51
-
@JimMack: See edited answer.Edgar Bonet– Edgar Bonet2025年05月08日 10:13:19 +00:00Commented May 8 at 10:13
Explore related questions
See similar questions with these tags.
select which one input is active
... isn't that what a mux does?