Design scheme of automobile embedded vehicle anti-theft system based on C51 single chip microcomputer

1 Introduction

This article refers to the address: http://

At present, the mainstream products in the anti-theft device market are electronic anti-theft devices, which are divided into one-way anti-theft devices and two-way anti-theft devices. Both of these anti-theft devices are controlled by the owner through a remote controller, and the two-way anti-theft device can feed back the real condition of the vehicle. Owner.

The GPS car alarm relies on the global positioning system, which transmits the alarm information and the location of the alarm vehicle to the alarm center silently. Since the owner cannot directly control the vehicle, the price and the use cost are relatively high, which makes the promotion and application of the vehicle very limited, and has not been widely used at present. GSM car two-way anti-theft device is a rising star of network anti-theft device. It relies on the global GSM network. The owner can directly receive alarm and control the vehicle through the mobile phone. The performance price is relatively good. It represents the development trend of the car anti-theft device and has been received since the launch. Customer's favor.

The car embedded vehicle anti-theft system proposed in this paper belongs to the GSM anti-theft system. It does not use expensive GPS module. The CPU adopts C51 single-chip microcomputer. The market price is low. After years of industrial application, it is stable and reliable, and has high cost performance.

2. Time trigger mode

Electronic control systems are generally real-time systems and often require input data for many concurrent events. The order and probability of arrival of these events are often unpredictable, and the system must be responsive within a predetermined time frame.

For how to control the complex behavior of the system, the event triggering scheme is generally adopted, that is, all behaviors of the system are executed in response to external events. However, the cost of interrupt loss and event-triggered systems is a problem that people often overlook. In order to meet the demanding requirements of safety, low cost and as simple as possible, the development of electronic control systems eventually goes to the event triggering structure. Event triggering means that all sampling inputs, calculations, and other related actions are performed before a predetermined time, thus ensuring accurate scheduling time.

The time trigger mode is an embedded software mode that uses the time stamp signal generated by the MCU hardware timer to schedule multitasking. It can be applied to an 8-bit 51 series MCU. The time-triggered mode can control the control accuracy to the millisecond level, which is very suitable for real-time control systems. In time-triggered embedded systems, designers can ensure that only one event is processed at a time by carefully arranging the controllable order. In addition to improving reliability, the time-triggered mode consumes very little memory and CPU resources, and can benefit from this system architecture even in small embedded systems.

The time-triggered cooperative scheduler is usually implemented by a timer hardware timer. Most of the tasks are time-triggered, which means that there is no other type of interrupt except for the timer interrupt. The hardware timer will be set to generate a periodic interrupt signal, which can be up to 1KMz.

The main function of the time-triggered cooperative scheduler is to wake up tasks that are scheduled to perform at a good time. During the work, the scheduler checks the static task list and determines whether there are tasks to be executed according to the period of the task. If there is one, execute the task immediately; after the task is executed, continue to check the task list and repeat the previous process. After completing the linked list check, the CPU can go to sleep and wait for the next clock beat. Its task scheduling mechanism is shown in Figure 1. Since the cooperative scheduler can guarantee that only one task in the system is triggered at the same time, and the system can guarantee that the task is executed at any time. In this way, the efficiency of the system is improved.

Time-triggered cooperative scheduler task scheduling diagram

The reliable and predictable cause of the cooperative scheduler is that only one task is active at any time. The task runs until it is completed, and then the control of the CPU is given to the scheduler. If preemptive scheduling is used, there are multiple active tasks performing "context switching" and "key segment protection", etc., which will increase the overhead of the system. Many studies have shown that cooperative schedulers have many advantages over preemptive schedulers.

3. System Overview

3.1 System function analysis and state transition diagram

After the requirements analysis, we define the functions that the system should implement as follows:

1) The system will monitor the status of the car engine;

2) The system can accept the settings of the mobile phone user and set the mobile phone number;

3) If the system alarm is turned on, the specified mobile phone user will be alerted by the wireless module when the car starts up;

4) The system accepts the control message of the mobile phone user, and cuts off the oil and powers off the car;

5) The system accepts the inquiry message of the mobile phone user, can report the location of the car, and can accurately reach the wireless cell in the urban area;

6) The system will take certain measures to ensure the stability of the system.

The above target functions are also indicators for measuring system design. In the latter design, we will use tools such as finite state machines to further refine the functions until the hardware and software design of the system is completed.

Based on the analysis of the system workflow, we can further design the state transition diagram of the system (Figure 2). From the above we can clearly see the workflow of the system.

System state transition diagram

3.2 system module composition

Modular design methods are commonly used in embedded system design to reduce development difficulty, reduce coupling between various parts, and enhance system stability. As shown in the figure, the whole system is mainly composed of CPU, sensor, RS232 interface and GSM module. The CPU is the core control part of the system, responsible for accepting the signals of each module, processing, and controlling other modules; the sensor detects that the car is activated; the GPRS module is used to send and receive short messages, and communicates with the CPU through the RS232 interface to the owner's mobile phone; electronic switch circuit It is used to control the automotive circuit system and achieve the purpose of cutting off the fuel and powering off the car.

