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

Designing an automated access control system. 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

Today, the electronic components market provides ample opportunities for creating systems for various purposes. However, the question arises: how to choose the right components for a particular system? The published article discusses the design of an automated access control system using widely available, inexpensive components.

So where to start? The development of any system begins with a list of requirements that it must meet. For the system described in the article, the list may look as follows. The system must:

  1. Control access to the room through one door.
  2. Provide unique identification for each user.
  3. Maintain a pass log with a record of pass time and user ID.
  4. Provide work with three categories of users.

Let's define what components the system should contain. To do this, consider the requirements listed above. From paragraph 1 it follows that one I / O line will be needed to control the door opening / closing mechanism and one device to enter an identifier.

The choice of user identification technology (clause 2) significantly affects such system characteristics as stability (prevent access to the object by third parties by selecting an electronic key/code), ease of use (the time that users will spend on the identification process), cost the system itself and its further operation. Examples of possible solutions here include entering a password through the keyboard, using magnetic stripe cards and iButton dongles from Dallas Semiconductor [1,2].

Entering a password through the keyboard is the simplest and cheapest to implement, although it is not very convenient and resistant, since users can forget the password or someone else can peep it. In addition, with frequent access to the premises, entering the code combination takes quite a lot of time.

Plastic cards are more convenient to use, and such a system is more difficult to "hack", however, its implementation requires additional devices for reading information from the card, as well as special equipment for writing information to it, which will be used when adding a new user. This greatly increases the cost of the final system.

Let's consider the last option. The iButton key is an integrated circuit placed in a metal MicroCan tablet case with a diameter of 18 and a height of 6 mm. The range of products manufactured in this design is quite extensive: real-time clocks, temperature sensors, non-volatile memory, and much more. The cost of an iButton is low (about $2), and the implementation of the reader is also quite simple - in fact, the data bus is connected directly to one I / O line of the microcontroller port. In this case, it is only necessary to implement the 1-Wire protocol in software. The convenience of using such a system is also obvious - in order for the code to be read, the user just needs to touch the "tablet" to the contact pad. For the described system, the DS1990 modification was chosen, which does not perform any other functions other than identification, i.e. the chip contains only a unique code that can be read by sending a special command to the device.

Let's return to the requirements for functionality. From paragraph 3 it follows that it will be necessary to keep track of time and record information about user access to the object of protection. Naturally, power outages must be anticipated, so the time and logging mechanism must be robust to these kinds of problems. Since DS1990 is chosen as a user identifier and in any case it is necessary to implement the 1-Wire protocol in software, it makes sense to use another iButton modification - DS1994 as a real-time clock. This chip contains a built-in lithium battery that guarantees a 10-year running time.

To store the log of passages, a series of Flash-memory from Atmel AT45 was chosen [3]. Reading/writing data to this type of memory is carried out via the serial SPI protocol, the total number of input/output lines involved is 7. AT45D041 with a memory capacity of 4 Mbit was selected from the available microcircuits of this series.

A keyboard is required to control system settings. In this case, a 3x4 button matrix with the numbers 0...9 and the symbols "*" and "#" is sufficient. Such a keyboard would require 3+4=7 more microcontroller I/O lines.

The last thing you need to have in the system is a small display for viewing the passage log and configuring the system. The range of currently available low-cost displays is quite extensive, but in our case, graphics output is not required, so an LCD is enough to display alphanumeric information. LCDs based on the HITACHI HD44780 controller are the most popular today [4]. They are distinguished by ease of connection and low cost. Data is transferred over an eight-bit or four-bit interface (depending on the mode used), plus three more I/O lines are needed to transmit control signals. In order to save I/O lines, a four-bit interface was chosen, therefore, the total number of I/O lines for controlling the LCD is also 7.

This completes the choice of peripherals. Now we have to choose a microcontroller that can effectively control all of the above devices. To begin with, let's calculate the number of required input / output lines that will be involved in the system (Table 1). The result obtained is not final, since in the future (during operation) additional I / O lines may be needed, for example, to connect LEDs, a dynamic speaker head, etc. Therefore, it is advisable to choose a microcontroller with a number of I / O lines greater than the specified in table. 1.

Design of an automated access control system

From the point of view of programming, microcontrollers are very attractive, in which the so-called ISP technology (Ip-System Programming - in-circuit programming) is implemented. In order to load a new program code into the microcontroller, it does not need to be removed from the board: programming is done in-circuit through special outputs. Moreover, for some modifications, even a programmer is not needed - "firmware" is carried out through the parallel port of the computer. Naturally, the most acceptable solution is to use just such a microcontroller in the system, which does not require additional funds for firmware.

