Reading the state of DIP-switches via 4017. Something escapes me...

dl324

Joined Mar 30, 2015
16,916
About the voltage: with one or few switches closed, it's very close 5V (readings around 1000), and it drops geometrically with the number of closed switches. With 6 switches closed (as per my 1st post, photo + "serial monitor" picture), readings are of just around (5/1023)*50 = 0.25V.
I don't think that this method will work because it depends on what the voltage levels are for HIGH and LOW and the amount each LOW pulling on a HIGH will decrease the voltage. You have no way of determining the actual combination of switches closed.

CD4017 output voltage specs:
upload_2018-12-16_10-4-44.png
upload_2018-12-16_10-4-59.png
upload_2018-12-16_10-5-16.png
The outputs of a single CD4017 will be similar under load, but that isn't guaranteed between IC's.
 
Last edited:

Thread Starter

CesareBrizio

Joined Dec 16, 2018
10
Dennis, many thanks!
A generous gift on your part, I'm speechless! I have the opposite problem of the members of this forum, in the sense that I need much time to mentally map a schematic drawing like yours to a breadboard circuit, but I can and will understand how I may implement it on breadboard.
If I understand correctly, I need a 4051 every 8 switches.
And a 4069 Hex inverter every two 4051 - my usual e-shop of electronics does not sell the 4069, is there any other similar IC that I may use as an alternative?
About the "resistor network", I never used it before. In your opinion, is this component a suitable one? http://ebmstore.it/index.php?route=product/product&path=174_187_190&product_id=1317
Many thanks again!
Cesare

Here's a circuit that will read the states of 16 switches directly using 4 address lines (D0-3), and one Arduino input:
View attachment 165916
When D3 (MSB) is LOW, you can directly address the states of the switches in S1 and S2. When D3 is HIGH, you access switches in S3 and S4.

When the CD4051 analog multiplexers are inhibited with a logic HIGH, the outputs float, so the outputs of the two multiplexers can be wire OR-ed.
 

dl324

Joined Mar 30, 2015
16,916
I need much time to mentally map a schematic drawing like yours to a breadboard circuit, but I can and will understand how I may implement it on breadboard.
A technique some use is to print the schematic and use a highlighter to mark each net as you wire it.
If I understand correctly, I need a 4051 every 8 switches. And a 4069 Hex inverter every two 4051
That only works for two multiplexers. If you expand to more than 16 switches, you need to use a different strategy for enabling one multiplexer at a time.
- my usual e-shop of electronics does not sell the 4069, is there any other similar IC that I may use as an alternative?
You can use any inverting gate. If you're operating at 5V, you can also use 74HC04, 74AC04, etc.
About the "resistor network", I never used it before. In your opinion, is this component a suitable one?
I'd use networks that have multiples of 4 resistors; actually 4 may be more convenient for wiring. You can use ordinary resistors; they just require a little more wiring.
 
Top