3.3 system hardware part

1) Using the AT89S52 microcontroller produced by Atmel as the processing core, the processor has 32 I/O ports, 3 Timers, and supports up to 8 interrupts. Because the on-chip RAM resources of 256B are not enough, the system uses an extended 64KRAM, and the 8K on-chip flash of the AT89S52 is sufficient for this system. The processor can support different power modes for cost and power sensitive applications.

System module

The EEPROM of the external model of the CPU is AT24C01 as a data memory for storing information such as the telephone number of the owner. AT24C series serial E2PROM has I2C bus interface function, low power consumption, wide power supply voltage (according to different models 2.5V ~ 6.0V), working current is about 3mA, quiescent current varies from 30μA to 110μA depending on the power supply voltage. The system uses the P2 port analog I2C bus to connect with the E2PROM. This way, the I2C protocol can simplify the circuit and reduce the cost compared with the hardware.

The AT89S52 chip provides a built-in watchdog. During a certain period of time, we must set the watchdog's registers. If it is not set in time, the watchdog will reset the system.

2) Each terminal needs to be initialized before use. This setting is done through the serial port, and the terminal device is initialized by multiplexing the serial port connected to the GPS. It is necessary to define its communication protocol and the specific content that needs to be configured.

3) The terminal is installed in a relatively hidden place in the car, and is powered by the vehicle power supply. The main functions of the terminal are responsible for receiving and processing GPS signals, reporting alarm data, receiving and processing central control commands, and executing commands.

4) The GPRS module adopts the French WAVECOM company Q2406B, the upload rate can reach 2618kbits/s, and the download rate can reach 5316kbits/s. The GPS module has the following two options:

a) Directly select the GPRSMODEM of the serial connection mode.

b) Select the built-in GPRS module plus antenna design method.

The first method can reduce the difficulty of development and maintenance, and the installation is convenient, but the cost is relatively high. The second method requires the design of related circuits on the hardware, which is difficult to develop, but can reduce costs.

5) The wheel speed sensor, also called the wheel speed sensor or the speed sensor, can measure the number of ring gears that rotate together with the drive shaft, and then generate an AC signal proportional to the wheel speed. The wheel speed sensor signal is converted to a digital signal by the ADC circuit and transmitted to the CPU for interpretation.

3.4 task design

Through the analysis of Figure 2 and the system function, we divide the system software into multiple tasks. The name of the task, the task cycle and the execution time are listed in Table 1.

Multiple tasks

Among the tasks listed in the table, Task1 queries the buffer every 1ms. If there is any information that needs to be sent or received, it will be sent and received through the serial port. The string stream received by the serial port is stored in the buffer and submitted to Task2 for processing. The Task2 period is 1s, which is responsible for the encoding and decoding of PUD short messages, the identification of commands and the transmission of control signals. It is the most resource-intensive task in the system. Task3 is executed every 10s. It discriminates the signal collected by the vehicle speed sensor. If an alarm is required, the message is sent to Task2 for processing. Task4 detects the message every 48ms and completes the transmission of the car control signal. Task5 sets the watchdog to less than 16383 CPU machine cycles (here, 12ms cycle) to ensure normal operation of the system.

According to the principle of the cooperative scheduler and the cycle of each task, the timer is set to generate a cycle interrupt signal every 1 ms. Because multiple tasks have been executed for more than 1ms, Task1 cannot be executed at the specified frequency. Therefore, the method of directly including Task1 into the timer interrupt service subroutine is adopted, so that the cycle and execution time of all tasks can meet the requirements of the system task schedulable.

The use of event-triggered patterns in engineering greatly increases the complexity of the system, resulting in a large code structure. Such code length and complexity are not suitable for ordinary developers to build, and commercial real-time operating systems are often expensive and require a large operating system overhead. The development of the system based on time-triggered mode can meet the engineering requirements of real-time, simple and predictable. In the application example, it can also be seen that for the task with a very different task period and execution time, in order to meet the schedulability requirement, the short task to be frequently executed is added to the timer interrupt service subroutine to prolong the interrupt processing time. At the same time, it weakens the system's real-time responsiveness and predictability. In addition, task schedulability can also be satisfied by decomposing a task with a long execution time into a task with a short execution time. Compared with the event trigger mode, the time trigger mode has higher requirements for engineers and technicians.

4. Conclusion

Through the design of software and hardware, the car anti-theft system realizes real-time monitoring and alarming of the car, and can realize hardware hardware anti-theft function. Embedded systems in automotive electronics have been widely used. How to integrate the original resources of automobiles and design powerful and practical applications will be the goal of embedded development in the future.

51V 100A Pylontech Battery

Lithium-ion Battery Pack 51V Lithium-ion Battery Pack
Portable Solar Generator 48000Wh Portable Power Station
Lithium Ion Batteries 48V Lithium Battery

Battery Storage For Solar

High Voltage Lithium Battery



51V pylontech battery , US2000 PYLONTECH, US3000 LIFEPO4

ShenZhen UFO Power Technology Co., Ltd. , https://www.ufobattery.com