5
\$\begingroup\$

What interface of your PC do you use in order to connect to simple custom hardware?

The most commonly used interface was RS232 some while ago and today is probably USB, but wouldn't it be simpler for beginners to use the parallel port to control really simple circuits like step motors or LEDs? I have the impression from what I have read so far that the parallel port was not really designed for things like that, but I am not sure about possible limitations with respect to that.

Unfortunately, I can find very little literature on how to use the parallel port probably because it is somewhat outdated for professional hardware.

Does it make a difference for the decision on the most suitable interface whether I will just use output or also input?

I should add that I do of course know about Arduino, but I don't want to have any complexity hidden from me.

Moerover, I am using Linux and have a parallel port available. So I am currently biased towards the parallel port.

\$\endgroup\$
  • 12
    \$\begingroup\$ The Parallel Port is dead Jim. Usb to Serial/Uart adapters are the most common solution now. \$\endgroup\$ – Passerby Oct 31 '13 at 7:07
  • 4
    \$\begingroup\$ Or even direct USB to MCU connections. \$\endgroup\$ – Ignacio Vazquez-Abrams Oct 31 '13 at 7:11
  • 4
    \$\begingroup\$ Arduino doesn't have to hide any complexity from you... \$\endgroup\$ – Ignacio Vazquez-Abrams Oct 31 '13 at 12:48
  • \$\begingroup\$ Well being open source and hiding complexity is not the same and I would like to emphasize that the ladt point is of course absolutely legitimate and sensible. But I am looking for a simple solution to a simple problem. Arduino is designed to do much more elaborate things than regulating motors or LEDs, but if you think of the additional software libraries behind it, it is more complicated than the parallel port. \$\endgroup\$ – Penguin Nurse Oct 31 '13 at 14:43
  • 1
    \$\begingroup\$ The major tradeoff to keep in mind is not so much the external hardware, but this. Parallel ports have availability concerns being largely deprecated on recent systems, while USB has latency concerns (even though USB can move large volumes of data quickly, it takes a much longer time, in computer terms, to do a round trip on the USB bus than it does on a local bus parallel port). You have to decide what is more intolerable for your project; to solve both, you sometimes need to offload not just the I/O but also the "thinking" to a powerful external micro. \$\endgroup\$ – Chris Stratton Oct 31 '13 at 15:23
11
\$\begingroup\$

The parallel port is great when you're using Windows 98 or DOS. All modern Windows operating systems have drastically changed how the parallel port interface works making it almost impossible to interface with anything other than a printer. And the parallel port is basically obsolete at this point anyway. Also, it's basically impossible to do any precisely timed control from a general purpose computer. If your target is milliseconds, it's not too bad. But if you want to get down much lower, it gets very, very hard to do so reliably. You're better off sending high level commands to a microcontroller or similar. I would get an Arduino if you have never used a microcontroller before.

If you want to do any serious interfacing with hardware, you're probably going to be using USB. If you need RS232 serial, get a USB to serial converter chip. These are readily available from companies like FTDI and Exar. Most of the boards I make have a header I can plug a small USB-serial adapter board in to, or they have a USB-serial chip on board. Ethernet is another option if you need higher speed communication, but supporting Ethernet on your device is usually quite a bit more complicated than a simple serial interface. It's also possible to interface with PCI, PCI express, and Serial ATA if you really need the performance.

Edit: I can no longer recommend FTDI with a clean conscience without also mentioning that FTDI has released a driver which contains code to intentionally (and likely illegally) destroy "counterfeit" FTDI chips. See http://www.eevblog.com/forum/reviews/ftdi-driver-kills-fake-ftdi-ft232/ and http://www.eevblog.com/forum/reviews/ftdi-driver-kills-fake-ftdi-ft232/msg535270/#msg535270 for more details. If you are considering using FTDI, then you need to weigh the risks of your devices failing in the field due to this driver, either due to counterfeit chips slipping into your production somehow or some issue with the counterfeit detection in the FTDI driver.

\$\endgroup\$
  • 5
    \$\begingroup\$ 2nd FTDI! Fantastic USB UART chips. Very simple interface from the hardware side. From the host side either a virtual COM port can be opened, or lower-level driver access. I have a nice python wrapper around the FTD2XX drivers providing a nice pythonic interface \$\endgroup\$ – JonRB Oct 31 '13 at 11:28
  • \$\begingroup\$ What advantage does the FTD2XX driver give you over a virtual COM port? I exclusively use FTDI chips due to their excellent driver support - works out of the box in Linux, and it's a piece of cake to install on windows. I actually had a very strange problem with an Exar USB serial chip on an Atlys FPGA board - they rev'd the die and turned on hardware flow control by default. The standard linux driver does not support changing the flow control, the Exar driver crashed my computer, and the CTS pin is tied high on the board. Had to modify the FPGA boards to get it to work. \$\endgroup\$ – alex.forencich Oct 31 '13 at 22:24
  • \$\begingroup\$ Ah well, there's still Prolific, as well as chips that work with the standard CDC drivers built into each OS. \$\endgroup\$ – Ignacio Vazquez-Abrams Nov 4 '14 at 20:51
  • \$\begingroup\$ Prolific did something similar, triggering blue screens when "counterfeit" chips were detected. It ended up earning Prolific the reputation of being unreliable. I had a couple of prolific cables a bunch of years ago that never seemed to work right so I ended up seeking out FTDI cables. I suppose at least FTDI is being upfront about it. Still, they pissed off a lot of people with that one. There are definitely lots of alternative chips out there now, so if you don't need to use some of the special features of the FTDI chips, one of those might be a better (and probably cheaper) option. \$\endgroup\$ – alex.forencich Nov 4 '14 at 21:00
