ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING Connecting a large number of buttons to one microcontroller input. Encyclopedia of radio electronics and electrical engineering Encyclopedia of radio electronics and electrical engineering / Radio amateur designer The idea of the proposed solution was presented in [1]. Its essence is to connect the maximum number of contact sensors (reed switches, buttons) to the microcontroller using the minimum number of its outputs. This idea was implemented using the universal timer KR1441VI1. The time-setting RC circuit of the timer is made up of a capacitor and a set of resistors connected in series with each button. A certain closed button corresponds to its own frequency of pulses generated by the timer, which is measured by the microcontroller [2]. The original version has two significant drawbacks. One of them is the use of two microcontroller inputs. Generated pulses are applied to one of them. The second serves to determine whether the button is closed, although this can easily be done in software, due to which this input of the microcontroller can be used for other purposes. Another disadvantage is the measurement of the frequency, and not the pulse repetition period. As a result, to obtain a linear dependence of the frequency on the button number, a large number of time-setting resistors of different ratings were used.
The proposed technical solution, the scheme of which is shown in Fig. 1 is free from these shortcomings. The timer KR1441VI1 of the CMOS structure (analogue of the LMC555) operates in a self-oscillating mode with a duty cycle of 2 [3]. In this mode, the pulse repetition period is equal to T = 2 ln2 C R, where C and R are, respectively, the capacitance and resistance of the elements of the timing circuit. With C = C1 and R = R1 N, consisting of N (according to the number of buttons) identical resistors with resistance R1 connected in series, the period T is equal to: T≈1,39 C1 R1 N It is obtained proportional to the number of resistors between the capacitor C1 and the first closed button SB1 - SB32 and can be easily measured by the microcontroller. As in the original source, when several buttons are closed at the same time, the one that has a lower number has priority. Resistor R38 is needed to maintain pulse generation when all buttons are open. The trimming resistor R35 sets the ratio of the timer oscillation period and the duration of the measuring interval formed by the microcontroller, necessary for correctly determining the number of the pressed button. The demo program of the microcontroller by interrupt IRQ0 measures the duration of the period T, translates it into a button number and displays it on the LCD MT-16S2S [4]. Communication between the microcontroller and the LCD is organized via a three-wire serial interface. Only four outputs of the microcontroller are occupied by the input and output of information, the rest can be used for other purposes. To measure the period, an eight-bit timer-counter 0 of the microcontroller was used. According to the rising level difference at the input of the interrupt request IRQ0, the program reads the duration of the measured period and resets the counting register. To improve the measurement accuracy, the counter prescaler is also reset. Since the prescaler of all timer/counters in the ATtiny microcontrollers is common, this can affect the duration of the time intervals generated by timer/counter 1 when used with a prescaler other than one. When the contacts of all buttons are open, the counter that measures the period overflows. According to the corresponding interruption, the open state is determined. The maximum number of recognized buttons depends on the instability of the time intervals formed by the timer and the microcontroller. When clocking the microcontroller from an internal RC generator and using a film capacitor with a small TKE, resistors with a small TCR and a deviation from the nominal value of no more than 1%, the number of buttons can reach 12-16 in the timing RC circuit. With a more accurate selection of resistors, 32 buttons were recognized. The stabilization of the frequency of the clock generator of the microcontroller by a quartz resonator can allow to increase their number even more. The layout of the device uses an imported film capacitor C1 (analogue K73-17) and resistors R1 - R32 for surface mounting CR1206-FX-5621ELF with a resistance of 5,62 kOhm ± 1%. Of the 50 resistors from one tape, 32 pieces were selected with a difference between the maximum and minimum resistance of no more than 20 ohms. To reduce the influence on the oscillation period of the dependence of the output voltage of the DA1 timer on the number of connected resistors R1-R32, resistors with lower resistance have lower position numbers, and timer outputs 3 and 7 are connected together. Trimmer resistor R35 must be multi-turn, for example, SP5-3 or similar. The adjustment is performed as follows. Close the button with a position number one less than the maximum (in this case, SB31) and find two positions of the R35 tuning resistor engine, corresponding to a change in the LCD readings from 31 to 32 and from 31 to 30. Set the engine to the middle between the positions found.
Checking the device and debugging the microcontroller program was performed on the layout shown in fig. 2. The microcontroller configuration bytes were programmed as follows: low - 0xBF, high - 0xD4, additional - 0xFF. Since the required number of buttons for the layout was not found, we had to use the PP7-4LV switch instead. The surface mount resistors are soldered directly onto the switch boards. With selected resistors in room conditions, the numbers of closed switch contacts were determined correctly, although the microcontroller worked from an internal RC generator. The microcontroller program can be downloaded from ftp://ftp.radio.ru/pub/2016/11/key-tx.zip. Literature
Author: S. Ivanov See other articles Section Radio amateur designer. Read and write useful comments on this article. Latest news of science and technology, new electronics: A New Way to Control and Manipulate Optical Signals
05.05.2024 Primium Seneca keyboard
05.05.2024 The world's tallest astronomical observatory opened
04.05.2024
Other interesting news: ▪ Micro-bots inside the human eye ▪ Android Polaroid Mirrorless Digital Camera ▪ What can be infected by eating sushi ▪ Toshiba launches new generation of 4K TVs News feed of science and technology, new electronics
Interesting materials of the Free Technical Library: ▪ section of the site Audio and video surveillance. Selection of articles ▪ article In childhood, my mother hurt. Popular expression ▪ article Why did Captain Cook fail to discover Antarctica? Detailed answer ▪ article Mortar pump operator. Standard instruction on labor protection ▪ article Map of colors. Focus Secret
Leave your comment on this article: All languages of this page Home page | Library | Articles | Website map | Site Reviews www.diagram.com.ua |