A digital temperature sensor and tachometer for your PC
READ THIS FIRST:
The following information is provided 'as-is' with absolutely
no warranty, expressed or implied. I (David Stafford) shall
not be held responsible for ANY consequences of the use
or misuse of this information. In particular, I am not
responsible for errors, or damage resulting from errors in this
information, even if I am aware of such errors.
In other words, I if you build this and if fries your computer,
I'm not
responsible. Period. By using this information you agree to this.
If you cannot agree to this, you may not use the information in
this document and must leave now.
This circuit provides one digital tachometer (fan speed sensor)
and one digital
thermometer, which can be read by the host computer. It can be
easily expanded to 4
devices. It communicates with the computer via the 8 data lines,
and 4 computer to printer lines of a standard parallel port.
The at the core of the board is a MC4040 12 bit binary counter, a
74LS253 demultiplexor, a 74LS564 register and a timer. These are
wired to count the number of pulses
from a external source in a given time quantum (set by the timer)
and present
the latest datum on the parallel bus. Each time the timer
"ticks", the current
output of the counter is loaded into the register and the counter
is cleared.
Therefore, the register always presents the latest valid data to
the
parallel port.
The temperature is sensed by connecting a thermistor to a 555
timer and using its
output as input to the counter. If the correct thermistor is
used, the output to the
computer will be directly proportional to the absolute
temperature.
The fan speed is monitored by placing an IR LED/phototransistor
pair across the blades
of the fan. The IR beam will then be periodically broken by the
movement of the fan.
The output of the phototransistor circuit can be used as input to
the counter,
forming a tachometer.
Two of the control lines from the printer #AF, and #SEL are used
to select one pair
of inputs from the demultiplexor. #STROBE is used to reset the
timers, reset the
counters and disable output. #INIT disables the outputs but
allows the circuit to continue running. The truth table for
#STROBE and #INIT is:
| (RESET) #STROBE | (#OEN)
#INIT | ACTION |
| LOW | LOW | Run out output data |
| LOW | HIGH | Run but keep outputs at
hi-Z |
| HIGH | LOW | reset and hold outputs at
hi-Z |
| HIGH | HIGH | reset and hold outputs at
hi-Z |
PINOUTS:
| My name | Parallel port name | Pin
number |
| DATA0 | DATA0 | 2 |
| DATA1 | DATA1 | 3 |
| DATA2 | DATA2 | 4 |
| DATA3 | DATA3 | 5 |
| DATA4 | DATA4 | 6 |
| DATA5 | DATA5 | 7 |
| DATA6 | DATA6 | 8 |
| DATA7 | DATA7 | 9 |
| Sel0 | #AF | 14 |
| Sel1 | #SEL | 17 |
| #OEN | #INIT | 16 |
| RESET | #STROBE | 1 |
The 74LS564 inverts the outputs so software needs to invert
them once
more.
Programming the card
To read one of the 4 input channels, execute the following
procedure:
- Put the printer port in INPUT mode
- Assert #OEN and RESET and the desired input channel number
on
the control pins.
- wait a few ms for the card to respond
- De-assert RESET (don't change the input channel or
#OEN)
- Wait a LONG TIME (500 or so ms)
- Read and invert the bits from the 74LS564 register.
In C, under Linux, with the parallel port at 0x278, this looks
like:
char get_register(int reg) {
int output;
unsigned char data;
switch(reg):
case(0): output=8;break;
case(1): output=10;break;
case(2): output=0;break;
case(3): output=2;break;
}
outb(32|output,0x27A);
usleep(100000);
outb(32|1|output,0x27A);
usleep(600000);
data=inb(0x278);
return(~data);
}
Building the circuit
You will need:
A PC with a free bi-directional parallel port.
Some basic electronics tools and equipment.
Linux 2.0 or higher if you plan to use my code.
The parts for the board itself, specifically:
(1): 74LS564 (octal register w/ 3-state outputs)
(1): mc4040 (12 bit binary counter)
(1): 74HC14 (hex inverter w/ Schmitt triggers)
(1): 74LS253 (dual 1-of-4 demultiplexor)
(1): 7805 (power converter)
(1): IR LED/Phototransistor pair
(1): 10K thermistor (or similar temperature
sensor)
Resistors: (1): 100ohm, (1): 220 ohm, (4): 470 ohm,
(10): 1,000 ohm, (2): 3,300 ohm, (1): 10K ohm,
(1): 1M ohm
Capacitors: (2): 100uF, (6): 0.1uF, (1): 0.2uF, (1):
0.5uF
Here, you can find the schematic for
a circuit.
Notes:
I recommend building the circuit on wire-wrap perfboard.
Disassemble an unneeded printer cable and connect the wires to
your circuit. Mount the whole thing in an unused 5 1/4" bay with
the LEDs sticking out through holes in the cover.
Heavily decouple the circuit. Preferably a .1uF capacitor
across every chip with
big capacitors at the input and output of the power converter.
The 74LS64 chip and
the timers must be heavily decoupled because of their capacitive
switching.
The temperature sensor should be as close as is practical to
the 555.
D3 and Q1 form the tachometer. They should be aligned so
that the fan blades
periodically break the IR beam as the fan rotates.
If you add more devices which still use the main timer (on
the right) connect
pin two from the 74HC14 to the corresponding input pins on the
74LS253. If all the
inputs use the same master timer, then the inverted timer output
can connect
directly to the counter and register.
You may need to add an RC delay of a few uS if your MC4040
chip resets faster
than the 74LS564 can load the data.
This isn't exactly supposed to be good EE design. I designed
it to work with
the parts I happened to have on hand.
The circuit takes about 65mA of current without the
LEDs
Here are some pictures of the assembled device:
dstaff(at)ugcs.caltech.edu