Efficient 2-Wire Interface Design: Simplifying LED and Pushbutton Connectivity
The concept of the ‘2-Wire Interface’ was introduced in Elektor magazine through basic and low-current versions, utilizing two transistors and several components to connect an LED and a pushbutton to a microcontroller. However, the author was driven to streamline this setup further. The result is an exceptionally minimal solution, achieved with only two resistors and a single I/O pin. It is difficult to imagine further simplification, unless, of course. You have a better approach! While reducing components places a slightly heavier workload on the microcontroller, this design assumes that an I/O pin can toggle between input and output modes, a situation commonly encountered.
In this configuration, the circuit can illuminate the LED in the ‘High’ state and assess the switch’s status when the LED is off. Examining the state table, specifically lines 1 and 2, provides clarity. By configuring the I/O pin as an input and applying voltage Uin based on the switch’s status, interpreted as ‘low’ or ‘high,’ provided resistors R1 and R2 are chosen correctly to match the supply voltage UB. The setup is optimized for efficient functionality.
Polling the Switch: Managing States 3 and 4
In states 3 and 4, where the I/O pin acts as an output, polling the switch might seem complex. However, the solution is surprisingly simple. The pin is momentarily switched to an input mode several times per second. This brief transition creates states 1 or 2 for a fraction of a second, which, due to the persistence of vision (a phenomenon where the human eye perceives a visual stimulus for a brief duration even after the stimulus is removed), goes unnoticed. If the pushbutton is depressed during this period, the pin stays in state 2 until it’s released, as state 4 (where the LED remains unlit) doesn’t affect the outcome and only leads to unnecessary current consumption. Following this, the controller promptly reverts to state 3, re-illuminating the LED.
In the microcontroller’s firmware, advanced debouncing and additional functions like variable LED brightness can be implemented effortlessly. The LED’s brightness can be modulated by toggling rapidly between states 1 and 3, allowing for creative possibilities. The author’s solution was based on the PIC16F883, which utilizes internal pull-up resistors similar to those in well-known AVR controllers. While these internal pull-ups could replace R2, their values range from 10 to 50 kΩ, potentially causing the LED to emit a faint glow in state 1. To counter this, the firmware activates the pull-up only during pushbutton polling to avoid this issue.
Diode Considerations and Resistor Dimensioning
Careful selection of R2 is essential to ensure the input’s switching threshold is surpassed, especially since the forward voltage (Uf) drops with small currents. This effect can be problematic, particularly with a red LED and a 5 V operating voltage. In such cases, an ordinary silicon diode placed in series with the LED resolves the issue. To determine resistor values relative to the supply voltage and LED color, reference a provided table. For various currents, additional calculations may be necessary for precise dimensioning. 2-Wire Interface for Illuminated Pushbuttons, Elektor April 2012, www.elektor.com/110572  2-Wire Interface version 2.0, Elektor January & February 2013, www.elektor.com/120071  Firmware: www.elektor.com/130115