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

Electronic lock with iButton keys. Encyclopedia of radio electronics and electrical engineering

Free technical library

Encyclopedia of radio electronics and electrical engineering / Microcontrollers

Comments on the article Comments on the article

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.

Electronic lock with iButton keys

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.

Electronic lock with iButton keys. Schematic diagram of the lock
Rice. 1. Schematic diagram of the lock

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.

Electronic lock with iButton keys. Diagram of external connections
Rice. 2. Diagram of external connections

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.
2. The display will show the letter "P", which means entering the programming mode.
3. Touch the panel with the master key.
4. The indicator will show the number "1", which indicates the number of the key to be programmed.
5. Use the button to select the desired number.
6. Touch the socket with any key.
7. The number on the indicator will start flashing, indicating that it is ready for programming.
8. Touch the panel with the key whose code you want to memorize.
9. In case of successful programming, the figure on the indicator will stop blinking and will start to burn constantly.
10. To exit the programming mode, just wait 5 seconds, after which the indicator will turn off.

Schematically, the process of programming a new key is shown in fig. 3.

Electronic lock with iButton keys. Programming a new key
Rice. 3. Programming a new key

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.

Electronic lock with iButton keys. Erasing an extra key
Rice. 4. Erase extra key (click to enlarge)

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.

Electronic lock with iButton keys. Block diagram of the main program loop
Rice. 5. Block diagram of the main cycle of the program (click to enlarge)

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.

Electronic lock with iButton keys. Flowcharts of subroutines used in key code programming
Rice. 6. Block diagrams of subroutines used when programming the key code

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:

  • lock.asm - source code for the lock program.
  • lock.bin - compiled program 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.

<< Back

Latest news of science and technology, new electronics:

Artificial leather for touch emulation 15.04.2024

In a modern technology world where distance is becoming increasingly commonplace, maintaining connection and a sense of closeness is important. Recent developments in artificial skin by German scientists from Saarland University represent a new era in virtual interactions. German researchers from Saarland University have developed ultra-thin films that can transmit the sensation of touch over a distance. This cutting-edge technology provides new opportunities for virtual communication, especially for those who find themselves far from their loved ones. The ultra-thin films developed by the researchers, just 50 micrometers thick, can be integrated into textiles and worn like a second skin. These films act as sensors that recognize tactile signals from mom or dad, and as actuators that transmit these movements to the baby. Parents' touch to the fabric activates sensors that react to pressure and deform the ultra-thin film. This ... >>

Petgugu Global cat litter 15.04.2024

Taking care of pets can often be a challenge, especially when it comes to keeping your home clean. A new interesting solution from the Petgugu Global startup has been presented, which will make life easier for cat owners and help them keep their home perfectly clean and tidy. Startup Petgugu Global has unveiled a unique cat toilet that can automatically flush feces, keeping your home clean and fresh. This innovative device is equipped with various smart sensors that monitor your pet's toilet activity and activate to automatically clean after use. The device connects to the sewer system and ensures efficient waste removal without the need for intervention from the owner. Additionally, the toilet has a large flushable storage capacity, making it ideal for multi-cat households. The Petgugu cat litter bowl is designed for use with water-soluble litters and offers a range of additional ... >>

The attractiveness of caring men 14.04.2024

The stereotype that women prefer "bad boys" has long been widespread. However, recent research conducted by British scientists from Monash University offers a new perspective on this issue. They looked at how women responded to men's emotional responsibility and willingness to help others. The study's findings could change our understanding of what makes men attractive to women. A study conducted by scientists from Monash University leads to new findings about men's attractiveness to women. In the experiment, women were shown photographs of men with brief stories about their behavior in various situations, including their reaction to an encounter with a homeless person. Some of the men ignored the homeless man, while others helped him, such as buying him food. A study found that men who showed empathy and kindness were more attractive to women compared to men who showed empathy and kindness. ... >>

Random news from the Archive

Smart chair Sharp 11.12.2014

If you are not a doctor, you are unlikely to feel love for going to the clinic. However, many doctors go there not at all out of love for their chosen profession and it is not for us to tell about it. It is possible to reduce visits by searching for answers on the Internet. Previously, for this they read the magazine "Health" or used the advice of grandmothers. But progress doesn't stand still, does it? New trends are sensors in smartphones and wearable electronics. Pulse, pressure, sweating intensity, primitive ECG - all this and much more, not yet implemented, will help to more accurately determine how you feel before visiting the doctor and, perhaps, completely postpone the visit.

The next level is more advanced systems for determining the physical and mental state of a person. To clarify, we are still talking about fairly inexpensive complexes, which in the future may be at home for everyone. A similar system was shown by Sharp at Semicon Japan 2014. This is a premium aircraft seat. The chair has a built-in set of sensors and a specialized computer system with a display. The data is taken and immediately analyzed with the output of the result in the form of understandable graphs or icons.

The armchair allows you to measure the mass, blood pressure, pulse rate, the state of the blood vessels (the pulse wave is being studied), as well as receive data on the state of the autonomic nervous system (about the sympathetic and parasympathetic divisions). Cross-analysis and special processing of data for each parameter gives an approximate picture of the current state of health. The data can be sent to the Sharp cloud, where it can be compiled into a database for each person and analyzed by a medical specialist, sending the processed information back to the patient.

Sharp notes that the request for such a chair came from companies involved in servicing the elderly. But the scope of such complexes is much wider. They can be installed in gyms, fitness centers, in companies that care about the health of employees, in private hospitals and in public medical institutions. Preliminary demand for the development was so strong that the company will start selling the "health chair" in the first half of fiscal year 2015 (April to September 2015).

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

▪ Smart T-shirt YouCare 5G

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

▪ article Autoguard with a small number of parts. Encyclopedia of radio electronics and electrical engineering

▪ article Dual-mode charger-discharge device. Encyclopedia of radio electronics and electrical engineering

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