|
-
April 30th, 2009, 10:04 AM
#1
How to detect an electrical switch closing ?
Hi,
I'm working on a a program for monitoring a conveyor belt. At random intervals an electrical switch will be tripped (closed) and reopened a short while later.
This switch is hardwired into the conveyor belt and I have no control over it. It's just a dumb type electrical switch that's either closed (current can pass through) or open (no current can pass). The switch is just there, there's nothing hooked up to it (yet). It closes when something is on the conveyor belt under a camera.
I need to detect the closing of the switch and then take a picture of what's on the conveyor belt via a the camera (no problem, I have that sorted). The picture is stored and then analysed in a background thread (got that sorted also).
The data will typically come in bursts of several "clicks" over a few seconds followed by seconds/minutes/hours of no action.
Pictures are analysed in background since there may not be enough time to fully process them between "clicks" as they happen (typically an image takes between 2 to 15 seconds to process).
The problem I have now... I somehow need to hook up this on/off switch to the pc, and write code to detect the switch presses.
I'm not that into hardware, but from old memory (well ancient actually, talking DOS era here). I seem to remember that you could just attach a switch between two pins of the RS232 and read out the com port status somehow to detect the open/closed state of the switch.
Anyone know if this is indeed possible... and how ? which pins on the RS232 do I need, what would I need to write in code to do this (the program runs in Windows)?
Ideal would be that tripping the switch would result in a message/interrupt/or other "wake up" type thing to happen in the program, although if need be continuous polling is possible as well (but less ideal because of used CPU time, and the possibility of not detecting a down/up of the switch if it happens fast enough).
Alternate solutions are welcome too. It doesn't have to be RS232. Printerport, Ethernet, USB... I can even solder some wires on the motherboard if really really necessary. Just looking for something easy/cheap that will work.
I can't change the actual switch, it's built into the conveyor belt and can't be substitured for another type switch.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|