To implement the task, the AT89S8252 microcontroller was selected, which is fully compatible in code and pinout with microcontrollers of the 8051 family. It has 8 KB of in-circuit programmable flash program memory with a resource of 1000 rewrite cycles, 2 KB of built-in EEPROM (electrically erasable programmable read-only memory), 256 bytes RAM, 32 I/O lines, three timers, watchdog timer, hardware supports SPI interface. Clock frequency - O...24 MHz (one machine cycle is performed in 12 cycles, therefore, the maximum performance is two million operations per second).

The choice of this particular microcontroller is justified by the following. Microcontrollers of the 8051 series have an extensive set of instructions, which facilitates their programming at a low level (for example, operations on individual bits are supported [5]). ISP technology speeds up debugging and facilitates development, hardware support for the SPI interface allows you to connect the selected AT45 series flash memory without additional programming of this protocol. The 2 KB of built-in EEPROM can be used to store information that must be preserved regardless of the presence of external power. 32 I/O lines are enough to implement the described system. The presence of timers allows flexible implementation of the 1-Wire protocol, since it requires accuracy in observing time delays.

The watchdog timer ensures that the system remains operational when exposed to strong electromagnetic interference, which can cause the controller to freeze. The watchdog timer is an independent subsystem in the microcontroller that every N cycles checks the state of one bit in the status register of the microprocessor. If this bit is set, the microcontroller is reset to its initial state, and if it is reset, it is set to 1 and the test stops. Accordingly, the program being executed must reset this bit at intervals of no more than N cycles. If this does not happen, it means that the operation of the microcontroller was disrupted by external interference and the next time the watchdog timer fires, the microcontroller will be reset to its initial state.

Before moving on to the software implementation, let's look at the architecture again from the point of view of its effectiveness in performing the direct functions of the system. The designed system will support two ways of entering information: using the keyboard (commands for setting up the system, viewing the pass log) and through the contact pad of the 1-Wire interface. Since the main purpose of the system is access control, the polling time of the 1-Wire pad must exceed the time allotted for polling the keyboard.

Considering the 1-Wire protocol specification, you can see that two fundamentally different situations are possible: the first, when there is only one device on the line, and the second, when there are more of them. In order to determine the number of devices on the line and their identifiers, there is a special search mechanism specified in the 1-Wire protocol specification. It consists in successive sifting of devices on the line and bit-by-bit scanning of the address space (the "Button" identifier space). Moreover, this procedure must be performed again after each cycle of communication with connected devices (since their composition may change).

As already mentioned, one 1-Wire line is planned in our system, which will be used both for connecting the real time clock and for identification keys, and the real time clock, which is part of the system, will be connected all the time. This means that we have a situation where there can be more than one device on the line. Taking into account the above and the presence of free lines of I / O ports, it is reasonable to allocate two lines in the system for the 1-Wire protocol: permanently connect a real-time clock to one of them, and use the second only for presenting user identifiers. This configuration ensures that there is only one device on each line at any time, which greatly simplifies system implementation, reduces response time, and saves program memory space.

The DS1994 real time clock has a five byte counter that increments 256 times per second. When it overflows, the count continues from zero. The capacity of 5 bytes is enough for 136 years of operation until the counter overflows. Due to the fact that the user needs to display the time in a format convenient for him, and it is also necessary to provide the ability to set the clock, the embedded system must support the conversion of date and time from the internal format to text and vice versa. The date 01.01.2000/00/00 00:2136:XNUMX was chosen as the reference point, which guarantees the operation of the clock and logging until approximately XNUMX.

And one more point to which you should pay attention. We have agreed that the pass log will be stored in external flash memory, but we still need to determine the place to store the list of access rights. When describing the microcontroller, there was mention of a built-in EEPROM with a capacity of 2 KB. It is ideal for this purpose, since the access list is more valuable than the pass log, and if, for example, the latter can be removed (physically) from the system by removing the corresponding chip from the board, then the list of access rights can be deleted only by removing the microcontroller, without which the system cannot work. In the described system, the specified amount of memory was enough to accommodate 168 accounts, i.e., the maximum number of users is 168.

The pass log is implemented as a circular list, and when it is full, the oldest entries are deleted. The size of one log entry is 12 bytes (4 bytes for the pass time and 8 bytes for the identifier). It follows that there is enough log memory to log approximately 45 passes before the first log overflow occurs.

During the development process, another component was added to the system - a reed switch on the door. It is necessary so that the system can determine whether the door is currently open or closed, as well as to timely turn off the power to the electromagnet. The following door opening algorithm is implemented: voltage is applied to the solenoid coil, and the system waits until the door is opened or until a time delay equal to 5 s expires, after which the voltage supply stops.

The schematic diagram of the developed device is shown in the figure.

Design of an automated access control system

As you can see, in addition to the DD1 microcontroller, it contains a DS1 Flash memory chip, a 12-button keyboard SB1 - SB12 and an LCD HG1. The clock frequency of the microcontroller sets the ZQ1 quartz resonator at 24 MHz. Port P0 is used to input information from the iButton clock (connected to socket X1) and identifier (connected to X2), control the relay (via a transistor key) that supplies power to the lock solenoid, the HL1 LED signaling the opening of the door, and register the state installed on her reed switch. The exchange of information with the DS1 Flash memory chip is carried out through port P1. The keyboard is served by port P2, the indicator HG1 is served by port РЗ. The device is powered by a stabilized voltage of 5 V. To power the relay that controls the operation of the electromagnet, a voltage source of 16 ... 20 V is required.

The device is assembled on a board of suitable dimensions. To connect the DD1 microcontroller and the DS1 memory chip, it is advisable to use the appropriate sockets. The mounted board is placed in a plastic or metal case, the keyboard and LCD display are displayed on the front panel. The device is installed inside the protected premises.

Microcontroller firmware codes and program source texts

After the device is turned on, the LCD displays a list of menu items shown in Table. 2. Since the indicator has only two lines, the "#" and "*" keys are used for horizontal "scrolling". To execute any of these commands, administrator privileges are required, and after selecting a menu item by pressing the corresponding key, you must present a key with administrator rights, otherwise the requested command is ignored.

Design of an automated access control system

In the process of working on the device, problems arose at various stages of development. I would like to note the following points.

Hardware part. Any microprocessor has the maximum allowable values ​​of the input and output current of the input / output ports. For example, if you need to use an LED in the system, then most microcontrollers will not be able to supply the required current to the I / O port if the active state is log. 1. In such a case, it is necessary to make the log state active. 0 by connecting the anode of the LED to the power rail. We should also not forget about the current limitation by turning on a resistor with a resistance of about 2 kOhm in series with the load. If you still need to use the log. 1 as an active state, and the load is too large, then a transistor switch should be used to turn on the load.

When implementing a 1-Wire bus, it is necessary to "pull up" the data bus through a resistor to the supply voltage. This is necessary so that during the transition from low to high, the line quickly reaches the switching threshold to the log. 1. The value of the resistor must be within 4,7 ... 5,1 kOhm. If the length of the wires is large enough (several meters), the resistance of the resistor can be reduced.

We should not forget about the maximum current that can be consumed by all devices connected to the ports of the microcontroller. It is necessary to consider the case when all of them are in an active state, and calculate whether the microcontroller can provide such an output power. If it exceeds the maximum allowable, the devices simply will not turn on at the right time.

Software part. Much in the development process depends on which compiler is used, how well it optimizes the code and allocates it in memory, whether it allows you to debug programs on your own emulator, as well as track the execution time of the program, etc.

If the program uses string constants, then due to the limited amount of RAM, special directives must be used to tell the compiler that they should be located in the program memory area. For example, for the Keil uVision compiler it looks like this: 'const char code sz[6] = "Hello"', where the "code" modifier tells the compiler that the string should be placed in program memory.

For time-critical operations, it is better to use a timer, since in this case the reference to the clock frequency occurs by introducing one constant, which can be easily corrected if the frequency changes.

You should not create functions with a large number of passed parameters, since when they are called, they are passed through registers (and when there are too many parameters, through fixed areas in memory). Each such call requires additional code to store the register values ​​before the function is called, and to retrieve those parameters within the function. The solution might be to use global variables, but you have to be very careful here if the called function in turn calls a function that uses the same parameters.

If a high-level language is used for programming, it is useful to evaluate the resulting assembler code in terms of optimality (if you encounter a memory shortage problem).

Modern compilers generate quite compact and fast assembly code when writing programs in a high-level language, so it is not necessary to write all the code in assembly. However, the use of assembler is reasonable in time-critical procedures (in terms of speed and accuracy).

Naturally, the system described in the article can be improved in several directions. For example, add access restriction by time of day, log unauthorized access attempts (presenting an identifier without access rights), add support for access control to the second object (this will require three additional I / O lines), however, as you know, there is no limit to perfection, but here The amount of program memory in the microcontroller is limited. The main purpose of the article is to show the full cycle of creating an embedded system using a specific example, as well as to give some practical advice on solving problems that may be encountered in the process of its development.

Literature

  1. Dallas Semiconductor technical documentation. - .
  2. Sinyutkin A. Electronic lock on keys-"tablets" iButton. - Radio, 2001, No. 2, p. 31 - 33; No. 3, p. 30. 31.
  3. Atmel technical documentation AT45D041. - .
  4. Hitachi white paper "HD44780U (LCD-11) (Dot Matrix Liquid Crystal Display Controller/Driver) ADE-207-272(Z) '99.9 Rev. CO".
  5. Predko M. Guide to microcontrollers. Volume 1. - M.: Postmarket, 2001.

