home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / sci / electron / 14369 < prev    next >
Encoding:
Text File  |  1992-08-14  |  2.7 KB  |  72 lines

  1. Newsgroups: sci.electronics
  2. 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
  3. From: rcook@gfx.engga.uwo.ca (Richard Cook)
  4. Subject: Re: How can I send a bit to an optocoupler connected tp PC
  5. Organization: University of Western Ontario, London
  6. Date: Fri, 14 Aug 1992 13:52:14 GMT
  7. Message-ID: <1992Aug14.135214.28649@julian.uwo.ca>
  8. References: <13AUG199218514852@judy.uh.edu>
  9. Sender: news@julian.uwo.ca (USENET News System)
  10. Nntp-Posting-Host: cad12.gfx.engga.uwo.ca
  11. Lines: 59
  12.  
  13. In article <13AUG199218514852@judy.uh.edu> cscc13@judy.uh.edu (NAVEED IQBAL) writes:
  14. >I want to write a program in C to turn on a relay controlled by an 
  15. >optocoupler. I want to connect the coupler to a Pcs serial/parellel 
  16. >port.
  17. >- What would be the pinout?
  18. >- How can I do that in C?
  19. >  - or another language?
  20. >- I don't want to use those interface boards as I can't afford to.
  21. >
  22. >
  23. >
  24. >Thanx
  25. >Naveed Iqbal
  26. >NIqbal@uh.edu
  27. >
  28. >
  29.  
  30. I have just finished testing control of a stepper motor through
  31. optocouplers and my printer port.
  32.  
  33. I used LPT2 in Borland C++; on my computer LPT2 is at address 278,
  34. which is 632 in decimal.  The output port is latched in the PC so
  35. using the following commands will turn on/off the output bit and
  36. leave it that way until you change it, turn off the computer, or
  37. run some other software that uses the printer port:
  38.  
  39.     outportb(632,1);    /*  set bit 0 to 1  */
  40.  
  41.     outportb(632,0);    /*  set bit 0 to 0  */
  42.  
  43. Bit 0 on the parallel port is pin number 2.  (bits 1 to 7 are pins
  44. 3 to 9).  All 8 bits are changed at the same time.
  45.  
  46. I fed pin 2 of a male DB-25 connector to a resistor, of
  47. about 470 ohms, then the resistor to pin 1 of the optocoupler.
  48. Connect pin 2 of the optocoupler to pin 25 of the DB-25.
  49.  
  50. I found this in an electronics magazine, (Radio Elect. or the like).
  51. If you are interested I will find the reference.
  52.  
  53. My e-mail address until the end of August is rcook@gfx.engga.uwo.ca
  54.  
  55. Good Luck
  56.  
  57.  
  58. +-----------------------------------------------------------------+
  59. | Adult Children of Alcoholics:                                   |
  60. |                                                                 |
  61. | God, grant me the serenity to accept the things we cannot       |
  62. | change, the courage to change the things we can, and the wisdom |
  63. | to know the difference.                                         |
  64. |                                                                 |
  65. | Help break the chain, become aware and educate others!          |
  66. +-----------------------------------------------------------------+
  67. -- 
  68.  
  69. +-----------------------------------------------------------------+
  70. | Adult Children of Alcoholics:                                   |
  71. |                                                                 |
  72.