The first exercise (output) was completed successfully.
The second exercise (input) produced unexpected results. The analog value of all 8 inputs is between 400 and 1100 when no input is grounded. What? What does that mean? Isn't this an 8 bit value? I was expecting 0-255.
If I ground one input, that particular input value drops to 0 (expected) but the other 7 input values drop to around 2 (unexpected). If I ground any two inputs simultaneously, all eight inputs drop to 0.
Has anyone seen this behavior before with a 74Hc4051? I tore the entire assembly apart and rebuilt it with a second 74Hc4051 - same unexpected result. Anyone know what's going on? Thanks in advance.
The ADC is 10 bit, this means 1023 as maximum value. When using a multiplexer with open inputs in a high impedance circuit the capacity of the MUX output to the ADC input will maintain the reading fairly well between different unconnected inputs.
Thank you for your reply. 10 bits explains the originally noted values.
If I understand you correctly, the MUX is pulling ALL the inputs close to the value of the grounded input. In the case of two inputs grounded simultaneously, all 8 inputs ALL read zero. This obviously defeats the purpose of knowing which inputs are high and which are low. What must I do to prevent this? Thank you.
The Arduino ADC inputs are basically open circuit, not pulling the signal either high or low, this means the capacity in the input, wire and output will mostly keep the voltage from the last selected input.
You can add a 1Mohm (or 10Mohm) pullup or pulldown resistor between the MUX output and the ADC input*, it will affect you measurement slightly, but also secure that unconnected inputs either read about 1023 (pullup) or 0 (pulldown).
*It is a resistor to Vcc or GND, not a resistor in series with the signal.
If the source impedance of the connected input is low enough, then unconnected inputs don't matter.
We measure one A/D input with the rest unconnected all the time.
The mosfet switches of the muxer have some resistance, so it's not wise to have a low resistor value on the common contact of the muxer (Arduino pin). Better then to have eight resistors on the muxer inputs.
1Megohm won't matter though.
Capacitors also provide a low impedance.
Picking a resistor or capacitor or nothing at all to ground depends on the application.
Wawa:
If the source impedance of the connected input is low enough, then unconnected inputs don't matter.
We measure one A/D input with the rest unconnected all the time.
The mosfet switches of the muxer have some resistance, so it's not wise to have a low resistor value on the common contact of the muxer (Arduino pin). Better then to have eight resistors on the muxer inputs.
1Megohm won't matter though.
Capacitors also provide a low impedance.
Picking a resistor or capacitor or nothing at all to ground depends on the application.
Not sure what 'speed' has to do with it.
Leo..
When you want to clearly identify unconnnected inputs you need some easily recognisable reading.
When looking at the pullup resistor you have to look at the source impedance and when placing it after the mux also at the mux impedance. I guesses that he used a source where 1-10Mohm would not affect the result.
Speed is relevant when selecting input and the capacitance has to be charged, with Mohm resistors it take a little time.