8

I need a number of digital outputs to connect my computer to the real world, however it seems that this job is not nearly as easy as I had hoped.

I've looked into a number of different methods, ranging from dedicated digital I/O cards, micro controllers with USB interfaces, serial ports, parallel ports, ect. However all of the solutions seem to be either too expensive, too much work, or the technology is too dated.

I hope to have 64+ digital outputs running at approximately 1khz each, individually controllable. So far the best idea I can come up with is sticking the outputs of a serial port to an 8-bit serial to parallel shift register and sending chars down the serial connection whenever I wish to change and output (run from a USB to serial port adaptor). I haven't tested this yet so i don't know if it will work.

Is there any other quick and dirty method of getting a fairly large number of inexpensive digital outputs from the computer of which I can easy control with very basic C++ commands?

mjh2007
  • 3,899
  • 24
  • 49
Faken
  • 1,688
  • 2
  • 23
  • 31
  • 1
    Somewhat related: http://electronics.stackexchange.com/questions/3475/what-microcontroller-should-i-use – endolith Sep 30 '10 at 14:16
  • Have you done some math? Simple non-usb RS232 usually has max speed of 115200bps, which is approximately 10KB. Let's say that each channel needs just 1 byte (which I doubt). You want to send 64 x 1000 bytes each second which is around 64KB. Much more then your serial throughput. There are some high speed USB serial cables with 921600bps, and although theoretically possible I doubt this is useful since this is on the edge and as I said 1 byte will hardy be enough, and micro controller will hardly have time for anything else. You will either have to lower your demands or prepare your wallet. – avra May 19 '11 at 08:44
  • 3
    Maybe you should reread your comments for obvious errors before you bash someone...GPOI pins output bits not bytes. That means 64 kiloBITS/s, well under the max 115.2kbs – Faken May 22 '11 at 21:48

3 Answers3

7

Sounds like you intend to flash some christmas lights. :-)

Anything wrong with using an arduino or similar? It would be fairly easy to expand the number of IO ports if the number of ports say on the mega 1280/2560 aren't enough. You can drive it via serial/USB terminal. You could use shift registers on the output pins of the arduino or you could use the i2c port expander and drive through that.

Using standard components like that will give you the shortest amount of prototyping time.

Note, my way may not be the cheapest. But it's effective and will actually get you rolling quickly.

Rob
  • 176
  • 2
  • 1
    Not quite with the flashing lights, I'm trying to control 32 stepper motors on a prototype automated universal fixturing device, except I don't have any funding...or knowledge of electronics whatsoever. Maybe I dismissed the micro controller too quickly, got any good step by step resources on how to get up to speed from the ground up with practical examples? (and I do mean from the ground up, I have a rather strange knowledge base that is way too theoretical and not enough practical, you can assume I know absolutely nothing...feels like it most the time anyways, heh) – Faken Sep 30 '10 at 07:21
  • 1
    Controlling stepper motors is going to require a bit of extra throught. You won't be able to drive them directly from microcontroller output pins. You'll need to use some electronics 'glue' in between the pin and the motor so you don't fry the micro. Like anything its best to start off small and work your way up to more advanced examples. One of the more avid enthusiasts I've seen around is http://tronixstuff.wordpress.com has some good step by step beginners stuff. I know the guy that runs it also frequents this stack exchange. – Rob Sep 30 '10 at 08:03
  • 1
    Yup, I found a very nice stepper motor driver to use in between the control signals and motor (just uses 2 inputs, step and direction). I'll look through that tutorial you linked, thanks. Btw, just to make sure, I want it to be my computer that sends the commands real time via a c++ program to the micro controller to move the motors. Is this possible or very easy to do with this micro controller? – Faken Sep 30 '10 at 08:40
  • 1
    Of course. The microcontroller acts as the buffer between computer and stepper motor driver board. It can interpret the commands that you send and act on them as well as provide feedback to the PC if required. The other benefit of using something a bit conventional is that you can get a lot of support/advice from the community, the chances are always good that someone has done something similar. So thats pretty handy in itself. The micro just provides a really nice low cost interface between pc and your driver boards. – Rob Sep 30 '10 at 09:56
  • Adafruit makes a nice board that can be used to drive 16 servos, and they can be chained together. It would be fairly easy to write some arduino code that reads data from a PC and then sends it out to the servo driver board. http://www.adafruit.com/products/815 – Eric Gunnerson Feb 06 '13 at 05:26
3

The serial to parallel shift register will work. Using the SPI port you will have no problem with the 1KHz update rate. IIRC on an ATmega328 with an 8MHz crystal (or higher) you should be able to get 1Mbits per second. A lot of other microcontrollers will work as well.

Another option is to use multiple microcontrollers. For example -- using an ATmega328 (which is around $5 with the passives) would give you 18 lines while keeping the TXD and RXD lines free. Parallel up the RXD lines and then all the uCs will receive the same command strings. You would need to parse the command strings on the uC. Use an FTDI cable to get to USB. Add an Arduino bootloader to the uC and you could use the Arduino tools.

The serial to parallel conversion is more straight forward. If your application can use open-drain outputs you could use a 16 channel LED driver. This would mean adding four chips.

Daniel Grillo
  • 7,659
  • 18
  • 51
  • 69
jluciani
  • 11,646
  • 1
  • 34
  • 54
1

The simplest option I've come across seems to be the IOIO-OTG. It's a PIC-controller based external OTG USB device, designed for android, but usable with a PC, via Eclipse and the Android Development Toolkit. It has 46 3.3v GPIO pins, as well as bunch of other useful stuff. It doesn't have the 64 pins necessary for your project, but you could just use a few serial to parallel shift registers, as mentioned by jluciani (or use stepper motor controllers instead, and use less pins).

There is also this PIC-based USB IO board, which does similar things, but has less pins.

naught101
  • 630
  • 3
  • 11
  • 20