Design of Embedded Ethernet Access Control System Based on STM32

This paper describes the hardware circuit and software design framework of STM32 with Cortex-M3 core as the main control chip, RF chip PN532 and Ethernet controller ENC28J60. At the same time, the Ethernet protocol LwIP is analyzed in detail. The access control system has a long transmission distance, ultra-low power consumption, excellent performance and stability, and is fully applicable to the campus and the company's access control system.


At present, there are many enterprises that use the work permit to complete the access control management, and still use the traditional manual method to complete, not only easy to be mixed in, and there is no record, there are various human errors. At the same time, the access control system in the market has problems such as limited transmission distance and poor performance.

With the rapid development of embedded technology and the popularity of Ethernet technology, more and more embedded products based on Ethernet are developing faster and faster. This paper studies the access control system that combines Ethernet transmission data and RF chip identification smart card. Compared with the traditional access control system, Ethernet solves the problem of transmission distance. Secondly, the RF chip PN532 based on the 80C51 core is used to make the performance more stable. The basic principle of its work is to put the smart card on the access control system. The system reads the data and transmits it to the main chip STM32 for processing. After the main chip is processed, the data is transmitted from the ENCN8J60 to the server through the Ethernet protocol LwIP.

1 access control system hardware components

The access control system is mainly composed of STMicroelectronics' main control chip STM3H, Microchip's Ethernet controller ENC28J60 and NXP's RF chip PN532.

The structure of the access control system is shown in Figure 1. The main chip STM32 transmits data to the ENC28J60 through the Ethernet protocol stack LwIP, and then can communicate directly with the server through the network cable, or can be connected to the server through the router. In the case of contactless card communication, the STM32 is connected to the PN532 via an SPI interface with a frequency of 1 MHz.

Design of Embedded Ethernet Access Control System Based on STM32

1.1 STM32 peripheral circuit design

This system uses STMicroelectronics' Cortex-M3 core 32-bit microprocessor STM32F103 as the main control chip, its main frequency is 72 MHz, the internal integrated storage space is 256K Flash and 64K SRAM, also includes I2C, SPI , I2S, USART, CAN, ADC, watchdog, etc. The price/performance ratio is very prominent in similar products. The hardware connection is shown in Figure 2.

Design of Embedded Ethernet Access Control System Based on STM32

We use SWD instead of JTAG during debugging because SWD not only has fewer pins, but is also more reliable in high speed mode.

1.2 RF chip PN532 hardware circuit design

The PN532 is a highly integrated contactless read/write chip from NXP that includes the 80C51 microcontroller core and integrates various active/passive contactless communication methods and protocols at 13.56 MHz. Support ISO14443A/14443B protocol. Working distance is over 75 mm. A signal from the antenna is received and the data is processed in accordance with the frame format specified by ISO 14443.

The PN532 supports three communication methods: SPI, I2C, and HUS. Since we use the SPI method to communicate with the master chip STM32, I0 and I1 are set to 0 and 1, respectively.

The peripheral circuit structure of PN532 is shown in Figure 3.

Design of Embedded Ethernet Access Control System Based on STM32

1.3 Ethernet controller ENC28J60 hardware design

The main control chip ENC28J60 is an independent Ethernet controller with an industry standard Serial Peripheral Interface (SPI). It can be used as an Ethernet interface for any controller equipped with an SPI. The ENC28J60 complies with all IEEE802.3 specifications and employs a range of packet filtering mechanisms to limit incoming packets. It also provides an internal DMA module for fast data throughput and hardware-supported IP checksum calculations. Communication with the host controller is accomplished through two interrupt pins and SPI with data rates up to 10 Mb/s.

Two dedicated pins are used to connect the LEDs for network activity status indication.

It should be noted that when reading a plurality of data from the ENC28J60, even if the data output from the master chip STM32 is not required, a data is written to the SPI transmission buffer to start the interface clock of the SPI before each data is read.

The typical application circuit of ENC28J60 is shown in Figure 4.

Design of Embedded Ethernet Access Control System Based on STM32

2 system software design

2.1 Ethernet Protocol LwIP

LwIP is a small open source TCP/IP protocol stack developed by the Swiss Academy of Computer Science. Since it only needs a dozen K of RAM and a ROM of about 40K to run, it is suitable for use in embedded systems where hardware resources are not sufficient.

LwIP is a loose communication mechanism that implements communication between the application layer and the underlying protocol by means of shared memory. It provides three APIs: 1RAM API, 2LwIP API, and 3BSD API.

The disadvantage of the RAM API is that the code is not easy to understand, and the development is difficult. The advantage is that it consumes less resources and is more efficient than the other two methods, and is more suitable for embedded use with relatively few resources, so we use RAM. The API method is written.

