Connecting a Footswitch to an RS-232 Serial Port
Connecting a Footswitch to an RS-232 Serial Port
(OP)
I would like to connect a simple (make/break contact) footswitch to a serial port, which will enable hands-free operation of an application. Before I begin development, has anyone done this? I've outlined the abstract below, but I don't want to re-invent the wheel! Alternately, if I am to do this, then comment would be useful. Oh, I forgot to mention, the platform is Windows/Intel.
Step 1: How to wire the connector. I'm guessing that the footswitch should be wired between DTR (always high) and some other input signal, say CTS. When the footswitch is depressed, then CTS goes high.
Step 2: Next we need an event-monitoring or interrupt-driven process that detects the CTS-high state.
Step 3: Last, we need a user-interface where we can easily configure what to do when the pedal is pressed. Most useful would be an ability to send a keystoke sequence to the active program. As a trivial example: if the pedal is pressed send F1 to the process, and the Help will appear.
Step 4: Allow for a second footswitch, wired, say, between DTR and DSR. Monitor and control in the same way.
Step 1: How to wire the connector. I'm guessing that the footswitch should be wired between DTR (always high) and some other input signal, say CTS. When the footswitch is depressed, then CTS goes high.
Step 2: Next we need an event-monitoring or interrupt-driven process that detects the CTS-high state.
Step 3: Last, we need a user-interface where we can easily configure what to do when the pedal is pressed. Most useful would be an ability to send a keystoke sequence to the active program. As a trivial example: if the pedal is pressed send F1 to the process, and the Help will appear.
Step 4: Allow for a second footswitch, wired, say, between DTR and DSR. Monitor and control in the same way.





RE: Connecting a Footswitch to an RS-232 Serial Port
You can even use the DTR and RTS outputs to supply power to the circuit (through diodes) to avoid the use of a battery. Just remember that the output can vary from 4V to 15V, so use a voltage regulator.
The Microchip webpage (www.microchip.com) even has many samples of code and circuits for interfacing switches to their microcontrollers.
RE: Connecting a Footswitch to an RS-232 Serial Port
What I'd suggest is to use the parallel port instead since it's connector is built of 5v lines with a 0=low and 5=high. It is composed of in and out control lines and you could use just one of them and connect the footswitch to it.
The drawback is that the PC does not support Interrupt via the parallel port (although their is an IRQ assigned to it though). So if you decide to go parallel, your program would have to poll the port from it's main loop or from a parallel process your program would launch.
Good luck
Marcel
Ruinbab
jcema@rocketmail.com
RE: Connecting a Footswitch to an RS-232 Serial Port
I haven't quite got my head around a micro-processor equipped footswitch, so I'm using my original idea - a simple make/break switch wired between DTR and CTS.
I've had some success with the first part of the problem (detecting CTS high) using Microsoft WIN32 SDK. In short:
1. Open the port using function: CreateFile
2. Set event mask using function: SetCommMask
(trap only EV_CTS)
3. Wait for an event using function: WaitCommEvent
(if this happens, someone pressed the footswitch)
When the code is reasonable stable and bug-free, I will post it for all. It'll probably work fine as a piece of embedded code in an application, but...
...the second part of the problem - having a way of mapping the event to a keystroke sequence so that it can be used with any already compiled application - is more challenging because a fairly substantial driver must be written, which will allow both keystroke programming and subsequent operation.
In the meantime I have sourced a commercially available solution that will do exactly what I want - the 'Savant 3-Action Programmable Footswitch'. Check out:
http://www.kinesis-ergo.com
For this you pay $129. So I am still interested in developing a less expensive (and probably less elegant) solution.