home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Edition 1: Linux / CD1.iso / doc / HOWTO / mini / Coffee < prev    next >
Text File  |  1998-10-14  |  15KB  |  463 lines

  1.   COFFEE-HOWTO
  2.   Georgatos Photis, <gef@ceid.upatras.gr>
  3.   v0.5, 15 January 1998
  4.  
  5.   One of the most bothering remarks on software, I have ever heard, is
  6.   weather this or that thing can make coffee.  So, Linux DOES make cof¡
  7.   fee. And it tastes good, instead!
  8.  
  9.   For a long time, humanity was wondering how could a computer make
  10.   coffee...  People need coffee to get awake and stay asleep in front of
  11.   the computer for a long time.  Everyone knows that coding is better at
  12.   night...
  13.  
  14.  
  15.   The main problem is how to control the coffee machine with the
  16.   computer, so that it will be controlled by software.  This generally
  17.   means an ON/OFF switch implemented as a circuit which controls the
  18.   coffee-machine's power supply.
  19.  
  20.  
  21.   1.  Menu
  22.  
  23.   1.1.  French
  24.  
  25.   Popular coffe among programmers because doesn't need a lot of care,
  26.   like all commercial software.  Its exciting taste has inspired
  27.   thousands of programmers in writing incredible software, written in
  28.   the very first ours of a day.  Windows for example are written at 5:00
  29.   o'clock in the morning, favouring to this coffee! Result is
  30.   guaranteed.
  31.  
  32.  
  33.   1.2.  Nescaffe
  34.  
  35.   Nescaffe is a rather strong coffee, made by pouring hot water in a
  36.   mixture of coffee, sugar and some water.  You usually take 1 spoon of
  37.   coffee and 1 spoon of sugar with just a bit of water, to mix it. In
  38.   the meantime you should have the water boiling. As soon as the water
  39.   is hot enough, you mix them all together and preferably add milk.
  40.   Although you can use something simpler than a coffee-machine to boil
  41.   the water, I have seen this scheme a lot of times...
  42.  
  43.  
  44.   1.3.  frappe
  45.  
  46.   Popular variation of the above mentioned coffee.  Actually, it doesn't
  47.   need any coffee-machine, rather a refridgerator to get cold water and
  48.   ice-cubes.
  49.  
  50.  
  51.   1.4.  freddo
  52.  
  53.   This is a difficult one, read coffee-faq (see references)
  54.  
  55.  
  56.   1.5.  cappuccino (To be added)
  57.  
  58.   1.6.  (To be added) espresso
  59.  
  60.   2.  Electronic circuit
  61.  
  62.   A general diagram is like this:
  63.  
  64.  
  65.  
  66.  
  67.   --------- 0-5V  --------- ~220V  ----------------
  68.   |  PC   |===>===|Circuit|========|Coffee-Machine|
  69.   ---------       ---------        ----------------
  70.  
  71.  
  72.  
  73.  
  74.  
  75.   The concept is that we take a controling voltage from the computer,
  76.   which drives an electrically isolated circuit with Relay or Triac.
  77.  
  78.  
  79.   You must choose a Relay circuit, if you have a big coffee-machine
  80.   (greater than 200W or so), otherwise you can use a triac-based one.
  81.  
  82.   All circuits presented are at least once tested, but it's YOURS
  83.   RESPONSIBILITY the results.  If you have no experience with
  84.   electronics you should NOT try with these, otherwise you may get a bad
  85.   one...
  86.  
  87.  
  88.   You should be very careful while experimenting with 220V, and there is
  89.   no obsolence in using an appropriate fuse.
  90.  
  91.  
  92.   2.1.  Driving voltage 0-5V from the computer
  93.  
  94.   Here is a simple example to get a voltage 0-5V from the parallel port
  95.   of the computer.
  96.  
  97.  
  98.  
  99.              Back View          -----    Pin 10 - ACK
  100.              Male DB-25         |   |    Pin  9 - D7
  101.              Connector          |   |                           Pin 2 - D0
  102.                                 v   v                           v   Pin 1 -
  103.        ~Strobe
  104.               ____________________________________________________________
  105.              /                                                            \
  106.              \     13  12  11  10   9   8   7   6   5   4   3   2   1     /
  107.               \                                                          /
  108.                \     25  24  23  22  21  20  19  18  17  16  15  14     /
  109.                 \______________________________________________________/
  110.  
  111.  
  112.  
  113.  
  114.  
  115.   Pin 1 is Strobe (inverse logic)
  116.  
  117.   Pins 2-9 is DATA BUS's signals, exactly what was written to the
  118.   parallel port's latches with an OUTB command.
  119.  
  120.   Pin 10 is the acknowledge signal (ACK), controlled by you, so that you
  121.   can produce an interrupt to the CPU.
  122.  
  123.   Pins 18-25 are short-circuited and this is the ground (GND).
  124.  
  125.  
  126.   In detail:
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.   <= in   DB25    Cent    Name of         Reg
  134.   => out  pin     pin     Signal          Bit     Function Notes
  135.   ------  ----    ----    --------        ---     -----------------------------
  136.   =>       1       1      -Strobe         C0-     Set Low pulse >0.5 us to send
  137.   =>       2       2      Data 0          D0      Set to least significant data
  138.   =>       3       3      Data 1          D1      ...
  139.   =>       4       4      Data 2          D2      ...
  140.   =>       5       5      Data 3          D3      ...
  141.   =>       6       6      Data 4          D4      ...
  142.   =>       7       7      Data 5          D5      ...
  143.   =>       8       8      Data 6          D6      ...
  144.   =>       9       9      Data 7          D7      Set to most significant data
  145.   <=      10      10      -Ack            S6+ IRQ Low Pulse ~ 5 uS, after accept
  146.   <=      11      11      +Busy           S7-     High for Busy/Offline/Error
  147.   <=      12      12      +PaperEnd       S5+     High for out of paper
  148.   <=      13      13      +SelectIn       S4+     High for printer selected
  149.   =>      14      14      -AutoFd         C1-     Set Low to autofeed one line
  150.   <=      15      32      -Error          S3+     Low for Error/Offline/PaperEnd
  151.   =>      16      31      -Init           C2+     Set Low pulse > 50uS to init
  152.   =>      17      36      -Select         C3-     Set Low to select printer
  153.   ==      18-25   19-30,  Ground
  154.  
  155.  
  156.  
  157.  
  158.  
  159.   2.2.  Controlling with a Relay
  160.  
  161.  
  162.   The simplest circuit that somebody can build is:
  163.  
  164.  
  165.  
  166.                                     Vcc
  167.                                      |
  168.                                      +------+
  169.                                      |    __|__
  170.                                    Relay   /^\  Diode 1N4002
  171.                                     Coil  /---\
  172.                                      |      |
  173.                                      +------+
  174.                                      |
  175.                                   | /
  176.                         4.7K    B |/  C
  177.        parallel port >-\/\/\/\/---|        NPN Transistor: BC547A or 2N2222A
  178.        data pi                    |\  E
  179.                                   | V
  180.                                     |
  181.        parallel port >--------------+
  182.        ground pin                   |
  183.                                  Ground
  184.  
  185.  
  186.  
  187.  
  188.   Connect Vcc with the same voltage as the relay type (usually 5 or
  189.   12V).  Obviously, the relay's specifications should be reasonable for
  190.   your coffee-machine.
  191.  
  192.   Barmen, usually, tend to put the relay AFTER the transistor, at the
  193.   emitter (E) pin instead of the collector (C) pin. This is a bad
  194.   practice because it biases the transistor badly, and may result in bad
  195.   coffee :-).  Diode 1N4002 is useful to protect the transistor from the
  196.   relay's currents.  If you don't use it the transistor will become
  197.   darker and smelling...
  198.  
  199.   2.3.  Controlling with TRIAC #1
  200.  
  201.   If you only want a simple circuit, you can use Motorola's triac driver
  202.   MOC301[012], together with a general purpose TRIAC like SC141D.  This
  203.   method has the advantage that you don't need an extra power supply.
  204.  
  205.  
  206.   For non-inductive loads this is the circuitry:
  207.  
  208.  
  209.  
  210.                270     1 +-------+ 6    180
  211.          +5v -VAVAVA-----+       +----VAVAVA-----+-------------- Line Hot
  212.                        2 |  MOC  |               |
  213.          TTL in ---------+ 3012  +nc            VA  SC141D
  214.                          |       | 4           / |
  215.                        nc+       +------------/  |
  216.                          +-------+               +----\/\/\/---- Line Neutral
  217.                                                        LOAD
  218.  
  219.  
  220.  
  221.  
  222.   If you are going to work with 220V, prefer a 3021.  Inductive loads
  223.   should be used in conjuction with bypass capacitors, see Motorola
  224.   Application Note AN-780.  Coffee-machines are mainly resistive loads
  225.   and not inductive (like a motor), but who knows what's yours...
  226.  
  227.  
  228.   2.4.  Controlling with TRIAC #2
  229.  
  230.  
  231.  
  232.  
  233.        +5VDC
  234.        |    180                      180            2.2k
  235.        +---/\/\/\----+-----+   +----/\/\/-+--/\/\/\---+-------> 120V
  236.                      |    1|   |6         |           |         Hot
  237.                      |    +=====+         |           | MT1
  238.                      |    | MC  | TRIAC   |          +-+
  239.                      |    | 3032| Driver  |        G | | TRIAC
  240.                      |    +=====+         |         /| |
  241.                      \    2|   |4         |        / +-+
  242.               2N3904  |----+   |          |        |  | MT2
  243.                      /     |   +--------- | -------+  |
  244.                     V      \              |        |  |
  245.                     |      /              |        \  |
  246.                     |      \ 43    .01u  ---   10k /  |
  247.                     |      /       500V  ---       \  |
  248.                     |      |              |        /  |
  249.                     +------+              |        |  |            Neutral
  250.                     |                     +--------+--+---o    o--> 120V
  251.                     /                                      load
  252.         >-/\/\--|  2N3904
  253.                     \
  254.                      V
  255.                      |
  256.                     ---
  257.                    ///
  258.        You should change resistors accordingly for 220V.
  259.  
  260.  
  261.  
  262.  
  263.   Circuit description:
  264.  
  265.   The MC3032 is an optoisolator TRIAC driver.  The 180-ohm resistor sets
  266.   the current for the LED emitter in the optoisolator.  Change the value
  267.   of this resistor - if necessary - to get reasonable current (e.g., 15
  268.   mA).
  269.  
  270.   Note that you cannot test this circuit without a load.  The TRIAC will
  271.   not switch unless connected to an AC voltage source, so you can't test
  272.   it for simple switching w/o applying AC and a load. Note the 500V
  273.   rating on the .01 cap.
  274.  
  275.  
  276.   3.  Software
  277.  
  278.  
  279.  
  280.   3.1.  Software
  281.  
  282.   You will have to build an executable that will perform like this:
  283.  
  284.   ╖  Get permissions to use I/O address space, by calling kernel, with
  285.      the command ioperm: eg ioperm( BASE, range ,1);
  286.  
  287.   ╖  Perform an out request instruction, to set the 0-5V voltage to the
  288.      parallel port, eg outb( 1, BASE );
  289.  
  290.   ╖  Wait for enough time so that coffee gets ready. It would be nice if
  291.      that time is read by looking at the command line.
  292.  
  293.   ╖  Then it will turn off the coffee-machine: outb( 0 , BASE );
  294.  
  295.   ╖  Before ending it should give back the paraller port with a ioperm(
  296.      BASE, range, 0);
  297.  
  298.      Change BASE = 0x3bc for /dev/lp0, 0x378 for /dev/lp1, and 0x278 for
  299.      /dev/lp2, range=8.
  300.  
  301.  
  302.   It would be nice if you had that program setuid, so that everybody can
  303.   drink coffee!
  304.  
  305.  
  306.   3.2.  Device driver
  307.  
  308.  
  309.   Just read kernel hacker's guide, implement a device driver (it could
  310.   even be user space i think).  Please, compile it as a module, so that
  311.   we won't need a kernel compile in every update.  Then write:
  312.  
  313.  
  314.   echo cappuccino >/dev/coffee
  315.  
  316.  
  317.  
  318.   And you will have a hot cup of coffee in 1 minute.  Remember to give
  319.   the right permission to /dev/coffee, depending on whether you want
  320.   only root making coffee or not.
  321.  
  322.  
  323.   The advantage of this method is that it supports feedback from the
  324.   coffee-machine by using the ACK of parallel port, so that smart
  325.   coffee-machines could produce an interrupt.
  326.  
  327.  
  328.   Do it as homework.
  329.  
  330.  
  331.   3.3.  Connecting with the Internet
  332.  
  333.   If you have implemented the C programme (see above), you just have to
  334.   write down a simple CGI script to turn ON and OFF the coffee-machine.
  335.   You should write some nice webpages, explaining how to make coffee,
  336.   and put them at an apache web server...
  337.  
  338.  
  339.   4.  Overdose symptoms
  340.  
  341.  
  342.   ╖  excitement
  343.  
  344.   ╖  nervousness
  345.  
  346.   ╖  insomnia
  347.  
  348.   ╖  tachycardia or cardiac arhythmia
  349.  
  350.   ╖  gastrointestinal disturbance
  351.  
  352.   ╖  restlessness
  353.  
  354.  
  355.   5.  Expansions
  356.  
  357.   These are our ideas:
  358.  
  359.   ╖  All hardware and software described here, can be expanded so that
  360.      it will support toast, beaf, applepies, etc.
  361.  
  362.   ╖  Cluster with 8 coffee-machines. This will let you have coffee even
  363.      when the one gets off. Of course there will be a perfomance hit.
  364.  
  365.   ╖  Parallel vector coffee-machine will be a future release.
  366.  
  367.   ╖  If you want the maximum automation you'll need more circuits and
  368.      censors, so that you can control water flow, temperature, coffee
  369.      quantity etc.
  370.  
  371.   ╖  In the near future we will implement SNMP features.
  372.  
  373.   ╖  Serial coffee-machine at 115Kbps.
  374.  
  375.  
  376.   6.  References
  377.  
  378.  
  379.   ╖  http://daisy.uwaterloo.ca/~alopez-o/caffaq.html This is Internet's
  380.      Coffee-FAQ
  381.  
  382.   ╖  http://lonestar.texas.net/~andrew/f_pc_.htm A lot of circuits in
  383.      ASCII. Some of them are for parallel port.
  384.  
  385.   ╖  http://shell.rmi.net/~hisys/parport.html Whatever you wanted to
  386.      learn about a parallel port and didn't dare to ask.
  387.  
  388.   ╖  http://sunsite.unc.edu/LDP/HOWTO/mini/IO-Port-Programming
  389.      Programming of I/O ports under popular operating system Linux.
  390.  
  391.   ╖  http://www.redhat.com:8080/HyperNews/get/khg.html How to write your
  392.      own device drivers. Come on, do it!
  393.  
  394.   ╖  http://www.hut.fi/Misc/Electronics/circuits/parallel_output.html
  395.      Tomi Engdahl's web page is a *must see* for everyone who likes
  396.      electronics.
  397.   ╖  http://www.yahoo.com/Computers_and_Internet/Internet/
  398.      Entertainment/Interesting_Devices_Connected_to_the_Net/Coffee_Machines/
  399.      Coffee-machines on-line. Unfortunatelly, there are no tests.
  400.  
  401.   ╖  http://www.cs.su.oz.au/~bob/coffee.html This coffee-machine offers
  402.      only cappuccino. It should be upgraded!
  403.  
  404.   ╖  http://einstein.et.tudelft.nl/~janssen/ Hot coffee from
  405.      Netherlands.
  406.  
  407.   ╖  http://circe.chinalake.navy.mil/cgi-bin/spion/snapit.cgi
  408.  
  409.   ╖  http://www.cl.cam.ac.uk/coffee/coffee.html
  410.  
  411.   ╖  http://www.menet.umn.edu/coffeecam/
  412.  
  413.  
  414.   7.  etc
  415.  
  416.   7.1.  preface
  417.  
  418.   This document was initially written in hellenic (greek), originating
  419.   from a small debate in the linux-greek-users list , whether linux can
  420.   make coffee or not.  It has been an article in our beautiful online
  421.   magazine on Linux called "magaz": http://www.linux.gr/magaz.
  422.   Remember, that magaz is greek.
  423.  
  424.  
  425.   7.2.  Authorship and maintenance
  426.  
  427.   My name is Georgatos Photis, still-yet-foralongmaybe student at
  428.   Computer Engineering and Informatics department in University of
  429.   Patras.  Usually, I am pretty busy with the greek documentation and
  430.   webpages maintainance, but I can accept submissions to this HOWTO, as
  431.   long as you don't be anxious on the changes.
  432.  
  433.  
  434.   7.3.  Copyrights
  435.  
  436.   The casual copyright with everything you get with linux...  To find
  437.   it, you'll have to read all of them and count the most common.
  438.   Otherwise, no, you can't copy it.
  439.  
  440.  
  441.   7.4.  Credits
  442.  
  443.  
  444.   ╖  Christofer Colombus. His real name is Cristobal Colon.  He was the
  445.      1st one who brought coffee from America, which was for first
  446.      discovered (among Europeans) by him in 1492.
  447.  
  448.   ╖  Kostas Lialiambis is the one who dared saying that he can't make
  449.      coffee with his Linux box!
  450.  
  451.   ╖  Panagiotis Vrionis, Yannakopoulos Haralambos, for giving me
  452.      interesting and humoristing notes.
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.