Advertisement

# Switch interfaces

April 10, 2017

Everywhere you look in industrial electronics there are switches and contacts: proximity switches, limit switches, relay contacts, activation switches and sometimes even keyboard switches. At one point, there was a plethora of integrated circuits that were aimed at switch matrices, but they all seemed to have faded to be replaced by versions of the 8042 that were used by IBM in the PC keyboard. Today if you were interested in making your own matrix encoder you would probably use a microcontroller of your own design. I have a recollection that Intel’s 8279 had a special mode for discrete switches.

However switches in the industrial sphere have their own peculiarities. First of all they often operate at high voltages - 24VDC is common. Second of all they don’t really lend themselves to a matrix configuration. (For you youngsters out there, a switch matrix is a method of multiplexing input contacts as a means to reduce the I/O pins needed to detect the switch state. I did a pair of blog posts on an aspect of this subject “Keyboard and display multiplexing -- the traditional approach” and “Keyboard and display multiplexing – Charlieplexing”.)   As a result, techniques are needed to condition the voltage to the microcontroller’s input voltage and to reduce the number of microcontroller I/O pins. In addition, where there is a mechanical contact, there is switch bounce and contact resistance.

I would love to write a blog on switch bounce, but Jack Ganssle beat me to it with a series of definitive articles on the topic (listed at the bottom), and it would be foolhardy to hold myself up for comparison with the master. You must read those articles.

Contact resistance can be a bother as well since sometimes the resistance is too high to be detected as a “make”. Some switches may require a minimum current to overcome the contact resistance (a “wetting” current).

There is a way to encode a number of inputs using a priority encoder, several of which you can find in the conventional logic families. These provide a code at their output that corresponds to the active input with the highest priority. Look at devices like the 74HC148 or the CD4532. You could also look at digital data multiplexers, again in the standard logic families like the 74HC151 (and there are others depending on the configuration you want). Of course you are still left with conditioning the input voltage. Analog switch multiplexers (e.g. CD4067) may add a degree of flexibility since they can work with elevated voltages, but that simply defers the voltage translation problem.

But of course, if I am writing about the subject, there are probably several other more comprehensive solutions. Most of these have serialized communications ports and as a result lend themselves to simplified isolation of the inputs, since each input does not have to be individually isolated.

Freescale/NXP (or whoever owns them now) offer the 33975/A and the 33972/A/T. Both are aimed at the automotive market, but there is no reason they couldn’t be used on the industrial stage. They have up to 15 inputs (at elevated voltage) with wetting current and an SPI output.

TI has a single offering, the industrially targeted SN65HVS880PWP, which has only 8 digital inputs with elevated voltage capability, but it has some other features. It has debounce filters, input current limits, serial output, is cascadable and has drivers for external LEDs that correspond to the inputs.

Maxim does have offerings very similar to TI’s. They are the MAX31911, MAX31912, MAX31913MAX31914, and MAX31915. If you only need to condition a single contact you may want to consider the MAX14838/9 industrial sensor output driver. The variations include a parallel output and SPI interface.

And finally Silicon Labs produces the Si838x family. Aside from the debounce of TI’s and Maxim’s offerings, this device has a diode bridge input (so no wiring polarity issues, although there doesn’t appear to be a smoothing capacitor so AC input appears unlikely) and most importantly include 2.5KV isolation.

I guess this blog complements “Where Have All the (MCU) Outputs Gone?” that I wrote a while back. Together the blogs cover both digital input and output in industrial systems and I hope they have provided some direction to design in that field.

Jack Ganssle’s Articles on Debouncing:

• 08.14.2019

• 08.03.2019

• 08.20.2019