74HC166 pinouts (shiftIN)

I've been playing with shiftOUT and shiftIN - successfully using a 74HC165 for the shiftIN. (I had one mysteriously in my box-o-bits)

Now my order of 74HC166 chips has arrived I have found that the pinouts are not only different but have different names. Grr.

The 165 was quite easy (I thought) but the 166 datasheet has gotten me a little foxed.

This is what I have so far...
(modified as incorrect)

Could anyone confirm if QH is indeed used for serial IN (looped in from the next chip along)?

Many thanks

No pin 13 is an output not an input.
It should be connected to the input pin of the arduino or the serial input of a cascading chip.
What else in the data sheet are you having trouble with?

Well if you look at the datasheet from NXP (which bought Phillips, who generally did the 74HC series chips):
http://ics.nxp.com/products/hc/datasheet/74hc166.74hct166.pdf

Pin 1 is Serial In and Pin 13 is Serial Out (which is opposite of what you have drawn.)

Pin 6 is the clock inhibit and should be connected to ground for correct operation.

Thank you gents! That's exactly what I needed to know.

James' datasheet link yields a somewhat friendlier datasheet than the one I'd found from TI. (can't find the source again now)

PIN 1 — serial data IN

PIN 13 — serial data OUT

Shall be sure to ground CLK INH. Thanks Mike.

For those that follow, the correct pinouts are...

James' datasheet link yields a somewhat friendlier datasheet than the one I'd found from TI.

TI and Phillips datasheets use different naming conventions. The pins all work the same, just named different things.

Sometimes the Phillips datasheet will have better timing diagrams, sometimes the TI.

Yep, I'm getting that. :\

The naming on the TI datasheet had me stumped - along with a lack of description of the QH pin.

The image in my diagram had come from the TI datasheet.

Thanks again. I hope this serves others too.

Party on!

I have found that TI data sheets are always very thorougher but steeped in their own convention. Phillips ( or NXP as they are now) can be a bit wordy but are easier to follow.

...and so it came to pass, that the project was brought back online and LO! it didn't work! Grr.

I did have all this working nicely with a 165 chip: Marcel Lenormand: All together now...
but as I resurrected the project I found the 165 setup wasn't working but decided to move to the 74HC166 chip so I'm on the same page as my chum whom I'm developing this for.

I've stripped back my code to troubleshoot it. (no shiftOUT or vUSB)

All I'm getting back is zeros - even when I bring one of the input pins high with a flying lead from +5V

I'm missing something. Does anyone have a keener eye than me?

int latchIN = 8;  //   PE  pin 15  74HC166
int clockIN = 9;  //            CP       7
int dataIN = 10;  //           DS       13

int LED = 13;

void setup() {
  pinMode(latchIN, OUTPUT);
  pinMode(clockIN, OUTPUT);
  pinMode(dataIN, INPUT);
  digitalWrite(latchIN, HIGH);
  Serial.begin(57600);
}


void loop(){
  read();
  delay(111);
}


//////////////////////////////////////
void read(){
  digitalWrite(LED, HIGH);
  digitalWrite(clockIN, HIGH);
  digitalWrite(latchIN, LOW);  // loads her up to be read 
    delay(11); 
  digitalWrite(latchIN, HIGH);  // (on a rising signal)
  for (int i=0; i <= 7; i++){  // count through the items (bits) in the array
    shiftIN(i);     // call the function to set the bit in the array
    delay(11); 
  }
  Serial.println(); ///////// ==========
  digitalWrite(LED, LOW);
  digitalWrite(latchIN, HIGH);  // close her down and switch to display mode
}

//////////////////////////////////////

void shiftIN(int i){
  digitalWrite(clockIN, LOW);
  int TEMP = digitalRead(dataIN);
  digitalWrite(clockIN, HIGH); 
  Serial.print(TEMP); ///////// ==========
}
//////////////////////////////////////

I've added a couple of delays along the way to slow things down in case it was all moving too fast. It made no difference. Serial monitor outputs lines of 8 ZEROS. (exception - jiggling the breadboard wiring sometimes outputs a line of ONES.

Answers on a postcard to...

thanks
[m]

Thanks.

Yep. At first I tried modifying the wiring then I stripped it all out and started over.

Maybe I've got the input pin pull-down resistors the wrong way round!? :wink:

[m]

Just out of curiosity... what made you change from 165 to 166?

My friend and I had both ordered some 166s but during the shipping wait I happily found a 165 in my stash of bits. Don't know where it came from. Hence, I ran it all up with the 165 and got on quite well with it.

I started this thread whilst trying to get my head around the different pin labeling on the 166. We didn't get time to make the swap back then but the project is back on the table now and we're both stumped as to why it's not working.

Just going to try pegging Master Reset to HIGH...

All ZEROS with Master Reset pegged LOW or disconnected...

...but with it pegged HIGH...

01010000
10100001
01010000
10100001
01000000
10100001
01000010
10100001
01000010
10000001
01000010
10000101
01000010
10000101
00000010
10000101
00001010
10000101
00001010
00000101
00001010
00000101
00001010
00000101
00001010
00010101

Pretty patterns! ;D >:(

From the timing sequence diagram in the datasheet (Philips) it looked as though MR should be held HIGH.

Stumped.

I don't know if this helps... sorry, it's a mess.

The most misleading part of this image however is that the blue lead from Arduino GND looks like it goes to PIN 15 on the 166 - it actually goes to the ground rail and PIN 15 is connected to Ard 8, but is hidden.

The connections to the Arduino are:

Arduino pin 8 9 10
Function Latch Clock Data
Cable colour Blue Orange White
166 pin 15 7 13

You will probably find a line over the words Master Reset. This indicates that the pin should have a zero to activate the name of the function. That is to reset it you need to put it low. Therefore to take it out of reset you place it high. This is the way most chips work.

I follow that Mike, thanks.

What's happening when I plug it HIGH then? I'm getting a lot of scrolling randomness.

Here's the rub, and probably the bottom line for me at this time...

I've swapped in a 165 and it's working. No snags.

I don't know what the deal is with the 166 but I'm lost.

We'll order in some more 165s and get on with the job in hand.

Thanks everyone for their assistance to date - it's much appreciated.

[m]

The two are totally different chips, they do different things.

The 165 is parallel in to serial out and is used for getting more input to the arduino

The 166 is a serial in parallel out and is used for getting more outputs from the arduino.

You can't just swap them out and expect them to do the same job.

Sorry Mike, are we talking about the same thing?

The datasheets I've got for the 74HC165 and the 74HC166 both state they are parallel in and serial out.

Are you thinking of the 74HC595 - which is serial in and parallel out? (I've got one of those driving a clutch of LEDs.)

[m]

Yes sorry they are both the same type but if you look at the pin out they have different functions of different pins. So you can't just swap them out you have to wire them up differently.

74LS165 - serial output shift register

74LS166 - serial output shift register shift register

For example pin 9 on the 165 is the serial output, where as pin 9 on the 166 is the ~Clear (note a ~ in front of a line indicates it is active when low, just like a bar over the top).

Note you will also need a decoupling capacitor across the power lines.