4
\$\begingroup\$

I think you have a couple of options.

Parallel ports

Parallel ports are still the simplest solution for controlling simple circuits. There are still kits out there that allow you to use the parallel port to control a set of relays.

A quick web search for "parallel port relay kit" yields a bunch of results. I've included the PDFs from two of those kits, because they contain part lists and block diagrams:

The software for controlling those kits can get a bit hairy, but I found a nifty Python library that worked really well on both Windows and Linux: http://pyserial.sourceforge.net/pyparallel.html

Most modern motherboards don't come with a parallel port any more, but there are many inexpensive expansion cards that provide one or two parallel ports. Alternatively you could buy an inexpensive all-in-one PC that still has a parallel port, like the Intel Atom DH2500.

Note that USB to parallel port cables will generally not work for this kind of thing. There are hacks out there that can make them work, but the hacks only work for certain cables.

Finally, if you want to use the parallel port for a permanent installation, be aware that during start-up, all of the relays will switch on and off briefly. There's not much you can do about this, unless you want to rewrite your PC's BIOS.

Microcontrollers

I've been playing with Arduino boards for a couple of months now. It's very easy to get it to send text to the PC on the USB serial port, and I imagine it won't be too difficult to make it listen for serial commands from the PC either.

Alternatively, programming the board to do all the control itself is also a very good solution. There are bunches of expansion boards, including sets of relays. Arduino boards are also really simple to feed - I've seen them run from about 5v all the way up to 20v, although I think they recommend between 9v and 12v for long-term use.

You shouldn't have too much trouble finding help with Arduino projects. The community for them is huge, and they're pretty much designed for tinkerers. I highly recommend their starter kit for people just starting with electronics.

Serial Ports (Including USB)

Learning to design and build USB port hardware is still on my TODO list. While I haven't used them myself, I've heard good things about two books in particular:

They're only about $25 each, and if you have more specific questions after reading them, I'm sure that you can find more help by asking specific questions here.

\$\endgroup\$
3
\$\begingroup\$

Bargain Basement ideas

Never rule out the sound-card analogue outputs for being able to control many things. You can send FSK (frequency shift keying) at several hundred baud perfectly well. This can of course be decoded with the appropriate chip.

You can even send tones that can be decoded to turn on or off anything you can reasonably think of. Several tones (each with their own decoder) can control several outputs simultaneously.

I've even seen one person attach a photodiode to part of their PC screen and decode the relative changes in brightness - this had a small dedicated area of the screen used for transmitting data. I can't say how well it would work with LCDs but I remember it providing hundreds of baud on a CRT.

\$\endgroup\$
3
\$\begingroup\$

The USB Bit Whacker 18F2553 Development Board from SparkFun lets you control 16 GPIO lines (either input or output) from the PC. It uses a Microchip PIC18F2553 and connects to the PC via USB, and shows up as a virtual RS-232 COM port.

enter image description here

The board costs $24.95. There is a fancier version of the Bit Whacker using a PIC32MX795 which has 78 available I/O lines and costs $39.95. I've used it in a project and where I controlled it using Python scripts.

\$\endgroup\$
1
\$\begingroup\$

If I was to design a device which interacts with a computer I would use a USB HID interface. It won't require any drivers on the windows side and will really be plug'n'play. Interfacing on the PC side will be a bit harder (compared to a serial port) but I've done it before and it just worked.

\$\endgroup\$
0
\$\begingroup\$

The de-facto interface on home and office personal computers is USB

The most common interfaces for simple electronic devices are I2C, SPI, 1-wire and GPIO (etc)

It is therefore unsurprising that you can buy things like USB to GPIO adapters like this or this

\$\endgroup\$
0
\$\begingroup\$

Parallel ports are awesome for really simple hardware. I have a little board I made about 10 years ago that gives 8 solenoid driver outputs and 4 protected digital inputs from a parallel port. The problem is that they are (1) very limited and (2) obsolete on "office" computers. You can probably still find embedded computers that have them and if you're "just tinkering" there is a steady stream of available old PCs that have them. It's harder to use them on Windows, but under Linux they are trivial to use if you have root access.

However, with the cost of small microcontrollers today, it is much more efficient to put all the I/O on one and use the PC as a user interface, communicating to the micro through serial or wireless connection.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.