Application of uCOS-II in mobile GPS mobile terminal

Application of uCOS-II in mobile GPS mobile terminal

1. General overview

At present, commercial embedded system products on the market, such as Vxwork, PSOS and Windows CE, are very mature, providing powerful development and debugging tools, but the development cost is expensive, and uCOS-II is a multi-task real-time operating system, kernel source The code is open, short and capable, and has strong portability. It is very suitable for the development of some small systems. This system describes how to transplant and apply uCOS-II to MCS51 series single-chip microcomputers, and discusses how to apply it to the "embedded equipment-vehicle GPS" system.

1. Introduction to uCOS-II

The real-time embedded operating system uCOS-II is a priority-based preemptive real-time multitasking operating system, including real-time kernel, task management, time management, communication synchronization between tasks (semaphore, mailbox, message queue) and memory management. . Most of the code is written in C language, and the hardware-related parts are written in assembly language, and its source code is open and free.

uCOS-II is for small and medium-sized embedded systems. The core containing all functional modules is about 10K. If only the core code is retained after reduction, it can be compressed to about 3K. The occupancy of RAM is related to the number of tasks in the system. The stack of the task occupies a large amount of RAM space. The size of the stack depends on the local variables of the task, the size of the buffer and the number of possible interrupt nesting levels. The time accuracy of the application program is determined by the system clock tick. UCOS-II requires the user to provide a periodic clock signal source for time delay and confirmation timeout. The general clock tick should be between 10 and 100 Hz (the maximum accuracy is 10 ms) Because uCOS-II checks whether every higher-priority task is waiting to be executed at every beat, if there is, it is necessary to switch tasks, so the higher the clock tick rate, the heavier the system's additional load.

2. The design goals of the system

This vehicle-mounted mobile terminal mainly completes the following control functions:

(1) Location and related information transmission, including real-time request transmission, equal time interval transmission, equidistant transmission, transmission methods include GPRS method and short message method, because GPRS method for data communication is charged according to the flow, every 1K bytes 2- 3 cents, the cost is much lower than SMS, so this system uses GPRS as the main communication method, with SMS as the supplement.

(2) Alarm function, divided into the following parts:

A. Specific area alarm function: After setting a specific alarm area (such as the driving task area specified by the control center), when the vehicle drives out of the set area, the monitoring center will alert the vehicle-mounted unit and record the real-time location information of the vehicle in time.

B. Emergency alarm function: When the vehicle encounters emergencies such as robbery and traffic accidents, the driver can send a distress signal to the control center through the emergency distress button and upload the vehicle positioning data.

C. Anti-theft alarm function: When the vehicle is set to the anti-theft state, any illegal movement of the vehicle, the vehicle-mounted unit will automatically alarm and upload vehicle positioning data.

D. Power failure alarm function: When the main power of the vehicle-mounted unit is powered off (or artificially cut off), the vehicle-mounted unit will automatically alarm and upload vehicle positioning data.

E. It can combine automatic alarm with manual alarm: the system supports manual single-key alarm and automatic alarm function generated by intelligent equipment. The single-key manual alarm requires the driver to perform fast concealed single-key operation to quickly alarm. Automatic alarms such as intelligent illegal mobile alarms, the system automatically generates alarm information and sends it to the monitoring center, and saves the alarm data, and the personnel of the monitoring center can take measures as needed.

(3) Power supply monitoring function, real-time monitoring of the backup power supply, if the power is found to be insufficient, it will automatically switch to the charging mode until the power is sufficient to automatically cut off the charging mode.

3. Function blocks of the system

The system structure is shown in Figure 1. There are three layers from outside to inside: hardware circuit layer, task layer, and operating system layer.

Figure 1 System structure diagram

Second, the hardware circuit layer design

The mobile terminal of this system mainly includes the following four parts: GPS module, GPRS module, handle, single-chip microcomputer control module, and its general functions are described as follows:

(1) GPS module-used for the collection of satellite positioning data, the collection time interval can be set, and the minimum interval is one collection per second

(2) GPRS communication module-used to realize GPRS data sending and receiving, short message sending and receiving and voice call function.

(3) Handle-used for voice calls.

(4) Microcontroller control module-used to control data reception, transmission, voice call control, short message sending and receiving, power supply monitoring management and oil and electricity control of GPS and GPRS modules.

3. Design of the task layer

1. System task layer composition and priority setting

The system task layer has the following six tasks in parallel: monitoring task, key processing task, off-hook task, GPRS task, short message task, serial port receiving task. Each task consists of the following three parts: application, task stack and task control block. Among them, only the application program is burned into the ROM, and the task itself is placed in the RAM, and then established when the system is running. The task stack is used to store CPU register contents. When a task changes from a running state to another state, the contents of the CPU register are pushed into the corresponding task stack, otherwise, the contents of the corresponding task stack are placed into the CPU register. As a data structure defined in the system, the content of the task control block includes the address of the task stack, the current state of the task, and the task priority. The operating system manages tasks by querying the content of the task control block.

The setting of priority is determined by the execution order of each task and the size of the impact on system security. The priority from high to low is: monitoring task, key processing task, off-hook task, GPRS task, short message task, serial port reception task. The system adopts static priority setting, that is, the task priority does not change during operation.

2. The status of the task

There are 4 kinds of state of each task in this system: wait state, ready state, running state and interrupt state. The state transition relationship is shown in Figure 2. When a task occupies the CPU, the task is in the running state, and its priority must be higher than that of all ready tasks. If the system operation causes the priority of a task in the ready state to be higher than the priority of the running state task, the scheduling function is called, the running state task will lose the CPU occupation and become the ready state, and the highest priority ready state task will become Running state. Only one task can be running at a time. The transition of the task between the ready state and the running state is called task switching. When the task in the running state expects a certain message (that is, the data transfer between the task and the task), the task will lose the right to occupy the CPU and switch to the waiting state. The waiting time can be set by the system. If the task receives a message within the waiting time, the task will be changed to the ready state, otherwise it will be forced to be ready by the time management function. When the interrupt occurs, the task in the running state will be put into the interrupt state, and the occupancy right of the CPU will be lost. Because there may be a message sent during the interruption, the task in the waiting state is transferred to the ready state, so after the interruption returns, the task scheduling function will be run first to determine the task state.

Milk Frother

Electric Milk Frother,Milk Frother,Milk Steamer Frother,Coffee Milk Frother

FOSHAN FORTUNE ELECTRICAL APPLIANCE CO.,LTD , https://www.coffelady.com