Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting a Footswitch to an RS-232 Serial Port

Status
Not open for further replies.

CC1492

Computer
Aug 12, 2003
3
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.
 
Replies continue below

Recommended for you

Add some intelligence to the switch! A footswitch is usually large enough to enclose a very small circuit, so you could use a very inexpensive microcontroller to interface between the switch and the serial port. I would suggest a PIC micro or perhaps an ATMEL micro. Most small microcontrollers have a built-in serial interface.

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 ( even has many samples of code and circuits for interfacing switches to their microcontrollers.
 
The serial port demands, by it's conception, some circuitery added to the footswitch like outlined by "tombihn" in the previous answer. The circuit must be composed of a UART chip or at minimal a driver chip to support the + 0 - voltage scheme of the RS-232.

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
 
Thanks for all the useful advice.

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:


For this you pay $129. So I am still interested in developing a less expensive (and probably less elegant) solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor