LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-19-2009, 08:09 PM   #1
darkxer0x
LQ Newbie
 
Registered: Feb 2009
Posts: 20

Rep: Reputation: 0
Send 5VDC signal from PC


Hi!
I want to generate a 5VDC signal from computer to "activate"/"deactivate" a contactor (well, now I have a TIP 120 transistor).

Now, what Iīm doing is connecting an arduino to the PC, and the 5VDC signal is "generated"/"controlled" by Arduino (in Linux I do-> echo "12" > /dev/tty.USB and arduino gives me 5 volts in pin 12).

Iīve tried with usb, but the problem is that USB is always giving me 5 VDC (using pin of 5VCC). I canīt controll when stop from giving me 5 volts. Itīs a feature of mother boards to always keep 5 volts, even when the computer is off (I think). Of course, Iīve tried to remove modules of usb, but itīs always giving me 5 volts. Iīve also tried to send a signal to a usb cable (usind data wires), but it doesnīt send anything. I think itīs because Linux doesnīt detect any hardware at that port, and it doesnīt send any singal (I think again).

Iīve also seen RS232 and audio output, but it seems to manage digital signals only.

Any ideas??
 
Old 10-19-2009, 08:18 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
personally i use serial or parallel port
easy to control serial is 12v and parallel is 5
 
Old 10-19-2009, 08:28 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
IMHO the easiest port to control is a built in parallel (printer) port if your computer has one. There are many sites that explain how to program the port to control the individual signals. USB to parallel ports adapters are not suitable for this purpose.
 
Old 10-20-2009, 02:17 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
So, to restate your question, you want to drive a transistor that acts as a switch to control power to a microcontroller board. Correct? You can use a serial port to do this, by controlling any either the RTS or DTR outputs. These signals are +/- 12 V, depending on the logic state. You should be able to use them to drive the transistor, although the transitions will be slow due to slew rate limiting. Typically the driver will limit current on the RS-232 signals for self-protection, and depending on the transistor, this may affect the ability to saturate the transistor. Your darlington pair device should be okay, but may require a blocking diode for the negative voltage logic state.
Most PC parallel ports output TTL logic levels, which may not be a full 5 volts at a logic high level. Parallel ports are, sadly, becoming uncommon these days. They are very useful for purposes such as yours, and you may be able to add one as a plug-in board, although if it is a PCI plug-in, you may have to write a special driver to control it in the way you require. If you get one that advertises itself as being compatible with anti-piracy dongles, it may work the same as a ISA-bus pug-in card. As a previous poster has already stated, a USB parallel port dongle is probably not a suitable replacement for your purpose.
--- rod.
 
Old 10-20-2009, 02:36 PM   #5
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by theNbomr View Post
So, to restate your question, you want to drive a transistor that acts as a switch to control power to a microcontroller board. Correct? You can use a serial port to do this, by controlling any either the RTS or DTR outputs. These signals are +/- 12 V, depending on the logic state. You should be able to use them to drive the transistor, although the transitions will be slow due to slew rate limiting. Typically the driver will limit current on the RS-232 signals for self-protection, and depending on the transistor, this may affect the ability to saturate the transistor. Your darlington pair device should be okay, but may require a blocking diode for the negative voltage logic state.
Most PC parallel ports output TTL logic levels, which may not be a full 5 volts at a logic high level. Parallel ports are, sadly, becoming uncommon these days. They are very useful for purposes such as yours, and you may be able to add one as a plug-in board, although if it is a PCI plug-in, you may have to write a special driver to control it in the way you require. If you get one that advertises itself as being compatible with anti-piracy dongles, it may work the same as a ISA-bus pug-in card. As a previous poster has already stated, a USB parallel port dongle is probably not a suitable replacement for your purpose.
--- rod.
WTF is a anti piracy dongle? LOL
anyway the kernel should auto drive it weather its ISA or PCI, it sets up a common device(does not apply to USB)
 
Old 10-20-2009, 03:38 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Anti-piracy dongles were common about 10-15 years ago. They were a type of hardware key that was used to allow software to run only when the key was present, usually on the parallel port. They relied on low-level access to a standard parallel port. Modern PCI parallel ports have an extra layer of PCI interface, so you can't just peek and poke at IO registers to access them, hence relying on drivers to support them. The drivers do not provide such low-level access and are therefore incompatible with such dongles, and most likely with software such as the original poster would write and use. Drivers provided with PCI parallel ports allow them to be used to talk to printers, and do not permit arbitrary setting of internal registers. This is the same problem as with a USB parallel port.
--- rod.
 
Old 10-21-2009, 03:21 AM   #7
darkxer0x
LQ Newbie
 
Registered: Feb 2009
Posts: 20

Original Poster
Rep: Reputation: 0
Hi!
Thanks to all.
I was able to send a 5 V signal from parallel port. Very, very easy with C and Linux (and root privileges :P). Now Iīve seen I can also manage a LCD display with parallel port, and I donīt need all the pins of parallel port, so Iīm going to use parallel port to switch on the transistor and print on the display. Ah, well, Iīm going to use a relay instead of a transistor. I donīt know what itīs better (transistor vs relay), but I think in my case itīs better a relay, because Iīm going to switch on/off a 12 VAC sinusoid signal.

Iīll update the post with the news
Thanks again

P.D. What a pitty parallel port is disappearing...

Last edited by darkxer0x; 10-21-2009 at 03:23 AM.
 
Old 10-21-2009, 10:59 AM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You may find a relay requires more current than a TTL level signal can source.
--- rod.
 
Old 10-21-2009, 12:12 PM   #9
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
i always drive a transistor that drives a relay that drives the load for the best coupling
 
Old 10-26-2009, 04:51 PM   #10
darkxer0x
LQ Newbie
 
Registered: Feb 2009
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by smeezekitty View Post
i always drive a transistor that drives a relay that drives the load for the best coupling
Yes, perfect, as I did, with a diode in paralell with the relay.
Iīve finished, and it works perfect!
But I had to use a data line in parallel port to use as control signal (DATA0 -> transistor base) because status lines are read-only, and control lines are at high-level when the computers restart...

If I get the LCD working with parallel port not using DATA0 (I use for open the door), Iīll tell you.

Thanks again to erveryone! Iīll published a tutorial explaining all (ldap + gnutls + rsyslog + pcscd + parallel port + circuit...). First in spanish, then in english
 
Old 10-26-2009, 05:03 PM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
What type of LCD are you using? A common 2 line or 4 line unit? If it uses the HD44780 chip then there is a 4 bit word mode that can be configured so you only need 4 data lines including strobe and select printer. I assume that you do not need to read data from the display.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pc doesn't send out signal to monitor MafiaTux Linux - General 4 08-07-2008 08:36 AM
how to send a signal to a thread stephenwalter Programming 2 10-17-2005 01:07 AM
trying to send signal from linux module andreiij Programming 1 05-02-2005 12:46 PM
What is hup signal? How to send one to squid? Niceman2005 Linux - Newbie 2 12-17-2004 07:37 PM
Send signal to /dev/dsp marghorp Linux - Hardware 5 05-25-2004 03:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration