Introduction: External Device Control (i.e. Coffee Machine).
The concept is that we take a controlling voltage from the computer or a micro-controller, which drives an electrically isolated circuit with Relay or Triac.
You must choose a Relay circuit, if you have a big coffee-machine (greater than 200W or so), otherwise you can use a triac-based one.
All circuits presented are at least once tested, but it's YOURS RESPONSIBILITY the results. If you have no experience with electronics you should NOT try with these, otherwise you may get a bad one...
You should be very careful while experimenting with 220V, and there is no obsolesce in using an appropriate fuse.
(Thanx to tldp.org)
Note: though the pinouts would be different, these circuts could be ADAPTED for microcontollers such as the Arduino MSP430, Beaglebone, Rasperry Pi, and etc.
Step 1: Driving Voltage 0-5V From the Computer.
Pins 2-9 is DATA BUS's signals, exactly what was written to the parallel port's latches with an OUTB command.
Pin 10 is the acknowledge signal (ACK), controlled by you, so that you can produce an interrupt to the CPU.
Pins 18-25 are short-circuited and this is the ground (GND).
Step 2: Controlling With a Relay.
Connect Vcc with the same voltage as the relay type (usually 5 or 12V). Obviously, the relay's specifications should be reasonable for your coffee-machine.
Barmen, usually, tend to put the relay AFTER the transistor, at the emitter (E) pin instead of the collector (C) pin. This is a bad practice because it biases the transistor badly, and may 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 become darker and smelling...
Step 3: Controlling With TRIAC V1.
If you only want a simple circuit, you can use Motorola's triac driver MOC301012 (or other opto-isolator), together with a general purpose TRIAC like SC141D (NTE5608). This method has the advantage that you don't need an extra power supply.
For non-inductive loads this is the circuitry: (See picture)If you are going to work with 220V, prefer a 3021. Inductive loads should be used in conjuction with bypass capacitors, see Motorola Application Note AN-780. Coffee-machines are mainly resistive loads and not inductive (like a motor), but who knows what's yours...
Step 4: Controlling With TRIAC V2.
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 reasonable current (e.g., 15 mA).
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 w/o applying AC and a load. Note the 500V rating on the .01 cap.
Step 5: Etc.
Here are three examples of controlling a relay from the PC's parallel printer port (LPT1 or LPT2). Figure A shows a solid state relay controlled by one of the parallel port data lines (D0-D7) using a 300 ohm resistor and 5 volt power source. The solid state relay will energize when a "0" is written to the data line. Figure B and C show mechanical relays controlled by two transistors. The relay in figure B is energized when a "1" is written to the data line and the relay in figure C is energized by writing a "0" to the line. In each of the three circuits, a common connection is made from the negative side of the power supply to one of the port ground pins (18-25).
There are three possible base addresses for the parallel port You may need to try all three base addresses to determine the correct address for the port you are using but LPT1 is usually at Hex 0378. The QBasic "OUT" command can be used to send data to the port. OUT, &H0378,0 sets D0-D7 low and OUT, &H378,255 sets D0-D7 high. The parallel port also provides four control lines (C0,C1,C2,C3) that can be set high or low by writing data to the base address+2 so if the base address is Hex 0378 then the address of the control latch would be Hex 037A. Note that three of the control bits are inverted so writing a "0" to the control latch will set C0,C1,C3 high and C2 low.
Step 6: Using Ssr's.
Using solid state relays (aka ssr's) are probably the easiest way to go. Be sure to get ones for the correct voltage you need. Follow the instructions per the manufacturers directions. Get a professional to help if you are unsure.
Step 7: Odds and Ends
(From Tomi Engdahl)
Connectors: D25 male
Resistors: 640k,320k,160k,80k,40k,20k,10k,5k,390 (+-1%)
(You can use different values of resistors, but the ratio of the values of the resistors must be same. 0.5, 1, 2, 4, 8, 16, 32, 64 etc.) 1, 2, 4, 8, 16, 32, 64, 128
Capacitor: Electrolytic or solid Tantalum 10 uF 10V
AVR programmer (see picture) (resistors are most 1k)
for more detail.
Lcd circuit. (see picture) see http://electrosofts.com/parallel/lcd.html for more details.
Step 8: I2C.
Note: diagrams from Maxim (They have sent me a lot of free samples), http://home.arcor.de, and etc.
I2C-Bus: What's that?
The I2C bus was designed by Philips in the early '80s to allow easy communication between components which reside on the same circuit board. Philips Semiconductors migrated to NXP in 2006.
The name I2C translates into "Inter IC". Sometimes the bus is called IIC or I²C bus.
The original communication speed was defined with a maximum of 100 kbit per second and many applications don't require faster transmissions. For those that do there is a 400 kbit fastmode and - since 1998 - a high speed 3.4 Mbit option available. Recently, fast mode plus a transfer rate between this has been specified.
I2C is not only used on single boards, but also to connect components which are linked via cable. Simplicity and flexibility are key characteristics that make this bus attractive to many applications.
Most significant features include:
- Only two bus lines are required
- No strict baud rate requirements like for instance with RS232, the master generates a bus clock
- Simple master/slave relationships exist between all components
Each device connected to the bus is software-addressable by a unique address
- I2C is a true multi-master bus providing arbitration and collision detection
For more info see: https://en.wikipedia.org/wiki/I2c
Step 9: Parallel LCD
Two ways to connect an hd4480 lcd. Also pictured is a circuit that uses a few less lines. but it requires a bit more sophisticated programming. This picture is I thknk for the arduino, but it could be adapted to te parallel port easily.
Step 10: Most Electronic Stores Carry NTE Electronic Parts.
Most electronic stores carry NTE electronic parts and at http://nte01.nteinc.com/nte/NTExRefSemiProd.nsf/$$Search You can get equivalent parts for what might be suggested in an electronics diagram.
Step 11: Just a Thought.
Before you go out and get a pir sensor or try to modify an air freshener, consider the Driveway alert system that Harbor freight sells. They go on sale for $10 once in a while.
No need to put a burden on the usb ports. You may want to get a internal to external power adapter to get the 5 and 12 volts you need for your projects. Caution, as I would get or make covers for the unused ports for safety reasons. Dell has nice ones.
Step 12: Adlib on the Parallelport?
Saw this article (http://www.raphnet.net/electronique/adlib/adlib_en.php)
about connecting and old eight (isa) bit sound card to the parallel port. Then I thought after looking at the connections that maybe the Arduino, RPi, Beagleboard, or the like could also be used. Just a matter of developing the software. Try this at your own risk. Then I thought there are lots of other old legacy eight bit cards that might be used (i.e serial, parallel, floppy, or etc).
Step 13: Extra Inputs.
You have limited input lines so you can expand the input lines, but you can only access them one at a time.
The 74151 is a 8 input channel multiplexer. It is exceptionally
useful when you need to expand your inputs. This allows you to convert 3 outputs and 1 input into 8 addressable inputs.
You would have to write software that would cycle through all the inputs to for them to be consistently valid. You would need know what the memory locations of the specific data lines are to take advantage of the multiplexer. An example might be:
data = inp(&h379)
IF (data and 32) = 32 then print "Out of paper / pin 12 high"
Step 14: Extra Outputs
You have limited input lines so you can expand the output lines, but you can only access them one at a time
The 74238 is a 8 output channel demultiplexer, Now we can also go in the opposite direction. That is we can choose the ouput line using just one data line in with three select inputs and eight data out lines. A demultiplexer (or demux) is a device taking a single input signal and selecting one of many data-output-lines, which is connected to the single input. A multiplexer is often used with a complementary demultiplexer on the receiving end
Step 15: Lazy Susan Webcam.
Though floppy drives are not really used anymore, they can be adapted
for other purposes. Most web cameras only look in one direction. With the help of a floppy drive and a sort of lazy suzan, you can control the direction of view for the webcam.
If the jumper from pin 11 to 12 is set and you have the
power source connected, the led of the disk drive should be on. If you do not want to use the picture:
A. Connect Pin 11 and 12 with a Jumper on the drive. B. Connect Pin 18 of the drive with Pin 2 of the parallel port. C. Connect Pin 20 of the drive with Pin 3 of the parallel port. D. Connect the rightest pin of the power from the drive to the red wire of the floppy power cable. E. Connect the pin left of the rightest pin of the power with black wire on the floppy power connector and to the ground to pin 18 of the parallel port. .
Probably use a cut off floppy cable connector with some ribbon cable attached. No need to solder directly to the pins, but you will need to connect wires together for pins 11 and 12 on the drive.
Now moving the head:
We need to connect the following: 14: Drive select enables or disables the motor and also the LED. This is useful if you want the LED only to be active when you hear a tone but clearly optional.20: Step steps the motor by one step by changing it from HIGH to LOW.18: Dir controls the direction of the motor. You should change it every step so your motor vibrates. Personally, I prefer vibrating over moving up and down as moving is not very loud and doesn't sound very good either
Direction change x = 1
out 888, 2^x
Step motor X = 2
out 888, 2^x
Step 16: Audio Line Control
You have four computers but have only one stereo. No problem you can control via the web which computer gets access to the stereo with cmos 4066 chips. No kludgy switches. You could say do this in reverse for an audio store to control audio output to several stereos or speakers,
Step 17: Pwm
Pulse-width modulation (PWM), or pulse-duration modulation (PDM), is a technique used to encode a message into a pulsing signal. It is a type of modulation. Although this modulation technique can be used to encode information for transmission, its main use is to allow the control of the power supplied to electrical devices, especially to inertial loads such as motors. In addition, PWM is one of the two principal algorithms used in photovoltaic solar battery chargers, the other being MPPT.
The average value of voltage (and current) fed to the load is controlled by turning the switch between supply and load on and off at a fast rate. The longer the switch is on compared to the off periods, the higher the total power supplied to the load.
The PWM switching frequency has to be much higher than what would affect the load (the device that uses the power), which is to say that the resultant waveform perceived by the load must be as smooth as possible. Typically switching has to be done several times a minute in an electric stove, 120 Hz in a lamp dimmer, from few kilohertz (kHz) to tens of kHz for a motor drive and well into the tens or hundreds of kHz in audio amplifiers and computer power supplies.
The term duty cycle describes the proportion of 'on' time to the regular interval or 'period' of time; a low duty cycle corresponds to low power, because the power is off for most of the time. Duty cycle is expressed in percent, 100% being fully on.
The main advantage of PWM is that power loss in the switching devices is very low. When a switch is off there is practically no current, and when it is on and power is being transferred to the load, there is almost no voltage drop across the switch. Power loss, being the product of voltage and current, is thus in both cases close to zero. PWM also works well with digital controls, which, because of their on/off nature, can easily set the needed duty cycle.
PWM has also been used in certain communication systems where its duty cycle has been used to convey information over a communications channel.
Most micro controllers have pwm pins on board, but you can easily generate or simulate pwm in software for systems without pwm pins. First you do not see the "1" and then you see more of it. Code compiled with freebasic fbc -lang qb [filename]
for x = 1 to 1000
for y =1 to (1000 - x)
for a = 1 to x
Here is another way using an actual led connected to the parallel port. Emu;ates the idea of the lights dimming and getting brighter.
out 888,0 turns all lights off
out 888,255 turns all lights on
for x = 1 to 50
for y =1 to x
for z = 1 to 500000
for a = 1 to 50 -x
rem ?" ";
for z = 1 to 500000
for x = 1 to 1000
for y =1 to (1000 - x)
rem ?" ";
out 888, 0
for a = 1 to x
Of course you can do it with single led's also.