2

Possible Duplicate:
I'd like to learn how to make my own USB gadgets
How to build a USB controller having knobs, sliders, and switches

I need to activate a relay via USB, using a program made with any language.

Someone have simple schematics to show me, or some information on how this works?

Daniel Accorsi
  • 123
  • 1
  • 1
  • 3
  • 1
    http://www.phidgets.com/ – kenny Mar 27 '12 at 16:09
  • 1
    http://electronics.stackexchange.com/questions/267/id-like-to-learn-how-to-make-my-own-usb-gadgets http://electronics.stackexchange.com/questions/1942/how-to-build-a-usb-controller-having-knobs-sliders-and-switches – Toby Jaffey Mar 27 '12 at 16:09
  • @DanielAccorsi - What's your desired integration level? Are you building a product that will work with someone's software, and therefore you'd want to build a custom PCB, are you working on a production line and want to buy an industrial IO solution and be done with it, or are you just trying to hack something together in your basement? – Kevin Vermeer Mar 28 '12 at 17:35
  • Hi @KevinVermeer. I want develop my own usb controller to activate some relays. But i think be necessary buy a USB to printer parallel adapter, or to serial, like people saying below. – Daniel Accorsi Mar 28 '12 at 18:20
  • @DanielAccorsi - Ah, then it is in fact a duplicate of the above posts. You don't need to get an adapter, that's more of a quick and dirty hack. The linked posts will have more information on what you want to do. – Kevin Vermeer Mar 28 '12 at 19:43

2 Answers2

6

The easiest way is to buy a premade USB to parallel interface unit. These are available and may not be especially expensive, but there is a cheaper way.


A USB to RS232 serial port interface gives you several controllable control lines that can drive relays. For example, see the diagram below. Vcc is provided by an external power supply suited to the relay voltage. Ground is commined with the interface unit and the power supply. DTR and RTS are RS232 signals from the interface unit.

enter image description here

From here

Many ebay USB to RS232 serial adapters

Example:

enter image description here


For more than a few relays, a USB to printer parallel port adapter gives you 8 actual data lines plus a number of printer port control lines that are under computer control. In most cases you will need a buffer IC to allow the logic level signals to drive relays. A ULN2803 IC, a USB to parallel printer port unit and a power supply suited to the relay operating voltage is all that will be needed.

Replace resistors and LEDs in this diagram with relays.
Zener optional. If not used connect V+ to pin 10.
V+ shown as 9V but choose to suit relays.

http://www.epanorama.net/circuits/uln2803circuit.gif

Excellent and extensive parallel port interfacing page

Many ebay USB o printer parallel port adapters

Example:

enter image description here


Parallel port to relay kitset with circuit

enter image description here


ADDED:

The text below is summarised from material from the reference above re parallel port adapters used for printing.
Note that using data output methods that treat the port as a printer should work correctly.
Control of low level bit adressed functions may not be possible but you should still be able to manage at least 8 lines of relay control with ease and probably a few more with a little effort. he article says:

  • Notes on USB parallel port adapters.

    The USB-Parallel Port Adapter enables users to connect parallel port interfaced devices like printers to a desktop or laptop PC via the PC's USB port.

    The parallel port through this kind of adapter looks pretty same as normal parallel port for high level programs on Windows system. The low level implementation of them is completely different, and the low level I/O control operations described in this document do not work with USB parallel port adapters.

    USB parallel ports are generally targeted for driving normal printers, and not designed for anything else ... and it will not work for the direct output pin controlling described in this document.

Russell McMahon
  • 147,325
  • 18
  • 210
  • 386
  • Great!! Thanks Russell. All information I was searching... I will try... – Daniel Accorsi Mar 27 '12 at 17:35
  • We aware that many USB to parallel port devices are really USB to printer devices and do not provide easy low level access to the pins. – Craig Mar 27 '12 at 19:56
  • *Be* aware of what Craig says! A quote from the very page referred to by Russell: "you can forget using the USB (to) parallel ports for your own harware controlling." – Wouter van Ooijen Mar 27 '12 at 21:11
  • @Craig - ? I explicitly mentioned "real" USB to parallel interfaces and printer interfaces, with more emphasis on the latter. If you can send a data word to a printer it should give you control of 8 relays from any application that can operate a printer, so I'm not sure what point you are making. It may be that you cannot toggle some of the control lines at low level but surely data lines must be accessible by right. If not, it would be useful to know what the problem encountered is. Can you be more specific please. – Russell McMahon Mar 27 '12 at 21:13
  • See addition to answer. Should be OK for basic 8 bit output. – Russell McMahon Mar 27 '12 at 21:24
  • The top circuit unfortunately dies after few hours for me - https://electronics.stackexchange.com/q/302093/28709 – Matija Nalis May 06 '17 at 23:59
0

I bought one of these things a while ago. They're useful if you want to use those relays to switch mains power to a device. I use them to power on my audio amp and desk lamp from the PC. Software is available for Linux (from http://sispmctl.sourceforge.net/ ) and I presume Windows is standard.

stevenvh
  • 145,145
  • 21
  • 455
  • 667
jippie
  • 33,033
  • 16
  • 93
  • 160