Pages: [1]   Go Down
Author Topic: DaisyChained 74HC165, only gettin data from 2 last  (Read 1096 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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

Lefty
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-sad.

Thank you.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8583
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1281702590/0
Logged

Rob Gray aka the GRAYnomad www.robgray.com

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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.

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

Yes. On this thread AWOL said:
Quote
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. smiley

Thanks guys.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8583
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry 2stl, just realised that thread was yours so I guess you knew about it  smiley
Logged

Rob Gray aka the GRAYnomad www.robgray.com

0
Offline Offline
Edison Member
*
Karma: 0
Posts: 1103
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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() {

  Serial.begin(9600);

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

void loop() {

  while (thread < 2500){
    pegar_registradores();
    thread++;
  }

  if(d==33){
    d=0;  
  }
  manda_dados(d++);
  thread=0;
}

void manda_dados(int dd){
      Serial.print(array_x[dd]);
      Serial.print(", ");
      
      if(dd==32){
        d=0;  
        Serial.println();
      }
}

void pegar_registradores(){
    pulsar_pin(pin_pload);

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

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

     pulsar_pin(pin_clock);
    }

}

void pulsar_pin(int pino){
 digitalWrite(pino,LOW);  
 digitalWrite(pino,HIGH);
}

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?

Thanks.
« Last Edit: August 23, 2010, 11:03:34 am by 2stl » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yahoow! smiley-grin

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!  smiley-grin smiley-grin smiley-grin

Thanks guys!

EDIT:
Maybe this brand of register isn't very reliable... It's from ST...
« Last Edit: August 24, 2010, 06:27:36 am by 2stl » Logged

Pages: [1]   Go Up
Jump to: