Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Using Joystick Ports to Measure Case Temperature?

Cliff posted more than 12 years ago | from the building-custom-temperature-probes dept.

News 47

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? ;-)]"

Sorry! There are no comments related to the filter you selected.

sms? (2, Insightful)

Gregory S Patterson (567055) | more than 12 years ago | (#3785175)

why bother having it message you? just have it shut the damn thing down

486? Heat? (3, Insightful)

Innomi (566928) | more than 12 years ago | (#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.

Who cares (-1)

GPL Troll (586731) | more than 12 years ago | (#3785199)

Mozilla does suck. Leaving it open for more than a day with "quickstart" causes RAM usage to jump to ridiculous levels, we're talking about > 60 MB here. That is just unacceptable. I cannot believe people actually put up with such a slow crappy browser. The menus draw so damn slowly I sometimes wonder if I am using a Java application instead of a "native" application. The interface is worse. It doesn't even look like any other windows apps. I realize that people want it to look the same on all platforms, but why? That is just about the worst idea I've ever heard. If you want Windows (or any) users to adopt your crappy browser, at least you could take the time to make it not look like a piece of shit on Windows. The "modern" skin looks like ass.
I'm just glad NS4.7x is phasing out of use. I've wasted more hours than I like to admit fooling with pages to render halfway decently on that piece of shit browser. Modern versions are much better (4.77 seems to at least render 25% of my CSS) but still really suck in comparison to IE or even Opera.

And a 9+ meg download for a browser WITHOUT a Java VM? Jesus Christ, talk about bloat. IE may not be the most trim download either, but at least it supports just about everything on the web.

The worst part about Mozilla is that it doesn't support the PWP. How can I enjoy all of Klerck's hard work if it just comes out as a long post? Pages want to be wide.

My favorite is hearing people talk about how bloated IE is and how fast Mozilla is. I am not sure what alternate dimension they live on, but here in reality Mozilla is a bloated, ugly, slow piece of shit.

I really really did try to give Mozilla a decent shot. Too bad it sucks ass. On a linux platform, Konqueror is really a much better choice, especially if you use KDE. But KDE is another bloated piece of shit too. Don't get me started on that. Opera is pretty nice, the mouse gestures rock, and I love the tabbed interface. Mozilla's implementation of the tabbed interface is joke compared to what Opera has done.

It's not like I have anything against Open Source. I have a Debian NAT/firewall that works nicely. My video capture card also works much better on my Debian box (blame ATI for writing sorry ass TV Tuner drivers). But I can't get used to the shitty GUI systems that are X-Windows, KDE, Gnome, etc. The command line interface is nice for admining servers over a network, but for everday use (which it is almost necessary to do anything remotely useful on a Linux machine) it is absolutely awful. Are these people addicted to typing a lot? How do people stand to use Mutt or Pine to access their email? Step into the 21st century, we are not in the 70s anymore. My monitor has more than 16 colors, is it wrong to want to use all of them?

I can't stand all of the Slashdot fags that try to say how much Linux is better than Windows or FreeBSD is better than windows or X is better than Y. Linux is not the end-all solution to every problem. It won't solve world hunger. Linux isn't perfect. The open sores development model isn't perfect. Windows isn't perfect. Get over it.

Also, the open source model isn't perfect either. There's something to be said for a good QC department. There's something to be said for any sort of Quality Control in general. I think it explains this question: Why is it that Linux lags several years behind any commercial operating system in terms of usability? The open source model lets you work on whatever the fuck you want to. Well, who wants to work on the not-fun-never-will-be-fun-in-a-million-years parts of an application? Nobody, so it takes a long time getting done. No boss to tell you you have to get that done.

Try saying anything bad about Linux or Open Sores to the bastards on Slashdot. You'll be modded "-1, Troll" faster than you can blink. Although everyone knows you should be modded "+5, Truthful and Non-Homosexual."

People that insist all software should be free are also fucking morons. I'm a software developer, is it wrong to want to be paid for my work? You pay the grocer for your food, the car mechanic to fix your car, rent to your landlord/apartment complex, so why the fuck is it wrong to pay for software? I'm sorry if I don't want to end up a fat bastard with a ruddy complexion that drinks way too much Jaegermeister.

Go push your communist agenda somewhere else you cumguzzling ass-fucking retarded free software zealots.

OK I'm done. Feel free to use this to crapflood or do anything else with. It is released under the NHFL (non homosexual free license).

PS Thanks Trollaxor for having a place like this so I can rant about this kind of crap and not get made fun of for being heterosexual.

Serial Troller's greatest hits: TRLLNPLK! (-1)

Linus Turdballs (558038) | more than 12 years ago | (#3785214)

THE TROLL POLKA (ARSCHFICKEN MIT ZIEGEN)
By Serial Troller [slashdot.org]
Is das nicht ein early post?
Ja! Das ist mein early post!
Is das nicht ein Goatse [goatse.cx] ghost?
Ja! Das ist mein Goatse [goatse.cx] ghost!
Early post, Goatse [goatse.cx] ghost,
Oh, du schöne,
Oh, du schöne,
Oh, du schöne,
Slashdot sucks!
Is das post at minus one?
Ja! Das ist at minus one!
Is das trolling so much fun?
Ja! Das trolling is so fun!
Minus one, trolling fun,
Early post, Goatse [goatse.cx] ghost,
Oh, du schöne,
Oh, du schöne,
Oh, du schöne,
Slashdot sucks!
Is das nicht ein big crapflood?
Ja! Das ist mein big crapflood!
Is it worthless Linux FUD?
Ja! Das ist mein Linux FUD!
Big crapflood, Linux FUD,
Minus one, trolling fun,
Early post, Goatse [goatse.cx] ghost,
Oh, du schöne,
Oh, du schöne,
Oh, du schöne,
Slashdot sucks!
Is das nicht der CowBoiKneel?
Ja! Das ist der CowBoiKneel!
Is dis nicht his manchode meal?
Ja! Das ist his manchode meal!
CowBoiKneel, manchode meal,
Big crapflood, Linux FUD,
Minus one, trolling fun,
Early post, Goatse [goatse.cx] ghost,
Oh, du schöne,
Oh, du schöne,
Oh, du schöne,
Slashdot sucks!
Is das nicht ein WIPO Troll?
Ja! Das ist der WIPO Troll!
Is das nicht ein Goatse [goatse.cx] hole?
Ja! Das ist der Goatse [goatse.cx] hole!
WIPO Troll, Goatse [goatse.cx] hole,
CowBoiKneel, manchode meal,
Big crapflood, Linux FUD,
Minus one, trolling fun,
Early post, Goatse [goatse.cx] ghost,
Oh, du schöne,
Oh, du schöne,
Oh, du schöne,
Slashdot sucks!
Is das nicht Jon Katz slave boys?
Ja! Das ist Jon Katz slave boys!
Und arent they Tacos sex toys?
Ja! They are Tacos sex toys!
Katz slave boys, Robs sex toys,
WIPO Troll, Goatse [goatse.cx] hole,
CowBoiKneel, manchode meal,
Big crapflood, Linux FUD,
Minus one, trolling fun,
Early post, Goatse [goatse.cx] ghost,
Oh, du schöne,
Oh, du schöne,
Oh, du schöne,
Slashdot sucks!
Is das nicht ein trolltalk thread?
Ja! Das ist ein trolltalk thread!
Is it nicht now FUCKING DEAD?
Ja! Is really FUCKING DEAD!
Trolltalk thread, FUCKING DEAD,
Katz slave boys, Robs sex toys,
WIPO Troll, Goatse [goatse.cx] hole,
CowBoiKneel, manchode meal,
Big crapflood, Linux FUD,
Minus one, trolling fun,
Early post, Goatse [goatse.cx] ghost,
Oh, du schöne,
Oh, du schöne,
Oh, du schöne,
Slashdot sucks!

____________________

Change Log:

  • Subtle changes to most verses. It sounded really gay before.
  • Removed all references to Tacos pud. May have been high at time. Will investigate further.
  • Finally think I have
  • goat sex written correctly in German. I think. Arschficken?

© 2002 Serial Troller. Permission to reproduce this document is granted provided that you send all the bukkake porn you can find to serialtroller@hotmail.com [mailto] .

Only Vaguely Related, but Cool... (3, Interesting)

Chasing Amy (450778) | more than 12 years ago | (#3785225)

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. :-)

Re:Only Vaguely Related, but Cool... (0)

Anonymous Coward | more than 12 years ago | (#3788662)

But there isn't any electronics in the controller except for the pots, fire buttons, and wires ...

I know this first-hand because I helped a friend fix a bad solder joint in his Star Wars machine.

Netsaints good. (4, Informative)

satanami69 (209636) | more than 12 years ago | (#3785229)

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]

Joystick ports are ancient ! (3, Informative)

redelm (54142) | more than 12 years ago | (#3785249)

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.

Re:Joystick ports are ancient ! (2)

morcheeba (260908) | more than 12 years ago | (#3786922)

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.

Re:Joystick ports are ancient ! (2, Informative)

cybermace5 (446439) | more than 12 years ago | (#3788443)

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.

Re:Joystick ports are ancient ! (1)

redelm (54142) | more than 12 years ago | (#3790487)

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.

Barking up wrong tree (3, Informative)

Bastian (66383) | more than 12 years ago | (#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.

It has a joystick port? (1)

mike_sucks (55259) | more than 12 years ago | (#3785261)

A joystick port, eh? Oh, good, that will help.

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

;)

What do I expect? (1)

hackwrench (573697) | more than 12 years ago | (#3785270)

on a 486? Windows 98

Re:What do I expect? (-1)

Linus Turdballs (558038) | more than 12 years ago | (#3785280)

On a 486, I would expect to have HOT STICKY GAY SEX with my favorite HOMOSEXUAL, ALAN "ANAL COCKS" COX. Wouldn't you expect to see HOT THROBBING COCKS if you had a 486?

I don't think this made any sense. I need sleep. Or maybe just a GIANT THROBBING COCK TO LICK. Eh, I'll just go repost the TRÖLLËNPÖLKÄ a few more times and go to sleep. Meh.

[sigh] ever tried google?... (1, Informative)

jantheman (113125) | more than 12 years ago | (#3785271)

http://www.allthingsspiny.co.uk/pcthermometer.html for one

[sigh] ever try reading the submission? (1)

Drunken Coward (574991) | more than 12 years ago | (#3785425)

Yes, I run Linux [it's a 486 - what did you expect? XP? ;-)]

Your link says:

1. Requirements
Microsoft Windows 95,98, 2000, Possibly ME. XP home, XP Pro

But thanks for playing!

Re:[sigh] ever try reading the submission? (1)

jantheman (113125) | more than 12 years ago | (#3785522)

Durr!
for the H/W! (ffs. I do have other things to do besides making helpful suggestions)

Re:[sigh] ever try reading the submission? (1)

Yottabyte84 (217942) | more than 12 years ago | (#3790092)

My cd burner 'requires' windows, but works fine in linux. All the 'requirements' means is that they only provide windows drivers.

Why the joystick port? (0)

MageNuts (585683) | more than 12 years ago | (#3785455)

What I don't get is why you want to figure out how to hook such a device to the joystick port...

(1) "Unless your computer is on a furnace..." Forget that, unless your computer is IN a furnace heat is the last thing you have to worry about with a 486er.

(2) On a pre-Pentium system I doubt if it's technically possible to find out the temperature of the CPU. However, I may be wrong...

(3) To me trying something through a joystick port sounds like one of those geek experiments that's powered by beer, determination, and having nothing better to do. The geek way is not always the best way to do things seeing as how simplicty is easily overlooked.

To me the easiest way to do this would seem to be to buy a cheap digital therometer. Somehow affix the temperature sensor to the CPU (That computer's old enough to where I'd just say duct tape the sucker.) Get the wires from the sensor inside the box hooked up to the reader outside the box. That way all you'd have to do is glance over at the box and see the temperature on the reader..

Would be a hell of a lot easier than jerry-rigging a device and writing the programming to do what you asked about...

Please GIVE UP on these STUPID ASK SLASHDOTS (-1, Flamebait)

Anonymous Coward | more than 12 years ago | (#3785460)

This has now gotten to the point where people are just submitting stupid requests to see their names on the front page. This has got to be the stupidest piece of shit idea I've ever heard of. Why don't you spend the $0.59 to buy an RTD and mount it in the case, and put the panel meter on the front. Better yet, turn your machine off, pack it in a box, and send it back to the manufacturer with a note saying you're TOO STUPID TO USE A COMPUTER.

Done it! (3, Informative)

orangesquid (79734) | more than 12 years ago | (#3785462)

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.

Don't go analog... (2)

cnvogel (3905) | more than 12 years ago | (#3785516)

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? (3, Informative)

Jess (11386) | more than 12 years ago | (#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)

Re:Why not serial port? (2)

sysadmn (29788) | more than 12 years ago | (#3788260)

Here's a good reference circuit [riccibitti.com] . Ignore the Visual Basic Software, build the circuit, attach it to the serial port, and grab any of several serial-port monitors from SourceForge. The circuit is even self-powered from the port.

Re:Why not serial port? (0)

Anonymous Coward | more than 12 years ago | (#3792584)

You can even get the sensors free by requesting samples from DS. There are multiple types of temp sensors that will work with Digitemp so you can get at least 3 or 4 sensors for free so you only have to buy the serial to one-wire adapter.

channels (3, Informative)

ForceOfWill (79529) | more than 12 years ago | (#3785545)

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

Re:channels (2)

ForceOfWill (79529) | more than 12 years ago | (#3785568)

"not counting the MIDI TX and RX" which I forgot to put in because my reference didn't have them (but I know they're there somewhere...)

Re:channels (1)

qurob (543434) | more than 12 years ago | (#3788912)


Use one of the axes to cut a hole in the case and let some air out.

axes (0)

Anonymous Coward | more than 12 years ago | (#3789169)

axes is the plural form of axis. you axehole.

Re:axes (0)

Anonymous Coward | more than 12 years ago | (#3793318)


Why don't both of you geeks kiss my white axe?

Oh Hell (2)

Hell O'World (88678) | more than 12 years ago | (#3786002)


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?!?


The WizTemp may be a clue (1)

netringer (319831) | more than 12 years ago | (#3786580)

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.

Analog input (1)

KarlH420 (532043) | more than 12 years ago | (#3786825)

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

Two solutions (2)

morcheeba (260908) | more than 12 years ago | (#3786865)

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.

Re:Two solutions (1)

ArcticChicken (172915) | more than 12 years ago | (#3787351)

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.

Re:Two solutions - source code (2)

morcheeba (260908) | more than 12 years ago | (#3787827)

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)

Re:Two solutions - source code (2, Insightful)

morcheeba (260908) | more than 12 years ago | (#3787911)

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...

Re:Two solutions - source code (1)

ArcticChicken (172915) | more than 12 years ago | (#3791982)

That's excellent morcheeba! Thanks very much for posting all that.

Use a joystick (1)

obtuse (79208) | more than 12 years ago | (#3787327)

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.

Re:Use a joystick (2)

schon (31600) | more than 12 years ago | (#3788775)

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.

google, google, google (1)

Jim Buzbee (517) | more than 12 years ago | (#3788461)


Measure temperature, light, etc with your joystick port :

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

PC Joystick code (1)

qurob (543434) | more than 12 years ago | (#3788953)


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've done it. (2)

whatnotever (116284) | more than 12 years ago | (#3789899)

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!

Um...try this place... (1)

ArsonPerBuilding (319673) | more than 12 years ago | (#3790344)

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.
Check for New Comments
Slashdot Login

Need an Account?

Forgot your password?