832 lines
32 KiB
HTML
832 lines
32 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
|
|
<TITLE>
|
|
Coffee Making
|
|
</TITLE>
|
|
</HEAD>
|
|
<BODY BGCOLOR=white>
|
|
|
|
<HR>
|
|
<H1>Coffee Making</H1>
|
|
|
|
<H2>Fotis Georgatos <
|
|
<A HREF="mailto:gef@ceid.upatras.gr?subject=COFFEE-HOWTO">gef@ceid.upatras.gr</A>> <BR></H2>V1.0 2004-08-29
|
|
<P><HR>
|
|
<EM>
|
|
<!--
|
|
coffee
|
|
-->
|
|
|
|
One of the most memorable comments about software ever said is whether this or that piece of code can make coffee. Coffee is a world commodity that is second only to oil. Linux DOES make coffee; and it tastes good as well! </EM>
|
|
<HR>
|
|
<P>
|
|
<H2><A NAME="toc1">1.</A> <A HREF="#s1">Introduction</A></H2>
|
|
|
|
<UL>
|
|
<LI><A HREF="#ss1.1">1.1 Copyright</A>
|
|
<LI><A HREF="#ss1.2">1.2 Disclaimer</A>
|
|
<LI><A HREF="#ss1.3">1.3 Version</A>
|
|
<LI><A HREF="#ss1.4">1.4 Translations</A>
|
|
<LI><A HREF="#ss1.5">1.5 Credits</A>
|
|
<LI><A HREF="#ss1.6">1.6 What do you drink/smoke while writing this?</A>
|
|
<LI><A HREF="#ss1.7">1.7 Feedback</A>
|
|
</UL>
|
|
<P>
|
|
<H2><A NAME="toc2">2.</A> <A HREF="#s2">Menu</A></H2>
|
|
|
|
<UL>
|
|
<LI><A HREF="#ss2.1">2.1 French</A>
|
|
<LI><A HREF="#ss2.2">2.2 Nescafe</A>
|
|
<LI><A HREF="#ss2.3">2.3 Frappe'</A>
|
|
<LI><A HREF="#ss2.4">2.4 Freddo</A>
|
|
<LI><A HREF="#ss2.5">2.5 Espresso</A>
|
|
<LI><A HREF="#ss2.6">2.6 Cappuccino</A>
|
|
</UL>
|
|
<P>
|
|
<H2><A NAME="toc3">3.</A> <A HREF="#s3">Hardware</A></H2>
|
|
|
|
<UL>
|
|
<LI><A HREF="#ss3.1">3.1 Driving voltage 0-5V from the computer</A>
|
|
<LI><A HREF="#ss3.2">3.2 Controlling with a Relay</A>
|
|
<LI><A HREF="#ss3.3">3.3 Controlling with TRIAC #1</A>
|
|
<LI><A HREF="#ss3.4">3.4 Controlling with TRIAC #2</A>
|
|
</UL>
|
|
<P>
|
|
<H2><A NAME="toc4">4.</A> <A HREF="#s4">Software</A></H2>
|
|
|
|
<UL>
|
|
<LI><A HREF="#ss4.1">4.1 Programming</A>
|
|
<LI><A HREF="#ss4.2">4.2 Device driver</A>
|
|
<LI><A HREF="#ss4.3">4.3 Connecting with the Internet</A>
|
|
</UL>
|
|
<P>
|
|
<H2><A NAME="toc5">5.</A> <A HREF="#s5">Building the Turing Complete Coffee Machine</A></H2>
|
|
|
|
<UL>
|
|
<LI><A HREF="#ss5.1">5.1 An adequate assembly language</A>
|
|
<LI><A HREF="#ss5.2">5.2 Hardware and interfacing</A>
|
|
<LI><A HREF="#ss5.3">5.3 Software</A>
|
|
<LI><A HREF="#ss5.4">5.4 A minor criticism on the Turing Machine</A>
|
|
</UL>
|
|
<P>
|
|
<H2><A NAME="toc6">6.</A> <A HREF="#s6">Overdose symptoms</A></H2>
|
|
|
|
<P>
|
|
<H2><A NAME="toc7">7.</A> <A HREF="#s7">Expansions</A></H2>
|
|
|
|
<P>
|
|
<H2><A NAME="toc8">8.</A> <A HREF="#s8">Further Information</A></H2>
|
|
|
|
<HR>
|
|
<H2><A NAME="s1">1.</A> <A HREF="#toc1">Introduction</A></H2>
|
|
|
|
<P>
|
|
<!--
|
|
coffee!introduction
|
|
-->
|
|
|
|
For a long time humanity has been wondering how could a computer make coffee...
|
|
<P>People need coffee to wake up, and stay awake for a long time in front of the computer.
|
|
It is common wisdom that coding is better at night!
|
|
<P>
|
|
<P>The main trick is interfacing a coffee machine to the computer,
|
|
so that it can be controlled by software. This HOWTO will show you how to do so.
|
|
<P>At first, it demonstrates an ON/OFF switch implemented as an electronic circuit
|
|
which controls the coffee-machine's power supply.
|
|
Another chapter will tell you the secrets of building
|
|
intelligent, Turing Complete suitable, coffee machines!
|
|
<P>This HOWTO was initially written as part of a debate in the mailing list linux-greek-users,
|
|
on whether linux can make coffee or not. It then became an article in our online magazine
|
|
called
|
|
<A HREF="http://magaz.hellug.gr">magaz</A>.
|
|
Just in case you wondered, magaz is in Greek and it will surely look like that to you!
|
|
<P>
|
|
<P>Enjoy.
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss1.1">1.1 Copyright</A>
|
|
</H2>
|
|
|
|
<P>Copyright © 2004-08-29 by Fotis Georgatos.
|
|
You are free:
|
|
<UL>
|
|
<LI>to copy, distribute, display, and perform the work</LI>
|
|
<LI>to make derivative works</LI>
|
|
<LI>to make commercial use of the work</LI>
|
|
</UL>
|
|
Under the following conditions:
|
|
Attribution. You must give the original author credit.
|
|
Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
|
|
<UL>
|
|
<LI>For any reuse or distribution, you must make clear to others the license terms of this work.</LI>
|
|
<LI>Any of these conditions can be waived if you get permission from the author.</LI>
|
|
</UL>
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss1.2">1.2 Disclaimer</A>
|
|
</H2>
|
|
|
|
<P>Use the information in this document at your own risk. I disavow any potential liability for the contents of this document. Use of the concepts, examples, and/or other content of this document is entirely at your own risk.
|
|
<P>All copyrights are owned by their owners, unless specifically noted otherwise. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark.
|
|
<P>Naming of particular products or brands should not be seen as endorsements.
|
|
<P>You are strongly recommended to take a backup of your system before major installation and backups at regular intervals.
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss1.3">1.3 Version</A>
|
|
</H2>
|
|
|
|
<P>The Coffee HOWTO is now called Coffee Making HOWTO and heads for release v1.0, which will first appear somewhere here:
|
|
<P>
|
|
<A HREF="http://fotis.home.cern.ch/fotis/Coffee.html">http://fotis.home.cern.ch/fotis/Coffee.html</A>.
|
|
<P>It is about time for everyone to know that Coffee Making is just one of
|
|
the standard features that come for free with *any* Linux distribution.
|
|
Or, does SCO have a patent on that, too? Gee...
|
|
<P>
|
|
<H2><A NAME="ss1.4">1.4 Translations</A>
|
|
</H2>
|
|
|
|
<P>You should be able to easily find a translation of this or previous
|
|
versions of the Coffee Making HOWTO in the following languages:
|
|
<UL>
|
|
<LI>Chinese</LI>
|
|
<LI>Japanese</LI>
|
|
<LI>Russian</LI>
|
|
<LI>Indonesian</LI>
|
|
<LI>Italian</LI>
|
|
<LI>Polish</LI>
|
|
</UL>
|
|
|
|
and hopefully many more... (Spanish and Portugeuse anyone?)
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss1.5">1.5 Credits</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<UL>
|
|
<LI>Ethiopia: Identified as the originating country of coffee. </LI>
|
|
<LI>Coffee was popular in the Middle East for ages,
|
|
until a failed invasion of the Turks at the city of Vienna at 1683
|
|
left behind sacks with strange brown beans nobody wanted:
|
|
<A HREF="http://www.vienna.cc/ekaffeeh.htm/">http://www.vienna.cc/ekaffeeh.htm/</A>.</LI>
|
|
<LI>Kostas Lialiambis is the one who dared claim
|
|
he can't make coffee with his Linux box, back then in year 1997.</LI>
|
|
<LI>Panagiotis Vrionis et al for giving me interesting
|
|
and humorous notes and let the ball roll in the early days.</LI>
|
|
<LI>NUMEROUS people on the internet with additions and remarks.
|
|
Thank you all, really!
|
|
Even though I might have not replied to your email.</LI>
|
|
</UL>
|
|
<P>
|
|
<H2><A NAME="ss1.6">1.6 What do you drink/smoke while writing this?</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<P>Well, to the best of my knowledge, this is a dope-free work.
|
|
<P>But, I can tell you the secret of the music playing on the background:
|
|
nearly any song spelled by Zampetas or Mpithikotsis (bouzouki and such).
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss1.7">1.7 Feedback</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<P>For your online commentary of your own DIY Coffee Machine steer at
|
|
<A HREF="http://coffee.sf.net/">http://coffee.sf.net/</A>.
|
|
<P>
|
|
<P>If you still have comments to say, emails get lost these days,
|
|
so why not send me a postcard with a picture from your great hometown,
|
|
adding a recommendation of your favourite cafe' in the area?
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
Fotis Georgatos,
|
|
Aliartou 32,
|
|
TK 11142 Athens,
|
|
GREECE
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>
|
|
<P>
|
|
<P>PS.
|
|
<UL>
|
|
<LI>Your suggestions won't be wasted, I really tend to travel quite a lot these days and might be around before your realize it.</LI>
|
|
<LI>Yes, I have been in Amsterdam and even lived there for three years;
|
|
coffee shops generally don't account as cafe's!</LI>
|
|
<LI>Surprise: I actually prefer chocolate and tea over coffee. ;-)</LI>
|
|
</UL>
|
|
<P>
|
|
<HR>
|
|
<H2><A NAME="s2">2.</A> <A HREF="#toc2">Menu</A></H2>
|
|
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss2.1">2.1 French</A>
|
|
</H2>
|
|
|
|
<P>Popular coffee among programmers because it doesn't need a lot of care
|
|
and its cooking is streamlined; just like commercial software.
|
|
Its exciting taste has inspired thousands of programmers
|
|
in writing incredible software, written in the very first hours of a day.
|
|
M$ Windows for example has been written at 5:00 o'clock in the morning,
|
|
only thanks to coffee! A similar result is guaranteed.
|
|
<P>
|
|
<H2><A NAME="ss2.2">2.2 Nescafe</A>
|
|
</H2>
|
|
|
|
<P> Nescafe is a rather strong coffee, made by pouring hot water
|
|
in a mixture of coffee, sugar and some water.
|
|
You usually take 1 spoon of coffee and 1 spoon of sugar with just
|
|
a bit of water, to mix it. In the meantime you should have the water
|
|
boiling. As soon as the water is hot enough, you mix them all together
|
|
and preferably add condensed milk.
|
|
Although you could use something simpler than a coffee-machine to
|
|
boil the water, I have seen this done so several times...
|
|
<P>
|
|
<H2><A NAME="ss2.3">2.3 Frappe'</A>
|
|
</H2>
|
|
|
|
<P>A popular variation of the above mentioned coffee.
|
|
Actually, you don't need a sophisticated coffee-machine,
|
|
rather a refrigerator for cold water and ice-cubes.
|
|
It is very popular in South Eastern Europe during the warm summer months.
|
|
<P>
|
|
<H2><A NAME="ss2.4">2.4 Freddo</A>
|
|
</H2>
|
|
|
|
<P>This is a complicated one, read coffee-faq (read further information)
|
|
<P>
|
|
<H2><A NAME="ss2.5">2.5 Espresso</A>
|
|
</H2>
|
|
|
|
<P>Espresso is a very strong, italian sort of coffee.
|
|
You serve it in small cups (You ask why? See chapter: Overdose Symptomes)
|
|
with one or two pieces of lump sugar.
|
|
To produce a good espresso you need fresh grinded coffee beans,
|
|
water, lump sugar and a special machine. These machines boil the water
|
|
and press the very hot steam through the grinded coffee beans. You can
|
|
buy a super-duper-automatic machine for a lot of money.
|
|
But a low cost machine is usable, too.
|
|
<P>OK., lets start. Fill water in your machine. Let it become hot. In the
|
|
meantime fill about 1 teespoon of coffeepowder in the filterhandle of
|
|
your machine. Press the coffeepowder down. Not too much. Now the water
|
|
is at the right temperature. Attach the filterhandle to the machine
|
|
and let the machine work. After about 30 seconds you can serve a
|
|
delicate, hot espresso. It is fine after a good meal. You feel good
|
|
and can code for a few more hours.
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss2.6">2.6 Cappuccino</A>
|
|
</H2>
|
|
|
|
<P>(See also chapter: Espresso)
|
|
If you have a more profi-like machine, you can use it, to froth milk
|
|
with it. You need this feature to make a creamy sort of coffee. It is
|
|
easy to prepare. Put some frothed milk in a coffee pot and fill it up
|
|
with espresso. Then decorade with some chocolade flakes. That's it.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<HR>
|
|
<H2><A NAME="s3">3.</A> <A HREF="#toc3">Hardware</A></H2>
|
|
|
|
<P>A generic diagram could look like this:
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
|
|
--------- 0-5V --------- ~220V ----------------
|
|
| PC |====>====|Circuit|==========|Coffee-Machine|
|
|
--------- --------- ----------------
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>
|
|
<P>The concept is that we take a controling voltage from the computer,
|
|
which drives an electrically isolated circuit with a Relay or Triac.
|
|
<P>
|
|
<P>You must choose a Relay circuit, if you have a coffee-machine
|
|
greater than 200W. You can use a triac-based one if your coffee machine isn't high power.
|
|
<P>All circuits presented are tested, but the results and risks are
|
|
YOUR OWN RESPONSIBILITY.
|
|
If you have no experience with electronics you should NOT try
|
|
building it on these, otherwise you may get a bad one...
|
|
<P>
|
|
<P>You should be very careful while experimenting with 220V,
|
|
and using an appropriate fuse is absolutely advisable.
|
|
<P>
|
|
<H2><A NAME="ss3.1">3.1 Driving voltage 0-5V from the computer</A>
|
|
</H2>
|
|
|
|
<P>Here is a simple example to get a voltage 0-5V from the parallel
|
|
port of the computer.
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
|
|
Back View ----- Pin 10 - ACK
|
|
Male DB-25 | | Pin 9 - D7
|
|
Connector | | Pin 2 - D0
|
|
v v v Pin 1 -
|
|
~Strobe
|
|
____________________________________________________________
|
|
/ \
|
|
\ 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 /
|
|
\______________________________________________________/
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>
|
|
<P>Pin 1 is Strobe (inverse logic)
|
|
<P>Pins 2-9 is DATA BUS's signals, exactly what was written to the
|
|
parallel port's latches with an OUTB command.
|
|
<P>Pin 10 is the acknowledge signal (ACK), controlled by you, so that you can
|
|
produce an interrupt to the CPU.
|
|
<P>Pins 18-25 are short-circuited and this is the ground (GND).
|
|
<P>
|
|
<P>In detail:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
|
|
<= in DB25 Cent Name of Reg
|
|
=> out pin pin Signal Bit Function Notes
|
|
------ ---- ---- -------- --- -----------------------------
|
|
=> 1 1 -Strobe C0- Set Low pulse >0.5 us to send
|
|
=> 2 2 Data 0 D0 Set to least significant data
|
|
=> 3 3 Data 1 D1 ...
|
|
=> 4 4 Data 2 D2 ...
|
|
=> 5 5 Data 3 D3 ...
|
|
=> 6 6 Data 4 D4 ...
|
|
=> 7 7 Data 5 D5 ...
|
|
=> 8 8 Data 6 D6 ...
|
|
=> 9 9 Data 7 D7 Set to most significant data
|
|
<= 10 10 -Ack S6+ IRQ Low Pulse ~ 5 uS, after accept
|
|
<= 11 11 +Busy S7- High for Busy/Offline/Error
|
|
<= 12 12 +PaperEnd S5+ High for out of paper
|
|
<= 13 13 +SelectIn S4+ High for printer selected
|
|
=> 14 14 -AutoFd C1- Set Low to autofeed one line
|
|
<= 15 32 -Error S3+ Low for Error/Offline/PaperEnd
|
|
=> 16 31 -Init C2+ Set Low pulse > 50uS to init
|
|
=> 17 36 -Select C3- Set Low to select printer
|
|
== 18-25 19-30, Ground
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>
|
|
<H2><A NAME="ss3.2">3.2 Controlling with a Relay</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<P>The straight-forward circuit one can build is:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
|
|
Vcc
|
|
|
|
|
+------+
|
|
| __|__
|
|
Relay /^\ Diode 1N4002
|
|
Coil /---\
|
|
| |
|
|
+------+
|
|
|
|
|
| /
|
|
4.7K B |/ C
|
|
parallel port >-\/\/\/\/---| NPN Transistor: BC547A or 2N2222A
|
|
data pi |\ E
|
|
| \
|
|
V
|
|
parallel port >--------------+
|
|
ground pin |
|
|
Ground
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
|
|
Connect Vcc with the same voltage as the relay type (usually 5 or 12V).
|
|
Obviously, the relay's specifications should be scaled for your
|
|
coffee-machine.
|
|
<P>Barmen, tend to put the relay AFTER the transistor, at the
|
|
emitter (E) pin instead of the collector (C) pin. This is bad practice
|
|
because it biases the transistor badly, and might result in bad coffee :-).
|
|
Diode 1N4002 is useful to protect the transistor from the relay's currents.
|
|
If you don't use it the transistor will sooner become dark and smelly...
|
|
<P>
|
|
<H2><A NAME="ss3.3">3.3 Controlling with TRIAC #1</A>
|
|
</H2>
|
|
|
|
<P>If you only want a simple circuit, you can use Motorola's
|
|
triac driver MOC301[012], together with a general purpose TRIAC like SC141D.
|
|
This method has the advantage that you don't need any extra power supply.
|
|
<P>
|
|
<P>For non-inductive loads, this is the circuitry:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
|
|
270 1 +-------+ 6 180
|
|
+5v -VAVAVA-----+ +----VAVAVA-----+-------------- Line Hot
|
|
2 | MOC | |
|
|
TTL in ---------+ 3012 +nc VA SC141D
|
|
| | 4 / |
|
|
nc+ +------------/ |
|
|
+-------+ +----\/\/\/---- Line Neutral
|
|
LOAD
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>If you are going to work with 220V, try to obtain a 3021.
|
|
Inductive loads should be used in conjuction with bypass capacitors,
|
|
better consult <EM>Motorola Application Note AN-780</EM>.
|
|
Coffee-machines are mainly resistive loads and not inductive (like a motor), but who knows what yours is?
|
|
<P>
|
|
<H2><A NAME="ss3.4">3.4 Controlling with TRIAC #2</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
|
|
+5VDC
|
|
| 180 180 2.2k
|
|
+---/\/\/\----+-----+ +----/\/\/-+--/\/\/\---+-------> 120V
|
|
| 1| |6 | | Hot
|
|
| +=====+ | | MT1
|
|
| | MC | TRIAC | +-+
|
|
| | 3032| Driver | G | | TRIAC
|
|
| +=====+ | /| |
|
|
\ 2| |4 | / +-+
|
|
2N3904 |----+ | | | | MT2
|
|
/ | +--------- | -------+ |
|
|
V \ | | |
|
|
| / | \ |
|
|
| \ 43 .01u --- 10k / |
|
|
| / 500V --- \ |
|
|
| | | / |
|
|
+------+ | | | Neutral
|
|
| +--------+--+---o o--> 120V
|
|
/ load
|
|
>-/\/\--| 2N3904
|
|
\
|
|
V
|
|
|
|
|
---
|
|
///
|
|
|
|
This design is for 120V. You should change resistors accordingly for 220V.
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>Circuit description:
|
|
<P>The MC3032 is an optoisolator TRIAC driver.
|
|
The 180-ohm resistor sets the current for the LED emitter in the optoisolator.
|
|
Change the value of this resistor - if necessary - to get a reasonable current
|
|
(e.g., 15 mA).
|
|
<P>Note that you cannot test this circuit without a load.
|
|
The TRIAC will not switch unless connected to an AC
|
|
voltage source, so you can't test it for simple switching without applying AC
|
|
and a load. Note the 500V rating on the .01 capacitor.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<HR>
|
|
<H2><A NAME="s4">4.</A> <A HREF="#toc4">Software</A></H2>
|
|
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss4.1">4.1 Programming</A>
|
|
</H2>
|
|
|
|
<P>You will have to build an executable that will take the following steps:
|
|
<UL>
|
|
<LI>Get permission to use I/O address space, by calling kernel, with
|
|
the call <B>ioperm</B>: eg <EM>ioperm( BASE, range ,1); </EM></LI>
|
|
<LI>Perform an out request instruction, to set the 0-5V voltage to the
|
|
parallel port, eg <EM>outb( 1, BASE );</EM></LI>
|
|
<LI>Wait enough time so the coffee is made. It would be nice
|
|
if that time is read by looking at the command line.</LI>
|
|
<LI>Then it will turn off the coffee-machine: outb( 0 , BASE );</LI>
|
|
<LI>Before ending it should give back the parallel port
|
|
with an <EM>ioperm( BASE, range, 0);</EM></LI>
|
|
</UL>
|
|
|
|
Change BASE = 0x3bc for /dev/lp0, 0x378 for /dev/lp1, and 0x278
|
|
for /dev/lp2; range=8.
|
|
<P>
|
|
<P>It would be useful if you had that program setuid,
|
|
so that everybody can drink coffee! You BOFH!
|
|
<P>
|
|
<H2><A NAME="ss4.2">4.2 Device driver</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<P>Just read
|
|
<A HREF="http://en.tldp.org/LDP/khg/HyperNews/get/khg.html">kernel hacker's guide</A>,
|
|
to implement a device driver; you might also do it in user space.
|
|
Please compile it as a module, so that we won't need a
|
|
kernel compile in every update.
|
|
Then write:
|
|
<P>
|
|
<PRE>
|
|
echo cappuccino >/dev/coffee
|
|
</PRE>
|
|
<P>And you will have a hot cup of coffee in minutes!
|
|
Remember to give the right permissions to /dev/coffee,
|
|
depending on whether you want only root making coffee or not.
|
|
<P>
|
|
<P>The advantage of this method is that it supports feedback
|
|
from the coffee-machine by using the ACK of parallel port and such,
|
|
so that smart coffee-machines can produce an interrupt when ready.
|
|
<P>
|
|
<P>Do it yourself, after reading the excellent book
|
|
of Alessandro Rubini and Jonathan Corbet
|
|
<A HREF="http://www.xml.com/ldd/chapter/book/index.html">Linux Device Drivers</A>
|
|
and studying the
|
|
<A HREF="http://lxr.linux.no/source/">Cross Reference Linux</A> source code repository.
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss4.3">4.3 Connecting with the Internet</A>
|
|
</H2>
|
|
|
|
<P>If you have implemented the controlling program in C (see above),
|
|
you just have to write a CGI script to turn ON and OFF
|
|
the coffee-machine or pass along more complex instructions.
|
|
You should write some nice webpages, explaining how to make coffee,
|
|
and put them on an <B>apache</B> web server...
|
|
<P>
|
|
<P>...LAMP technology (Linux, Apache, MySQL, [Perl|Python|PHP]),
|
|
will help you to build a perfect user-customizable coffee system!
|
|
<P>At some time in the future when the applications get rather complex,
|
|
you might want to extend on the basis of Flow-Based Programming:
|
|
<A HREF="http://www.jpaulmorrison.com/fbp/">http://www.jpaulmorrison.com/fbp/</A>.
|
|
What a great match for a great Coffee Machine!
|
|
<P>
|
|
<HR>
|
|
<H2><A NAME="s5">5.</A> <A HREF="#toc5">Building the Turing Complete Coffee Machine</A></H2>
|
|
|
|
<P>
|
|
<P>Do you pine for the nice old days,
|
|
when men were men and build their own coffee machines?
|
|
<P>
|
|
<P>This chapter is about assembling a smart, intelligent!, coffee machine.
|
|
It will be a computer designed with a von Neumann architecture,
|
|
comprised of a CPU, ROM/RAM and I/O and will also be suitable
|
|
for generic use, a.k.a. Universal
|
|
<A HREF="http://www.wordiq.com/definition/Turing_machine">Turing Machine</A>.
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss5.1">5.1 An adequate assembly language</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<P>Unlike other complex, but popular, systems that are either CISC or RISC,
|
|
our machinery will be MISC: Mono-Instruction Set Computer!
|
|
<P>Alas, our processor will understand just one command and yet,
|
|
given enough memory and time, it is able to perform any action
|
|
that your 3GHz Pentium IV could do, or just simulate it alltogether;
|
|
It can solve any computable problem by running simple code like this:
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
|
|
SBN $mem1, $addr1
|
|
SBN $mem2, $addr2
|
|
SBN $mem3, $addr3
|
|
SBN $mem4, $addr4
|
|
SBN $mem5, $addr5
|
|
SBN $mem6, $addr6
|
|
[...]
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>
|
|
<P>The magic command is called SBN $mem, $addr (Subtract and Branch if Negative),
|
|
and does take the value of a memory cell $mem, subtract it from the
|
|
accumulator (A is the only available register in this architecture)
|
|
and store it back to the accumulator and memory $mem <EM>: [mem] <= A <= A-[mem]</EM>.
|
|
If the result is negative, and only then,
|
|
it jumps to the designated address $addr.
|
|
If $addr points to the next command, there is no conditional jump.
|
|
Now, with that command at hand you can subtract, add,
|
|
zero memory addresses, move bytes around, multiply,
|
|
compare and so on, so forth.
|
|
What's best of all, you can easily build an optimizing compiler.
|
|
<P>
|
|
<P>Voila. This is a great system for any Turing Complete problems plus,
|
|
it is even simpler in coding than the original Turing Machine!
|
|
<P>
|
|
<H2><A NAME="ss5.2">5.2 Hardware and interfacing</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<P>The great thing with this innovative MISC processor is that you need
|
|
0 bits to store the opcode of your commands. This makes your CPU
|
|
much, much simpler: you only have to read a couple of operands each time.
|
|
You might wish to extend the capabilities of your processor
|
|
by extending the SBN instruction to 3 or 4 operands,
|
|
so that it can directly load and store data from main memory.
|
|
This is an exercise left to the reader; kudos to
|
|
<A HREF="http://www.google.com/">google</A>.
|
|
<P>The CPU diagram looks like this:
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
|
|
<========= ADDRESS BUS ==============>
|
|
= =
|
|
= +---------+ =
|
|
= | CONTROL | =
|
|
+---------+ +-----------------+
|
|
| ALU & A | | Program Counter |
|
|
+---------+ +-----------------+
|
|
= | LOGIC | =
|
|
= +---------+ =
|
|
= =
|
|
<=========== DATA BUS ===============>
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>
|
|
<P>Now, all you have to do is just hook together some memory chips,
|
|
for example by recycling static cache RAM from old 386 PCs,
|
|
an ALU and a few glue components. You may pick one of
|
|
TTL or CMOS for logic gates and latches; I'm a CMOS guy,
|
|
but this really depends on your favourite flavor.
|
|
You may build an 8, 16, 32, 64 bit or whatever width system you need.
|
|
Just in case, for larger word widths, I have found preferable building
|
|
the ALU with pre-programmed 27128 EPROMS instead of the harder-to-find 74x181s. Look around for a carry propagation unit, too.
|
|
<P>
|
|
<P>The monolithic nature of this system allows only memory-mapped I/O,
|
|
and requires special design provisions for bidirectional interfacing,
|
|
but nothing more peculiar than what is seen in older-generation systems.
|
|
<A HREF="http://www.sandroid.org/Apollo/">AGC</A>,
|
|
the computer that drove Apollo 11 mission to the moon was making use
|
|
of such techniques, so it should be sufficient in this case, too.
|
|
<P>
|
|
<P>Note that the data bus has to be exactly as wide as the address bus,
|
|
that implies that the notion of a byte is only applicable to 8 bit coffee machines,
|
|
which you will eventually find that it is more of a feature than a bug.
|
|
You will be surprised with what a coffee you can have for 8 or 16 bits bus!
|
|
It is really a general-purpose piece of hardware, built for peanuts.
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss5.3">5.3 Software</A>
|
|
</H2>
|
|
|
|
<P>Such a pure system will make a good fit together with the,
|
|
famous for embedded systems controlling,
|
|
<A HREF="http://www.wordiq.com/definition/Forth_programming_language">FORTH</A> programming language.
|
|
The major prerequisite for doing so is to have a stack mechanism,
|
|
which in this case can be constructed by a counter
|
|
combined together with a memory pool.
|
|
<P>If you want to claim a serious coffee development platform,
|
|
C portability is an absolute must nowadays.
|
|
Your choices might be hacking one of gcc, lcc or sdcc,
|
|
which with proper tweaking at the back-ends will be able
|
|
to spit out the specially crafted MISC assembly code.
|
|
One day you might even want to rewrite another language like C,
|
|
forget the D letter - it is taken already,
|
|
so do not make again the same mistakes with your compiler please:
|
|
http://www.gnu.org/software/gcc/projects/beginner.html
|
|
<P>
|
|
<P>Just in case you thought of writing your own compiler, please read
|
|
in advance about flex, yacc and just a little bit of related theory.
|
|
In particular you will quickly appreciate Noam Chomsky's taxonomy on languages:
|
|
<UL>
|
|
<LI>regular grammars (the abstract formalism for regular expressions), </LI>
|
|
<LI>context free grammars (any BNF-described language is such)</LI>
|
|
</UL>
|
|
so on, so forth. Read ahead on
|
|
<A HREF="http://www.wordiq.com/definition/Computability_theory">Computability Theory</A>.
|
|
<P>
|
|
<P>
|
|
<H2><A NAME="ss5.4">5.4 A minor criticism on the Turing Machine</A>
|
|
</H2>
|
|
|
|
<P>Because of the way a Turing Machine works (see for that
|
|
<A HREF="http://plato.stanford.edu/entries/turing-machine/">http://plato.stanford.edu/entries/turing-machine/</A> ), it is
|
|
a very complicated device to program, and debug at the end of the day.
|
|
The reason is, that its behavior is a sequential process
|
|
that is completely determined by the following parameters:
|
|
<UL>
|
|
<LI>(1) the State the machine is in, </LI>
|
|
<LI>(2) the Symbol (or number) on the square it is scanning, and </LI>
|
|
<LI>(3) a Table of Instructions</LI>
|
|
</UL>
|
|
<P>The major contemporary disadvantage of the Turing Machine (TM) is that
|
|
it is of sequential nature, which implies that only a particular
|
|
range of problems can be mapped to it in a straightforward way.
|
|
TMs are suitable for problems that are described well on a serial
|
|
storage medium (tapes) and don't make use of indexes for data reference.
|
|
This is in contrast to the Coffee Machine (CM) that can handle any
|
|
Random Access algorithms as well (with no compromise of simplicity).
|
|
<P>Add to this, that TMs impose a very high and unnecessary
|
|
complexity on item (3) in favor of keeping (1) and (2) simple.
|
|
And just in case you don't agree that the so called
|
|
Table of Instructions gets trully overwhelmed,
|
|
have you ever tried to write a compiler for a Turing Machine?
|
|
A system that isn't easily programmable and is hard to debug,
|
|
should be considered a seriously questionable system,
|
|
at least as far as Computer Engineering (!= CS) is concerned.
|
|
For instance, try to simulate the Coffee Machine with a Turing Machine and vice versa.
|
|
Hey, if you still disagree, show me the code.
|
|
<P>Bottom Line:
|
|
The Coffee Machine (CM), is a much better model for the von Neumann
|
|
architecture and has a O(1) relationship with what is standard practice
|
|
of weighting algorithms, in the current form of complexity theory.
|
|
<P>
|
|
<P>
|
|
<HR>
|
|
<H2><A NAME="s6">6.</A> <A HREF="#toc6">Overdose symptoms</A></H2>
|
|
|
|
<P>
|
|
<UL>
|
|
<LI>excitement</LI>
|
|
<LI>nervousness</LI>
|
|
<LI>insomnia</LI>
|
|
<LI>tachycardia or cardiac arhythmia</LI>
|
|
<LI>restlessness</LI>
|
|
<LI>Hypersensibility to light</LI>
|
|
<LI>Annoyance in respect with various audio stimuli</LI>
|
|
<LI>gastrointestinal disturbance</LI>
|
|
</UL>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<HR>
|
|
<H2><A NAME="s7">7.</A> <A HREF="#toc7">Expansions</A></H2>
|
|
|
|
<P>
|
|
<P>
|
|
<UL>
|
|
<LI>All hardware and software described here, can be expanded so that
|
|
it will support toast, beaf, applepies, etc.</LI>
|
|
<LI>Cluster with 8 coffee-machines. This will let you have coffee
|
|
even when the first one gets off. Of course there will be a perfomance hit.</LI>
|
|
<LI>Parallel vector coffee-machine will be a future release.</LI>
|
|
<LI>If you want the maximum automation you'll need more circuits and
|
|
sensors, so that you can control water flow, temperature, coffee
|
|
quantity etc.</LI>
|
|
<LI>In the near future we will implement SNMP features.</LI>
|
|
<LI>Serial coffee-machine at 115Kbps.</LI>
|
|
</UL>
|
|
<P>
|
|
<P>
|
|
<HR>
|
|
<H2><A NAME="s8">8.</A> <A HREF="#toc8">Further Information</A></H2>
|
|
|
|
<P>
|
|
<P>
|
|
<UL>
|
|
<LI>
|
|
<A HREF="http://db.uwaterloo.ca/~alopez-o/Coffee/coffaq.html">http://db.uwaterloo.ca/~alopez-o/Coffee/coffaq.html</A>
|
|
This is most known Internet's <B>Coffee-FAQ</B></LI>
|
|
<LI>
|
|
<A HREF="http://faculty.washington.edu/chudler/caff.html">http://faculty.washington.edu/chudler/caff.html</A>
|
|
Caffeine and effects of on the Nervous System</LI>
|
|
<LI>
|
|
<A HREF="http://www.gardfoods.com/coffee/coffee.coffee.htm">http://www.gardfoods.com/coffee/coffee.coffee.htm</A>
|
|
A pretty comprehensive, if informal, history of humans' interaction
|
|
with the coffee plant. People have been chewing coffee berries in
|
|
Africa for 100,000 years or so. Coffee was definitely growing in
|
|
Yemen, where it is not native (so must have been planted), in 525 AD.</LI>
|
|
<LI>
|
|
<A HREF="http://www.faqs.org/rfcs/rfc2324.html">http://www.faqs.org/rfcs/rfc2324.html</A>
|
|
RFC2324: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)</LI>
|
|
<LI>
|
|
<A HREF="http://www.faqs.org/rfcs/rfc2325.html">http://www.faqs.org/rfcs/rfc2325.html</A>
|
|
RFC2325: Definitions of Managed Objects for
|
|
Drip-Type Heated Beverage Hardware Devices using SMIv2</LI>
|
|
<LI>
|
|
<A HREF="http://www.tldp.org/HOWTO/mini/IO-Port-Programming">http://www.tldp.org/HOWTO/mini/IO-Port-Programming</A>
|
|
Programming of I/O ports under popular operating system Linux.</LI>
|
|
<LI>
|
|
<A HREF="http://www.ee.washington.edu/circuit_archive/circuits/F_ASCII_Schem_PC.html">http://www.ee.washington.edu/circuit_archive/circuits/F_ASCII_Schem_PC.html</A>
|
|
A lot of circuits in ASCII. Some of them are for parallel port.</LI>
|
|
<LI>
|
|
<A HREF="http://www.citr.auckland.ac.nz/~james/parport.html">http://www.citr.auckland.ac.nz/~james/parport.html</A>
|
|
Whatever you wanted to learn about a parallel port and didn't dare to ask.</LI>
|
|
<LI>
|
|
<A HREF="http://en.tldp.org/LDP/khg/HyperNews/get/khg.html">http://en.tldp.org/LDP/khg/HyperNews/get/khg.html</A>
|
|
How to write your own device drivers. Come on, go ahead!</LI>
|
|
<LI>
|
|
<A HREF="http://www.hut.fi/Misc/Electronics/circuits/parallel_output.html">http://www.hut.fi/Misc/Electronics/circuits/parallel_output.html</A>
|
|
Tomi Engdahl's web page is a *must see* for everyone who enjoys electronics.</LI>
|
|
<LI>
|
|
<A HREF="http://dir.yahoo.com/Computers_and_Internet/Internet/Devices_Connected_to_the_Internet/Coffee_Machines/">http://dir.yahoo.com/Computers_and_Internet/Internet/Devices_Connected_to_the_Internet/Coffee_Machines/</A>
|
|
Coffee-machines on-line. Unfortunately, there are no benchmark tests.</LI>
|
|
<LI>
|
|
<A HREF="http://www.cs.su.oz.au/~bob/Coffee/index.html">http://www.cs.su.oz.au/~bob/Coffee/index.html</A>
|
|
This coffee-machine offers only cappuccino. It has to be upgraded!</LI>
|
|
<LI>
|
|
<A HREF="http://web.archive.org/web/19980121162752/http://einstein.et.tudelft.nl/~janssen/">http://einstein.et.tudelft.nl/~janssen/</A>
|
|
Hot coffee from the the The Netherlands.</LI>
|
|
<LI>
|
|
<A HREF="http://www.cl.cam.ac.uk/coffee/coffee.html">http://www.cl.cam.ac.uk/coffee/coffee.html</A> The Trojan Room Coffee Machine </LI>
|
|
<LI>
|
|
<A HREF="http://www.menet.umn.edu/coffeecam/">http://www.menet.umn.edu/coffeecam/</A> CoffeeCAM</LI>
|
|
</UL>
|
|
<P>The list of links in this chapter, often becomes outdated,
|
|
therefore you might wish to use the excellent
|
|
Way-Back Machine to find them again:
|
|
<A HREF="http://www.archive.org/">http://www.archive.org/</A><P>
|
|
<P>
|
|
<HR>
|
|
</BODY>
|
|
</HTML>
|