home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.electronics
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!wupost!sdd.hp.com!cs.utexas.edu!torn!newshost.uwo.ca!gfx.engga.uwo.ca!rcook
- From: rcook@gfx.engga.uwo.ca (Richard Cook)
- Subject: Re: How can I send a bit to an optocoupler connected tp PC
- Organization: University of Western Ontario, London
- Date: Fri, 14 Aug 1992 13:52:14 GMT
- Message-ID: <1992Aug14.135214.28649@julian.uwo.ca>
- References: <13AUG199218514852@judy.uh.edu>
- Sender: news@julian.uwo.ca (USENET News System)
- Nntp-Posting-Host: cad12.gfx.engga.uwo.ca
- Lines: 59
-
- In article <13AUG199218514852@judy.uh.edu> cscc13@judy.uh.edu (NAVEED IQBAL) writes:
- >I want to write a program in C to turn on a relay controlled by an
- >optocoupler. I want to connect the coupler to a Pcs serial/parellel
- >port.
- >- What would be the pinout?
- >- How can I do that in C?
- > - or another language?
- >- I don't want to use those interface boards as I can't afford to.
- >
- >
- >
- >Thanx
- >Naveed Iqbal
- >NIqbal@uh.edu
- >
- >
-
- I have just finished testing control of a stepper motor through
- optocouplers and my printer port.
-
- I used LPT2 in Borland C++; on my computer LPT2 is at address 278,
- which is 632 in decimal. The output port is latched in the PC so
- using the following commands will turn on/off the output bit and
- leave it that way until you change it, turn off the computer, or
- run some other software that uses the printer port:
-
- outportb(632,1); /* set bit 0 to 1 */
-
- outportb(632,0); /* set bit 0 to 0 */
-
- Bit 0 on the parallel port is pin number 2. (bits 1 to 7 are pins
- 3 to 9). All 8 bits are changed at the same time.
-
- I fed pin 2 of a male DB-25 connector to a resistor, of
- about 470 ohms, then the resistor to pin 1 of the optocoupler.
- Connect pin 2 of the optocoupler to pin 25 of the DB-25.
-
- I found this in an electronics magazine, (Radio Elect. or the like).
- If you are interested I will find the reference.
-
- My e-mail address until the end of August is rcook@gfx.engga.uwo.ca
-
- Good Luck
-
-
- +-----------------------------------------------------------------+
- | Adult Children of Alcoholics: |
- | |
- | God, grant me the serenity to accept the things we cannot |
- | change, the courage to change the things we can, and the wisdom |
- | to know the difference. |
- | |
- | Help break the chain, become aware and educate others! |
- +-----------------------------------------------------------------+
- --
-
- +-----------------------------------------------------------------+
- | Adult Children of Alcoholics: |
- | |
-