1 Introduction to the 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 coordination of software and hardware is required. First of all, it is necessary to ensure that the hardware processing speed meets the real-time requirements. For software, it is necessary to use an embedded real-time operating system (ERTOS) that is compatible with it.
The use of an embedded real-time operating system (ERTOS) can ensure the real-time performance of task switching 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 system function expansion. 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, thereby greatly reducing the system development cost and development cycle. At present, there are many kinds of embedded real-time operating systems, 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, support C51 reentry functions, support 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 buttons are used to set the temperature of the thermostat. When the temperature exceeds the limit, the output control part outputs a 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 be awakened. After the task is awakened, it performs the corresponding processing and enters the sleep state again. Each task adopts an infinite loop structure, which is as follows:
Task wake-up is accomplished 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.
Previous article:Design of portable blood pressure monitor based on MSP430 and USB bus
Next article:Design of LED intelligent lighting control system based on single chip microcomputer
- Popular Resources
- Popular amplifiers
- Practical Development of Automotive FlexRay Bus System (Written by Wu Baoxin, Guo Yonghong, Cao Yi, Zhao Dongyang, etc.)
- CVPR 2023 Paper Summary: Video: Low-Level Analysis, Motion, and Tracking
- CVPR 2023 Paper Summary: Efficient and Scalable Vision
- IC packaging basics and engineering design examples
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Xingkong Board Python Programming Learning Main Control Board] Use of various sensor functions and network connection
- Espressif ESP32-S3-BOX-LITE lights up the RGB light
- U-boot transplantation record
- I got a Raspberry Pi Pico and turned it on
- EEWORLD University Hall----Live Replay: Microchip Security Series 18 Using PKCS #11 and Security Devices to Develop Secure IoT Edge Devices to Cloud Applications on Linux?
- LED chip and driver circuit application quick reference
- #Idle Market# Memory stick, CPU
- TI millimeter wave radar classification and technical solutions
- The SD card driver code is really difficult
- I have a question, what is the principle of the Wolman amplifier circuit, the role of the common-emitter amplifier and the common-base amplifier, and how do they amplify?