Professional Documents
Culture Documents
Home
Become a subscriber (Free)
Projects
Join 29,000 other subscribers to receive subscriber sale
Arduino discounts and other free resources.
Name: Your First Name
MAX7219 Dotmatrix
E-Mail: Your Email
MCP23017 I/O Expander
DS18B20 Thermometer
Humidity DHT22/11
Don't worry -- youre-mail address is totally secure. I
Rotary Encoder promise to use it only to send you MicroZine.
MAX6675 0 to 1024 DegC
BACK TO
Battery Charger TOP
SSD1306 OLED
74HC595 Shift Register Show Index
74HC595 I/O Expander The 74HC595 is useful if you find yourself needing more outputs than you have
available on your microcontroller; Its time to think about using a serial shift
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Hitachi HD44780 register such as this chip.
Logic Level Converter Using a few of your existing microcontroller outputs you can add multiple 595's to
DigitalWrite
extend outputs in multiples of 8; 8 outputs per 595. When you add more 595s
you don't use up any more of your existing microcontroller output pins.
Ebooks
PIC
Serial LCD
LCD Keypad
DS1307 Clock
Infrared Receiver
PIC Sonar
Interfaces fill the 595 memory. To transfer the new stored data to the outputs toggle
another pin and you're done - 8 new outputs working. Like 18
SPI Interface
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
I2C Interface Search Site...
Tip: The 74HC595 series chips are useful but only provide outputs. If
PIC Resources Visit our Facebook Page:
you need both Inputs and Outputs (and interrupts on input) then have a
To Visit Click Here
look at this device : The MCP23017.
PIC Introduction
PIC ICSP
You can also string together multiple 595's for even more outputs! There are
Programmer Types several examples here that show you how to do it. Recent Articles
Resources This 74HC595 tutorial shows you examples of driving 7 segments, LEDs, and PCF8591: An 8
using multiple 595's for 8, 16 or 32 outputs all using just a 3 wire interface. You bit ADC you can
Tips & Techniques
can also find out the correct way of using these devices to drive LEDs and seven easily connect
PIC Tutorials segment displays and learn how to add 8, 16, 32, or more, outputs with multiple using I2C
595's.
Microcontroller Blog
Site map The 74HC595 is a serial-to-parallel shift register or SIPO (Serial In Parallel Out) PCF8591: A four input
device for increasing the number of outputs from your microcontroller. Its simply ADC with single DAC.
Other a memory device that sequentially stores each bit of data passed to it. How good is this 8 bit
ADC, and should you
Articles You send it data by presenting a data bit at the data input and supplying a clock
use it in your next
Books
signal to the clock input. At each clock signal the data is passed along a chain of
project?
d-types - the output of each d-type feeds into the input of the next.
Read more
When you have clocked in 8 bits of data you can then activate the parallel 8 bit
output from the d-type stores.
AD9833 a
versatile easy
to use signal
generator on a BACK TO
TOP
chip
Show Index
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Find out how to use
the AD9833 to
generate sine, square
and triangle waves at
0.1Hz resolution.
Read more
How to use an
SPI Interface arduno Nano as
an ISP (In
The 595 uses the standard SPI interface. The three serial control signals from the System
microcontroller are: Programmer)
Serial Data In.
Serial Clock.
Latch Clock.
With only these 3 serial controls you can add as many outputs as you need - the
number of serial control wires always remains the same.
On the chip there are also two other control signals: BACK TO
TOP
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
The output enable is not really useful for modern designs just connect it to Arduino Nano as the
ground (see here for what it should really used for). ISP programmmer.
One common
problem:
Programming a
sketch into the chip
without a reset
control - solved here.
Read more
Arduino
Voltage
Reference
Capabilities
You can wire the Master Reset (MR) control inactive unless it is vital that the
outputs are reset to zero on power up. Leaving it active means a software reset is
required at the start to send zeros to the shift register and then strobe them to
the output using the latch clock.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
accurate. In addition
find out how to use it
to measure the
supply voltage 1V8 ~
5V5
Read more
Arduino
EEPROM - how
it works and
how to use it -
with examples.
Arduino EEPROM:
Note: On my bench, on first power up, all the outputs came up fully On! How to use it and
If this is a problem then use a global reset signal (that you make from a How to preserve the
few components to hold the reset line low for a while after power up). life of EEPROM. Two
You can also use this signal to reset any other components that have an examples sketches to
active low reset - they usually do - such as the processor. save multiple values
to EEPROM.
The 595 allows you to transmit data in a serial stream using a few wires with the Read more
outputs at the destination delivered in parallel. In addition multiple 595's can be
daisy chained so you can have as many outputs as you need without any increase
How to use the
in serial wiring.
ADS1115
Microcontroller systems come in 8, 16, 32 bit parallel bus designs because it is
BACK TO
faster to send data internally inside a chip using a wide bus (a set of parallel TOP
connections). However when you need to interconnect devices outside the
processor, connecting and routing 32 wires all over the place becomes a problem Show Index
(even 8 is a pain). The solution is to use a serial interface and translate the A tutorial on using the
ADS1115 precision 16
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
parallel 8, 16 or 32 bit data into a timed stream of data. The 595 will translate bit ADC for low power
that back into an 8 bit output (see later for increasing the parallel output width). use.
Read more
The diagram below shows the internal structure of the 595: "This site really is
the best and my favorite.
I find here many useful
projects and tips."
- Milan
bursach<at>gmail.com<
"Awesome site,
BACK TO
very, very easy and nice TOP
to navigate!"
Show Index
- Matt
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
matt_tr<at>
wolf359.cjb.net
Learn Microcontrollers
"Interested in
Microcontrollers?"
FREE GUIDE :
CLICK HERE
- Dave
de_scott<at>bellsouth.net
congratulations."
Show Index
- Suresh
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
integratredinfosys<at>
yahoo.com
- Anon
74HC595 pinout
The diagram below shows the pinout of the 74HC595. It follows the standard TTL
chip layout with power at top right and ground at bottom left. All outputs except
one are on the left side of the chip and control signals are on the right. The serial
output QH' is at bottom right and this is for daisy chaining the devices.
BACK TO
TOP
Show Index
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Pin name Functions
QA-QH Outputs Q0 (QA) to Q7 (QH).
QH' Serial data output.
SER Serial data input.
SRCLK Serial data input clock.
RCLK Output register (Latch) clock.
SRCLR Active low, Asynchronous Shift register Clear.
OE Active low, Output Enable.
VCC Positive Power Supply.
GND Negative Power supply (Ground - 0V).
The diagram below shows the simple connections required (note how the serial
clock signals are fed into both chips while the data signal is shifted out from the
1st chip and into the 2nd chip):
BACK TO
TOP
report Show
this ad Index
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
BACK TO
TOP
Show Index
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
BACK TO
TOP
Show Index
Note: The only change that is required to control the outputs is that instead of 8
x SRCLK clock pulses you will need 16 x SRCLK clock pulses, with associated
serial data (SER) i.e. a software change is required.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Daisy chaining more than 2 x 74HC595s
How to serial connect 4 74HC595s in a chain; This is very simple to do - it is just
an extension of the above process i.e. connect the serial out of the previous
74HC595 to the serial input of the next. The only difference is the total number of
bits to be transmitted.
Note: The only change is a software change, and that is to send more
serial data and serial clocks to the 1st 595. The data then ripples
through to the last 595, as long as you send enough clocks!
This project shows how to wire up and control 16 LEDs and two seven segment Show Index
displays using 4 74HC595 chips. There are three sets of code going through 8,16
and 32 outputs to allow easy wiring of the devices.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Note: You can wire each chip up in turn as you go through the three
examples below - you don't need to do them all at once.
Note: all resistors for led drives including the seven segment displays
are : 470 Ohms. See discussion here for why this should be the lowest
value i.e. not 330 Ohms
As you can see only three connections are required from the Arduino and you can
add more 595 chips as you require more outputs, without using any more
Arduino pins.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
This example Arduino sketch shows how to drive a single 74HC595 using the
outputs for driving LEDs. The walking one direction is controlled by the variable
dir while the actual value is set into variable d. If a high bit is detected at either
end of the byte then the direction is changed. in this way the walking one goes
left and right through the byte. After each shift the value is output to the 595
using the shiftOut function, MSB first. Note: shiftOut operates on bytes only.
Copy Sketch
void setup() {
Serial.begin(9600); // start serial port (debug).
Serial.println("74HC595 Demo.");
d=1;
BACK TO
} TOP
Copy Sketch
void setup() {
Serial.begin(9600); // start serial port (debug).
BACK TO
d=1; TOP
}
Show Index
void loop() {
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Example 3 : 32 bit walking 1 and 2 x 7 segments
This example Arduino sketch extends the previous example keeping the original
operation but now driving 2 seven segment displays as well. Seven segment
displays are just arrangements of LEDs that are used to represent digits. In the
datasheet each LED is assigned a letter in a standard position; These are letters
are 'a' through 'g' and 'dp' (for the decimal point). To make coding easier it is
best to assign 'a'-'g' to b0-b6 of the output and dp to b7. Note to make routing a
pcb easier, you could assign outputs as needed but then the array holding the
conversions value (display digit) would have to be changed.
In this example the "walking one is kept as before" but now to further 8 bit
shiftOut calls are made. Note how everything is shifted right to get it to the lower
8 bits for the shiftOut function.
Note: Even for 32 outputs (or even more) you still only need 3 control
wires!
Copy Sketch
// Demonstration code for 74HC595 16 bit output and 2x7 segment display
int RCLKPin = 3; // pin 12 on the 74hc595 latch - nSS
int SRCLKPin = 6; // pin 11 on the 74hc595 shift register clock - SCK
int SERPin = 4; // pin 14 on the 74hc595 data - MOSI
unsigned long d; // Data to be sent to the shift reg.
int dir,num; // Direction of walking 1, output number.
BACK TO
char buf[12]; // General purpose buffer. TOP
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
0x06, // one
0x5b, // two
0x4f, // three
0x66, // four
0x6d, // five
0x7c, // six
0x07, // seven
0x7f, // eight
0x67 // nine
Arduino library code modules are available but they use shiftOut as does the code
above. So it may not really be worth using them as all you need to do is set RCLK
low, send out the data using shiftOut, then set RCLK high. The library will just
tidy the code a bit. I have also read that the 74HC595 library can not cater for
more than 8 bits - not sure if that is true but if it is, then definitely use the
method shown in the examples in this page.
74HC595 datasheet
BACK TO
Click the image or the link to open the 74HC595 data sheet in a new window. TOP
Show Index
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
74HC595 as an LED Driver (output
current)
BACK TO
Driving LEDs with the 74HC595 TOP
You can drive LEDs with the 595 but the output current must be kept low (70mA) Show Index
for the whole chip. The following discussion details how to do this and
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
recommends a reliable current limit resistor value. Note that the LED output
current also depends on the LEDs being driven (see discussion below).
Note: The datasheet does suggests use of the device as a low current
LED driver i.e. limit the max output current for the total "all-on-state" to
70mA (this is the 74HC595 max current for the whole chip!).
It does not. The datasheet has been mis-read; The actual value (70mA)
is for the total current through the chip. While the maximum for any pin
is 35mA the total current through the whole chip should not exceed
70mA. BACK TO
TOP
Also note that in that instructable there is a statement that holding the
latch pin low disables the output - rubbish, it does not - all it does is "not Show Index
update the output" - there is no disabling.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
The control pin OE disables the output (see here for information on OE).
The actual operation is that a rising edge on the Latch pin clocks the
data to the output.
Getting something right by design is more important than testing just a couple of
chips and saying it works! Datasheets show what has been tested to guarantee
operation and long term reliability. Yes, the conditions may be a bit conservative
and less than could be achieved, and yes, the chip may work for a while under
extreme overdrive but it is not worth the risk for a "real" design.
The answer is therefore No (for high current output).; Any electronics designer
reading the datasheet will see that the maximum output current for the whole
chip is 70mA meaning for 8 LED the maximum that can be output for each LED is
70e-3/8=8.75. In fact the Motorola datasheet states ±6mA per output pin (other
datasheets don't state this) - this is probably to allow current for internal FET
operation. The solution is to use boost the output using FETs or Transistors or a
transistor array.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
You can probably get away driving LEDs if either:
When you see a design that uses 330Ω (Rd) resistor in series with and LED
driven by the output of a 595 then the current that should be driven is:
Note: Different LEDs have different forward voltage drops (see below).
The following table shows current for a 330Ω current limit resistor with different
LED colours (with a 5V power supply).
Current Current
(mA) (mA)
LED type Vf (V)
( Rd = 330Ω ( Rd = 470Ω
) )
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Green LED forward voltage 2.1 8.7 6.1
You can see that those designs are not driving the LEDs at maximum output
(usually 20mA - check each LED datasheet for max. allowed). However on the
bench, with standard LEDs, they look bright enough to me! Also the 7 segment
display looks good at about 7mA (Rd=470Ω) for each red LED segment..
However for 10mA at each output there will be 80mA used which is beyond the
design limit for the 595. The only one that will be in-spec is the Bright White or
Blue LED (5.4 x 8 = ~48mA).
There is a little bit of room to decrease the resistor but the LEDs will be
underpowered. However the question is do you really need maximum brightness?
Conclusion
Probably the best way to go (for long term reliability) is to choose a high
brightness type and adjust the resistor accordingly. However the safe route is to
BACK TO
use 470Ω for all current limit resistors. TOP
Note: This is also why the example circuit shown in the datasheet Show Index
(above) uses current limit resistors of value 560Ω for driving LEDs -
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
that value seems a bit conservative which is why I used 470Ω which also
allows the total output current to be below 70mA.
Advanced Topics
Data bandwidth
As with all serial interfaces the ultimate outcome is the appearance of data at the
output from end to end. You start off with an 8 bit quantity serialise it and then
reconstruct it at the output. The time taken to do this process is the limiting BACK TO
TOP
factor.
Show Index
If you are only setting indicators or turning slow speed relays on and off, then
this is not an issue, however, if you are doing a more complex operation such as
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
driving PWM outputs or other high speed operation then the bandwidth is
important (this chip is not the best for PWM - use a dedicated PWM device e.g.
TLC5940 for easy PWM expansion).
if you want to turn on and off the outputs at a specific rate then you can work out
the required operational speed. As an example say you want to go at 100kHz
(turn on an d off an output at 100kHz). When you serialise it the data has to be 8
times faster (plus a bit more for the strobe signal) i.e. ~800kHz. If you had 16
outputs then it would require an update rate of ~1600kHz or ~1.6MHz.
That sounds like I have contradicted myself but I haven't. The internal module
can operate very fast so a burst of serial data can be output very fast. That does
not mean that the slower processor can keep up. This is what determines the
overall data rate i.e. there will be a highs speed burst and then a waiting period
while the processor decides to react to the interrupt generated from the SPI
module. It is the processor speed that determines throughput.
SPI operation
You could use the internal SPI module to output data faster, so that the processor
operation is not consumed by the 595 update. However the limiting factor now
becomes how fast can you update the SPI module and that depends on interrupt
timing and processor speed i.e. what other stuff it is doing. The other limiting BACK TO
factor is the speed of the HC595 (25MHz) as some microcontrollers can operate TOP
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
74HC595 OE
What is the (OE) Output Enable for?
In the old, old days of yore, when a high end design consisted of an 8 bit system
(similar to an 8 bit microcontroller) the only design technique was to buy
individual components such as:
Each of the above chips is a separate, individual device and the question was:
The answer is that each device has an 8 bit bus, so that bus had to be used to
transfer data around the system.
If the EPROM is constantly outputting data, how do I get the ADC to output
data to the processor instead?
The answer is that you have to be able to turn off the output at a specific time (a
set period in the processor instruction cycle) e.g. during a processor read
operation the relevant device needs to be activated. The processor will have a
BACK TO
dedicated read signal output usually labeled active low RD. Note a similar signal TOP
is used for write nWR.
Show Index
You do that by setting all output enables of all other devices high (output is
inactive) so that all other devices are not driving the bus and then you pull the
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
ADC output enable low, so that only the ADC drives the bus - in this way the
processor can read the ADC output when it wants to.
Note: All the above components are now inside a microchip but the
same design process is used to enable each individual unit to access the
(internal) bus. It is just that now you do not need to think about it i.e. it
is hidden.
So OE is a legacy from that design process. The advantage was that you could
keep on adding devices to the main bus (within the fan out limitation of the
processor) as long as you could control the output enable of the device. That is
why there is an OE control pin in the 74HC595.
TIP: One unusual idea I have seen on the web for making use of the OE control
input is as a current output controller i.e. a dimmer (if using the outputs as LED
drivers). All you do is feed in a PWM signal to the OE input and voila, instant
dimmability (of course this affects all the outputs of the 74HC595 at once).
Like 18 people like this. Sign Up to see what your friends BACK TO
like. TOP
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Have your say about what you just read! Leave me a comment in the box
below.
Add a comment...
Sree Sreedhara
sir, iam student pls post me regarding pic microcintroller basics
Like · Reply · 3y
John Main
Hi Sree, Thanks for commenting here. As I develop projects etc
I notify you of them via email so jst sign up using the forms on
any page.
Like · Reply · 2 · 3y
John Main
Hi Abdul, Glad you like it. Thanks
Like · Reply · 3y
Aec Shammu
BACK TO
I want to learn how could interface a pic sirial port with usb port. TOP
Like · Reply · 2y
Show Index
John Main
Hi Aec, The easier way is to use a PIC with a built in USB
hardware module e g 18F2550 or 18F4550 These have built in
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
hardware module e.g. 18F2550 or 18F4550. These have built in
support for USB. It is jst a matter of setting up the code in the
PIC - following the datasheet. When you do this the PIC device
looks just like another serial port in the Windows software - you
set the baud rate in the PIC and match that in the Windows
terminal program. Then you can transfer serial data to/from the
PC and PIC.
Sarath Chandrasena
Excellent Article, Good Job, Keep It Up and Condrat's.
Like · Reply · 2y
BACK TO
TOP
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copyright © 2005-2020 Best-Microcontroller-Projects
All Rights Reserved.
No reproduction without permission.
BACK TO
TOP
Show Index
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD