This commit is contained in:
gferg 2004-06-09 23:26:00 +00:00
parent 7da9412f94
commit f9718ec295
1 changed files with 276 additions and 276 deletions

View File

@ -1,276 +1,276 @@
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN"> <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
<article id="HomeElectric"> <article id="HomeElectric">
<articleinfo> <articleinfo>
<title>Home Electrical Device Control HOWTO</title> <title>Home Electrical Device Control HOWTO</title>
<author> <author>
<firstname>Rui</firstname> <firstname>Rui</firstname>
<surname>Li</surname> <surname>Li</surname>
<affiliation> <affiliation>
<address><email>ruili@worldnet.att.net</email></address> <address><email>ruili@worldnet.att.net</email></address>
</affiliation> </affiliation>
</author> </author>
<abstract> <abstract>
<para>This HOWTO will tell you how to use Linux to control your home electrical <para>This HOWTO will tell you how to use Linux to control your home electrical
devices. You will only need to make a very devices. You will only need to make a very
simple circuit to control almost any kind of electrical simple circuit to control almost any kind of electrical
device using Linux!</para> device using Linux!</para>
</abstract> </abstract>
<pubdate>2003-02-08</pubdate> <pubdate>2003-02-08</pubdate>
<revhistory> <revhistory>
<revision> <revision>
<revnumber>0.008</revnumber> <revnumber>0.008</revnumber>
<date>2003-02-08</date> <date>2003-02-08</date>
<authorinitials>Goldencat</authorinitials> <authorinitials>Goldencat</authorinitials>
</revision> </revision>
<revision> <revision>
<revnumber>0.007</revnumber> <revnumber>0.007</revnumber>
<date>2002-02-12</date> <date>2002-02-12</date>
<authorinitials>RL</authorinitials> <authorinitials>RL</authorinitials>
</revision> </revision>
<revision> <revision>
<revnumber>0.006</revnumber> <revnumber>0.006</revnumber>
<date>2001-06-27</date> <date>2001-06-27</date>
<authorinitials>JEY</authorinitials> <authorinitials>JEY</authorinitials>
</revision> </revision>
<revision> <revision>
<revnumber>0.005</revnumber> <revnumber>0.005</revnumber>
<date>2001-06-13</date> <date>2001-06-13</date>
<authorinitials>RL</authorinitials> <authorinitials>RL</authorinitials>
</revision> </revision>
<revision> <revision>
<revnumber>0.004</revnumber> <revnumber>0.004</revnumber>
<date>2001-06-12</date> <date>2001-06-12</date>
<authorinitials>JEY</authorinitials> <authorinitials>JEY</authorinitials>
</revision> </revision>
</revhistory> </revhistory>
<othercredit role="converter"> <othercredit role="converter">
<firstname>Joy</firstname> <firstname>Joy</firstname>
<surname>Yokley</surname> <surname>Yokley</surname>
<contrib>Coverted document from Linuxdoc to DocBook v4.1 (SGML).</contrib> <contrib>Coverted document from Linuxdoc to DocBook v4.1 (SGML).</contrib>
</othercredit> </othercredit>
</articleinfo> </articleinfo>
<sect1 id="Introduction"> <sect1 id="Introduction">
<title>Introduction</title> <title>Introduction</title>
<para>Many people asked me, "Is it possible to control some electrical <para>Many people asked me, "Is it possible to control some electrical
stuff [e.g. lights, radio, tv, etc.] by using a home computer?" The answer is YES. stuff [e.g. lights, radio, tv, etc.] by using a home computer?" The answer is YES.
The process is very easy, and anyone can do it.</para> The process is very easy, and anyone can do it.</para>
<para>After I read the Coffee Machine Mini-HOWTO, I got an idea of how to control <para>After I read the Coffee Machine Mini-HOWTO, I got an idea of how to control
my home electrical appliances. I made some modifications on the circuit discussed in that my home electrical appliances. I made some modifications on the circuit discussed in that
Coffee Machine Mini-HOWTO, and wrote a simple program. The circuit can Coffee Machine Mini-HOWTO, and wrote a simple program. The circuit can
control many small electrical devices.^_^ You can use <command>crontab</command> control many small electrical devices.^_^ You can use <command>crontab</command>
to set your lights to come on automatically or to turn on your airconditioner. I use it to control my VCR and VCD ( I do still need some modification on VCR/VCD). to set your lights to come on automatically or to turn on your airconditioner. I use it to control my VCR and VCD ( I do still need some modification on VCR/VCD).
By writing a simple program, you can control everything over the web. You can use By writing a simple program, you can control everything over the web. You can use
telnet with SSH and your telephone dial in to control all the appliances you have on the circuit.</para> telnet with SSH and your telephone dial in to control all the appliances you have on the circuit.</para>
<para>This circuit is VERY SIMPLE. Even if you don't know anything <para>This circuit is VERY SIMPLE. Even if you don't know anything
about circuits, you can set up this circuit.</para> about circuits, you can set up this circuit.</para>
</sect1> </sect1>
<sect1 id="SysRequirements"> <sect1 id="SysRequirements">
<title>System Requirement</title> <title>System Requirement</title>
<para>Get any computer that is running Linux and has a working parallel port. :) <para>Get any computer that is running Linux and has a working parallel port. :)
I'm using a 386DX with 4MB RAM 40MB HD. I'm using a 386DX with 4MB RAM 40MB HD.
You will need gcc to compile the program. If you want to use telnet or SSH, You will need gcc to compile the program. If you want to use telnet or SSH,
you will also need <application>telnetd</application> or <application>sshd</application>. You can write your own you will also need <application>telnetd</application> or <application>sshd</application>. You can write your own
program by using <application>ioperm</application> and <application>outb</application>. If you would like to program by using <application>ioperm</application> and <application>outb</application>. If you would like to
use my program, you will need g++.</para> use my program, you will need g++.</para>
<para>Click the following link to download my program. You will need g++ to compile it. <para>Click the following link to download my program. You will need g++ to compile it.
<ulink URL="http://edc.sourceforge.net/paralle.tar.gz"> edc.sourceforge.net/paralle.tar.gz</ulink>.</para> <ulink URL="http://edc.sourceforge.net/paralle.tar.gz"> edc.sourceforge.net/paralle.tar.gz</ulink>.</para>
</sect1> </sect1>
<sect1 id="Circuit"> <sect1 id="Circuit">
<title>Electronic Circuit</title> <title>Electronic Circuit</title>
<para>The data line of the parallel port can provide between 0 and 5 volts. <para>The data line of the parallel port can provide between 0 and 5 volts.
Therefore, we can use this line to control a relay and let that relay control Therefore, we can use this line to control a relay and let that relay control
an electrical device.</para> an electrical device.</para>
<para>Use pins 2 through 9 to get +5V</para> <para>Use pins 2 through 9 to get +5V</para>
<para>Use pins 18 through 25 as the Ground</para> <para>Use pins 18 through 25 as the Ground</para>
<programlisting> <programlisting>
____________________________________________________________ ____________________________________________________________
/ \ / \
\ 13 12 11 10 9 8 7 6 5 4 3 2 1 / \ 13 12 11 10 9 8 7 6 5 4 3 2 1 /
\ / \ /
\ 25 24 23 22 21 20 19 18 17 16 15 14 / \ 25 24 23 22 21 20 19 18 17 16 15 14 /
\______________________________________________________/ \______________________________________________________/
| Vcc for Relay | Vcc for Relay
| |
| |
/ -------+--------| |---------| / -------+--------| |---------|
P data 4.7K B / c | 1N4002 |_| |------- P data 4.7K B / c | 1N4002 |_| |-------
-----------/\/\/\/\---------+-----| NPN _____ | relay |home device -----------/\/\/\/\---------+-----| NPN _____ | relay |home device
| \ e /_\ |-| |------- | \ e /_\ |-| |-------
LED X \ +--------| |---------| LED X \ +--------| |---------|
P Ground | | | P Ground | | |
----------------------------+-------+--------+ ----------------------------+-------+--------+
Relay Ground | Relay Ground |
---------------------------------------------+ ---------------------------------------------+
</programlisting> </programlisting>
<para>Below is the key to the diagram above:</para> <para>Below is the key to the diagram above:</para>
<programlisting>P data parallel port data line(pin 2 to pin 9, use any) <programlisting>P data parallel port data line(pin 2 to pin 9, use any)
P Ground parallel port ground (pin 18 to pin 25, use any) P Ground parallel port ground (pin 18 to pin 25, use any)
Vcc depends on the type of your relay. I'm using 12VDC Vcc depends on the type of your relay. I'm using 12VDC
Relay Ground the ground for 12VDC Relay Ground the ground for 12VDC
4.7k 4.7K resistor 4.7k 4.7K resistor
NPN C2235 NPN transistor NPN C2235 NPN transistor
1N4002 1N4002 diode 1N4002 1N4002 diode
LED light emitting diode LED light emitting diode
relay a coil relay</programlisting> relay a coil relay</programlisting>
<para>+5 volts from parallel port will turn on the relay. Once the relay is on, <para>+5 volts from parallel port will turn on the relay. Once the relay is on,
the device connected to that relay will be on. When the parallel port's data the device connected to that relay will be on. When the parallel port's data
line goes back to 0, it will turn off the relay, and device is off.</para> line goes back to 0, it will turn off the relay, and device is off.</para>
</sect1> </sect1>
<sect1 id="relay"> <sect1 id="relay">
<title>Examples of Relays</title> <title>Examples of Relays</title>
<para>The diagrams below are used to explain how relays work.</para> <para>The diagrams below are used to explain how relays work.</para>
<para>The relay itself is just a switch as seen in the diagram below:</para> <para>The relay itself is just a switch as seen in the diagram below:</para>
<programlisting> <programlisting>
relay power off relay power on relay power off relay power on
|3 |3 |3 |3
| | | |
| | | |
o o o o
\ | \ |
o \ o o \ o
| | | |
| | | |
| | | |
|4 |4 |4 |4
</programlisting> </programlisting>
<para>The diagram below demonstrates the setup of a 4 pin relay.</para> <para>The diagram below demonstrates the setup of a 4 pin relay.</para>
<programlisting> <programlisting>
____________________________ ____________________________
| | | |
1 | | 3 1 | | 3
-----|---------s o----------|------- -----|---------s o----------|-------
| coil s \switch | | coil s \switch |
2 | s \ | 4 2 | s \ | 4
-----|---------s o- \-------|------- -----|---------s o- \-------|-------
| | | |
| | | |
| | | |
|__________________________| |__________________________|
</programlisting> </programlisting>
<para> <para>
In the diagram above, pin 3 and pin 4 are disconnected by default. In the diagram above, pin 3 and pin 4 are disconnected by default.
When you send +12V between pin 1 and pin 2, When you send +12V between pin 1 and pin 2,
it will turn on a switch, and pin 3 and 4 are now connected. it will turn on a switch, and pin 3 and 4 are now connected.
</para> </para>
<para>The following is a 5 pin relay:</para> <para>The following is a 5 pin relay:</para>
<programlisting> <programlisting>
_______________________________ _______________________________
| | | |
1 | | 5 1 | | 5
---------|---+ o------------|---------------- ---------|---+ o------------|----------------
| |-----------/---- s | | |-----------/---- s |
| / s | | / s |
3 | / s | 3 | / s |
---------|-----------o/ coil s | 4 ---------|-----------o/ coil s | 4
| o---s-------|---------------- | o---s-------|----------------
| | | | | |
| | | | | |
2 | | | 2 | | |
----------|---------------------+ | ----------|---------------------+ |
|_____________________________| |_____________________________|
</programlisting> </programlisting>
<para> <para>
In the above diagram pin 3 is connected to pin 5, by default. In the above diagram pin 3 is connected to pin 5, by default.
By sending +12V between pin 1 and pin 2, you will By sending +12V between pin 1 and pin 2, you will
will turn on a switch. Pin 1 and pin 2 will disconnect, will turn on a switch. Pin 1 and pin 2 will disconnect,
and pin 5 and pin 4 will connect. and pin 5 and pin 4 will connect.
</para> </para>
<programlisting> <programlisting>
relay power off relay power on relay power off relay power on
|5 |5 |5 |5
| | | |
| | | |
o o o o
\ | \ |
o \ o o o \ o o
| o | | | o | |
| | | | | | | |
| | | | | | | |
4| |3 4| |3 4| |3 4| |3
</programlisting> </programlisting>
<para>Some relays may have more that 5 pins. More pins just means there are more switches.</para> <para>Some relays may have more that 5 pins. More pins just means there are more switches.</para>
<para>I wrote a simple program that can control 8 relays. The program is available at the following location and <para>I wrote a simple program that can control 8 relays. The program is available at the following location and
will need g++ in order to be able to use this program. will need g++ in order to be able to use this program.
<ulink URL="http://edc.sourceforge.net/paralle.tar.gz">http://edc.sourceforge.net/paralle.tar.gz</ulink></para> <ulink URL="http://edc.sourceforge.net/paralle.tar.gz">http://edc.sourceforge.net/paralle.tar.gz</ulink></para>
<para>A complete circuit can control up to eight relays, that means that a complete circuit can control <para>A complete circuit can control up to eight relays, that means that a complete circuit can control
eight different devices. You will need a DB25 connector. Using a parallel eight different devices. You will need a DB25 connector. Using a parallel
switch cable, connect this relay board to your computer. I put the relay board in a box switch cable, connect this relay board to your computer. I put the relay board in a box
and use a parallel switch cable to connect it to my Linux box:</para> and use a parallel switch cable to connect it to my Linux box:</para>
<programlisting>Panel: LED, Switch Back: DB25 connector</programlisting> <programlisting>Panel: LED, Switch Back: DB25 connector</programlisting>
<para>Below is an example of how a relay board would connect with your electrical device:</para> <para>Below is an example of how a relay board would connect with your electrical device:</para>
<programlisting> <programlisting>
CONNECTED RELAY BOARD CONNECTED RELAY BOARD
+-----+ power outlet +-----+ power outlet
1 _______3 | __|________ || || 1 _______3 | __|________ || ||
--| |---------+ | | | || || --| |---------+ | | | || ||
2 |relay|4 | (o) (o) | _||___||__ 2 |relay|4 | (o) (o) | _||___||__
--|_____|----+ |------|---| | | --|_____|----+ |------|---| | |
| | | | | | | |
| +------------+ | | plug | +------------+ | | plug
ground | | hot | | ground | | hot | |
| | | | | | | |
__|_|__ | | __|_|__ | |
| | | | |________| | | | | |________|
| | | | plug | | | | plug
| | | | | | | |
|_|_|_| (i know it doesn't look like a plug, but it's a plug :-) ) |_|_|_| (i know it doesn't look like a plug, but it's a plug :-) )
|| || || ||
|| || || ||
</programlisting> </programlisting>
<para> <para>
To connect the system, just connect your home electrical device to the power outlet. That is it! To connect the system, just connect your home electrical device to the power outlet. That is it!
You don't need to make any change on the electrical device. And you can You don't need to make any change on the electrical device. And you can
connect any kind of device to that power outlet. Plug this power outlet into any wall outlet. connect any kind of device to that power outlet. Plug this power outlet into any wall outlet.
</para> </para>
<para>To see photos of what the finished product looks like, go to the following sites:</para> <para>To see photos of what the finished product looks like, go to the following sites:</para>
<itemizedlist><listitem><para><ulink URL="http://edc.sourceforge.net/p1.jpg">http://edc.sourceforge.net/p1.jpg</ulink></para></listitem> <itemizedlist><listitem><para><ulink URL="http://edc.sourceforge.net/p1.jpg">http://edc.sourceforge.net/p1.jpg</ulink></para></listitem>
<listitem><para><ulink URL="http://edc.sourceforge.net/p2.jpg">http://edc.sourceforge.net/p2.jpg</ulink></para></listitem> <listitem><para><ulink URL="http://edc.sourceforge.net/p2.jpg">http://edc.sourceforge.net/p2.jpg</ulink></para></listitem>
<listitem><para><ulink URL="http://edc.sourceforge.net/p3.jpg">http://edc.sourceforge.net/p3.jpg</ulink></para></listitem> <listitem><para><ulink URL="http://edc.sourceforge.net/p3.jpg">http://edc.sourceforge.net/p3.jpg</ulink></para></listitem>
</itemizedlist> </itemizedlist>
<para>The following URL shows a complete electronic circuit (control 8 devices): <para>The following URL shows a complete electronic circuit (control 8 devices):
<ulink URL="http://edc.sourceforge.net/01.png">http://edc.sourceforge.net/01.png</ulink></para> <ulink URL="http://edc.sourceforge.net/01.png">http://edc.sourceforge.net/01.png</ulink></para>
</sect1> </sect1>
<sect1 id="thanks"> <sect1 id="thanks">
<title>Special Thanks</title> <title>Special Thanks</title>
<para>Special thanks to Rufus Chang <ulink URL="mailto:rufus@chu.url.com.tw"> <para>Special thanks to Rufus Chang <ulink URL="mailto:rufus@chu.url.com.tw">
rufus@chu.url.com.tw</ulink>.</para> rufus@chu.url.com.tw</ulink>.</para>
<para>Special thanks to Chih-Wei Huang <ulink URL="mailto:cwhuang@linux.org.tw"> <para>Special thanks to Chih-Wei Huang <ulink URL="mailto:cwhuang@linux.org.tw">
cwhuang@linux.org.tw</ulink>.</para> cwhuang@linux.org.tw</ulink>.</para>
</sect1> </sect1>
<sect1 id="copyright"> <sect1 id="copyright">
<title>Copyright and License</title> <title>Copyright and License</title>
<para>Copyright Rui Li 2000-2001. License is GNU GPL, but it is requested that <para>Copyright Rui Li 2000-2001. License is GNU GPL, but it is requested that
you retain the author's name and email on all copies. Please keep my name and you retain the author's name and email on all copies. Please keep my name and
e-mail address when you are copying this HOWTO.</para> e-mail address when you are copying this HOWTO.</para>
</sect1> </sect1>
</article> </article>