# 16 separate lines via USB

So let me start apologizing if the question doesn't make any sense at all, I'm a total noob and I haven't quite grasped most of the concepts yet.

I have designed this small visual indicator, which roughly consists of two 595 shift registers driving a bunch of LEDs arranged in rows. So the 595 outputs are set to whatever the row must display, and then the row goes LOW allowing the flow of current and turning on said row. It then goes HIGH again, shift register is set for the next row, and so forth. Basic multiplexing (isn't it?), definitely not reinventing the wheel here.

Well, what I'd like to do is break down the design in modules, so that each row is optional and stackable. In theory this should be nothing impossible to do, but I'm stuck trying to figure out the connection between each module.

Enough with the explaination anyway, if anything I'm making things less clear. A schematic is worth a thousand words, so here it is.

The one above is a raw sketch of what I have now. Below is where I'd be going expanding it:

As you can see, my current interpretation forces me to have a 16-pin connector on each expansion module, which honestly I'd love to avoid.
So here finally is the initial question: is it possible to connect new modules via USB, or the limited number of wires simply doesn't allow it without extra ICs? Because well, honestly, despite the rather ridiculous price, I'm NOT going to add any 595 on the expansion modules.

A small but appreciated extra, in case my idea is unfeasible, would be a pointer to anyone manufacturing small connectors (PCB headers just won't do) that I could use in the project. (googling didn't help much in this case, I probably don't have the right keyword)

NB: as you can see the board would be replaced by an ATTiny, it shouldn't make any difference but still I thought it might have been useful to see the whole picture here. There's also a couple other points I haven't quite figured out yet, not to mention parts omitted from the schematics. Again, this is a very rough skecth of what I have and I'm including it only for completeness sake.

Looking forward your point on this.

(extra: this question was originally and mistakenly posted on StackOverflow, I'm now moving it here hoping to find more interest in it)

EDIT: as far as I can tell from the answers received, bottom line here is that it just can't be done unless I'm packing up each module with extra ICs. at this point, question naturally becomes 'what connector+socket pair would you suggest?' I had in mind something similar to Apple's Lightning connector, which indeed isn't a viable option due to its cost (can't find it below 5€ which is crazy imo).

• Why must it be USB? USB is only two wires, but it is a very complex protocol. Why not use the three signals that a shift register needs (data, clock, enable) to chain stuff together? – gbulmer Jun 9 '16 at 14:19
• There are really quite a lot of connector options - have you considered edge connectors? "Mezzanine" connectors? (e.g. mouser.co.uk/ProductDetail/Molex/503308-1610/… ) Otherwise, Tom Carpenter's answer is on the money. Any form of multiplexing is going to require an IC, especially USB. – pjc50 Jun 9 '16 at 14:28
• Further to the connector thing, what are your size and durability requirements? How long a wiring loom do you want between units? Are you going to be hand-soldering the result (which kind of sets a lower limit on size!) Would HDMI be suitable: it's small and the cables are available for a few dollars? Or even micro-HDMI. – pjc50 Jun 10 '16 at 11:33
• Size should be as small as possible, the LEDs array is about 30mm wide so anything below 1/2 of such figure would be the best option. No wiring between modules, one should stick to the following one; internally there would be something like 5mm wires to the components. I've took a quick look at the HDMI solution, but am I wrong assuming that it's a SMB solution and not a TroughHole? If that's the case I'd be totally lost soldering... – nxet Jun 10 '16 at 15:29

## 2 Answers

Have you considered making putting a 595 on each board and feeding through the three control signals instead of the 8 data lines? In this setup you would essentially have each shift register in parallel so that each one loads the same data. Yes it is duplication of hardware, but it does reduce the cable count to only 3.

You then have another shift register for row select. You could do this one by using discrete registers instead of a 595 ICs. Each board would have two registers. The first has a data input from the previous board and its output goes to the next - this then forms a shift register through each board. The second register acts as a latch for the row signal so that it doesn't change while you are loading the data.

This would reduce the number of cables you require between boards to only 4 + power. Plus it allows the number of modules to be increased pretty much indefinitely (limited by how long you have to load the data).

Here is a diagram of what I am proposing:

Another option to the design would be to split out the MCU part and have just one design for expansion modules that can then be connected to any MCU:

The jumper on the expansion board selects whether the data for the row select comes from the output of the 595 (i.e. on the first board), or from the row select of the previous board (i.e. on all subsequent boards).

This could actually then allow you to have multiple displays showing the same thing - after say 8 boards, you could connect a 9th board which uses the 595 output again to restart the sequence.

I am of course assuming from your original diagram that you are feeding in the row select data from the output of the 595. If this is not the case then you can omit the jumper and use the MCU to control the RDAT signal (marked as optional).

• whoa. this is extremely interesting and I'm definitely going to dig deeper into your explaination. unfortunately it's far beyond my reach atm, not to mention I'd really like to keep the components' number very limited on each expansion. but again I'm sure there's a bunch of points I haven't quite grasped, so just give me a couple hours to absorb all the information and understand the diagram, and I probably will be able to give you a better comment. for now, thanks a lot Tom, both for the very detailed explaination and for the 'MCU split' part (which I would have never thought of myself). – nxet Jun 9 '16 at 15:20

AFAICT, all you need to move to each module is data. This can be moved serially.

Edit:
There is absolutely no need to use a 16 way connector.

It may even be cheaper overall to use a small connector (5 wire) and electronics to move the data, than use a 16 way connector.

You are already using 595 shift registers. They use three signals: data, clock and enable. This is a subset of Serial Peripheral Interface (SPI), which is a synchronous protocol, and quite fast over a few 10's of centimetres.

You can actually buy LED driver chips which implement the same SPI-like interface as a 595.

For example TI make a lot of LED drivers, but one I found is TLC59025 which will drive 16 LEDs; it is a constant current source, so there is no need for resistors on each LED.

MAXIM Integrated's MAX7219 is also driven by 'SPI' (data, clock and enable). It can drive an 8x8 matrix of LEDs, handling the row select and column drive itself.

Using SPI, each connector would only need three signals plus, at least, ground and if not too many modules, power.

MAX7219 modules including 8x8 LEDs are 'cheap as chips' on shopping sites. You can buy them as 'DIY kits' if you want to discard their PCB, and they are even cheaper.

You wouldn't need any more processing than these types of chips, though the main microcontroller does need to know how many units it needs to drive so that it sends the correct number of bits of data.

Their are lots of PCB connectors which would work. You only need three signal pins and ground, plus power. Their are PCB connectors which are 'polarised' (can only be plugged in the correct way), and have 'locking, to resist being shaken apart.

Examples include JST, Molex, also 3M, Harting, Hirose and TE. There are many more. Go to a large electronics distributer, like Farnell, Digikey, Miouser, or RS and look for "PCB connectors".

EDIT:
For example Farnell's PCB Connectors or RS PCB Connectors

Put one MAX7219 on each 'module'. It can drive upto 8x8 LEDs. Connect the MCU to each module using a 5 wire 'SPI' (data, clock, enable) and power.
Connect each 'module' together using the same 5 wire 'SPI'.

Job done.

Further, you can buy modules off the shelf for about \$1 per module.

If you really want to use a connector for every signal, look at the distributers and their PCB connector selection. Low-power connectors come in 0.5mm pitch, dual row, so a 20 pin connector (a common, and easy to find size) would be under 8mm wide.

A 74xx595 can only sink or source a few 10's of mA, so a low power connector should be enough.

• I've recently purchased some TLN5940 to experiment with RBG dot-matrices, but it's worth pointing out that this design won't involve any. in regard of the PCB connectors, well.. initially I was thinking that 16 "spiky" PCB connector pins for each module would have been a bit of a bummer to handle, on the other hand I can't find anything on a smaller package (sort of an Apple's Lightning connector). somebody mentioned edge or mezzanine connectors: interesting point of view indeed, but I can't seem to find any small connector+socket pair other than a few over 40mm wide. – nxet Jun 9 '16 at 15:28
• Have you gone to any of the distributers I have mentioned and searched for "PCB Connector"? 1. you need more than 16 signals, the connector needs a ground return. 2. somehow power (and hence ground) also needs to be connected. – gbulmer Jun 9 '16 at 15:47
• commenting on your last edit: why do I need more than 16 pins? I understand what you're saying, I just don't get why I need a reference ground and power? ATM I have this whole thing prototyped on the breadboard, and just like in my schematics, the ground to each led is provided by the row enable line. is this completely wrong? (please keep in mind I really am not experienced in the field and there might be many errors, you pointing them out with a bit of insights would be ace) – nxet Jun 9 '16 at 16:15
• @nxet - I apologise I had imagined there would be more than LEDs on each board. However, if it is only LEDs on each board, you are correct, and I am wrong. – gbulmer Jun 10 '16 at 10:57
• Good to know, you were just about to destroy the few things I thought I knew about multiplexing :D either way your observation was in fact right, because based on the answers received I do indeed need to put more than LEDs on each expansion to limit the wires – nxet Jun 10 '16 at 11:11