There are two protocols, TCP and UDP, in the TCP/IP transport layer. TCP provides reliable transmission of data in an IP environment, and UDP provides unreliable transmission. Since the access control system must require correct data transmission, TCP is used. Figure 5 is a block diagram of the TCP processing flow under LwIP.

The RAM API puts the protocol stack and applications in a process based on function callback techniques. Below are some of the key configuration and code for LwIP.

(1) LwIP configuration

Modify the following places in the LwIP configuration file lwipopts.h.

Whether to use the operating system, we don't need it, so fill in as 1:

#define NO_SYS 1

Configure the size of the heap:

#define MEM_SIZE

Configure the size of the pool



The above three configurations occupy most of the memory of the LwIP protocol stack, and need to be modified to an appropriate value according to their needs.

(2) LwIP code

1 Set the IP address, subnet mask and gateway separately:




2 Initialize the underlying function, that is, configure the MAC address, initialize the ENC28J60, configure the maximum output unit, etc.:


3 Connect to the remote host, when the connection is established, the fourth parameter Conn_Back will be called:


4 Callback function called when new data is received:


5 Callback function called after the server successfully receives the data:


6 handle the wrong callback function:


7 Whether the data is received:


Once the communication is over or an abnormal condition occurs, be sure to use the pbuf_free() function to release the pbuf to avoid wasting memory. It is also important to note that the timer functions tcp_fasttmr() and tcp_slowtmr() functions must be called regularly at regular intervals during normal operation.

2.2 Access Control System Software Architecture and Design

The main flow of the access control system is shown in Figure 6. After each restart, first initialize the relevant registers, initialize each module, determine that the server has been connected, and then enter the main loop of the program.

Design of Embedded Ethernet Access Control System Based on STM32

First, it is necessary to monitor whether it is necessary to call the fast timer and the slow timer inside LwIP. Then, it is monitored whether the server is disconnected. If it is disconnected, the server is reconnected. If there is no disconnection, it detects whether there is a smart card. In some cases, the information in the receiving card is processed and then sent to the server.


This paper describes the hardware and software architecture of the access control system using STM32 as the main control chip. It has guiding significance for the use of the chip and Ethernet protocol involved in the paper, which can greatly reduce the cost, and at the same time, the access control system The use will be more stable and the transmission distance will be longer.

0 times
Window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdMiniList": false, "bdPic": "", "bdStyle": " 0", "bdSize": "24" }, "share": {}, "image": { "viewList": ["qzone", "tsina", "tqq", "renren", "weixin"], "viewText": "Share to:", "viewSize": "16" }, "selectShare": { "bdContainerClass": null, "bdSelectMiniList": ["qzone", "tsina", "tqq", "renren" , "weixin"] } }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.' + ~(-new Date() / 36e5)];

With Curved LED panels, The LED screen can be mounted in different location, will have wider viewing angle and more option. both concave and convex due to the diameter, Bringing high-tech innovation to your digital signage with curved displays is not only eye-catching but also efficient. The Indoor Curved LED Display provides strong long-term investment, low maintenance costs and energy requirements while adapting to existing building curves or increasing interest in the pupils and the square.

 Recycle lost advertising space with our display solutions, empowering you to create 360-degree emotional connections with customers and prospects. It offers cylindrical LED signage, no matter what you like - usually without structural reinforcement.

 At the airport: Visitors who frequent the big cities are full of praise for their experience in the city, but they are saddened by the transit times to and from the country's largest metropolis. Airport managers understand that they need to make up for this shortcoming in order to get rid of their bleak reputation, revitalize the tired airport audience, and remind them of the true character of the big city.

 At school: Universities know they need a goal to identify students who drive business growth. In order to promote the spirit of the school's commitment to innovation, the college must promote a higher level of cooperation between teachers and students. The government needs a space that can provide large open areas, and visitors to all buildings can interact by chance, but in order to build such a spontaneous network, the building needs an anchor point, a focus that immediately draws everyone's attention.

 High Definition and can be adjusted, can showing DVD, TV, Dynamic images, VCRS, graphs, letters and animations for 24 hours. Sharp, colorful, synchronized with computer monitor. Waterproof, Sun-screen, antisatatic, damp proof, anti -freeze, anti-thundering etc.Best equality, commendably solve the problem of the mosaic, have the excellent consistency of light.To pictures and character, have clear, exquisite and real display effect of led sign.Big viewing angle to horizontal line and vertical line, can see at every angle at this range, no picture change, no color excursion.Can repair each led lamps, so the cost of maintain is lower, and easy to repair for led sign!

Indoor curved LED panelCurved LED screen

Indoor Curved Led Display

Indoor Curved Led Display,Transparent Curving Led Screen,Indoor Stage Curved Led Display,Indoor Hanging Curved Led Display

Shenzhen Bako Vision Technology Co., Ltd. ,