Using 74HC595, but need to control *10* bits - Page 1
Forum section: electronics / projects

author: Peabody
author_rank: Super Contributor
timestamp: May 02, 2018, 10:27:59 pm
content: This is a typical example of having limited GPIO bits available for various multiplexer and decoder type control lines, plus having to move between two boards through headers, all leading to generating the needed bits through a shift register, in this case the 74HC595. Three lines are available to control the 595 - Data, Serial Clock, and the Output Latch Clock.But I need to control 10 bits of output, not 8. So at the moment the design uses two 595s, which just strikes me the wrong way. My first alternative to that is to use one 595 for the first 8 bits, and then use the actual level of the Data and Latch Clock lines as the other two bits. But this leads to a bit of flutter, particularly on the bit driven by the Data line, which may or may not work well enough.But I wondered if anyone had a better idea. Of course the second chip could be a 4-bit register/latch, but that's not really going to be materially cheaper, plus it adds another line item to th BOM. But is there a way to extend the shift register and latch by even one more bit, so I wouldn't have to use the Data line? An HC74 would do it I think - one D F/F used as the shift bit, and the other as the latch. But maybe there's a smaller, cheaper, more efficient way.Any suggestions appreciated.

author: wholder
author_rank: Regular Contributor
timestamp: May 02, 2018, 11:18:16 pm
content: I don't know how to get more than 8 bits from a 74HC595, but I do have some experience making the most out of the available I/O lines on a microprocessor, so you might consider getting your extra bits from there. If you're driving any LEDs as indicators, then you should consider using an approach often called Charlieplexing (see:https://en.wikipedia.org/wiki/Charlieplexing) to reduce the number of pins required. I developed a similar technique for reducing the number of pins need to scan a set of pushbutton switches that can be more efficient that multiplexing. You can read about my technique athttps://sites.google.com/site/wayneholder/keyplexlib-wayneplexing-on-arduino-made-easy.Wayne

author: bson
author_rank: Unknown
timestamp: May 02, 2018, 11:54:11 pm
content: Another option is to program a 16 pin µC like an MSP430 to act like a shift register of the size you want. (Or as an I2C/SPI device.)

author: DaJMasta
author_rank: Super Contributor
timestamp: May 02, 2018, 11:56:20 pm
content: Have you looked into just a different package of the same micro? Honestly, a TTL chip is going to run you another like 20 cents in moderate quantity, right? For that budget you probably could just get a bigger packaged micro with more GPIOs.Do you need the latching output? There are a variety of demux chips that could be an option, but you could just daisy chain another 595 on the end toohttps://www.best-microcontroller-projects.com/74hc595.htmlIf you can share them with other pins and don't need them latching, you could use something like a bus transceiver (245 or similar) and just turn the outputs off when you're using the other data, or you could get the latching with a 573 transparent latch. I still think if you're optimizing for cost, though, that your best bet is more GPIOs on your micro.

author: Ash
author_rank: Regular Contributor
timestamp: May 02, 2018, 11:57:09 pm
content: There are 16 bit serial-in, parallel-out latches available.. 74F675A was the first I found.. that is probably a drop in equivalent (or close).There are also a large number of "GPIO extender" options.. most work with I2C or SPI and provided configurable inputs and outputs, interrupts and other features.. pretty much just like most micro controller ports. These are "stand alone" in that you don't need to add your own code to them like an auxiliary microcontroller so much easier to deal with for basic IO.I recommend you do a bit of googling for "GPIO extender" or "GPIO expander".Ash.

author: Siwastaja
author_rank: Super Contributor
timestamp: May 03, 2018, 05:55:44 am
content: Why not just put two 74HC595s? They are designed to be chainable, so no extra design work needed, and it's so ubiquitous and cheap that two chips cost probably less than a wider shift register. Sure, you'll have a few excess pins, so if this is PCB estate constrained, then you'd need to think about something else. As a plus, you would have expansion capability for future outputs.

author: mikerj
author_rank: Super Contributor
timestamp: May 03, 2018, 09:05:09 am
content: Quote from: Siwastaja on May 03, 2018, 05:55:44 amQuote from: Peabody on May 02, 2018, 10:27:59 pmOP simply wants to know if there is a "better" way. In terms of cost vs functionality I doubt there is; the 595 is a cheap part. If board size is more important then one of the 16 bit GPIO extenders in a small package would be the simplest solution.

author: CJay
author_rank: Super Contributor
timestamp: May 03, 2018, 11:31:47 am
content: Second '595 is probably simplest as you've already got the code to control it but the 16 bit MCP23S017 (SPI) or MCP23017 (I2C version) GPIO extender is probably the solution I'd use, it's cheap ($1.26 each on Mchip Direct in singles) and easy to use if you can bit bang or have EUSART for SPI or I2C

author: TJ232
author_rank: Frequent Contributor
timestamp: May 03, 2018, 03:36:53 pm
content: I would stay away from the MCP23xxx series for reasons that you will discover yourself sooner or later.Better the classic PCF8574/5 for a simple GPIO port expander or PCA9685 for a nice 16Channel 12-bit PWM I²C-bus LED controller one.For more details about, drivers code inspiration, etc , you can take a look here:GPIO and PWM expanders related articles

author: CJay
author_rank: Super Contributor
timestamp: May 03, 2018, 03:56:39 pm
content: Quote from: TJ232 on May 03, 2018, 03:36:53 pmWell I've used them in quite a few things and not found any significant problems for my applications but please, explain?

author: madires
author_rank: Super Contributor
timestamp: May 03, 2018, 04:12:21 pm
content: Several years ago I wrote a driver for the MCP23xxx and it required some tweaking to make the MCP23xxx work despite following the datasheet.

author: CJay
author_rank: Super Contributor
timestamp: May 03, 2018, 05:37:17 pm
content: Quote from: madires on May 03, 2018, 04:12:21 pmOdd, I wrote some code for the SPI version and thought I'd followed the datasheet correctly (for a change) as it worked perfectly, was yours the I2C or SPI one?

author: madires
author_rank: Super Contributor
timestamp: May 03, 2018, 06:07:42 pm
content: Also the SPI version.

author: Peabody
author_rank: Super Contributor
timestamp: May 03, 2018, 10:25:47 pm
content: Thanks for the suggestions. I think using two 595s is probably the simplest and lowest cost solution that has all the outputs latched. The I/O expanders appear to be in a different cost class than the cheap 74HC stuff. The expanders are more capable, but in this case all I need is a shift register with latched outputs.But I will also see if it might work to have two of the outputs unlatched, so they could be driven directly by the serial Data and output Latch lines. They would experience some flutter, or switching noise, during the shift process, but then settle at final values. If all this happens fast enough, the flutter may not be noticeable. I'll just have to consider which lines, if any, can best tolerate that.

author: David Hess
author_rank: Super Contributor
timestamp: May 04, 2018, 12:49:58 am
content: There is nothing wrong with using two 595s and this is the simplest solution.If I needed more signals from a single package, I would program a microcontroller like a PIC or AVR to operate as an I/O expander but this will not work for synchronous systems.

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 04, 2018, 01:09:00 am
content: Best compromise I found so far is the MAX7317, exactly 10 IOs and SPI (hard to find, most are I2C, if you want to exclude the Microchip ones for some reason).I don't know what your cost target is. They are certainly more expensive that 2 HC595, but will take much less real estate on your board.