Switch interfaces:Switch interface (hardware)

Switch interface (hardware)

Context

● You are developing an embedded application using one or more members of the 8051 family of microcontrollers.

● The application has a time-triggered architecture, constructed using a scheduler.

● You are creating the user interface for your application.

Problem

How do you create a very robust switch interface for use in a hostile (e.g. industrial, automotive) environment?

Background

Consider the following scenarios:

● Your embedded application is used in an industrial environment where high levels of electrostatic discharge are likely. How can you ensure that your device remains fully operational?

● Your automotive security application may be the subject of deliberate vandalism or damage. Specifically, reports on the WWW have revealed that thieves have found it possible to disable a similar security system by applying 12V from a car battery directly to one of the system switches. How can you ensure that your system is more robust?

In general, SWITCH INTERF ACE ( SOFTW ARE ) [page 399] describes techniques that are only suitable in ‘safe’ applications: in hostile environments, you need a more robust solution. This must be hardware based.

Solution

As noted in ‘Background’, creating a robust switch interface requires the use of off- chip hardware.

Traditionally, techniques involving J-K flip-flops, high-impedence CMOS gates or R-C integrators have all been used for switch debouncing: Huang (2000), for example, provides details of these techniques. In general, these approaches – while performing the debounce operation – provide only very limited protection, at best, again ESD and similar hazards. Because, as we saw in SWITCH INTERF ACE ( SOFTW ARE ) [page 399], the process of switch debouncing is almost trivial in a scheduled application, the cost of external hardware for switch debouncing alone cannot generally be justified.

More recently, several specialized ICs for protection and switch debouncing have appeared on the market. Of these, the Maxim 6816/6817/6818 family are a good example (Figure 19.7).

This is how Maxim describes these devices:

● The Max6816/Max6817/Max6818 are single, dual, and octal switch debouncers that provide clean interfacing of mechanical switches to digital systems. They accept one or more bouncing inputs from a mechanical switch and produce a clean digital output after a short, preset qualification delay. Both the switch opening bounce and the switch closing bounce are removed.

● Robust inputs can exceed power supplies by up to ±25V.

● ESD protection for input pins:

±15 kV Human Body Model

±8 kV IEC 1000-4-2, Contact Discharge

±15 kV IEC 1000-4-2, Air-Gap Discharge

● Single-supply operation from +2.7V to +5.5V.

● Single (Max6816), dual (Max6817) and octal (Max6818) versions available.

● No external components required.

● 6 µA supply current.

image

Hardware resource implications

Reading a debounced switch input imposes minimal loads on CPU and memory resources.

Reliability and safety issues

For the reasons discussed in ‘Solution’, this is a highly reliable method for creating a switch interface.

For additional reliability – particularly in the event of malicious damage – see SWITCH INTERF ACE ( SOFTW ARE ) [page 399] for discussions on the use of multi-pole switches.

Portability

These techniques are inherently portable.

Overall strengths and weaknesses

Greatly increased reliability (compared with software-only solutions) in hostile environments.

Increased costs and hardware complexity.

Related patterns and alternative solutions

See SWITCH INTERF ACE ( SOFTW ARE ) [page 399].

Example: Reading 8 switch inputs in a hostile environment

Figure 19.8 illustrates the use of a Max6818 to read the inputs from eight switches connected to Port 1 of an 8051 device. The results are reported on Port 2.

image

image

Leave a comment

Your email address will not be published. Required fields are marked *