Programmable Logic Controller Switch Debounce at the Hardware Level

Return to the Industrial Control and Automation Index

The concept of switch debouncing was likely covered in your digital logic and microcontroller classes. There, you learned that a switch or relay does not close in a clean manner. Instead, the contacts bounce like a steel ball on a steel anvil. The result is a signal with dozens of on-off-on transitions before settling to a fully on state. Digital logic is often faster than the switch closure and fully capable of reading the transitions resulting in unpredictable operation. Surprisingly, this is not something a Programmable Logic Controller (PLC) programmer normally considers. This article will answer the reason with an exploration of typical underlying hardware.

Let’s start with a recognition that switch debouncing is a very important consideration for the PLC. After all, the core of a PLC is a high-speed microcontroller that can respond to fast transitions such as switch bouncing. The beauty of the PLC is that most manufacturers have already mitigated the problem. Most have a default setting that accommodates the debounce for the most common switches and pushbuttons. Consequently, it’s not something beginning PLC programmers need to consider. However not all inputs signals are equal. One day, you may wish to monitor a signal with fast transitions that would be lost inside the debounce filter.

In this article we will explore the open-source design featured on the KUNBUS DIO module as shown in Figure 1. In this image, the DIO module is above with the Revolution PI Core S with its Ethernet and USB connections below. We will explore the concept of voltage domains with clear demarcation between DIO module’s input connections. We will also explore purpose-built PLC interface modules such as the MAX31913 featured in the KUNBUS product.

Figure 1: Picture of the KUNBUS DIO module (above) along with the Revolution Pi PLC controller.

The importance of PLC voltage domains

Open-source hardware is a gift to the developing technologist and engineer. One of the benefits is that we can have access to real-world function designs. For example, the input section of the DIO module picture in Figure 1 uses two significant integrated circuits including a pair of MAX31913 ICs and a single MAX14850.

  • MAX31913: 8-channel digital to serial (SPI) interface purpose built for PLC input applications. This includes a built in debounce filter. Together, these devices form an umbrella that protects the underlying delicate microcontroller:

  • MAX14850: 6-channel digital isolator able to withstand up to 600 V_{RMS} with data speeds up to 50 Mbps.

If you have damaged a microcontroller, you will already know that there are many ways to do so. It only takes a second of reverse polarity or over voltage to destroy the microcontroller. Inside the DIO module, the Maxim IC protect against the hazards commonly found in an industrial environment such as transients, reverse polarity, and to a certain extent overvoltage conditions. We could say it is easy to destroy a microcontroller. You need to work much harder to destroy a PLC module.

Switch debounce with purpose-built PLC input modules

A typical switch bounding waveform is shown in Figure 2. This particular snap action switch takes nearly 1.5 ms to settle down. Clearly, the PLC must contend with this physics problem or there is a risk of unpredictable program response.

Figure 2: Debounce time for a normally open switch providing 24 VDC to the input of the PLC.

The first line of defense is found within the MAX31913. An inspection of the datasheet reveals that the serializer IC itself has a built-in filter. The filter is set via the MAX14850 DB1 and BD0 inputs with 4 discrete ranges from off to 3 ms.

We can argue that a hardware solution is ideal as it minimizes the code complexity. However, if necessary, it’s not too difficult to construct a debounce operation in software. We would likely monitor for switches changes over many PLC program scans.

Tech Tip: Be sure to verify the debounce setting in your PLC software. This can save you a great deal of troubleshooting time. For example, the settings for the Revolution Pi PiCtory are shown in Figure 3. Here the debounce settings (red arrow) corresponds to those listed on the Maxim MAX31913 datasheet.

Figure 3: The debounce setting is highlighted in this PiCtory screen capture.

Have you ever encountered a problem with a PLC switch debounce filter? We would love to hear from you. How long did it take to locate the problem? What lead you to the solution?

Best Wishes,

APDahlen

Return to the Industrial Control and Automation Index

1 Like