multiplexing with cd4021be and +12v.

Hi,

I´m planning to do a Circuit similar to the one in the shift in tutorial https://www.arduino.cc/en/Tutorial/ShiftIn

This one:

The purpose is to get a lots of push buttons input without using to much inputs on the Arduino board.

There will be from about 2 to 25 meter between then cd4021be/resistors and the buttons.

But I only have 12v and a common ground where the buttons is, and I like to safe my limited unused wires for other purposes (avoid a wire with +5v) . So my question is, is it ok to use +12v instead of +5v in the top left corner of the diagram ? (will it work? and of course not destroy the cd4021 or the Arduino )

(If yes, is 10K ohm still the correct value)

Best regards and thanks in advance

Kent

Yes, you can power it with 12V.
However, you will need higher voltage level control signals, and the signal coming back will need to be attenuated to a 5V level.

Can you put a 5V regulator with the chip?

OK, this gets pretty complex quite quickly!

Firstly, as with most Arduino site tutorials, this circuit is very bad!


It illustrates buttons being connected to a power rail and pull-downs to ground. This is just asking for trouble should a short circuit occur - since most short circuits will be to ground; either the power line connected to the button is shorted to ground or the button line is grounded and shorts the power when the button is pressed.

It is vastly more sensible (engineering practice) to have the buttons connecting to ground. The pull-ups (10k is probably not unreasonable) then connect to +5V on the circuit board where a short is much less likely. And in this case, this means that the 12 V line is not involved at all, so we do not have to worry about voltage limits.

Well, maybe.

You did say 2 to 25 metre cables?

All sorts of horrible things can still happen over that distance! And will! Such as radio signal pick-up.

Not to worry. We now have your switches on the end of wires to ground. And we have a 10k pull-up to 5 V on each wire. Between that common connection and the Arduino input - or shift register - we put a nice big resistor value - 47k sounds suitable. And how about a 0.1 µF capacitor from the input to ground. That will filter out a lot and protect the input up to at least 50 V.

Sorted?

@CrossRoads

I don't want to power it with 12v, - since I have 5v where the cd4021be is , but I want to use 12v as "control signals" (button/triggers)

Hi Paul,

Thanks for your input, It worries me if the tutorials is that bad, since most of us newbie relie on them!

You explanation is at little complex/abstract for me as newbie, do you have knowledge of that diagram on internet showing your suggested solution ?

If I stick to the original idea, will the 12 voltage “trigger signals” damages anything?

/Kent

kent2016:
Thanks for your input, It worries me if the tutorials is that bad, since most of us newbie rely on them!

Worries a lot of us here. :roll_eyes:

kent2016:
You explanation is at little complex/abstract for me as newbie, do you have knowledge of that diagram on internet showing your suggested solution?

My, but don’t you want everything?

OK, this is the closest I can find. It could not be simpler.

The resistors are all at the Arduino end of the wiring. R1 is your 10k pull-up, R2 is 47k. Add a 0.1 µF capacitor directly from the input (microcontroller, shift register, it doesn’t matter) to ground for suppression of RF and impulses.

kent2016:
If I stick to the original idea, will the 12 voltage “trigger signals” damages anything?

Do not “stick to the original idea”. That would be particularly foolish,

kent2016:
If I stick to the original idea, will the 12 voltage “trigger signals” damages anything?

Yes it will. As a general rule never put a voltage input to any chip that is higher than that chip's power rail.