ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING Electronic lock with iButton keys. Encyclopedia of radio electronics and electrical engineering Encyclopedia of radio electronics and electrical engineering / Microcontrollers Some time ago, the project "TOUCH-MEMORY DS1990A SIMULATOR" appeared, i.e. master key. Now your attention is invited to the lock to this master key :-). The lock has a simple design and is intended mainly for individual use. The lock works with any type of iButton keys, so you can use existing keys for other purposes. In total, up to 9 keys can be stored in memory, although this number can be easily increased. To authorize the programming process, a master key is used, the code of which is stored in the ROM and cannot be erased or changed by the normal lock programming procedure. Recently, locks have become widespread, the key to which is an iButton (or touch memory) electronic tablet from Dallas Semiconductor. Such locks are often used on the doors of entrances, as well as inside many institutions. In addition, iButton keys are often used for payments at gas stations and other places. So many people already have iButton keys for something. Therefore, when designing a homemade lock, it is rational to use the keys that the user already has in it. This is exactly what is done in the proposed lock: any type of keys can work with it, since only the serial number stored in the iButton ROM is used, which is in any of their types. In addition, the command to read this number is the same for all types of keys (33H). The family code, which differs for different types, can be anything. It is perceived as another digit of the serial number. It should be noted that the cheapest type of keys is DS1990A. The castle was designed for individual use and has an extremely simple design. On the front door from the outside there is only a socket for iButton and a door opening LED. Opening the doors from the inside is carried out using a button. As an actuator, a standard latch with an electromagnet is used, which is designed for a voltage of 12V. Key codes are stored in non-volatile memory and can be deleted and added by the user. A master key is used to protect against unauthorized reprogramming of the lock. In total, 9 keys can be stored in memory. This number is dictated by the capabilities of the 1-digit indicator of the number of the programmable key. If you also use letters, you can increase the total number of keys to 15. This is done by changing the value of the MAXK constant in the program. In the same way, you can reduce the maximum number of keys.
Schematic diagram of the lock is shown in Figure 1. The design is based on the U1 microcontroller type AT89C2051 from Atmel. A 1-segment indicator is connected to port P7, which is used when programming keys. The SB1 button connected to the P3.7 port is also intended for the same purposes. Key serial numbers are stored in EEPROM U3 type 24C02, connected to ports P3.4 (SDA) and P3.5 (SCL). The external iButton socket is connected to the P3.3 port via the XP2 connector and VD4, R3, VD5 and VD6 protection elements. The pull-up resistor R4 is selected according to the single-wire bus specification. Parallel to the external socket, an internal XS1 socket is also connected, which is used for key programming. The door open button is connected to the P3.2 port via the XP1 connector and the same protection elements as for the iButton. The actuator of the lock is an electromagnet connected via terminal XT1. The electromagnet is controlled by the VT3 key, which is a powerful MOS transistor of the IRF540 type. Diode VD7 protects against self-induction emissions. The VT3 key is controlled by the VT2 transistor, which inverts the signal coming from the P3.0 port and provides 0/12V control levels at the VT3 gate. The inversion is needed so that the actuator does not work during the reset of the microcontroller, when there is a logical one level on the port. The 12-volt control levels made it possible to use a conventional MOSFET instead of the more scarce low-threshold (logick level) one. To indicate the opening of the lock, an LED is used, which is controlled by the same port as the electromagnet, but through a transistor key VT1. The LED is connected through the same connector as the iButton. Since the device must operate around the clock without maintenance, a U2 type ADM1232 supervisor is installed to improve reliability. It has a built-in watchdog and power monitor. On port P3.1, the microcontroller generates periodic pulses to reset the watchdog timer. The device is powered by a built-in power supply unit containing a transformer T1, a rectifier bridge VD9-VD12 and an integral stabilizer U4. As a backup power source, a BT1-BT10 battery of 10 AA size NiMH batteries with a capacity of 800mAh is used. When the device is powered from the mains, the battery is charged through the resistor R10 with a current of approximately 20mA, which is 0.025C. The mode of charging with a small current is called drip (trickle charge). In this mode, the batteries can be indefinitely long, control of the end of the charging process is not required. When the batteries are fully charged, the energy they take from the power source is converted into heat. But since the charging current is very small, the generated heat is dissipated into the surrounding space without any noticeable increase in the temperature of the batteries. Structurally, the device is made in a housing measuring 150x100x60mm. Most of the elements, including the power transformer, are mounted on a printed circuit board. Batteries are placed in standard plastic holders, which are fixed inside the case next to the board. In principle, other types of batteries can also be used, such as the 12-volt maintenance-free acid battery used in security systems. The board has TB-2 type terminals for connecting an actuating device, all other external circuits are connected via small-sized connectors with a pin pitch of 2.54 mm. The connectors are located on the printed circuit board and are not accessible from the outside of the housing. The wires exit the housing through rubber seals. Since the HG1 indicator, the SB1 button and the iButton XS1 socket are used only during programming, they are placed on the board inside the device. This simplifies the design of the housing and makes it more protected from external influences. On the side panel of the housing there is only a VD13 power-on indication LED. The scheme of external connections is shown in fig. 2.
When the door is opened, a pulse lasting 3 seconds is applied to the electromagnet. The logic of the device is such that if the door opening button is held down, then the electromagnet will be energized all this time and, accordingly, the door will be open. The lock can have a maximum of 9 keys, plus one master key. The key codes are stored in non-volatile memory under numbers from 1 to 9. The master key code is stored in the ROM of the microcontroller and cannot be changed. Programming new keys or erasing old ones can only be done with a master key. Like other keys, the master key can be used to open the lock. To program a new key, do the following: 1. Press the programming button.
Schematically, the process of programming a new key is shown in fig. 3.
If you need to program several keys, then you can immediately go from step 9 to step 5 and repeat steps 5 - 9 as many times as necessary. If, after step 7, it turns out that the wrong number has been selected, then to avoid losing the key code under this number, you can press the button or simply wait 5 seconds. In the first case, the current number will increase by one, and the contents of the memory will remain unchanged. In the second case, a complete exit from the programming mode will occur without changing the codes. In general, you can exit programming at any time if you pause for more than 5 seconds. To erase an extra key from the memory, the sequence of actions remains the same as during programming, only all actions are performed by the master key. Those. the erasing process is actually writing the master key code to unused numbers. Schematically, the process of erasing an extra key is shown in Fig. four.
During programming, you can open the door with the button, but opening with iButton is blocked. Since the inner and outer sockets are connected in parallel, care must be taken that during programming no one touches the outer socket with any keys. The master key code is written to the ROM of the microcontroller programs, starting from the address 2FDH. The code length is 8 bytes. The sequence of numbers should be the same as on the touch-memory case, you need to read from left to right. Those. at address 2FDH, the checksum value is entered, then at addresses 2FEH - 303H, six bytes of the serial number, starting from the high byte, and, finally, at address 304H, the family code. For example, the code as a whole might look like this: 67 00 00 02 D6 85 26 01. The electronic lock program has a main loop, the block diagram of which is shown in fig. 5. In the main loop, the socket is polled, and if a key is found there, then its code is read. Then this code is checked, and if it matches the code of the master key or any other key (user key) stored in memory, the lock opens. The state of the door opening button is also checked, and if a press is detected, the lock also opens.
There are two subroutines for handling events related to programming: PROGT and PROGS, the block diagrams of which are shown in fig. 6. The first one is called when the key code is read in the programming mode, the second - when the programming button (NUMBER) is pressed. The programming process is divided into 3 phases. When the NUMBER button is pressed, programming is entered, i.e. transition to phase 1. In this case, the letter "P" is displayed on the indicator. The key codes that are read after that are checked for a match with the master key code, since only it can allow programming to continue. If such a match occurs, then the transition to phase 2 is carried out. The indicator displays the number of the current key, which the NUMBER button can change. If a key touch is registered again, then a transition to phase 3 will occur. Another key touch will lead to storing its code and returning to phase 2. By pressing the NUMBER button, you can also return to phase 2, but without changing the contents of the memory. Any action in the programming mode causes the reset of the return timer, which has an interval of 5 seconds and is checked in the main loop. If a reset of this timer is detected, the programming mode is exited.
Shown in fig. Flowcharts 5 and 6 are greatly simplified, but they allow you to understand the general logic of building a program. The described castle, of course, does not have a wide range of possibilities. However, it is very simple, which makes it easy to repeat. The open source code of the program allows you to independently improve the design or adapt it to specific requirements. Download:
Authors: Ridiko Leonid Ivanovich, wubblick@yahoo.com, Lapitsky Viktor Petrovich, victor_lap@yahoo.com; Publication: cxem.net See other articles Section Microcontrollers. Read and write useful comments on this article. Latest news of science and technology, new electronics: Artificial leather for touch emulation
15.04.2024 Petgugu Global cat litter
15.04.2024 The attractiveness of caring men
14.04.2024
Other interesting news: ▪ France to get rid of coal-fired power plants ▪ Freeform displays from Sharp ▪ Key Optical Transistor Technology ▪ Navigation on atomic clocks will replace GPS News feed of science and technology, new electronics
Interesting materials of the Free Technical Library: ▪ section of the site Note to the student. Article selection ▪ article Fundamentals of sociology and political science. Crib ▪ article What is the oldest song in the world? Detailed answer ▪ Marant's article. Legends, cultivation, methods of application
Leave your comment on this article: All languages of this page Home page | Library | Articles | Website map | Site Reviews www.diagram.com.ua |