Menu English Ukrainian russian Home

Free technical library for hobbyists and professionals Free technical library


ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING
Free library / Schemes of radio-electronic and electrical devices

Connecting a large number of buttons to one microcontroller input. Encyclopedia of radio electronics and electrical engineering

Free technical library

Encyclopedia of radio electronics and electrical engineering / Radio amateur designer

Comments on the article Comments on the article

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.

Connecting a large number of buttons to one microcontroller input
Rice. 1. Construction scheme

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.

Connecting a large number of buttons to one microcontroller input
Rice. 2. Checking the device and debugging the microcontroller program

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

  1. 2-Wire Keypad Interface Using a 555 Timer. - URL: radiolocman.com/shem/schematics.html?di=88598.
  2. Evstifeev A. V. AVR microcontrollers of the Tiny family - M .: "DODEKA-XXl", 2007.
  3. LMC555 CMOS Timer. - URL: pdf1.alldatasheet.com/datasheet-pdf/view/9100/NSC/LMC555CN.html.
  4. MT-16S2S. LCD alphanumeric indicator 2 lines of 16 characters. - URL: melt.com.ru/docs/MT-16S2S.pdf.

Author: S. Ivanov

See other articles Section Radio amateur designer.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

A New Way to Control and Manipulate Optical Signals 05.05.2024

The modern world of science and technology is developing rapidly, and every day new methods and technologies appear that open up new prospects for us in various fields. One such innovation is the development by German scientists of a new way to control optical signals, which could lead to significant progress in the field of photonics. Recent research has allowed German scientists to create a tunable waveplate inside a fused silica waveguide. This method, based on the use of a liquid crystal layer, allows one to effectively change the polarization of light passing through a waveguide. This technological breakthrough opens up new prospects for the development of compact and efficient photonic devices capable of processing large volumes of data. The electro-optical control of polarization provided by the new method could provide the basis for a new class of integrated photonic devices. This opens up great opportunities for ... >>

Primium Seneca keyboard 05.05.2024

Keyboards are an integral part of our daily computer work. However, one of the main problems that users face is noise, especially in the case of premium models. But with the new Seneca keyboard from Norbauer & Co, that may change. Seneca is not just a keyboard, it is the result of five years of development work to create the ideal device. Every aspect of this keyboard, from acoustic properties to mechanical characteristics, has been carefully considered and balanced. One of the key features of Seneca is its silent stabilizers, which solve the noise problem common to many keyboards. In addition, the keyboard supports various key widths, making it convenient for any user. Although Seneca is not yet available for purchase, it is scheduled for release in late summer. Norbauer & Co's Seneca represents new standards in keyboard design. Her ... >>

The world's tallest astronomical observatory opened 04.05.2024

Exploring space and its mysteries is a task that attracts the attention of astronomers from all over the world. In the fresh air of the high mountains, far from city light pollution, the stars and planets reveal their secrets with greater clarity. A new page is opening in the history of astronomy with the opening of the world's highest astronomical observatory - the Atacama Observatory of the University of Tokyo. The Atacama Observatory, located at an altitude of 5640 meters above sea level, opens up new opportunities for astronomers in the study of space. This site has become the highest location for a ground-based telescope, providing researchers with a unique tool for studying infrared waves in the Universe. Although the high altitude location provides clearer skies and less interference from the atmosphere, building an observatory on a high mountain poses enormous difficulties and challenges. However, despite the difficulties, the new observatory opens up broad research prospects for astronomers. ... >>

Random news from the Archive

fuel cell Mercedes 18.03.2014

Mercedes-Benz is developing "next generation environmentally friendly fuel cell vehicles".

Mercedes already has experience in this area. In particular, the company has developed the B-Class F-CELL model. In this car, hydrogen is stored in three tanks at a pressure of 700 bar. They are able to take together a little less than 4 kg of gaseous fuel. The tanks, according to the manufacturer, are absolutely hermetic and even when the machine is idle for a long time, they do not allow hydrogen to escape. Due to the high degree of gas compression, the B-Class F-CELL manages to cover distances of up to 400 km on a single filling.

The permanent magnet synchronous motor develops a peak power of 100 kW/136 hp. With. and a nominal torque of 290 Nm, characteristic of electric power plants, which is available to the driver from the first turn. A high-voltage lithium-ion battery is used as a source of stored energy.

For the B-Class F-CELL, Mercedes-Benz has further developed the fuel cell electric drive strategy. When starting a "cold" electric motor at low temperatures, it receives energy from both a lithium-ion battery and a "booting" fuel cell system. At higher temperatures, battery power is usually sufficient, while the fuel cells are connected later, depending on the load. While the vehicle is in motion, the energy management system keeps the F-CELL drive in the optimum operating range at all times. The lithium-ion battery dynamically compensates for power demand differences depending on the current driving situation.

With each braking and during periods without a foot on the gas pedal, the electric motor recovers the kinetic energy of the moving car, turning it into electrical energy, which is then stored in the battery.

It is reported that the next generation fuel cell car will use an advanced propulsion system. Market participants believe that it will be installed in a compact crossover. Apparently, the system is being developed jointly with Ford and Nissan in order to reduce the cost. An announcement is expected in 2017.

Other interesting news:

▪ Micro-bots inside the human eye

▪ Android Polaroid Mirrorless Digital Camera

▪ What can be infected by eating sushi

▪ Color vision of bats

▪ 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 The simplest signal generator on a single zener diode. Encyclopedia of radio electronics and electrical engineering

▪ article Map of colors. Focus Secret

Leave your comment on this article:

Name:


Email (optional):


A comment:





All languages ​​of this page

Home page | Library | Articles | Website map | Site Reviews

www.diagram.com.ua

www.diagram.com.ua
2000-2024