ShiftIn tutorial problem

Hi all,

Sorry for the repost, I think I put this in the wrong forum first time.

I've been trying the ShiftIn tutorial (http://www.arduino.cc/en/Tutorial/ShiftIn), but my switch presses are not being registered at all. When monitoring the serial input, I just get 0 returned every time.

I am using the HCF4014B chip instead of the CD4021B:

http://www.st.com/stonline/books/pdf/docs/4898.pdf

I'm guessing that the problem could be that this chip has synchronous parallel output instead of asynchronous. It that is the issue, would it still be possible to use this chip with different code? Or should I order some new chips?

Thanks!

It is indeed a synchronous vs. asynchronous issue. Take a look at the logic truth tables for both the 4021 and the 4014. With the 4021 - the device specified in the tutorial - the button press jams a bit into its respective shift register; then, switching modes, the code clocks in the register serially.

With the 4014 - your IC - a button press doesn’t jam the bit into a shift register, you have to clock it in synchronously. As long as you call the routine frequently enough, it shouldn’t be a problem. But, you’ll have to either revise the code to account for the different devices, or purchase a 4021.

I use 74LS165 for most of my PISO (parallel-in, serial-out) work; for example, serially reading a parallel device. Here’s is my shiftIn for that device:

byte shiftIn() {
    int i, temp = 0;
    byte myDataIn = 0;

    for( i=7; i>=0; i--) {
      PORTC &= 0XFE;              //drop clock
      delayMicroseconds(5);      //wait to read each bit
      temp = digitalRead(QH);     //read a bit
      if( temp ) {
          myDataIn = myDataIn | (1 << i);
      }
      PORTC |= 0x01;              //raise CLK
    }
    return myDataIn;
}

Thanks. I've ordered some 4021s but I will have a play with the code to see if I can get anything useful from the 4014.

and did you find something to get the 4014 working?