{"id":1813,"date":"2026-10-04T14:10:00","date_gmt":"2026-10-04T06:10:00","guid":{"rendered":"https:\/\/lemaele.com\/blog\/push-button-debounce-guide\/"},"modified":"2026-10-06T17:25:39","modified_gmt":"2026-10-06T09:25:39","slug":"push-button-debounce-guide","status":"publish","type":"post","link":"https:\/\/lemaele.com\/de\/blog\/push-button-debounce-guide\/","title":{"rendered":"Push Button Switch Debouncing for PLC and Microcontroller Inputs"},"content":{"rendered":"<style>.lema-article{min-width:0;max-width:100%}.lema-article img{max-width:100%;height:auto}.lema-article figure{margin:24px 0}.lema-table-wrap{max-width:100%;overflow-x:auto}.lema-table-wrap table{min-width:640px;border-collapse:collapse}.lema-table-wrap th,.lema-table-wrap td{border:1px solid #ddd;padding:12px;text-align:left}.lema-video{position:relative;padding-bottom:56.25%;height:0}.lema-video iframe{position:absolute;inset:0;width:100%;height:100%;border:0}.single-post article{min-width:0;max-width:100%}<\/style>\n<div class=\"lema-article\">\n<p>Push button debounce makes one intended operator action produce the intended controller event despite brief contact transitions. For ordinary PLC or microcontroller command inputs, first establish the raw electrical state, then accept a stable state and generate the required press or release event. Choose filtering from measured contact behavior and the acceptable response time; do not apply one fixed delay to every button or use filtering to hide defective wiring.<\/p>\n<p>This guide concerns normal operator commands such as selecting a mode or counting presses. It does not design an emergency-stop or other safety function. LEMA PBS push buttons are the illustration reference. The exact contact arrangement, action and controller input requirements still need confirmation for the chosen model.<\/p>\n<h2>Define the command before choosing a filter<\/h2>\n<p>Write down what one press is supposed to do. It may toggle a mode, increment a value, issue a single start request or hold a manual command while pressed. Those functions require different event logic even when the physical button is identical. Identify whether press, release or both transitions matter and whether a held button should repeat.<\/p>\n<p>Create acceptance examples before implementation: one press gives one event; holding gives the specified behavior; a rapid second press is accepted or intentionally rejected according to the requirement. Also define startup behavior when the button is already held. A filter can produce a stable state but still create the wrong command if the event rules are incomplete.<\/p>\n<h2>Distinguish contact bounce from other signal problems<\/h2>\n<p>Moving contacts can settle through several transitions around one actuation. The University of Washington Makeability Lab lesson explains this basic contact-bounce mechanism. A trace that continues changing while the button is held can have another cause, such as a loose connection, a floating input or mechanical re-actuation. Diagnose the signal rather than calling every unwanted edge bounce.<\/p>\n<p>Observe the physical button, raw input and accepted event together where possible. Confirm the actual NO or NC contact mapping and released state. Keep illumination wiring separate unless the model drawing explicitly connects it. A lamp turning on does not prove that the controller contact circuit is correct. Use the approved electrical inspection procedure for the equipment.<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/lemaele.com\/wp-content\/uploads\/2026\/10\/lema-backfill-push-button-debounce-guide-body1-20261006.webp\" alt=\"Finger operating a disconnected PBS button beside qualitative input traces\" title=\"Finger operating a disconnected PBS button beside qualitative input traces\" loading=\"lazy\"><figcaption>Finger operating a disconnected PBS button beside qualitative input traces. Product-reference illustration; not a dimensioned drawing, installation instruction or test result.<\/figcaption><\/figure>\n<h2>Measure at the input the controller uses<\/h2>\n<p>The relevant signal is the voltage or logic state at the controller input, not only at the switch terminals. Wiring, input electronics and existing hardware filtering can change what the program sees. Review the controller input specification and sampling behavior. For a PLC, check the configured input filter and task or scan arrangement; for a microcontroller, check voltage limits and pull configuration.<\/p>\n<p>Take measurements using suitable isolated or otherwise approved methods and qualified personnel. Do not attach a grounded instrument indiscriminately to an unknown circuit. Preserve representative press and release traces and the operating conditions. The result should identify transition duration and valid press behavior, not merely provide a screenshot that resembles a generic example.<\/p>\n<h2>Accept stable states without blocking unrelated work<\/h2>\n<p>A common software approach tracks the latest raw state and the time when it changed. When that raw state has remained unchanged for the selected interval, update the accepted state. Generate an event only if the accepted state makes the intended transition. Restart the qualification interval when the raw state changes again.<\/p>\n<p>The official Arduino debounce example demonstrates timed state acceptance. Treat it as an educational pattern, not a production controller program or a universal delay recommendation. A nonblocking implementation lets other required work continue while the input settles. Review timing arithmetic, startup initialization and event handling for the actual controller rather than copying code without understanding its assumptions.<\/p>\n<div class=\"lema-table-wrap\">\n<table>\n<thead>\n<tr>\n<th>Symptom<\/th>\n<th>Possible layer<\/th>\n<th>Useful check<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Several edges around one press<\/td>\n<td>Contact settling or raw input conditioning<\/td>\n<td>Measure the actual controller input<\/td>\n<\/tr>\n<tr>\n<td>Repeated commands during a long hold<\/td>\n<td>Command event logic<\/td>\n<td>Separate level, edge and repeat behavior<\/td>\n<\/tr>\n<tr>\n<td>Valid short press is missed<\/td>\n<td>Combined filter and task timing<\/td>\n<td>Compare press duration with total acceptance path<\/td>\n<\/tr>\n<tr>\n<td>State changes while held<\/td>\n<td>Connection, noise or mechanical behavior<\/td>\n<td>Inspect circuit and actuator before adding delay<\/td>\n<\/tr>\n<tr>\n<td>Command appears at startup<\/td>\n<td>Initialization and event rules<\/td>\n<td>Test powered startup with button already held<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>Account for PLC filtering and program timing together<\/h2>\n<p>A PLC input may already include a configurable hardware or firmware filter. The program may then add a timer and edge detector. Combined delays can make a command feel slow or reject a legitimate short press. Document the complete path from contact change through input acceptance to program execution and output action.<\/p>\n<p>Check whether the program reads the accepted state in the intended task and whether an edge is generated once. Repeated execution of a level-based command is not necessarily contact bounce. A held input can trigger the same code repeatedly if the logic has no event rule. Use the controller maker&#8217;s documentation for its actual instructions, scheduling and input behavior.<\/p>\n<h2>Select press and release timing deliberately<\/h2>\n<p>Press and release can have different requirements. A value-entry button may tolerate a short qualification delay, while releasing a hold-to-run command may need a different validated response. Specify both directions and verify that the chosen filter does not create an unacceptable delay or retain a command after release.<\/p>\n<p>Do not treat a normal input filter as a solution for a safety circuit. Emergency stops and protective functions require the applicable designed and validated architecture. For ordinary commands, define the maximum acceptable response, shortest valid press and minimum separation between distinct actions. Use measurements and the command requirement to select the settings, then record why the chosen values were accepted.<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/lemaele.com\/wp-content\/uploads\/2026\/10\/lema-backfill-push-button-debounce-guide-body2-20261006.webp\" alt=\"PBS buttons and isolated contact forms beside a generic settling trace\" title=\"PBS buttons and isolated contact forms beside a generic settling trace\" loading=\"lazy\"><figcaption>PBS buttons and isolated contact forms beside a generic settling trace. Product-reference illustration; not a dimensioned drawing, installation instruction or test result.<\/figcaption><\/figure>\n<h2>Use hardware filtering only with input specifications<\/h2>\n<p>An RC network, Schmitt-trigger input or dedicated debounce circuit can condition a signal, but its design must match the input voltage thresholds, contact arrangement, supply and required response. Component tolerances and both transition directions affect behavior. Do not add a capacitor across unknown equipment terminals based on a hobby circuit diagram.<\/p>\n<p>Keep contact load and minimum-load information in the review. Hardware changes can affect the current through the button and the electrical stress during switching. Where an input module already provides a supported filtering option, evaluate that documented capability before adding an external circuit. The complete interface, rather than a single component value, must be validated.<\/p>\n<h2>Avoid lockout rules that lose valid operator actions<\/h2>\n<p>An alternative pattern accepts an initial edge and ignores changes for a fixed interval. That can suit some interfaces, but it differs from waiting for a stable state. It may reject a valid second press or accept a noise spike as the first event. Choose the pattern based on the command semantics and known signal conditions.<\/p>\n<p>For repeated actions, define whether a long hold repeats after a separate delay and at what controlled rate. Keep repeat logic distinct from contact qualification. Likewise, double-click recognition needs an explicit interaction requirement; it should not emerge accidentally from bounce timing. Test ordinary human behavior, including slow presses, partial releases and fast consecutive actions within the intended operating range.<\/p>\n<h2>Validate one complete button channel at a time<\/h2>\n<p>Build a test record containing raw state, accepted state, press event, release event and resulting command. Check isolated single presses, long holds, rapid repeated presses, startup while held and any supported illumination behavior. Add the relevant input disconnection or abnormal-state checks defined by the design authority.<\/p>\n<p>Record counts rather than relying on a statement that the button feels better. If one deliberate press gives two events, identify whether the duplicate came before qualification, in edge detection or in command handling. If a valid press is lost, compare its duration with the filter and task timing. Correct the responsible layer instead of increasing every delay until the symptom disappears.<\/p>\n<h2>Specify and document the button interface for production<\/h2>\n<p>For a LEMA inquiry, provide the intended action, contact arrangement, controller input duty, illumination requirements, panel mounting and environment. Ask for relevant model data without requesting an unsupported universal debounce number. The button supplier and controller documentation contribute different pieces of the interface design.<\/p>\n<p>At design release, retain the switch order code, wiring diagram, controller configuration, qualification logic and acceptance record. If the button model, input module, software task or wiring changes, reassess the timing and electrical assumptions affected. The objective is a predictable operator command that matches its defined behavior, not merely a smoother oscilloscope trace.<\/p>\n<h2>Further learning<\/h2>\n<p>This neutral electronics lesson illustrates contact bounce and its treatment. It supports ordinary input conditioning, not the design or certification of a safety function.<\/p>\n<div class=\"lema-video\"><iframe src=\"https:\/\/www.youtube-nocookie.com\/embed\/jOcqeQiCDCg\" title=\"Switch Bounce and How to Deal with It | All About Circuits\" loading=\"lazy\" allow=\"encrypted-media; picture-in-picture\" allowfullscreen><\/iframe><\/div>\n<h2>Related LEMA resources<\/h2>\n<ul>\n<li><a href=\"https:\/\/lemaele.com\/product\/pbs-series-push-button-switch\/\">Push Button Switch Debouncing for PLC and Microcontroller Inputs product reference<\/a><\/li>\n<li><a href=\"https:\/\/lemaele.com\/blog\/industrial-push-button-switch-selection-guide\/\">Industrial push button selection<\/a><\/li>\n<li><a href=\"https:\/\/lemaele.com\/blog\/no-vs-nc-push-button-switch\/\">Normally open and normally closed contacts<\/a><\/li>\n<li><a href=\"https:\/\/lemaele.com\/blog\/push-button-switch-troubleshooting\/\">Button fault diagnosis<\/a><\/li>\n<\/ul>\n<h2>Technical references<\/h2>\n<ul>\n<li><a href=\"https:\/\/makeabilitylab.github.io\/physcomp\/arduino\/debouncing.html\" rel=\"noopener\" target=\"_blank\">University of Washington Makeability Lab debouncing lesson<\/a>: Explains contact settling and hardware\/software approaches; application timing must be chosen from measured behavior and command requirements.<\/li>\n<li><a href=\"https:\/\/docs.arduino.cc\/built-in-examples\/digital\/Debounce\/\" rel=\"noopener\" target=\"_blank\">Arduino official debounce example<\/a>: Demonstrates timed state acceptance for a push button. Its example delay is not a universal equipment setting.<\/li>\n<\/ul>\n<h2>Frequently asked questions<\/h2>\n<h3>Is a fixed fifty-millisecond delay correct for every button?<\/h3>\n<p>No. Example code uses example values. Choose the interval from measured behavior, controller input filtering and the shortest valid operator action, then validate the complete response.<\/p>\n<h3>Should debounce happen before or after edge detection?<\/h3>\n<p>For a stable-state acceptance pattern, qualify the raw state first and create the intended event from the accepted transition. Otherwise multiple raw transitions may create multiple events before filtering can help.<\/p>\n<h3>Can filtering repair a loose terminal?<\/h3>\n<p>No. Repair and validate the connection using the approved procedure. A filter can hide symptoms while the physical defect remains. Investigate changes during a held state separately from normal contact settling.<\/p>\n<h3>Can this method be used for an emergency-stop input?<\/h3>\n<p>This guide does not specify a safety function. Use the appropriate designed and validated safety architecture and applicable instructions. Normal operator-input debounce must not be treated as a substitute for that work.<\/p>\n<\/div>\n<p><script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"Is a fixed fifty-millisecond delay correct for every button?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. Example code uses example values. Choose the interval from measured behavior, controller input filtering and the shortest valid operator action, then validate the complete response.\"}}, {\"@type\": \"Question\", \"name\": \"Should debounce happen before or after edge detection?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"For a stable-state acceptance pattern, qualify the raw state first and create the intended event from the accepted transition. Otherwise multiple raw transitions may create multiple events before filtering can help.\"}}, {\"@type\": \"Question\", \"name\": \"Can filtering repair a loose terminal?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. Repair and validate the connection using the approved procedure. A filter can hide symptoms while the physical defect remains. Investigate changes during a held state separately from normal contact settling.\"}}, {\"@type\": \"Question\", \"name\": \"Can this method be used for an emergency-stop input?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"This guide does not specify a safety function. Use the appropriate designed and validated safety architecture and applicable instructions. Normal operator-input debounce must not be treated as a substitute for that work.\"}}]}<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Debounce normal push button commands by separating raw input, stable state and events. Covers PLC timing, hardware limits and practical operator-input validation.<\/p>","protected":false},"author":9,"featured_media":1810,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[54],"class_list":["post-1813","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-push-button-switch"],"_links":{"self":[{"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/posts\/1813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/comments?post=1813"}],"version-history":[{"count":1,"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/posts\/1813\/revisions"}],"predecessor-version":[{"id":1814,"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/posts\/1813\/revisions\/1814"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/media\/1810"}],"wp:attachment":[{"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/media?parent=1813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/categories?post=1813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lemaele.com\/de\/wp-json\/wp\/v2\/tags?post=1813"}],"curies":[{"name":"WP","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}