ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339
Rep:
Quote:
Originally Posted by theNbomr
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)
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.
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...
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.