Author: A. Rantsevich, Minsk

See other articles Section Microcontrollers.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

Machine for thinning flowers in gardens 02.05.2024

In modern agriculture, technological progress is developing aimed at increasing the efficiency of plant care processes. The innovative Florix flower thinning machine was presented in Italy, designed to optimize the harvesting stage. This tool is equipped with mobile arms, allowing it to be easily adapted to the needs of the garden. The operator can adjust the speed of the thin wires by controlling them from the tractor cab using a joystick. This approach significantly increases the efficiency of the flower thinning process, providing the possibility of individual adjustment to the specific conditions of the garden, as well as the variety and type of fruit grown in it. After testing the Florix machine for two years on various types of fruit, the results were very encouraging. Farmers such as Filiberto Montanari, who has used a Florix machine for several years, have reported a significant reduction in the time and labor required to thin flowers. ... >>

Advanced Infrared Microscope 02.05.2024

Microscopes play an important role in scientific research, allowing scientists to delve into structures and processes invisible to the eye. However, various microscopy methods have their limitations, and among them was the limitation of resolution when using the infrared range. But the latest achievements of Japanese researchers from the University of Tokyo open up new prospects for studying the microworld. Scientists from the University of Tokyo have unveiled a new microscope that will revolutionize the capabilities of infrared microscopy. This advanced instrument allows you to see the internal structures of living bacteria with amazing clarity on the nanometer scale. Typically, mid-infrared microscopes are limited by low resolution, but the latest development from Japanese researchers overcomes these limitations. According to scientists, the developed microscope allows creating images with a resolution of up to 120 nanometers, which is 30 times higher than the resolution of traditional microscopes. ... >>

Air trap for insects 01.05.2024

Agriculture is one of the key sectors of the economy, and pest control is an integral part of this process. A team of scientists from the Indian Council of Agricultural Research-Central Potato Research Institute (ICAR-CPRI), Shimla, has come up with an innovative solution to this problem - a wind-powered insect air trap. This device addresses the shortcomings of traditional pest control methods by providing real-time insect population data. The trap is powered entirely by wind energy, making it an environmentally friendly solution that requires no power. Its unique design allows monitoring of both harmful and beneficial insects, providing a complete overview of the population in any agricultural area. “By assessing target pests at the right time, we can take necessary measures to control both pests and diseases,” says Kapil ... >>

Random news from the Archive

Biochar will improve the environment 08.10.2013

Researchers at the University of Tübingen (Germany) have proven that microorganisms in the soil can affect the reduction of nitrous oxide emissions.

Adding biochar to agricultural land changes the composition and activity of microorganisms so that nitrous oxide (N2O) emissions are significantly reduced, say researchers Johannes Harter and Hans-Martin Krause. This discovery is important not only for understanding how to use nitrogen fertilizers more efficiently, but also provides new opportunities for reducing greenhouse gas emissions into the atmosphere.

Biochar is produced by the high temperature thermochemical decomposition of organic material, a process known as pyrolysis. Unlike coal, which is used to generate heat, biochar is used as a soil amendment in agriculture. It prevents the leaching of nutrients from poor soils, and also has a positive effect on the number, composition and activity of microorganisms in the soil, which form a complex with the participation of plants and animals. Biochar helps to retain carbon and water in the soil and reduces nutrient leaching from the soil, which improves soil fertility and helps reduce greenhouse gas emissions.

Biochar not only has the potential to open up new lucrative markets in agriculture and industry, it also offers huge opportunities for soil and climate protection.

According to a report by the UN Intergovernmental Panel on Climate Change (IPCC), the concentration of nitrous oxide in the atmosphere has increased by 20% since 1750 due to human activities. The main source of nitrous oxide emissions is agriculture (84%). Therefore, it is extremely important to find a solution to this environmental problem: reduce nitrous oxide emissions, but at the same time maintain high yields.

Other interesting news:

▪ Long range toothfish

▪ Robotic dogs will fly to Mars

▪ Samsung 8Gb DDR4 chips and 32GB DDR4 modules

▪ Canon M-i1 Android Projector

▪ Huawei Watch D with blood pressure monitor and ECG

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ site section Power supply. Article selection

▪ article More poets, good and different. Popular expression

▪ article What is stronger - web or steel? Detailed answer

▪ article Kalanchoe pinnate. Legends, cultivation, methods of application

▪ article Electronic fuse. Encyclopedia of radio electronics and electrical engineering

▪ article Norms of acceptance tests. Load switches. 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