A digital temperature sensor and tachometer for your PC

Or would you rather view Home!, Projects! , Tux the penguin!, My resume.


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) #INITACTION
LOWLOWRun out output data
LOWHIGHRun but keep outputs at hi-Z
HIGHLOWreset and hold outputs at hi-Z
HIGHHIGHreset and hold outputs at hi-Z
PINOUTS:
My name Parallel port name Pin number
DATA0DATA02
DATA1DATA13
DATA2DATA24
DATA3DATA35
DATA4DATA46
DATA5DATA57
DATA6DATA68
DATA7DATA79
Sel0#AF14
Sel1#SEL17
#OEN#INIT16
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:

  1. Put the printer port in INPUT mode
  2. Assert #OEN and RESET and the desired input channel number on the control pins.
  3. wait a few ms for the card to respond
  4. De-assert RESET (don't change the input channel or #OEN)
  5. Wait a LONG TIME (500 or so ms)
  6. 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:

Here, you can find the schematic for a circuit.

Notes:

Here are some pictures of the assembled device:


dstaff(at)ugcs.caltech.edu