CD4021 - all Q's "pulled down" , still a value...?

Ugh, me again...

Some of you have had the pleasure of working with the CD4021 Par->Ser and i've looked closely
at the other forum posts of people having trouble this IC, to no prevail.

I've attached a pic of the breadboard I made to test the IC and the shiftIN functionality.
code is fairly simple but for the sake of it:

int inLatchPin = 2; 
int inDataPin = 4;
int clockPin=3;

byte inData=0;
void setup(){

 
 pinMode(inLatchPin,OUTPUT);
 pinMode(inDataPin,INPUT);
 
 pinMode(clockPin,OUTPUT);
 
 Serial.begin(9600);
 
}
void loop(){ 
 digitalWrite(inLatchPin,HIGH);
 delayMicroseconds(20);
 digitalWrite(inLatchPin,LOW);

 inData=shiftIn(inDataPin,clockPin,MSBFIRST);

 if (inData>0){Serial.println(inData);}

 
}

As you can see in the pic, I pulled down all inputs (yes +/- of both sides of BB are bridged) with a 10k resistor which is how it's explained in the Arduino Tutorial, and this should return "0"s , but for some reason it still returns "16".

Which means that Q5 is somehow stuck?

ps: I actually was working on a PCB with buttons and pulldowns and there I get a "7" (different 4021).

Please, show us a schematic.

Posting images:Simple guide for inserting images in a post - Website and Forum - Arduino Forum

Why do you have a capacitor from pin 9 to GND.

There is a capacitor on the par/ser input - bad bad bad, lose it.

And you need a decoupling cap across the chip from supply to ground - I suggest you
repurpose that capacitor or preferable use a ceramic 100nF one.

Without decoupling any logic chip can do pretty much anything you don't expect, they are
never optional.

Thanks everyone.

MarkT, that capacitor was not in the tutorial ,but i'll give it a go later on and let you know!

“I don't want to be rude”

Never though you were.

You give us information we try to help.

If this is it, it is helpful if you include it in your question.

UdoVR:
Thanks everyone.

MarkT, that capacitor was not in the tutorial ,but i'll give it a go later on and let you know!

Which tutorial? It needs updating.

MarkT:
Which tutorial? It needs updating.

https://www.arduino.cc/en/Tutorial/ShiftIn

larryd provided the picture that's in there in another reply.

After adding the decoupling capacitor, confirm that no I.C. pins have been bent under the chip.

Here I am again.

Made some adjustments to the setup to get the wires as short as possible.

Bridged the 5v/GND with a cap, bought 2 new CD4021's just to be sure.
The other 47uF (barely visible) on the +/- lines is something I found again on the internet in an article about de-coupling.

(Update on code, printing with BIN now.)

What I'm getting now is erratic changing numbers, sometimes, or "100".
4 of the pins seem to be working ok in the sense that using a button on PI 1 to 4 give me they give
me the right binary place, but with "100" behind it. So "1100" for PI 1, "10100" for PI 2 etc...

Going to try the other way later, putting 5V with resistor on the PI's and have it get the 0's instead.

Also bought a 7805 , maybe I should try get my 5v from another source...?

Do you measure 5v with a DVM, between the two power rails on your solderless breadboard?

larryd:
Do you measure 5v with a DVM, between the two power rails on your solderless breadboard?

4.95 to be exact... (and not much change when I use a button)

next reply might be a bit later. Having supper and Dr Who now :slight_smile:
(also the forum puts a limit on it)

Another update. I tried the pull-up version (Pull-up resistor - Wikipedia) using 4.6k resistors.

I have a "bit better" result now but still not proper. again PI 1 to 4 work moderately ok.
they go to 0 but anything else is a shamble.

Maybe my house is electromagnetically cursed, or just me.(I touch the stove or gas line or floor regularly) .

This was the last CD4021 I tried right now...
Tomorrow I'll give it another go on a new breadboard I bought last month.

But i doubt I could blame it on the one that came with the starter kit...everything else worked fine.
(logic gates, H-bridge,...)

Why are you using CD4021s with a microprocessor?

The latest photo shows the data input pin is connected to the Q6 output (pin 2) rather than the correct Q8 (pin 3).

WattsThat, thanks! just tried that now before going to work.
output makes a bit more sense now but some still hanging / false / not responding.

Paul__B:
Why are you using CD4021s with a microprocessor?

You mean in general ?

  1. 8 "button" inputs for the price of 3 pins...?
  2. Arduino uses them in their tutorial
  3. I saw others use them too with Arduino/Genuino/....

Also, i'm in (and very likely will STAY in) an experimental phase.
If you have a more stable solution with another IC, happy to hear about it.

Most likely is a poor connection somewhere on the solderless (some call it contactless) breadboard. When a thin legs of i.e. resistors are in the same row as thick legs of other component the contact on resistor legs may be poor. What it worse it may be intermittent and change with slight movement of the components, breadboard or simply random. The more you use the breadbord the worse it is and soon you spend more time looking for a poor connection than building the circuit...

Smajdalf:
Most likely is a poor connection somewhere on the solderless (some call it contactless) breadboard. When a thin legs of i.e. resistors are in the same row as thick legs of other component the contact on resistor legs may be poor. What it worse it may be intermittent and change with slight movement of the components, breadboard or simply random. The more you use the breadbord the worse it is and soon you spend more time looking for a poor connection than building the circuit...

Hmm, didn't think of that.

Guess I'll start making a stripboard then, which means I'll need to buy some of those tiny caps called SMD's ?
or can I just put the normal caps on the flip side of the strip board...?

UdoVR:
2. Arduino uses them in their tutorial

Sadly, a singularly poor recommendation!

UdoVR:
3. I saw others use them too with Arduino/Genuino/....

Which follows.

While it is true that the functions in the Arduino IDE do tend to slow the logic to the speed of the original CD4000 series, you should be using the proper 74HC4021 or 74HC165.

Paul__B:
Sadly, a singularly poor recommendation!
Which follows.

While it is true that the functions in the Arduino IDE do tend to slow the logic to the speed of the original CD4000 series, you should be using the proper 74HC4021 or 74HC165.

Boy , my electronics dealer is gonna love me , huhu. Thanks for the advise...