Hi, dear board!
Long time no see :)

For some project i would need to have a great deal of simple logic circuits, mainly hundreds of SR flipflops, and something like multiplexers that scans them.
This also needs to be reasonably fast, say, it must easily operate at 100Khz.

I'm looking for the easiest and cheapest way of achieving this...
Do some of you have experience that could help me?

Do you know integrated circuits that have high pin count and contain simple logic like that? Most needed are the flip flops, best i have seen are two SR flipflops in a 14 pin package i think, but maybe i dont know what to search.

First i would like the chips to be something you can solder on your own, but later i might want to want the boards to be produced by some company...

Could an fpga or cpld achieve what I want ?
what is the cheapest an fpga can get, and how many IO pin do those have?

Also, what do you thing is the simplest way of feeding data from the board to a PC with reasonably low latency?say, maybe 8Kbit/s (but maybe 100 or 1M or more would be nice) , with the clock of the device being asynchronous to the clock of the pc input device, maybe... i thought of the soundboard line-in or custom usb interfacing boards...but i would need maybe 10ms latency, less is better, dont know if it's easy.

Do you know where i should search that info?

Any help appreciated guys.
Posted on 2009-10-30 23:48:40 by HeLLoWorld
Look into microcontrollers, with external counting ICs and multiplexing ICs. I have experience with PICs, but wouldn't really recommend them vs ARM-based ones.
FPGAs can achieve all, but are harder to code for, and you'll rarely find a worthy one in DIP package.
Serial-port should be enough. With modern parallel-ports, I could achieve <1uS latency easily, but they're nowadays rare to find on mobos including mine.
Generally entry-"fee" into uCs and fpgas is >$100.

If you provide schematics (or block-schems), we could pinpoint what ICs you need optimally.
Posted on 2009-10-31 11:08:58 by Ultrano
Microcontrollers are the way to go. Atmel's ATmegas are cheap and easy to code for (Atmel gives free IDE for them, you can code in asm and in C).

Main characteristics:
-most of them are much faster than most PIC-based ones.
-most of them are much slower than most ARM-based ones.
-integrated devices, like 10-bit ADC, or PWM generator (which can be easily made to work as PCM generator).
-They operate at speeds up to 20 MHz and execute every instruction in 1 cycle, including multiplication.
-Cheap, like 1 Euro a piece (of course you need to buy a programming device which can be bought for 10-100 Euro and -surprisingly- the cheaper ones are more realiable and easier to operate)
-free IDE with integrated assembler
-free C/C++ addon for the IDE
-'avrfreaks' site with many demos, examples and forums.
-They don't have any division instructions and only support integers. So you need to rely on numerical methods if you need div or floating-point operations (there are readily available examples for that).
-ARM-based ones are still the way to go if you need ultra high speeds.

So I would say their powers and prices go like:  PIC < AVR < ARM. Pick whichever one suits your needs.
Posted on 2009-10-31 11:56:55 by ti_mo_n
Hi guys, thank you very much for sharing your knowledge, it's appreciated.
I won't post schematics now unfortunately, I guess what I'm trying to achieve is not exactly rocket science, but still it's best if I can do it efficiently from the start.

The first stage is an array of flip-flops wired to multiplexers that scans them in one pass reasonably fast in order to memorize which flip flops changed state.
(The second stage is less of a concern for now (memorize and transmit data), and there are obviously numerous ways of doing this.)

So! I was just wondering if there was a better way of doing this first stage than what I thought (SR flipflops done with nand gates (maybe pre-made D-latches could suffice) , and multiplexers on individual ICs).
The thing is, for the final thing, the number of things to scan will be like 500 to 2000, so, really, the less circuits, pins, etc, the better :)

Thats it for now...thank you again.
Posted on 2009-11-07 23:32:15 by HeLLoWorld
The only way 2000 buttons can get scanned with few pins (44+45) is http://esd.cs.ucr.edu/labs/decode_key/decode_key.html . To make the thing handle multiple button presses, 2000 diodes will be necessary.
If the input is not keypad-like, 2000 wires and 2500 pins will always be necessary, you can only make the design have the wires as short as possible. 2500 pins... 156 4-bit demux at the first stage. In this case I'll look for chips with optimum price/pin, buy SMD versions in bulk, design the PCB for surface-mounting (no holes), and get a company to manufacture the PCB (around $50-$100).
Posted on 2009-11-07 23:54:09 by Ultrano
Yeah, 2k+ will definitely need many (de)muxes, despite how you do it. Make sure you use (de)muxes with latches if the controlled/scanned signals need to be held during the operation.

The question that arises is: Are you absolutely sure that you need to scan this many pins? Isn't there any better solution to the problem?

If the devices being scanned are physically far away from the logic circuitry (and also if they are far away from each other), you can minimize the number of wires by converting groups of I/O ports into serial buses (for example I2C). There are cheap 16-bit I/O port chips for I2C bus. This simple solution would reduce the number of wires 8- to 16-fold.

In other words, always try thinking of something smarter before you actually implement it.
Posted on 2009-11-08 12:31:26 by ti_mo_n
Heh, I usually implement it, think of something smarter, fail miserably, and go back to plan A :P
Posted on 2009-11-09 00:27:24 by Homer
Thanks again for all your suggestions! One always benefits from hearing other people's ideas! :)

Ultrano, the keyboard-like grid is very interesting, however i don't think it's really applicable in my case, even though detecting only one button could be quite ok...the inputs should likely be "frozen" before the mux, and they are not real buttons, but maybe i should give that idea more thought.
4-bit demuxs, i guess you mean 4 adresses, 16 lines. Is that the max you can get in a chip? :) (ok, thats not bad already.) Maybe someone has a precise reference to recommend? For the PCB, is it 50-100$ per unit produced? Any limitation, especially size?

ti_mo_n, muxes with latches, now you've got me extreeeemely interested. Any particular chip in mind (my one-minute search is not very successful :) )? how many lines in one chip? :p Nothing in mind for massive SR flipflops?
The IO port chips are interesting too, i'll keep that in mind just in case.
There may be several solutions to the problem but i think the solution involving this circuitry needs those many lines, but i think they're worth it. :)

Ah, Ultrano, just out of curiosity, about <1uS latency on parallel port (easily 8)) , thats very impressive :shock:!
latency is between what and what? between the signal going high on the external device and something showing up on the PC screen? How was it measured? Is it a regular (although modern) parallel port? that thing is in something called the superIO chip connected to the southbridge isnt it? As you say parallel port are not as ubiquitous as they used to be...what about latency of RS232 and the like? Are such results achievable on the USB bus? is the USB overhead significant? Does the number of connected devices and number of hub levels have an impact?

Thanks,
Posted on 2009-11-09 09:38:11 by HeLLoWorld
1uS was: x86 code writes to port, microcontroller reacts with PIC code, x86 code reads result. I measured it by how many x86 cpu-cycles were necessary to wait for the result from uC to come.
Of course, the OS happily will interrupt you for 1ms or more now and then.
USB sounds like roses and honey until you try it. (hell on earth).
Dunno about RS232, the LPT was available and easy for me.

Mouser and Digi-Key can aid you in searching for logic-elements.

Setup for a PCB is $50, after which a single 10 square-inch 4-layer PCB is $2.50 or less. (so everyone generally orders 10 copies of their prototype PCB). Cost is proportional to surface-area and num_layers. After that, shipping costs ~$30.
Posted on 2009-11-09 13:00:34 by Ultrano
Thank you again for these useful pieces of information :)
Posted on 2009-11-12 02:13:35 by HeLLoWorld