More pins - brainstorming
Dr_Acula
Posts: 5,484
I always seem to need more pins!
So I'm working on a "super gadget gangster" board with lots of I/O. Tempting to use a pile of HC373 latches for more digital outputs. Define a 16 bit bus and isolate it with HC245 chips. Inputs could be HC244 chips
Bring out lots of pins. Maybe 4x40=160. Headers like these http://futurlec.com/ConnHead.shtml
Arduino stackable headers are tempting, but they do seem more expensive than the dual female headers a little further down. Maybe bring out 20x4 = 40 pins, and have four of these = 160 I/O lines. Stagger them if you want to stack boards.
I seem to have a need for several different things:
1) latchable digital outputs. Always handy for leds, memory chips, displays.
2) Bidirectional data transfer. Good for talking to a bus that might exist on another board that normally is being used by that board.
3) Pins that you can toggle rapidly
#3 is a concept I have been thinking about a lot. You can have a pin that you can toggle rapidly - eg /RD or /WR on a ram chip. But there are never enough. So you need groups of pins that you can select as a block - maybe of 4 or 8 pisn. Select block 1 - toggle pins rapidly on a ram chip. Select block 2 and toggle pins rapidly on an SD card.
I've got a bit stuck though with the idea of pins being either inputs or outputs.
The propeller is very flexible in that pins can be defined as inputs or outputs, and can be L, H or HiZ. That really is 4 states for each pin. How can you expand that to talk to more I/O while still maintaining the flexibility of all of those 4 states?
I've been thinking about the idea of the Open Collector. There were lots of 74xx pins with open collectors, and they are great in that you can have a single pullup resistor, and lots of things can be inputs or outputs. It is one way of expanding propeller pins while keeping the flexibility of those 4 states above.
For 3V, 74HC is better, so 74HC07 type chips could be useful. 74hc125 is interesting too, particularly if you join the data and control lines together, then the outputs are either Low or HiZ but High is not allowed. Emulates an open collector circuit.
Still a bit messy though when changing from inputs to outputs.
I wonder if the good old fashioned 4016 could be useful? Could it switch, say, an SD card?
"On" resistance might be a problem. There were problems recently with 2000 ohm series resistors on a touchscreen stopping an SD card working. 4066 might be better. Hmm - a 74HC4066 might be even better again - only about 100 ohms.
I wonder if you could use a bunch of 74HC4066 chips to do things like use some propeller pins to talk to an SD card, then later, use the same pins to talk to a keyboard? That ought to work. It might be not quite as good using those same pins to then talk to a TV display but probably would be good enough.
Thoughts would be most appreciated!
So I'm working on a "super gadget gangster" board with lots of I/O. Tempting to use a pile of HC373 latches for more digital outputs. Define a 16 bit bus and isolate it with HC245 chips. Inputs could be HC244 chips
Bring out lots of pins. Maybe 4x40=160. Headers like these http://futurlec.com/ConnHead.shtml
Arduino stackable headers are tempting, but they do seem more expensive than the dual female headers a little further down. Maybe bring out 20x4 = 40 pins, and have four of these = 160 I/O lines. Stagger them if you want to stack boards.
I seem to have a need for several different things:
1) latchable digital outputs. Always handy for leds, memory chips, displays.
2) Bidirectional data transfer. Good for talking to a bus that might exist on another board that normally is being used by that board.
3) Pins that you can toggle rapidly
#3 is a concept I have been thinking about a lot. You can have a pin that you can toggle rapidly - eg /RD or /WR on a ram chip. But there are never enough. So you need groups of pins that you can select as a block - maybe of 4 or 8 pisn. Select block 1 - toggle pins rapidly on a ram chip. Select block 2 and toggle pins rapidly on an SD card.
I've got a bit stuck though with the idea of pins being either inputs or outputs.
The propeller is very flexible in that pins can be defined as inputs or outputs, and can be L, H or HiZ. That really is 4 states for each pin. How can you expand that to talk to more I/O while still maintaining the flexibility of all of those 4 states?
I've been thinking about the idea of the Open Collector. There were lots of 74xx pins with open collectors, and they are great in that you can have a single pullup resistor, and lots of things can be inputs or outputs. It is one way of expanding propeller pins while keeping the flexibility of those 4 states above.
For 3V, 74HC is better, so 74HC07 type chips could be useful. 74hc125 is interesting too, particularly if you join the data and control lines together, then the outputs are either Low or HiZ but High is not allowed. Emulates an open collector circuit.
Still a bit messy though when changing from inputs to outputs.
I wonder if the good old fashioned 4016 could be useful? Could it switch, say, an SD card?
"On" resistance might be a problem. There were problems recently with 2000 ohm series resistors on a touchscreen stopping an SD card working. 4066 might be better. Hmm - a 74HC4066 might be even better again - only about 100 ohms.
I wonder if you could use a bunch of 74HC4066 chips to do things like use some propeller pins to talk to an SD card, then later, use the same pins to talk to a keyboard? That ought to work. It might be not quite as good using those same pins to then talk to a TV display but probably would be good enough.
Thoughts would be most appreciated!
Comments
Really, I think at least 2 parallel busses, along with say 8 spi devices would be nice for me.
For simple buffering, 3/5 volt level-shifting I've used the 74HC244/245. No Latching, but you can select I/O direction and Hi-Z also. Oh, and if you end up looking at the HC373 latches, save yourself some headaches and go with the HC573s. Much saner layout, I/O pins grouped in a row on each side.
They are a disaster. Given some electrical noise in an industrial environment they will flip their outputs to inputs and every thing stops working.
That's even when we have opto isolators on all inputs and outputs.
After endless rearrangements of grounding and shielding etc we gave up on them.
Were you only doing an INIT once ?
I've seen that effect (but not in 8255) in doing noise-tolerance-kill tests (a suppressor removed AC Brush PowerDrill is good..), and one 'cure' we used, was to refresh the INIT/CONFIG registers, in an interrupt.
99.9% of the time, this simple replaced the same value, but if it DID change for some reason, it reduced the effect from permanent.
I think we got around it by unloading and loading the Linux PIO driver module when things went wonky. It did not happen very often so that was workable. Luckily the thing we were communicating with implemented a serial connection and the problem went away:)
Amazing thing was that we could make this glitch on the bench just by turning a lab PSU on and off nearby. That's even with the PC with 8255s being run from a battery powered UPS, opto isolators on the I/O, no electrical connection to that PC in any way. Even the short connections from 8255 to opto's being via shielded cables.
I have long wished for the illusive Prop 1.5, but those gits at the lottery have, again, witheld my funding.
Okay, so how about the MAX7301?
Simple make your own "spi type" running in one cog that constanly updates at 1mhz.
Turn seven prop pins in to 32 inputs and 48 outputs.
pin1: clock shared with all the chips that are daisy chained pairs.
pin2: latch to all the ser-par and used as reset for the par-ser
pin3: serial in from par-to-serial converter 1-2
pin4: serial in from par-to-serial converter 3-4
pin4: serial out to ser-to-par converter 1-2
pin5: serial out to ser-to-par converter 3-4
pin7: serial out to ser-to-par converter 5-6 (100ma open drain version)
A 8bit latch version probably could be done with 12pins (64out and 64 inputs)
1) 74HC595 8-bit Shift Registers. Great tutorial here: http://www.ermicro.com/blog/?p=1050
2) Microchip MCP23S17 16-Bit SPI I/O Expander. Tutorial: http://www.ermicro.com/blog/?p=1846
The 74HC595 is simpler, can be daisy-chained, but is Parallel Out only. Does latch and Hi-Z.
The MCP23S17 is pretty cool, very flexible in In/Out for each pin, interrupts on input change, etc.
The datasheet for the MCP23S17 makes me cross-eyed, but the above above link gave me the "aha" moment that made it possible for me to use this with the 16-bit Microchip processors.
I know there are some SPI -related drivers on OBEX but I've no experience with any of them. I'd be interested anyone's experience using SPI on the Propeller with any of these general I/O devices.
I agree that the 573 is much better than the 373.
Re bidirectional switching, I have been looking at the 74HC4316. It is similar to the 4066 but it has an enable pin which enables all four connections when it is low. This means you can tie the four control leads high (always on) and switch the entire chip with a single active-low signal.
So this gives you the ability to move pins up and down at Propeller speeds and have the flexibility to use those pins to drive an SD card and then switch to a keyboard or a display.
Re switching between groups, I think the criteria there is not speed but rather, saving propeller pins. I am looking at the range of microcip I2C expanders eg MCP23008 http://hackaday.com/2011/06/07/working-with-i2c-port-expanders/ (there is also a 16 pin version).
One super simplistic idea is to take on MCP23008 and a pile of 74HC4316 chips and have two groups of 28 pins (32 minus two for I2C and two for download) and you can select group 1 or select group2.
I'd call that expensive. A CPLD and most vanilla micros are cheaper.
You can still buy 82C55, but at 'go away' price points.
So you best bet is to choose something mainstream, and cheap per IO.
A CPLD could create an interesting expansion, like a QuadSPI version of a 82C55 ( IO Latch and Data Direction Registers)
in 44/48/ 64/100 pin packages. 24 io will fit into 44 pins, with a couple of address pins, so you can save /SS fanout trees.
but cheapest is a small Micro, and putting 'Microcontroller' into Digikeys search, gives 30,000(!) + hits.
you then filter for stock, IO count, and price, and avoid the fringe ones....
Cheapest at $1.28 1+ is a RS08 part with 31 io, then you have a PIC16F59 at $1,56, and a highest stock goes to a AT89S51 at $1,87.
RS08 I think has 4 pins as LCD only, so the IO drops there, but the PIC and AT89 are pretty vanilla - just too dumb.
Showing up for the first time, in stock, I see is the Nuvoton Mini51 $2.05 1+, and $1.02 100+ for 29 io pins.
http://search.digikey.com/us/en/products/MINI51ZAN/MINI51ZAN-ND/2786714
This has Wide Vcc 2.5 V ~ 5.5 V, and 24MHz On Chip Osc, and plenty of peripheral options (SPI, UART) and speeds.
Just 4K of code, but for IO expander, that's plenty.. Choice of QFN or TQFP48
(Interesting to note some smaller LPC11xx series are tagged as 'Non Stock' at Digikey, and they are narrow Vcc anyway, and their volume price is well above the Mini51 )
One challenge could be to consider a propeller chip that had less pins - eg say it had 4 pins and you wanted to use those 4 pins for an SD card, then swap some code and use them for TV output, and then swap some code and use them for a keyboard input.
Another concept is to consider that if everything you talk to can be made HiZ, then you don't need to isolate it.
Consider an SD card sharing pins with a SPI D to A. If the /CS lines are driven by an I2C expander, then both those SPI devices can share pins because they can both be deselected. Hmm - for safety you might use a demultiplexer like a 138 so that no two devices can be on at the same time.
I'm trying to think of solutions that don't require modifying existing objects - solutions that pass through data at the same speed the propeller runs.
How about a board that gives you the 28 prop pins, 8 (or 16) "control" pins from an I2C expander, and a pile of digital outputs from 573 latches? The rule for anything that connects is that it must be able to be put into HiZ. So, for instance, if you wanted to add a keyboard, you might use one pin from the I/O expander to switch on a 74HC4316. That means the keyboard can be totally isolated if you then want to use those pins for something else.
It's an 8 bit addressable output latch.
16 pin package with 8 output pins, 3 address pins and a data pin (write a 1 or 0 to any bit)
Also an /enable for a chip select if desired (expansion)
It's one of my old time favorites.
VERY LOW software overhead when banging individual output bits.
Conversely, a one of eight multiplexer (74LS151) can make an expanded 8 bit input port.
The same three address lines above...
Decode a couple more pins for addresses (74LS139 a is good one - dual 2 to 4)
for chip selects and you suddenly get lots of IO for the pins invested.
8255s are fun, but have overhead.
And have to have all 8 data pins, 2 address pins, /Rd, /Wr, and /CS
13 pins gets you 24.
Zylog ZIO chips gave bit level control, but were also byte-wide devices.
13 pins get you 16.
But to be fair, these guys can be paralleled, with a couple more bits decoded for chip selects.
http://gauss.sdsmt.edu/shop/datasheets/ttl/259.pdf
No I didn't know about that one. Very useful looking chip. I can see several places where that could decrease the chip count. Thanks!
The problem with HC573, is they have no readback - you can get devices like SN74LVCZ161284AGR that give 19io with readback, and even a open collector mode, but they lack latches.
- and even in volumes they are no cheaper than the vanilla uC above.
Another approach is to use a device like TLE7232GS, which is a SPI driver with 1 Ohm 240mA pins, and it does have read-back.
If you want standard PROP libraries, the Mini51 above has high baud rate options, and SPI is good to > 4MBd in slave, and with a variable length to 32 bits per transfer.
UART also seems fast, with UART_CLK / (A+2), {A must >=3}, so I think that makes it
4.423680
3.686400
3.159771
2.764800 etc
& 2.211840MBd would map to the 80MHz Prop with a 0.46% error.
It could be coded rather like a CPLD, with a very small and stable driver (even in ASM?), that allowed the SPI port, to access IO and Timer and ADC and UART and PWM etc registers.
I don't know what your costs are for additional parts, boards, layout etc; but if it costs more than $8 for 22 pins and 6 cores, you might consider adding additional prop chips. The PropForth MCS module (Muli-Channel Sybchronous serial) allows one to add more bare prop chips directly to the configuration, using only two capacitors, four resistors, and a couple wires. Once the channel is set up, it appears that the new cogs and pins are local to the main propchip. Since the communication channel runs at clock speed, the remote resources are not noticably slower than the local resources.
This might be reasonable in some cases, since one only has to buy the same trhee parts in quantity, instead of lots of different parts in smaller volumes.
Ok, P0-P27 are generic pins that can control anything. 8 groups of these = 224 pins.
A "group" could be a physical board, like a Gadget Gangster board. These can all be stacked and each board selected as needed. Each board has 28 I/O pins.
The rule for any board is simple - there is a "board select" line that is low to select that board. If it is high, then all pins must be HiZ.
So - for SD cards that is easy - connect /CS to the /board_select line and connect the other 3 pins directly to the prop pins.
Digital outputs = just connect them up (eg 573 latches)
Digital inputs = use a 74HC244 and the HiZ control goes to /board_select
Bidirectional bus when you can control the direction = use a 74HC245
Bidirectional bus when you don't know the direction = use a 74HC4316 (eg for keyboard/mouse)
For TV and VGA that will load the prop pins with (effectively) low value pulldown resistors = use a 74HC244
For audio you might use a 74HC4316 to prevent data noise
To select a board, P0-P3 are temporarily used to select which board. After this is done, P0-P3 can be used as inputs or outputs by that board.
See the schematic below.
The programming sequence is designed to isolate P0-P3 before using them to select which board.
A 3-8 decoder is preferable to 8 latches because only one group must ever be selected at any one time.
The outputs need to be latched and a 137 provides the same function as a 573 followed by a 138.
The eeprom data line is used to select this chip. At startup this line will be toggling rapidly and this could give random outputs on different boards so the 137 is disabled with a RC network that takes about 2 seconds to charge the capacitor and then select the chip.
There are weak pullups on P0-P3 to start the chip in deselected mode. These may not be necessary as the two enable inputs would override these 4 pins.
In software you would need to have 16 longs - 8 to control the DIR data for each group, and 8 to control the OUTA status of each group when changing to different groups.
One could envision a stack of boards each assigned a different group. C3. Dracblade. ILI9325. Cluso's board. Prop demo board. Software select and switch between them. It could be very handy for developing software for multiple platforms.
You could either pass the 8 outputs of the 137 to each board. Or you could have a local 137 on each board as they will all respond the same way to P0-P4 and P29
I hope there are no bugs I haven't thought of. 244 I/O pins would be cool!
This sounds interesting, but I do not completely understand what you are saying. Let's assume a situation of two Prop chips. Does this mean that COGNEW has access to 16 cogs, and what would be the total IO count available?
Bruce
GM to ya.
I don't completely understand your post either.
I see you are using P0-P3. Would these same pins be used on all boards, Such as (4) Prop pins = 224 GPIO?
Bruce
P0-P3 are used on all boards, along with P4-P27. The gadget gangster format simply passes all 32 pins through to each board. The aim was to use P0-P3 (or more if needed) to select which board, but still make these pins available for general purpose I/O when a board is selected.
While a board is deselected it will obviously not be connected to the propeller. There may be an argument for having some pins always selected. An example is serial inputs, keyboard and TV. But not serial outputs for instance, those can be selected on the fly when required.
To make a certain pin always selected, I guess you simply connect that pin to a TV or whatever but then that pin is not available to any of the other boards.
I am trying to think of something that is as flexible as possible, rather than rigidly saying "this pin must connect to an SD card, and these pins always do TV etc"
Oh, and by the way idbruce, I have some good news for you - re this thread http://forums.parallax.com/showthread.php?137266-Propeller-GUI-touchscreen-and-full-color-display/page2 and your post #21 see this article http://www.ctv.ca/CTVNews/Entertainment/20120305/elle-macpherson-jeff-soffer-reported-split-120305/