Erratic behaviour joystick button on soundblaster

Hi everybody,
I just installed an old PC that has a sound card(isa with sound card+joystick interface) that i use as an automation device(programmed
in Pascal). What it does is read for many hours the joystick port for buttons pressed(a digital sensor connected to a relay closes the circuit and generates the event). The problem is that is generating erratic button presses( with absolutely no aparent reason - it works for days with no problem then it fails) - it might be the sensor who sends the wrong signal..electric noise...but i believe the problem is on the side of the computer. What should i do - might it be a defective sound blaster compatible card?
The sensor is trying to sense a metal(the metal is glued to a 35mm cinema film)..when it senses the metal(very rapidly..in a fraction of a second) it activates a "relay" that closes the circuit for the joystick button generating an event.
The code i use to read the bit In pascal:
FUNCTION button_1 : Byte; BEGIN button_1 := ((Port[$201] AND $10) XOr $10) ShR 4; END;
Isn't there a way to force the event to last longer than the time the relay is active to allow me to diferentiate between real events and hipothetical electricity contamination?
Some sort of a timer..everything happens very quickly...
Any help would be welcome. Thank You.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
cyberfreak wrote:

Google "switch debouncer" and you should find a number of circuits for this type of thing. If you are getting fleeting noise, something like a Schmitt trigger on the input may help. Again, a G search will turn these up. Basically this type of gate only responds to voltages above a certain level.
In the modern world all of this can be programmed with a simple microcontroller. That allows you to play more with the values, just in software.
The old game port on a sound card or a stand-alone card is not instrumentation grade. If adding the noise filtering to the switch inputs doesn't help you should consider a better interface. You can buy these for ISA and PCI slots for maybe $200 (some are more, with added features), ready to go. Depending on how critical it is to sense the foil mounted onto the film this small investment could be well worth it.
-- Gordon
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Thu, 21 Aug 2008 09:45:18 -0700 (PDT), cyberfreak

Searching google finds sites like below. An NPN transistor could be used in place of the relay to do the joystick button push. You could do something similar with the serial port. A voltage blip on the rx line will leave jibberish in the input buffer, which can be read on a repeating basis by software.
http://home.cogeco.ca/~rpaisley4/LM555.html#29
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.