Using GPIO in PC

If you can still find one, it's worth mentioning that a true parallel port is about as close to a GPIO as you'll find in an off-the-shelf PC. Classic implementations lack some flexibility in that many of the pins have fixed direction, and some are inverted, but people have been working around that for years.

The greater limitation is that such ports are becoming extinct. The more abstract replacements such as USB-parallel converters are typically usable only to control actual printers, and lack registers which you can directly read/write to set or monitor pin state. There have been rumored to be a few which do have this capability, but they can be hard to find, and require detailed attention to drivers.

At that point it tends to become more practical to use a USB-connected I/O device. Often this is a microcontroller running a simple firmware, either from the manufacturer or custom.

One major advantage of a custom implementation is the possibility to offload the lowest level, most repetitive, and/or timing critical parts of I/O manipulation to the processor on the device, instead of trying to do it from the PC where the latency of USB packetization, traversing multiple buses, and multitasking operating systems tend to make bit-by-bit operations painfully slow.

If you haven't yet figured out exactly what form your solution will take, one possibility is to grab something like an Arduino which is packaged in both the hardware and toolchain sense for ease of use, and could operate as either a stand alone solution or as an I/O helper to do low-level tasks under command from an attached PC.


I'd recommend using an FTDI FT232RL using a special driver that enables it's bitbang mode. This method will work on virtually all PC's and allows decent latency access to a simple GPIO.
There are many FTDI chip breakout boards out there, but I personally use this one.


It's not clear what you want the PC to do and what the device is supposed to do ("host device" makes no sense), but it seems you want basic digital I/O from a PC.

PC's are not really designed for direct digital I/O to external devices. But, you can buy digital I/O modules that connect to the PC via USB, which then allow you to read and write individual digital signals. You can do this yourself most easily by having a microcontroller communicate with the PC via a COM port.

However if this is really just a simple control problem, why do you need a PC at all? Have a small microcontroller do the whole task itself. That's exactly what micronctrollers are for. They are small computers with digital and other I/O lines coming out that are intended to connect directly to external hardware.

Tags:

Gpio