Go Down

Topic: DaisyChained 74HC165, only gettin data from 2 last (Read 1 time) previous topic - next topic


Hello there.

I've successfully daisy-chaned 2 of these ICs together, i'm using this example to get the data from them.
Everything was working very well, then I added 2 more ICs on the chain, however, now i can't get the data from the first two... i didn't forgot to change the int into long, and if i setup 3 of them, i can't get data from the first. So only the last 2 are actually working.

The setup is very basic, as i'm trying to assemble a musical keyboard, i simply linked every Clock, Clock Enable and Parallel Load pin together, connected to the respective arduino pin, and the Q7 from the last IC on the chain to arduino, and chained the Q7 to the DS of the next IC. I can make a schematic if it's hard to understand.

I'm totally noob and couldn't figure out what's wrong.

Thanks in advance.


Of course we wouldn't have to ask (and you wouldn't have to answer) ANY of these questions if you had provided a circuit diagram.

Yes asking for circuit diagrams and code listings is a never ending chore around here.  ;D



Thanks guys.

I just figured out that by printing bit-by-bit it's possible to get the entire data  :-[.

So it's a software problem. Another thing that i figured out is that you can simply connect that silly ClockEnable Pin to the ground.

The problem probably is that I don't understand the bitwise operations very well. I wanted to send a long binary string to the computer, but it's hard to do this using my very limited knowledge, so i am sending an array.

Now i have another problem... i plan to connect more than 200 inputs using daisychained 74HC165's, however, i don't know if massive printing is heavy, but it can't detect quicker presses... i knew it was going to be slow, but the guys on the other thread said it was going to be alright to make a musical keyboard (>3us of rate) however, even with 32 inputs the thing is very slow :(.

Thank you.


Rob Gray aka the GRAYnomad www.robgray.com


Huh?  What does "i don't know if massive printing is heavy" mean here?  I have no clue what you are talking about.  Take a deep breath and describe what you are trying to do. If you start at the beginning, maybe we can follow along.

It's because the program is summing the bits and sending (printing) to the serial with no delay. I don't want to bore you with coding, etc. I just want to be sure that it's possible to get good reading speed.

That is probably an issue with your software. So far, you have shown us no software and no hardware diagrams, so we're pretty much shooting in the dark here. Hope its fun for you.

I hope it's a software problem.

There was a thread about almost this exact problem (218 inputs) the other day.

Yes. On this thread AWOL said:
digital loop 2856

that the full reading loop would take 2856us. This is 0.003 seconds, so, we could say that the keys detection would run at 333Hz, what is very acceptable. However, the practical tests that i ran with only 32 inputs were much slower than this.

If it's a software problem, I'm gonna figure out for myself .I just want to be sure that it's possible to "achieve" 333Hz of "reading rate" for my 218-key Musical Keyboard. :)

Thanks guys.


Sorry 2stl, just realised that thread was yours so I guess you knew about it  :)
Rob Gray aka the GRAYnomad www.robgray.com


the practical tests that i ran with only 32 inputs were much slower than this.

Could you show us the code? Shifting-in 200+ bits should indeed not take more than 15us*200 = 3ms!


Aug 23, 2010, 06:03 pm Last Edit: Aug 23, 2010, 06:03 pm by 2stl Reason: 1
Could you show us the code? Shifting-in 200+ bits should indeed not take more than 15us*200 = 3ms!

Code: [Select]
int pin_pload = 13;
int pin_clock = 12;
int pin_dados = 11;

byte bit_x;

int thread = 0;
int d = 0;

long array_x[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

void setup() {


 pinMode(pin_pload, OUTPUT);
 pinMode(pin_clock, OUTPUT);
 pinMode(pin_dados, INPUT);

void loop() {

 while (thread < 2500){


void manda_dados(int dd){
     Serial.print(", ");

void pegar_registradores(){

   for (int n=0; n<32; n++){

    bit_x = digitalRead(pin_dados);

       if(bit_x == 1)
           array_x[n] = array_x[n] + 1;



void pulsar_pin(int pino){

This is the current code that I am using to see if it doesn't 'register' a quick press. Of course later i'm gonna use 115200 baud.

It prints one array element every 2500 cycles to keep tracking the swiches states as much as possible.

Is it possible that this is happenin because i'm using analog pins in digital mode? Or because i discarded that "ClockEnable" pin? Or maybe a register is defective?



Aug 24, 2010, 01:25 pm Last Edit: Aug 24, 2010, 01:27 pm by 2stl Reason: 1
Yahoow! :D

After exhaustive testing, I figured out the problem! It was a defective register! I just replaced the defective one and now the fastest press is being read more than 200 times! Man! This is blazingly fast! A "normal" press is being read more than 1000 times while it wasn't even being detected with the defective register on chain.

I don't have the numbers, but it's VERY acceptable now!  :D :D :D

Thanks guys!

Maybe this brand of register isn't very reliable... It's from ST...

Go Up