Hello all.
I've just acquired two 74LS674s and need help understanding the datasheet. The output pins are pretty obvious, and I can GUESS at the clock, data and latch pins, but would totally appreciate if someone more knowledgeable could tell me which are the clock, data and latch.
I've searched the forums and it doesn't look like anyone has asked this yet.
Many thanks.
see pages 2 & 4
There is no "LATCH" pin. There is a R/W(bar). There's "shift & read", "shift & write", & "parallel load". (see Function Table, lower left, page-2)
and I can GUESS at the clock, data and latch pins
That's funny , being as there is no latch pin.
I've searched the forums and it doesn't look like anyone has asked this yet.
Probably because the question doesn't make sense, based on the datasheet.
If you are familiar with the funtion of a R/W pin then you must know that pulling the W-bar pin LOW performs the "LATCH" function , (as you have called it) . This is a shift register. Forget about "LATCH" and start thinking in terms of READ & WRITE. Read the function table. It's all there. Your problem is starting out with the assumption that there is a "LATCH" pin and then ignoring the obvious function of a R/W-(BAR) pin.
I was not even able to find the word "LATCH" anywhere on the datasheet so I think it is clear that the "Write" function performs that effectively.
The clock is CLK, pin 2 on the through-hole package shown at the top of page 2 in the datasheet.
Data pins are SER/Q15, and P1 through P15. SER/Q15 is the only output on this device, delivering the state of the most significant bit in the shift register, and it can also function as a serial input. P1 through P15 are inputs for parallel-loading the shift register.
There's no single pin that performs a "latch" function. To parallel-load the data on P1 through P15, R/W and MODE must be high, chip select CS must be low, and the clock must have a falling edge. There's no asynchronous load function, like the load function on the 74LS165. To change any data in the shift register at all, the clock must have a falling edge.
The function of the R/W pin isn't particularly intuitive. If it functioned like a typical Read/Write pin, it would be high for reading data, and low for writing data. In this IC, R/W must be high for writing data from the parallel input pins P1 through P15 into the shift register. It's also high for reading data serially from SER/Q15. The only time it's low is for serially entering data into the shift register via the multi-function pin SER/Q15. When R/W is low, SER/Q15 operates as an input to the least significant bit of the shift register. If you won't be using the serial input function on this IC, then you can tie R/W permanently to 5V, and still be able to use the parallel load, or "latch," function.
When input CS is high, nothing happens on this IC - the other inputs have no effect on the contents of the shift register, and the only output, SER/Q15, is set to high-impedance. If you're only going to use one of these devices, you can probably connect CS to GND, to permanently enable the IC. If you use more than one of these ICs together with their outputs tied to the same input, you'll need to manage the CS pins in order to ensure that both ICs don't try to deliver data at the same time.
If you find yourself with CS tied low, and R/W tied high, then you can treat the MODE pin as a sort of "latch" pin, active high, remembering that the clock must have a falling edge before the parallel data will be transferred into the shift register.
Finally, the datasheet has a warning that CS shouldn't transition to high unless CLK is low. The logic diagram on the bottom of page 4 shows why: when CLK is high and CS is low, a rising edge on CS will clock the internal flip-flops, possibly changing the data to something you didn't expect.
@Tmd3,
Well done !
Thanks.
Let me try this... Has anyone used this particular shift register before?
Anyone want to make some money via online consulting? Perhaps a fritzing diagram and a simple sketch lighting 16 LEDs? I'll take it from there.
PM me.
Thanks
kyled:
... a simple sketch lighting 16 LEDs?
I don't see that this IC will help you light a lot of LEDs. It has many input pins, which it can shift to a single output pin. A typical use might be to attach a lot of digital inputs to its input pins, and fetch them into an Arduino using only one pin for input, and a couple of pins for control. If you want to to the reverse - generate a lot of outputs with a few Arduino pins - you'll need a different part - maybe the 74LS673, which has a complicated interface a lot like the 674, or a 74LS675, with a simpler interface. If you want an IC with a lot of lore in the forum and elsewhere, I'd recommend a couple of 74LS595's. For higher output current, you could add a buffer, or just use a pair of TPIC6C595's. There's oodles of tutorials about how to use those ICs on the web, and lots of discussion in this forum.
I would use a TLC5940
Fantastic. Thanks folks!
FYI,
The most useful functions:
//The most useful functions:
Tlc.analogWrite(channel (0 - 15), value (0 - 4095), chip (0 - n));
Tlc.analogWriteAll(value (0- 4095), chip (0 - n));
Tlc.setPWMperiod(PWM period (0 - n) milliseconds);
Also, if you take a close look at this sketch I think you will see how it could be modified so as not to be "random". Think of it as a possible diagnostic utility.
#include "Tlc5940.h"
long randNumber;
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
Tlc.init(0);
}
void loop()
{
randNumber = random(32);
{
Tlc.set(randNumber, 4095);
Serial.print(" LED # ");
Serial.print(randNumber);
Serial.print(" is on.\n");
}
Tlc.update();
delay(2000);
Tlc.clear();
}
This is the most popular example in the TLC5940 Library. It is the proverbial "Knight Ryder" dashboard led display like the one from the famous TV series.
If you look at the code , it is relatively straight forward : (the wiring is also shown)
If you have never used this chip before be warned. It is not very forgiving of mistakes wiring the power pins. If you get those swapped by rushing or being careless, you can kiss your chip goodbye before you even get your hand off the power switch.POOF! Another DON'T is DON'T ever omit the current limiting resistor on pin 20. If you omit it nothing will happen because that is the return path for the led current. If , on the other hand , you mistakenly replace the 2k (or whatever value you choose) resistor from pin-20 to ground with a jumper wire, then you can kiss all 16 of your leds goodbye before you even get your hand off the power switch. It might be a good idea to order at least one spare chip.
/*
Basic Pin setup:
------------ ---u----
ARDUINO 13|-> SCLK (pin 25) OUT1 |1 28| OUT channel 0
12| OUT2 |2 27|-> GND (VPRG)
11|-> SIN (pin 26) OUT3 |3 26|-> SIN (pin 11)
10|-> BLANK (pin 23) OUT4 |4 25|-> SCLK (pin 13)
9|-> XLAT (pin 24) . |5 24|-> XLAT (pin 9)
8| . |6 23|-> BLANK (pin 10)
7| . |7 22|-> GND
6| . |8 21|-> VCC (+5V)
5| . |9 20|-> 2K Resistor -> GND
4| . |10 19|-> +5V (DCPRG)
3|-> GSCLK (pin 18) . |11 18|-> GSCLK (pin 3)
2| . |12 17|-> SOUT
1| . |13 16|-> XERR
0| OUT14|14 15| OUT channel 15
------------ --------
- Put the longer leg (anode) of the LEDs in the +5V and the shorter leg
(cathode) in OUT(0-15).
- +5V from Arduino -> TLC pin 21 and 19 (VCC and DCPRG)
- GND from Arduino -> TLC pin 22 and 27 (GND and VPRG)
- digital 3 -> TLC pin 18 (GSCLK)
- digital 9 -> TLC pin 24 (XLAT)
- digital 10 -> TLC pin 23 (BLANK)
- digital 11 -> TLC pin 26 (SIN)
- digital 13 -> TLC pin 25 (SCLK)
- The 2K resistor between TLC pin 20 and GND will let ~20mA through each
LED. To be precise, it's I = 39.06 / R (in ohms). This doesn't depend
on the LED driving voltage.
- (Optional): put a pull-up resistor (~10k) between +5V and BLANK so that
all the LEDs will turn off when the Arduino is reset.
If you are daisy-chaining more than one TLC, connect the SOUT of the first
TLC to the SIN of the next. All the other pins should just be connected
together:
BLANK on Arduino -> BLANK of TLC1 -> BLANK of TLC2 -> ...
XLAT on Arduino -> XLAT of TLC1 -> XLAT of TLC2 -> ...
The one exception is that each TLC needs it's own resistor between pin 20
and GND.
This library uses the PWM output ability of digital pins 3, 9, 10, and 11.
Do not use analogWrite(...) on these pins.
This sketch does the Knight Rider strobe across a line of LEDs.
Alex Leone <acleone ~AT~ gmail.com>, 2009-02-03 */
#include "Tlc5940.h"
void setup()
{
/* Call Tlc.init() to setup the tlc.
You can optionally pass an initial PWM value (0 - 4095) for all channels.*/
Tlc.init();
}
/* This loop will create a Knight Rider-like effect if you have LEDs plugged
into all the TLC outputs. NUM_TLCS is defined in "tlc_config.h" in the
library folder. After editing tlc_config.h for your setup, delete the
Tlc5940.o file to save the changes. */
void loop()
{
int direction = 1;
for (int channel = 0; channel < NUM_TLCS * 16; channel += direction) {
/* Tlc.clear() sets all the grayscale values to zero, but does not send
them to the TLCs. To actually send the data, call Tlc.update() */
Tlc.clear();
/* Tlc.set(channel (0-15), value (0-4095)) sets the grayscale value for
one channel (15 is OUT15 on the first TLC, if multiple TLCs are daisy-
chained, then channel = 16 would be OUT0 of the second TLC, etc.).
value goes from off (0) to always on (4095).
Like Tlc.clear(), this function only sets up the data, Tlc.update()
will send the data. */
if (channel == 0) {
direction = 1;
} else {
Tlc.set(channel - 1, 1000);
}
Tlc.set(channel, 4095);
if (channel != NUM_TLCS * 16 - 1) {
Tlc.set(channel + 1, 1000);
} else {
direction = -1;
}
/* Tlc.update() sends the data to the TLCs. This is when the LEDs will
actually change. */
Tlc.update();
delay(75);
}
}