8
\$\begingroup\$

I've got a simple project on host device that should drive 2 pins with high logic level (voltage 3.3V, 5V or 12V - doesn't matter) and wait for 2 others pins become driven high level by the peripheral device.

Can I implement such host device with a standard PC and what hardware (built-in or extra) should I use?

\$\endgroup\$
  • 2
    \$\begingroup\$ Are you looking to buy something like mccdaq.com ? \$\endgroup\$ – kenny Oct 18 '12 at 13:23
  • 1
    \$\begingroup\$ I'm interested, maybe PC already has some built-in functionality (controller, pins) for my purposes? And if not - find some solution to buy (btw, thanks for the link!) \$\endgroup\$ – Andrey Pesoshin Oct 18 '12 at 13:34
  • 1
    \$\begingroup\$ A potential solution, that is both simple and economical, would be use something like a MSP430 Launchpad, connected to the PC via USB, programmed in an Arduino like software environment, called Energia, all for $4.30 including S/H (Fedex 2 day, worldwide), or even cheaper DIY board using an AVR (like attiny85 with bitbanged USB) programmed on PC side in Arduino (if you like or prefer to). \$\endgroup\$ – icarus74 Jan 5 '13 at 18:48
7
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ We don't have a full description of the desired functionality, but my guess is that he needs a dual SR-flip-flop. Which you can emulate with a 1 billion transistors CPU :-). \$\endgroup\$ – stevenvh Oct 18 '12 at 13:43
  • 1
    \$\begingroup\$ thanks for your answer. I understand that there is a huge amount of solutions to perform, but I wanted to ask certainly about direct connection of external device to PC. Now I see that I cannot do it directly but with extra controller or I/O board. \$\endgroup\$ – Andrey Pesoshin Oct 18 '12 at 13:46
  • \$\begingroup\$ @stevenvh I've simplified the description of a project for better undestanding ;) I need to clarify just interfacing part \$\endgroup\$ – Andrey Pesoshin Oct 18 '12 at 13:49
12
\$\begingroup\$

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.

\$\endgroup\$
  • 2
    \$\begingroup\$ Should OP choose the parallel port route it is worth noting that NT-based OS (i.e. any Windows OS released in the last decade) will require a special kernel-mode driver in order to access the parallel port. Should you be using a version of Windows with Kernel Mode Code Signing Policy (e.g. Vista/W7 x64, maybe even W7 x86), then this driver will also need to be digitally signed. \$\endgroup\$ – ajs410 Oct 18 '12 at 16:11
  • 1
    \$\begingroup\$ great answer, I'd vote up if I could :-) \$\endgroup\$ – Andrey Pesoshin Oct 18 '12 at 18:06
  • 1
    \$\begingroup\$ @ajs410 - such code signing requirements likely apply to drivers for any other interface, such as USB, as well. The one possible end-run may be to use something for which the operating system already provides the driver code, and all that is needed is a configuration/information file, for example a virtual com port. That is not GPIO, but it can be used as a command/status channel to talk to a helper micro which has GPIOs. \$\endgroup\$ – Chris Stratton Oct 18 '12 at 18:14
8
\$\begingroup\$

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.

\$\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.