Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Hardware Software Linux

Control 8 Electrical Devices With Your Parallel Port 48

Michael Williamson writes "A PC parallel port can provide 0 or 5v on 8 pins, individually controllable. This can be used to directly drive LED lights, or with the addition of an external power supply, some switching transistors, and some relays, control 8 higher-powered devices. I've written a handful of example programs that drive a homemade 8-LED display in amusing ways."
This discussion has been archived. No new comments can be posted.

Control 8 Electrical Devices With Your Parallel Port

Comments Filter:
  • by skinfitz ( 564041 ) on Tuesday May 06, 2003 @07:46PM (#5896674) Journal
    I got a relay kit from Carl's Electronics [electronickits.com] which switches 8 relays and works brilliantly. Great fun!
  • by ObviousGuy ( 578567 ) <ObviousGuy@hotmail.com> on Tuesday May 06, 2003 @07:47PM (#5896690) Homepage Journal
    value = pin[0]*1 + pin[1]*2 + pin[2]*4 + pin[3]*8 + pin[4]*16 + pin[5]*32 + pin[6]*64 + pin[7]*128;

    And they say Perl looks like line noise.
  • by forsetti ( 158019 ) on Tuesday May 06, 2003 @07:56PM (#5896802)
    With a few extra chips (decoders), it would be awfully easy to control 2^8=256 devices. Note that I said "control", and not "drive". You will definitely need some external power to drive this....
    • With a few extra chips (decoders), it would be awfully easy to control 2^8=256 devices.

      Wouldn't it be 128? You do need a line to control the chosen device, ie on/off.

      • mmmm.....well, I would use the standard 8 data pins to select the device, then the 5 control pins to send actions to the selected device.

        Although, it may make more sense to use the 5 control lines as select (limiting you to 32 devices), the 4 low data lines for "instructions", the 4 high data lines for output data, and the 4 input lines for input data.

        Of course, then again, I am definitely spending way to many brain cycles on this.......
    • You could also boost the amount of devices using only transistors. You have 8 basic imputs, add a few transitors to make AND/OR gates and the rest is common sense from there. The best use of this (other than the want for more devices ofcourse) is so you can use a thinner cable. UTP Cat5 cable is cheap, but it only has 4 pairs, so eight wires, one has to be the ground. So now we have 7 data wires and 1 ground. 1 - 7 1 AND 2 - 1 AND 7 2 AND 2 - 2 AND 7 3 AND 3 - 3 AND 7 4 AND 4 - 4 AND 7 5 AND 5 - 5 AND 7 6
    • How about 13 with no extra hardware at all? Standard parallel port (and by "standard" I mean the all the way down to ye olde 8086 machines) have 8 data, 5 control and 4 status (input) pins.

      The only hitch is that four of the 5 control lines are inverted (output a 1 and it becomes a ground, 0 and it goes +5v high). But god forbid you should do any logic or anything :)

      You really can't do much with +5v anyway... so you're likely to drive a set of power transistors / relays to switch lights or motors anyway...
      • I have tinkered a lot with 555 ic's for a while, and for the life of me, cannot find an understandable way to use transistors to replace the relays I am using with the 555's. Can anyone point me to a decent web page describing how to use transistors in my 555 application or in the paralell port device control project that this article is about?
  • by curious.corn ( 167387 ) on Tuesday May 06, 2003 @08:18PM (#5897035)
    Take a diagram like this [ksu.edu] and add another line of FF on the outputs to mask the output while shifting... (say, DTR will shut them keep/thru, RTS to strobe... use CTS on a dead FF or buffer to sync for propagation delays) Heh, can you buy FF sticks anymore? it would be fun to play with...
  • USB parport (Score:3, Interesting)

    by n1ywb ( 555767 ) on Tuesday May 06, 2003 @08:25PM (#5897094) Homepage Journal
    I can't belive people are still using the parallel port. I just finished my first project using USB for my interface, and it was pretty easy overall. I guess not as easy as using the parallel port, but then again I can control 127 USB devices, and each one could be controlling an arbitrary number of other devices. I would like to see some decent USB experimentation products and drivers out there. Maybe I'll hear my own calling.
    • How about some schematics? Or maybe a pointer to a website on how to build some hardware?
      • Re:USB parport (Score:3, Interesting)

        by n1ywb ( 555767 )
        I used Microchip's USB PICs. They'll send you free samples, although you'll need to be able to program them somehow. I won't go into the details of getting started in PIC programming, you can google for that and find 1000 pages. They supply USB firmware, which is pretty easy to use. Just define your descriptors (this will require reading parts of the USB spec), and then put copy your data into a buffer and put the number of bytes in W and call their library routine. Data sent.

        If you look at the data sheet
        • Question for you before I go off and start surfing on it: Would you say that is a good way to make a device that I could hook up to Linux?

          For example, a little robot with a USB connection, a PIC processor to load memory and maybe the same processor to run the robot or perhaps a different one. Plug robot into my Linux box with USB cable. (Appropriate software on Linux box and in robot firmware). Download new robot program through USB, flip a switch and let it run.

          Never built any really complicated electron
          • You can, but I don't believe there is much documentation on it. I am a Windows programmer, but am starting to learn Gtk programming now. The article at http://usb.cs.tum.edu/usbdoc/ may be helpful to learn about USB on Linux.
          • Would you say that is a good way to make a device that I could hook up to Linux?

            It certainly is. If you use the USB scanner driver (which actualy isn't necissarily just for scanners at all) you can write all your control software without having to change kernel code. Your favorite distro almost certainly has the scanner module built already. Personally I find writing a kernel based driver easier (probably because it's what I do for a living and I'm used to it), and you can do that too.

            If you want to acce
    • I agree on this. Switching 8 channels isn't hard. We did this on a cbm64. It should also be possible in an usb device.

      Many usb devices are way more powerful than the commodore, so it shouldn't be too hard at all to make something like it

      Maybe there are DIY packages for it already.

      It would be nice if I could use all of the expansion port devices I made for the 64 with a modern PC :)
  • Coffee (Score:3, Informative)

    by infernalC ( 51228 ) <matthew.mellon@g o o g l e . com> on Tuesday May 06, 2003 @08:43PM (#5897241) Homepage Journal
    There has been a HOWTO for controlling an automatic drip coffee machine for years using your legacy paraport. See Coffee HOWTO [tldp.org].
  • Hmmmm... lets see my senior project controlled a radio telescope using the parellel port 10 years ago... wasn't even considered new then, there were internet sites telling you exactly how to do it (well I/O through the parellel port, we had to handle the D-A conversion ourself)

    I guess it just suprises people when they use an I/O port to do I/O

  • Also, (Score:1, Informative)

    by Anonymous Coward
    There are other neat computer chips out there that will light up LEDs or perform logical functions, or whatever you want. Start here [tinaja.com].
  • You can control the lights at a party with a setup like this (yes, I've done it with relays) with this cool Open Source XMMS plugin: Palace [sf.net]. I'm working on a circuit that uses a 1-in-16 demux and 16 74ls373's on the 4 control pins to run 128 LED's (though I haven't had much time to spend on it).

    Disclaimer: I wrote Palace. It used to be based on XPLSISNJASP (can't reach its project page anymore), but most or all of that old code has been ripped out and/or rewritten.
  • I dont know much about electronics or physics or anything :(
    I once tried wiring a led to an AA battery but it didnt do squat, lol.
    I wouldnt even know where to get electronics material. There is no radio shack in Portugal :(
    If anyone knows of a fool-proof tutorial on led-play for the utterly clueless dummies like me, I would kill to be able to make a battery-powered led constellation to hang on the wall.
    • LEDs are diodes, which means they only conduct electricity (and in doing so give of light) in one direction. Usually on LEDs the shorter of the two leads is the cathode, which means the side that's to be connected to the negative side of the battery. The other side (the anode) connects to the positive side of the battery.
  • My dear friend and cousin Jerry wrote a nice little Perl Parallel Programming HOWTO [geekinventions.com] for controlling your parallel port with perl.

    He has used this to write an interface app for a Bar Monkey type program. Pictures here. [geekinventions.com]

  • Done it. Here's the one I worked on back in the early days of college: The Button [wpi.edu] It's 8 LEDs and a button connected to a paralel port (The button is attached to the select line... We got 9 uses out ouf ours!). When the button is pressed some scripts are run on the host that update this website, turn on the LEDs and other things. What the LEDs do is controlled by this web form.

    This story is so 1996.
  • This is so 1987 [google.com].

  • Long time ago, when I was little, I hooked some 5.25" drive stepper motors through a multiplexer to the parallel port and controlled it through a program in slackware. But this was a long time ago.

    Now I wonder whats with this news over here? Next week: guess what! A serial port can be connected to another to transfer data!!!

    Please keep my slashdot interesting.
    • Yes, it is a good /. story.

      Believe it or not, there are geeks who've lived only in the software world, and never even picked up a soldering iron (sad but true), but would like to learn a little. A simple electronics project that gives them a taste of the hardware world is just perfect for them.

  • I recently wrote a Python C extension for doing just this. It's nice to be able to twiddle bits back and forth realtime from inside the Python interpreter when you're debugging hardware.

    Download it here: PyPortIO [ultrasoul.com]

    Use it like this:

    import portio

    lp0 = portio.Port(0x378)
    lp0.outb(0xFF)

    There's also a good list of links for reading up on more projects there.

  • As per the recent survey on fun ways to reboot one's PC, and the mention of reading "sleep" buttons on 'nix...

    How about some more basic instructions on how to configure 'input' devices on the parallel port, and then maybe some programming tips (windows and 'nix both) on how to work with them.

    Personally, I've been wondering if I could make my own input-device. Maybe a DDR floor panel or something? Or just I/O, with panels that light up as well as sending back info. How about it?
    • If you're playing DDR on a playstation, you just grab a $5 knockoff playstation controller and wire to the button connectors on the circuit board. I did this, using heavy modifications on the design found here [geocities.com]. If you're playing on the PC, I think you can then just get an adapter to convert the playstation controller to USB.
  • back in '88 or so, I built a parallel-port D/A converter and wrote some DOS drivers for it (in *assembler*, baby). It produced pretty good sound quality, after downloading some 12-bit samples from a borrowed MIDI sampler - beat the hell out of trying to modulate the PC speaker by switching it on or off at about 100kHz.
  • I just have one word

    Yawn.

  • The joy of making things work, even if it seems trivial to some seasoned expert, is not to be undervalued! Controlling things through the parallel port may not be novel, but learning how to use it to turn on and off LEDs and relays is still worthwhile.

    There is this wonderful connection between the 1's and 0's of software actually appearing as electrical signals with one or the other voltage on them.

    I have preferred connecting something to the serial port myself, since that was easier to get working unde

  • This is really easy, and cheap to do. LEDs shouldn't need any extra components - most bright ones you should be able to drive directly without causing any problems.

    For control, you need a few extra components, but not many. A TIP122 or similar power switching resistor (a cheaper 2N2222 might work, dunno) and a 12V power supply can be used to control dirt-cheap automotive relays. The only (minor) gotcha is you need to hook up a diode in reverse across the coil to stop the back EMF. A 1N4002 connected with t
    • On my computer, the fans are controlled by something like this. I just used 4 2n2222's and used two parallel port lines, one with a 10k and the other with a 5k resistor, on each so the speed was variable. I'm thinking of adding some 74HC595 shift registers to get more outputs - these can be chained to get virtually as many outputs as you want. I also added some buttons to override the computer control, if necessary. The hardware's a mess but it works well with the software I wrote (the fan speed increases

If all else fails, lower your standards.

Working...