ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING Code lock control module. Encyclopedia of radio electronics and electrical engineering Encyclopedia of radio electronics and electrical engineering / Home, household, hobby The use of modern components, in particular microcontrollers, makes it possible to reduce the weight and dimensions of electronic devices and increase the number of functions they perform. This article describes a combination lock module made using a PIC controller. The device is intended for use as a security unit (electronic lock cylinder) in combination locks, alarm control systems or other devices, access to which must be restricted completely or in certain modes. The module provides the appearance of a high logical level at its output when typing a seven-digit decimal number - a code - from the keyboard. When it is dialed again, a low level appears at the output. The module contains two channels independent from each other, each of them controls one output. Channel access codes can be specified (modified) by the user in a special preset mode. The channel goes into it when you type the seven-digit preset code from the keyboard (each channel has its own code). From this mode you can modify both the access code and the preset code itself. All codes for both channels are stored in the module's electrically programmable data memory (EEPROM), which is writable by software. The module diagram is shown in Fig. 1. Its basis is the PIC16F84 microcontroller from MICROCHIP, which ensures low power consumption and minimal costs [1]. All functions are implemented in software. The pins of port B of the microcontroller DD1 (RBO-RB6) are used to connect a standard 12-key keyboard. RB0-RB3 are programmed for data input, and RB4-RB6 are programmed for output. Pin RB7, programmed as an output, is used to supply audio signals. Each time you press any key, which is detected and evaluated by the program as “true,” a burst of 13 pulses appears at pin 1 of DD124 with a period between them of about 4 ms. A short beep sounds. When you hold down the key, the bursts follow each other without pauses (constant signal). When the correct code (access or preset) is dialed, 1240 such pulses appear on this pin (a sound signal lasting about 5 s). On elements R5, R6, C4, VD1 there is an external reset unit for the microcontroller when the power is turned on. The pins of port A of the RAO-RA4 microcontroller are programmed as outputs. RAO is the preset mode enable flag for both channels. The setting of this flag (enabling the preset mode) is indicated by the lighting of the HL1 LED. The flag is set by pressing the “*” button on the keyboard, and is reset by pressing the “#” button or upon completion of code modification in the preset mode in any channel or at the time of a system reset (when turning off the power). RA1 and RA2 are flags of the preset modes of channels 1 and 2. Each of them is set when the corresponding preset code is dialed, and is reset when the “#” button is pressed or after modification of the codes in the preset mode in the corresponding channel is completed or upon a system reset. The setting of each of these flags is indicated by the lighting of the corresponding LED HL2, HL3. Modification of codes in the selected channel is possible only if the preset mode flag of this channel and the preset mode enable flag are set. RA3 and RA4 are outputs of channels 1 and 2, respectively. Each of them goes high when the corresponding access code is dialed, and clears when the code is dialed again or the system is reset. RA3 has TTL levels, and RA4 is an open drain output. Actuators are connected to the channel outputs. From the above it follows that the module is actually four-channel: in addition to two “full” channels, which are set and reset only by a set of access codes, there are two more “incomplete” channels (RA1 and RA2). They are set by a set of preset codes, and reset by pressing the “#” button, i.e. they limit access only to turning on actuators, but not to turning them off. To avoid erroneous modification of codes in EEPROM. When using "incomplete" channels, make sure that the preset mode enable flag is reset. A simplified block diagram of the program's operation algorithm is shown in Fig. 2. After turning on the power, a system reset occurs, resetting all flags and outputs of port A. Next, the program begins to poll the keyboard. When a pressed key is detected, polling pauses until the key is released. Anti-bounce protection for key contacts is implemented in software. The typed code is accumulated in the register RAM of the microcontroller. After entering the seventh digit, the dialed code is compared with the preset code of channel 1. In case of a mismatch, it is compared with the preset code of channel 2. When the dialed code matches one of these codes, the program sets the corresponding preset mode flag and resets the dialed code. If it does not match, it is compared sequentially with the access codes of channels 1 and 2. If the dialed code does not match with them, it is reset. Following each digit entered from the keyboard, the program checks whether the preset mode enable flag is set. Having made sure that this has happened, the program sequentially checks whether the preset mode flags for channels 1 and 2 are set. If at least one of them is set, the transition to preset mode will occur. As a result of each press of the “0”-“9” keys in this mode, the code of the corresponding digit is written to the EEPROM cell, “erasing” the code that was previously there. After entering fourteen digits (seven digits of the access code and seven digits of the preset code), the preset mode is automatically exited (all flags are reset). You can also exit the preset mode by dialing any number of digits (less than fourteen), for example, when you only need to modify the access code. To do this, press the "'#" button after dialing seven digits. The program was prepared in the MPLAB environment [2]. When programming the crystal, you should set OSC=XT, WDT=Off, PWRTE=On, CP=Off, and write code 00h to all addresses in the EEPROM data. To power the module, you can use a DC voltage source of +7,5...+15 V. The current consumption of the microcontroller DD1 from the integrated stabilizer DA1 with the LEDs HL1-HL3 off is about 1 mA. Any quartz resonator ZQ1 can be used at a frequency of 2...4 MHz (can be replaced with an RC circuit), however, it should be taken into account that the tone of the audio signals at pin 13 of DD1 depends on the frequency of the clock generator. Piezo emitter NA1 - ZP-3. To match the logical levels at the output of channel 2 (pin 3 of DD1) with the actuator, the lower output of resistor R12 in the circuit is disconnected from the stabilizer and connected to the positive terminal of the actuator's power supply. The design of the module must be such as to exclude outside access to its output circuits. The device does not require setup, however, before starting operation, the user must enter his own codes into the memory of both channels. This is done as follows. After turning on the power for the first time, you need to press the “0” button seven times. The HL2 LED should light up and a long beep should sound. Then click on the “*” button. The HL1 LED should now light up. The next operation is for the user to enter fourteen digits from the keyboard, the first seven of which will be the access code for channel 1, and the rest will be the preset code for this channel. When fourteen digits are dialed, the HL1, HL2 LEDs will go out. By repeatedly pressing the “0” button seven times (the HL3 LED should light up and a long beep should sound), and then the “*” button (the HL1 LED should light up), the user enters another fourteen digits - the access code and the channel 2 preset code. LEDs HL1 and HL3 go out. The module's EEPROM now contains the user's own codes. If the user has forgotten his access code, it is simply replaced with a new one from the preset mode. If you forget the preset code, you can only see it using the programmer by reading the EEPROM of the PIC controller data. The preset code for channel 1 is located there at addresses 19h-1Fh, and for channel 2 at addresses 27h-2Dh. It should be noted that EEPROM has a limited number of controller data write cycles, so it is not recommended to modify the codes very often. With the "#" button, you can forcefully reset the dialed code in case of an error in typing. Literature
Author: P.Redkin, Ulyanovsk See other articles Section Home, household, hobby. Read and write useful comments on this article. Latest news of science and technology, new electronics: Machine for thinning flowers in gardens
02.05.2024 Advanced Infrared Microscope
02.05.2024 Air trap for insects
01.05.2024
Other interesting news: ▪ Muscle tone without physical activity ▪ Intel Tunnel Falls silicon qubit processor ▪ Artificial intelligence will predict magnetic storms ▪ Updated Efinix Titanium FPGA line News feed of science and technology, new electronics
Interesting materials of the Free Technical Library: ▪ section of the site RF power amplifiers. Article selection ▪ article Hut on chicken legs. Popular expression ▪ article Which animals have a funeral ritual? Detailed answer ▪ article Head of the railway station. Job description ▪ article Radio communication on VHF. Encyclopedia of radio electronics and electrical engineering
Leave your comment on this article: All languages of this page Home page | Library | Articles | Website map | Site Reviews www.diagram.com.ua |