Small RTOS51 realizes the design of temperature controller based on 8-bit microcontroller

Publisher:HarmonyInLifeLatest update time:2010-08-17 Source: 现代电子技术 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

At present, 8-bit single-chip microcomputers still occupy an important position in the field of measurement and control and the application of intelligent electronic products. The application of embedded real-time operating system (ERTOS) will greatly facilitate the software development of 8-bit single-chip microcomputers. This article briefly introduces the embedded real-time operating system and its advantages in program design, focusing on the embedded real-time operating system Small RTOS51 suitable for small RAM single-chip microcomputers, as well as the design methods and processes of hardware and software based on 8-bit single-chip microcomputers.

1 Introduction to embedded real-time operating system Small RTOS51

Embedded systems have become one of the hot topics today. From consumer electronics to various industrial equipment, embedded systems have penetrated into every corner of daily life. For embedded systems, an important feature is real-time performance, that is, completing the specified functions within a certain time and being able to respond correctly to external asynchronous events. To ensure the real-time performance of the system, the cooperation of software and hardware is required. First of all, it is necessary to ensure that the hardware processing speed meets the real-time requirements, and for software, it is to use an embedded real-time operating system (Embedded Real_Time Operating System, ERTOS) that is compatible with it.

The use of embedded real-time operating system (ERTOS) can ensure the real-time switching of tasks in the system, the determinism of event response time and the high reliability of the system. At the same time, ERTOS regards user applications as multiple tasks running on it, which provides great convenience for program writing, debugging and expansion of system functions. In addition, due to the use of ERTOS, the application software is objectively independent of the underlying hardware environment, which is convenient for the transplantation of embedded software, thus greatly reducing the system development cost and development cycle. At present, there are many kinds of embedded real-time operating systems that have been launched, and the more commonly used ones are VxWorks, WinCE, VRTX, pSOS, Palm OS, embedded Linux, Delta OS, etc. For the 8051 series of single-chip microcomputers, due to the small amount of RAM and ROM, the most suitable operating system for this type of single-chip microcomputer is Small RTOS51, which uses the stack management mechanism of RTX Tiny brought by Keil C51 and is preemptive like μC/OS-Ⅱ. At present, the latest version of Small RTOS is 1.20.3, which can support dynamic creation and deletion of tasks, reentry functions of C51, dynamic memory allocation, etc.

2 Embedded thermostat

2.1 Structure and principle of embedded thermostat

The system structure of the thermostat based on 8-bit single-chip microcomputer implemented by Small RTOS51 is shown in Figure 1. The single-chip microcomputer is the control core, which is responsible for reading the temperature of the temperature sensor and outputting it to the LED display. The button is used to set the temperature of the thermostat. When the temperature exceeds the limit, the output control part outputs the control signal to drive the relay or alarm device. The power supply part supplies power to the entire system.

2.2 Embedded temperature controller hardware circuit

Since the peripheral circuit of the temperature controller is relatively simple and the main controller requires few input/output ports, Atmel's AT89C2051 is used. The temperature sensor uses the DS18B20 of DALLAS Semiconductor, USA. Its data signal line is connected to the microcontroller P3.7. The LED display is composed of 4 common cathode digital tubes, driven by 4 serial input and parallel output shift registers 74LS164. It adopts static display mode. P1.1 is used as the serial data input of the LED display, and P1.0 is used as the serial clock input of the LED display. The output control signal is output by P1.7 to control the PNP transistor. In addition, 4 buttons are set to connect to P3.2~P3.5 of the microcontroller respectively. Its hardware circuit is shown in Figure 2.

3 System software design

3.1 Task decomposition and division

Task division includes determining which transformations belong to which task and determining the priority of each task. The specific division principle can be found in reference [1]. According to the principle of task division and the specific functions of the embedded temperature controller, this system decomposes the task into three tasks: key display processing, temperature measurement, and output execution.

3.2 System software design

System software design mainly includes main program design and task program design.

The main program flow chart of this design is shown in Figure 3. After the main program is initialized, three tasks are established in sequence and the CPU enters the sleep state. After each task runs, it first enters the task sleep state and waits for the corresponding task to wake up. After the task is awakened, it performs corresponding processing and enters the sleep state again. Each task adopts an infinite loop structure, which is as follows:



Task wakeup is completed by the function OSTaskResume(TASK_ID). Create a project under KeilμVision 2, edit the corresponding header file config.h, and set the relevant contents of OS_CFG.h and OS_CPU.h accordingly, and compile until success.

4 Conclusion

According to the hardware circuit of the embedded thermostat, the embedded real-time operating system Small RTOS51 is used to program it. KeilμVision 2 is used to build the project and compile it. After downloading the code, the thermostat works normally. For the 8-bit microcontroller that is still widely used, it is simple and convenient to use Small RTOS51 for program design. By using interrupts, semaphores, and message queues, more functions and effects can be achieved; in addition, there are many real-time operating systems, but their principles are similar. If you understand one of them, you can draw inferences from it and understand and apply other embedded real-time operating systems.

Reference address:Small RTOS51 realizes the design of temperature controller based on 8-bit microcontroller

Previous article:Design of image processing system based on ISP technology and 89C55 single chip microcomputer
Next article:Design of Thyristor Trigger Based on AT89C52 Single Chip Microcomputer

Recommended ReadingLatest update time:2024-11-16 17:38

Enteral Nutrition Infusion System Based on Small RTOS51
introduction With the continuous deepening of the application of various electronic systems in various fields, the requirements for electronic systems themselves are becoming higher and higher, especially for the reliability of control system software design, real-time response and other aspects of performa
[Medical Electronics]
Enteral Nutrition Infusion System Based on Small RTOS51
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号