Design of electronic control system based on time-triggered mode

Publisher:咖啡狐狸Latest update time:2014-01-07 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction

Electronic control systems are generally real-time systems that often need to process input data streams of many concurrent events. The arrival order and probability of these events are usually unpredictable, and the system must respond accordingly within a pre-set time limit [1].

For how to control the complex behavior of the system, the event-triggered scheme is generally adopted, that is, all the behaviors of the system are executed in response to external events of the system. However, interrupt loss and the overhead of the event-triggered system are often overlooked. Reference [2] discusses such an example: an event-triggered system containing 27 tasks and using the RM scheduling algorithm has an actual CPU utilization rate of only 18%. At the same time, the electronic control system can also be regarded as a real-time system that can collect a set of defined input values ​​in real time and give a correct output at a predetermined time interval. In order to meet the stringent requirements of safety, low cost and as simple a program as possible, the development of electronic control systems eventually moves towards a time-triggered structure [1]. Time triggering means that all actions related to input sampling, calculation and output results are executed before a pre-given time, thus ensuring accurate scheduling time.

1 Task Scheduler of Time-Triggered System

Scheduler is an operating environment for electronic control systems, and can also be seen as a simple operating system. Using schedulers in electronic control systems can shorten development time and improve the modularity of software. Schedulers have two forms: cooperative and preemptive. If a "woken up" high-priority task can interrupt other running low-priority tasks, the scheduler is preemptive; otherwise, it is cooperative. Due to the particularity of its application background, most of the tasks running in electronic control systems are periodic tasks (such as periodic data acquisition tasks, LED display refresh tasks, etc.), and the task's ready time, start time, execution time and deadline information can be known in advance. Therefore, a cooperative scheduler based on time triggering can be used, that is, tasks are scheduled in a periodic or one-time manner at a specific time.

2 Mechanism of Time-Triggered Cooperative Scheduler

Time-triggered cooperative scheduler is usually implemented through a hardware timer. All tasks are triggered by time, which also means that there are no other forms of interrupts except timer interrupts. The hardware timer will be set to generate a periodic interrupt signal with a frequency of about 1kHz.

The main function of the time-triggered cooperative scheduler is to wake up the task to be executed at a predetermined time. During working hours, the scheduler checks the static task list and determines whether there is a task to be executed based on the task cycle. If there is, the task is executed immediately; after the task is executed, the task list is continued to be checked, and the previous process is repeated. After completing the list check, the CPU enters a dormant state due to energy saving until the next clock beat arrives. Its task scheduling mechanism is shown in Figure 1. Since the cooperative scheduler can ensure that only one task is triggered in the system at the same time, and it can be guaranteed that there are tasks executing in the system at any time, the system's utilization efficiency is improved. In a distributed system, there is time drift between nodes (due to differences in the environment in which each node is located and the manufacturing process of the clock crystal oscillator, etc.), so the node clock must be dynamically adjusted to synchronize the clocks of each node in the entire system.

The main reason why cooperative schedulers are reliable and predictable is that only one task is active at any time. This task runs until it is completed and then the scheduler takes control. If preemptive scheduling is used, there are multiple active tasks, and the execution of "context switching" and "critical section protection" will increase the system overhead. Figure 2 [3] compares the use of cooperative schedulers and preemptive schedulers to design cruise systems. It can be seen that the use of cooperative scheduling mode can reduce the number of lines of code required and save program memory and data memory space. At the same time, many studies have shown that in addition to the much faster task-level response time, cooperative schedulers have many advantages over preemptive schedulers. For example, literature [4] points out that compared with preemptive alternatives, cooperative scheduling has the following four advantages: simplicity, reduced system overhead, easy testing, and easier for authorities to accept this form of scheduling. 3 Application Examples The solar tracking system is designed for applications such as solar air conditioning, high-efficiency solar photovoltaic power generation, and high-efficiency solar water heaters that require real-time tracking of the sun. By keeping one side of the device perpendicular to the sun at all times, the maximum solar energy can be obtained. The tracking system involved in this article adopts a mode that combines sensor tracking with astronomical positioning tracking. That is, the sunrise and sunset times are calculated through the local longitude and latitude and the current date, and then a pulse is output at regular intervals to control the device to automatically move westward according to the time difference between sunset and sunrise and the step angle of the motor. At the same time, according to the input of the photoelectric sensor, the motor is controlled to automatically adjust the device in the four directions of east, west, south and north at regular intervals to keep the device perpendicular to the sunlight. Figure 3 shows the context diagram of the solar tracker and gives a simple description of the system interface with sensors and actuators. It can be seen from Figure 3 that the tasks, task cycles and execution times required to realize the system functions are listed in Table 1.







Among the tasks listed in Table 1, Task2 performs a keyboard scan every 120 ms to set the current time, longitude and latitude, and save the input of the manual adjustment device. Task6 adjusts the device orientation according to the input of the manual adjustment device and the input of the photoelectric sensor. Task7 calculates the sunrise and sunset times. Task3, Task4, Task5 and Task6 are executed once every 24 hours. The switch_case structure is used. If it is not within the running time range, the program will jump out directly, otherwise the corresponding task will be executed. Task8 takes effect when the sunset time is reached or the device touches the west limiter to control the motor to align the device with the rising position of the sun.

According to the principle of cooperative scheduler and the cycle of each task, the timer is set to generate a periodic interrupt signal every 4 ms. Because the execution time of multiple tasks exceeds 4 ms, Task1 cannot be executed at the specified frequency. In addition, the worst execution time of multiple tasks exceeds 30 ms, which affects the sensitivity of keyboard scanning. Therefore, the method of directly including Task1 and Task2 into the timer interrupt service subroutine is adopted, so that the cycle and execution time of all tasks can meet the requirements of system task schedulability.

Conclusion

The use of event-triggered mode in engineering will greatly increase the complexity of the system, resulting in a huge 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 systems based on time-triggered mode can meet engineering requirements such as real-time, simplicity, and predictability. It can also be seen in application examples that for tasks with a large difference between task cycle and execution time, in order to meet the requirements of schedulability, the method of adding short tasks that need to be executed frequently to the timer interrupt service subroutine prolongs the interrupt processing time and weakens the system's real-time response capability and predictability. In addition, the task schedulability can also be met by decomposing tasks with long execution time into several tasks with short execution time. Compared with the event-triggered mode, the time-triggered mode has higher requirements for engineering and technical personnel.

Reference address:Design of electronic control system based on time-triggered mode

Previous article:Design of an Embedded Dual-computer Fault-tolerant Real-time System
Next article:Research on Several Commonly Used Single Chip Microcomputer System RAM Testing Methods

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号