Forgot your password?
typodupeerror
News

Using Joystick Ports to Measure Case Temperature? 47

Posted by Cliff
from the building-custom-temperature-probes dept.
cheros asks: "Due to lack of options I had to stick one of my machines in a spot where I'm worried it might get hot, so I am looking for a low cost way to monitor environment temperature. As it's a humble 486 it doesn't have sensors, but it DOES have a joystick port. I'm merely looking for one of 'OK', 'Warm', 'Hot', or 'Get the fire extinguisher!' style status info so I'm not too bothered about granularity. If I remember correctly, a joystick port gives me 2 channels to fool with. I was wondering if anyone has already been playing with the idea to use an NTC (temperature sensitive resistor), and if they got anywhere. In my case it's a matter of scanning the port every so often and sending an SMS email if the situation warrants attention. As a matter of fact, the joystick port also has a couple of switch lines as well - there's all sorts of fun to be had. The last time I've coded was in 6303 assembler on Psion Organisers, so don't expect too much of me in the way of coding skills - it'll take me a while to get up to speed in Perl. Yes, I run Linux [it's a 486 - what did you expect? XP? ;-)]"
This discussion has been archived. No new comments can be posted.

Using Joystick Ports to Measure Case Temperature?

Comments Filter:
  • sms? (Score:2, Insightful)

    why bother having it message you? just have it shut the damn thing down
  • 486? Heat? (Score:3, Insightful)

    by Innomi (566928) on Friday June 28, 2002 @03:57AM (#3785186)
    A 486 is hardly a heat sensitive piece of hardware. Hell, many of them didnt even bother with heatsinks. If you can get your 486 to overheat, take it out of the oven.
  • by Chasing Amy (450778) <asdfijoaisdf@askdfjpasodf.com> on Friday June 28, 2002 @04:19AM (#3785225) Homepage
    I have no idea how one would measure temperatures through some sort of joystick port dongle; however, it put me in mind of the coolest hack I've ever seen for a joystick port, very cool. It may even be vaguely on topic since he mentions the "all sorts of fun to be had" with the joystick port... Take a look:

    Hooking an Arcade Star Wars Flight Yoke to a PC [speedhost.com]

    What a cool joystick port hack--it uses all the original electronics from a circa 1984 Star Wars or RotJ controller, except for a change of POTS. Better than any cheesy gaming steering wheel. :-)
  • Netsaints good. (Score:4, Informative)

    by satanami69 (209636) on Friday June 28, 2002 @04:20AM (#3785229) Homepage
    I use a program called netsaint to monitor the internal network.

    They have a cool hack premade for what you need
    http://www.netsaint.org/docs/hacks/hltherm.php [netsaint.org]
  • by redelm (54142) on Friday June 28, 2002 @04:28AM (#3785249) Homepage
    It's been awhile since I checked, but the PC original joystick port is extremely primative. You charge some capacitors, then discharge them through the joysticks resistors [~1k IIRC] and measure the time to some cut-off voltage in software! Slow to read, and very CPU intensive. Maybe some modern chipsets do better. Like this, I'd expect PC joysticks are a severe handicap for modern games [USB should be _much_ better].

    Your biggest problem is going to be getting thermisters in the right resistance and wattage range. IIRC, most thermisters are in the 10-100k range, and aren't good for many volts [Watts]. Self-heating!

    As another poster has commented, why are you worried? A 486 certainly only needs a passive heatsink (if that) and you could probably lose the PSU fan without overheating if the Linux box is fairly idle due to idle-at-HLT powersavings.

    • P=E^2/R

      So, for 5 volts over a 10k thermister, you get 0.0025W. Over a 100k resistor, you'll get 0.00025W. Hardly enough to toast any parts, but ideally you want no self-heating (which means power=0).

      But, as long as you're not measuring the ambient temperature in the middle of a block of styrofoam, you won't really need to worry about selfheating - if you're in a good airflow or well connected to a mass of metal, any extra selfheating power will be disipated - there's not much temperature difference between a processor operating at 10 W and 10.00025 W.
    • You don't know what you're talking about.

      Joystick pots are usually around 50K, no you do not remember correctly. And joysticks are not processor-intensive, the A/D conversion simply puts the value on the bus where it can be retrieved. Yes, the joystick port uses charge times to determine the analog value; this is used in hundreds of embedded devices to do simple A/D conversions. It's perfectly acceptable for a joystick application. In fact, I'd bet most USB joysticks do this, anyway. I've programmed USB devices and the timed-charge method is used all over the place where cost is an issue.

      There is no problem getting the right thermistors. They are available in practically any reasonable resistance range necessary. Not to mention that 5 volts is about the maximum you'll see in a joystick port, and if you're running enough power to heat the thermistor, something's wrong.

      While you are a moron when it comes to electronics, I agree that a 486 probably doesn't have to worry about heating. Unless it's a late-model DX4.
      • I probably shouldn't reply to the flame. Casting pearls before swine. But for the potentially confused:

        I measured a joystick -- 1.6k at one end, 10k center, 90k at the other. I also found a reference to 250k.

        One-shots are cheap for A/D. But they are slow and have considerable latency. USB will not help this.

        A one-shot may be fast enough if you have nothing else to do. Else it needs a dedicated counting circuit. The original PC used the CPU! reading port 201h. This cost CPU cycles that can be used for other things (redraw). Perhaps current Southbridge chips have this counting circuit.

        Thank you for the reassurances on thermisters. I've always had trouble finding them. Do you know a good source, perhaps for 20 ohm 1/4W that would be good for fan speed control?

        I think that joysticks are a good gaming I/O device. Unfortunately, the original PC architecture had a very cheap Game Port. Had it had an interrupt-driven port like a Mouse Port (RS232 or PS/2), then the joystick would have had better "action" (responsiveness) and the PC would be a more competitive gaming platform. Yes, consoles are attractive for more than their "action" -- they are cheaper, simpler devices.

  • by Bastian (66383) on Friday June 28, 2002 @04:30AM (#3785253)
    Unless you have your computer sitting on top of a furnace, you won't have to worry much about overheating a 486 - my 486 doesn't even have a heatsink/fan, and, come to think of it, I've never seen a 486 with that going on.

    Probably the easiest thing you can do is just attatch a heatsink and fan with some thermal compound, and maybe get one of those ball-bearing fans that fits into a PCI slot if you want some extra cooling. That alone should remove any worries you need to have about overheating the computer, so you won't even need a heat sensor.
  • A joystick port, eh? Oh, good, that will help.

    What about my 466? It DOES have a power supply...

    ;)
  • on a 486? Windows 98
  • http://www.allthingsspiny.co.uk/pcthermometer.html for one
  • Done it! (Score:3, Informative)

    by orangesquid (79734) <orangesquidNO@SPAMyahoo.com> on Friday June 28, 2002 @06:12AM (#3785462) Homepage Journal
    I've done this before. I simply picked up a thermistor from radio shack, stuck it in the holes, and then wrote a little program to record the current time, flip the bit, and just sit in a wait() loop reading, and then check the current time, subtract them, and convert. I found a formula on a webpage somewhere that approximated the resistance based on the delay, and then I just interpolated the temperature from the numbers on the back of the thermistor package. The problem I tended to get, though, was that I needed to take several readings and then discard any outliers. Even with realtime priority and -20 niceness on the process, I frequently got timing errors that gave me temperatures 10, 20, or even 50 degrees off.

    You could always try to hack the kernel's joystick driver to do this... aim for more accuracy.

    I don't have the program I wrote anymore (sorry!) because it was an a very old boxen that has since been replaced, but I remember it was fairly short.
  • Go digital!

    Get some (up to eight) LM78 chips which you can (usually) connect directly to your parallel port. (use the i2c-pport module from linux-i2c or lm-sensors). Then you can use all usual hardware-monitoring programs that exist for linux.

  • Why not serial port? (Score:3, Informative)

    by Jess (11386) <[ude.tim.mula] [ta] [cjniheg]> on Friday June 28, 2002 @06:54AM (#3785537)
    Doesn't this box have a serial port? I monitor the temperature of our computer room [ornl.gov] using Dallas Semiconductor [dalsemi.com] DS-18S20 sensors and Digitemp [brianlane.com]. The sensors can be connected to your computer via the serial port and are relatively inexpensive (approx $3.00 for the sensor, $10.00 for the serial port interface)
  • channels (Score:3, Informative)

    by ForceOfWill (79529) on Friday June 28, 2002 @06:56AM (#3785545) Homepage
    If I remember correctly, a joystick port gives me 2 channels to fool with. ... As a matter of fact, the joystick port also has a couple of switch lines as well - there's all sorts of fun to be had.
    Actually, you have 4 analog inputs and 4 binary inputs (not counting the MIDI TX and RX). Two axes and two buttons each on two joysticks. Here's a pin diagram, looking in at the PC side of the connection:

    8-------------------1
    s\ l a m e n e s s /
    ss\ f i l t e r s /
    ss9\-------------/15
    and the pin meanings:

    1. +5v
    2. joy A btn 1
    3. joy A x-coord
    4. gnd
    5. gnd
    6. joy A y-coord
    7. joy A btn 2
    8. +5v
    9. +5v
    10. joy B btn 1
    11. joy B x-coord
    12. gnd
    13. joy B y-coord
    14. joy B btn 2
    15. +5v

  • Due to lack of options I had to stick one of my machines in a spot where I'm worried it might get hot

    Too many ways to answer...

    • *sigh* Global warming strikes again.
    • That's the way it is down here in hell.
    • You stuck your WHAT, WHERE?!?


  • Network Wizards [nw.com], the first site that kept Internet census numbers, had a product called the WizTemp [nw.com] that connected to an RS-232 port on a *nux machine. I used a bunch of them on a Sun/Solaris. It was a thermistor in mini-phone plug that plugged directly into a RS-232 connector. It included a script that would monitor the temperature and log it and take actual- send an email - on high temperatures.

    Alas, the site site says the WizTemp product is no longer available, but you may want to email him to get the details on what he used and how it worked.
  • Basicly your just doing analog input. Joystick port should work. Otherwise you could use the "line in" of your sound card. Youl have to code a way to bring in the signal from the joysick port or soundcard line in. I'm sure you can find a libary out there that someone has written to read the A/D value. Setup a VREF 4.096V zener precision references for some accuracy. Othrwises you could just refrence the NTC thermistor off any 5V or so line. Setup a votage divider circuit.
    VREF----
    |
    |
    * 100K or larger resistor
    *
    |
    |---- signal to voltage input
    |
    *
    * 30K @ 25C NTC Thermistor
    |
    |
    ---- gnd
  • The most extreme, fun way is to use pyrometric cones [ortonceramic.com] - just wait for these cones to droop and move the joystick, and you'll find out the temperature! Here's [webcom.com] how to use the cones when upgrading the wiring [webcom.com] of your computer.

    A much more practical way is to use the Dallas Semiconductor [dalsemi.com] (now bought by Maxim [maxim-ic.com], and not the magazine [maximonline.com])

    Dallas has a demo application you can use as an example - a weather station [ibutton.com] and some good application note examples. It uses the DS1820 [maxim-ic.com] or the DS18S20 [maxim-ic.com] and you can get up to 2 free samples of each [maxim-ic.com]. This device is digital, so no calibration is needed for the accuracy you need. They have a lot of other temperature sensors [maxim-ic.com]; some even have alarm outputs, so once you program it, reading only one bit will tell you if the temperature is out of limits. It has a well-written and complete datasheet [maxim-ic.com]. They've got software [ibutton.com] for win32, linux, beos, java, and 8051. If you write your own software or modifiy theirs, you don't really need a serial port adapter; just a wire on the parallel port will do (and it will power the device, too!!)

    If anyone's interested, I can dig up some c-code that I used - it works with the parallel port under dos.
    • If anyone's interested, I can dig up some c-code that I used - it works with the parallel port under dos.

      If you can find it easily, and if it's not too long, can you post it? Those Dallas Semi products look interesting. I've got an old Pentium Pro system that has some heat issues - it'd be great to be able to remotely check the temperature.
      • Compiled under turbo c circa 3/97. As you can see, I've got one wire powering the 1820, and another for the data. I think I'm using the parallel port's open collector output with a built-in pull-up resistor, as required by the DS1820.

        The us_delay function is a hacked-up form of the built-in turbo c library tick_delay function - I'm not sure if it's still copyrighted, so I didn't include it. It may not be that useful because it was custom-tuned to my 486. Yep, I had an oscilliscope available to do the tuning, but there are otherways to tune the loop.

        ---- file test1821.c
        #include <stdio.h>
        #include <dos.h>
        #include <conio.h>
        #include "usdelay.h"
        unsigned char outport1=0, outport2=0x0A;

        #define lptbase 0x378 // LPT1

        // for DS1821 .
        #define DQ_hi() {outport2&=0xF7; outp(lptbase+2,outport2);}
        #define DQ_lo() {outport2|=0x08; outp(lptbase+2,outport2);}
        #define DQ_in() ((inportb(lptbase+2)&0x08)^0x08)

        #define DS1821off() {outport1&=0xFB; outp(lptbase,outport1);}
        #define DS1821on() {outport1|=0x04; outp(lptbase,outport1);}

        // 1= no presence detect, 0=presence detected
        unsigned char reset_onewire(void)
        { unsigned char alone;
        disable(); // interrupts off
        DQ_lo();
        us_delay(750); // reset pulse
        DQ_hi();
        us_delay(100); // look for ack...
        alone=DQ_in();
        us_delay(380); // wait min time
        enable();
        return alone ? 1 : 0;
        } / / lameness filter fix

        void sendbyte_onewire(unsigned char byte)
        { unsigned char mask=1; // LSB first
        disable(); // interrupts off
        while (mask)
        { if (mask & byte) // send a 1
        { DQ_lo();
        us_delay(1);
        DQ_hi();
        us_delay(60);
        } //
        else // send a 0
        { DQ_lo();
        us_delay(60);
        DQ_hi();
        us_delay(1);
        } // lameness filter fix
        mask <<= 1;
        } // lameness filter fix
        enable();
        } / / lameness filter fix

        unsigned char getbyte_onewire(void)
        { unsigned char byte=0;
        unsigned char mask=1; // LSB first
        unsigned char bit;

        disable(); // interrupts off
        while (mask)
        { DQ_lo();
        us_delay(1);
        DQ_hi();
        us_delay(12);
        bit=DQ_in();
        us_delay(45);
        if (bit)
        byte |= mask;
        mask <<= 1;
        }
        enable();
        return byte;
        } / / lameness filter fix

        unsigned char read_1821(unsigned char cmd)
        { reset_onewire();
        sendbyte_onewire(cmd);
        return getbyte_onewire();
        } / / lameness filter fix

        void cmd_1821(unsigned char cmd)
        { reset_onewire();
        sendbyte_onewire(cmd);
        } / / lameness filter fix

        #define readstatus_1821() read_1821(0xAC)
        #define readTH_1821() read_1821(0xA1)
        #define readTL_1821() read_1821(0xA2)
        #define readtemp_1821() read_1821(0xAA)
        #define start_1821() cmd_1821(0xEE)
        #define stop_1821() cmd_1821(0x22)

        void main()
        { int i;
        unsigned char s;
        printf ("=== DS1821 test ===\n");
        DS1821on();
        DQ_hi();
        delay(100); // allow powerup
        i=reset_onewire();
        if (i)
        printf ("No one-wire devices detected.\n");
        else
        { printf ("ALONE=%d\n", i);
        printf ("STATUS=0x%02x\n", (unsigned int) readstatus_1821());
        i=(int) (char) readTH_1821();
        printf (" TH= %6.1føC,%6.1føF\n", i*1.0, i*1.8+32.0);
        i=(int) (char) readTL_1821();
        printf (" TL= %6.1føC,%6.1føF\n", i*1.0, i*1.8+32.0);
        i=(int) (char) readtemp_1821();
        printf ("temp= %6.1føC,%6.1føF\n", i*1.0, i*1.8+32.0);
        start_1821();
        getch();
        printf ("STATUS=0x%02x\n", (unsigned int) readstatus_1821());
        i=(int) (char) readTH_1821();
        printf (" TH= %6.1føC,%6.1føF\n", i*1.0, i*1.8+32.0);
        i=(int) (char) readTL_1821();
        printf (" TL= %6.1føC,%6.1føF\n", i*1.0, i*1.8+32.0);
        i=(int) (char) readtemp_1821();
        printf ("temp= %6.1føC,%6.1føF\n", i*1.0, i*1.8+32.0);
        while (!kbhit())
        { if ((s=readstatus_1821()) & 0x80) // if conv. done
        { i=(int) (char) readtemp_1821();
        printf ("temp= %6.1føC,%6.1føF\n", i*1.0, i*1.8+32.0);
        start_1821();
        }
        }
        getch();
        }
        getch();
        DQ_lo();
        DS1821off();
        } / / lameness filter fix

        lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away)
        lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away) lamenessfilter doesn't like posts with too few characters per inch. I guess they like obtuse perl programs instead of nicer c programs (flame away)
        • Damn. It took me longer to get around the lameness filter than it did to find the code. What the point of the "code" selection on the comment form when all it does is change the font?

          And the funny thing - when I added the above paragraph to the post, it didn't pass the compression test -- but all that repetition I used did pass, and adding the above useful paragraph should have made it better... oh well...
  • Link a joystick with all springs removed to a big outdoor thermometer's bimetallic element, so that as the element moves (as it would move the needle) it moves the joystick.

    • Link a joystick with all springs removed to a big outdoor thermometer's bimetallic element, so that as the element moves (as it would move the needle) it moves the joystick.

      Better:

      Train a hamster to run in it's wheel when it gets touched by the thermometer's bimetallic element; then connect the wheel to a portable generator, which powers an electric bell. When the bimetallic element moves, it touches the hamster, which then runs in the wheel, which then rings the bell, which alerts you that there's a problem.

      If you're gonna do a Rube Goldberg, you should always involve a hamster.

  • Measure temperature, light, etc with your joystick port :

    http://www.epanorama.net/documents/joystick/pc_c ir cuits.html

  • No offense, but it's very obvious you haven't been a geek very long. We've all battled with graphics cards, serial ports, game ports, parallel ports, sound cards....anyways, here's what you need:


    Fucking lameness filter....

    Heres the link

    PCGPE - Joystick [iitb.ac.in]
  • I currently have my joystick measuring the temperature of my room once a minute. I originally planned to use thermistors, but experiments with a diode turned out to work just fine. Now, I honestly have no clue how it works, because the specific diode I'm using is basically broken (doesn't act like a diode should in a normal circuit), and a normal diode doesn't work in my circuit. So it was just complete luck that it worked out for me (and I *really* don't know why it works...) But it should work theoretically with thermistors in the same way. Essentially, as long as your current varies with temperature, you can measure temperature with it.

    The code is amazingly simple. Here's the important part (C, obviously, running on a Linux 2.2 kernel):

    #include <sys/time.h>
    #include <asm/io.h>

    long getreading(short int which) {
    struct timeval before,after;

    outb(1,0x201); // Poke the monostable multivibrator ;)

    gettimeofday(&before,NULL);
    while( (inb(0x201) >> which) & 0x1 );
    gettimeofday(&after,NULL);

    if(after.tv_sec > before.tv_sec) after.tv_usec += 1000000;

    return (after.tv_usec - before.tv_usec);
    }

    "which" is just the channel you want to read.

    The tricky part is the calibration. You'll first just hope that your readings scale linearly with temperature, and mess around with an offset and slope until it matches some known readings. If it's not linear, well... But if you just want "Good", "Bad", and "This reading wasn't taken, because the CPU is a puddle of slag", then it's not so bad.

    Good luck. It was a fun project for me. I still don't have the calibration worked out quite right, but that's okay. Oh, and I use RRD Tool [ee.ethz.ch] to graph the results. I have pretty, colorful, utterly useless graphs of the temperature of my room. Yay!

  • Arstechncia...go to the openforums...navigate aroudn there; try case and cooling fetish.

    Just my 2 cents directing a guy to a place w/ lots of people who do this seemingly daily.

The opposite of a correct statement is a false statement. But the opposite of a profound truth may well be another profound truth. -- Niels Bohr

Working...