Share this

Development of a circuit breaker controller based on the us/OS-II operating system

2026-04-06 07:14:16 · · #1
Abstract: This paper introduces the design of a novel intelligent controller for low-voltage circuit breakers based on the us/OS-II embedded operating system and the TMS320LF2407A DSP. The paper describes the us/OS-II embedded operating system, the hardware design and software development of the embedded system, and focuses on the porting of us/OS-II to the TMS320LF2407A chip. Field tests of the prototype show that the controller has high reliability, and the test results meet the expected design requirements, demonstrating broad application prospects. Keywords: us/OS-II, Embedded, Circuit Breaker, Intelligent Controller Abstract: The design of a new intelligent controller for low voltage circuit breaker based on us/OS-II embedded operating system and TMS320LF2407A DSP is presented. The us/OS-II embedded operating system and the design of hardware and software of embedded system are introduced. In particular, the design of transplant from us/OS-II to TMS320LF2407A is introduced in detail. The results of industrial tests show that this intelligent controller has high reliability. The results of experiment have achieved anticipation request. It can be widely applied. Keyword: us/os-II, Embedded, Circuit Breaker, Intelligent Controller 0. Introduction Intelligent operation of circuit breakers is a brand new concept in the process of intelligent development of circuit breakers. The intelligent controller is the core component for realizing intelligent operation [1]. Its basic task is to provide corresponding control information by collecting and processing power grid parameters. In addition, the intelligent controller can be connected to a computer through fieldbus for remote monitoring and management. The core of an intelligent controller is its software design. Currently, most controllers in China use a design method that combines a main loop program and interrupt service routines. However, in recent years, embedded systems have become increasingly mature, with the us/OS-II embedded operating system gaining widespread application due to its open-source code, small kernel size, and good portability. This paper uses TI's TMS320LF2407A DSP chip as the embedded system hardware, porting the us/OS-II embedded operating system to the DSP chip, thus improving the system's operating efficiency and reliability. 1. us/OS-II Embedded Operating System An embedded system is a device or system that performs dedicated functions and is controlled by an internal computer. The operating system and application software are integrated into the computer hardware system; that is, the system's application software and hardware are integrated. Embedded systems are characterized by less software code, high automation, and fast response speed, making them particularly suitable for real-time and multi-tasking applications. The us/OS-II embedded operating system is a complete, open-source, portable, fixed, and customizable preemptive real-time multi-tasking kernel. It is a non-preemptive kernel, so task priorities must be set before task scheduling. us/OS-II includes the following parts: kernel management, task management, time management, event control block, semaphore management, mailbox management, etc. Tasks created in us/OS-II have 5 states [2], namely: sleep state, waiting state, ready state, running state, interrupt service state. us/OS-II is a preemptive kernel. Each task must be set with a priority. The task with the highest priority can enter the CPU first to run, while other tasks can only wait in the ready state. us/OS-II can create up to 64 tasks (56 can actually be used because the priority of the first 4 and the last 4 tasks is reserved for system upgrades). 2. Hardware design of embedded system 2.1 Overall structure and working principle of intelligent controller The overall structure of the intelligent controller hardware system is shown in Figure 1. The main task of the controller is to collect the current and voltage signals on the power grid. After the signal processing circuit is conditioned, the signal is converted into the standard input voltage of DSP from 0 to 3.3V. The DSP controller analyzes the collected signals, correctly issues action commands, and sends relevant data to the monitoring computer through the CAN bus to realize remote monitoring and management. The system composition mainly includes the minimum system composed of DSP and its peripheral circuits, A/D signal acquisition and processing circuit, LCD display circuit, power supply, trip circuit and other parts. The peripheral circuits of DSP include crystal oscillator, filter circuit and some gate circuits used when selecting memory space for external RAM connection. 2.2 Introduction to TMS320LF2407A chip and its development environment CCS2.2 TMS320LF2407A is designed for control-based applications. It integrates high-performance DSP core and rich microcontroller peripherals into a single chip, thus becoming an ideal replacement for traditional microcontrollers. The peripherals of TMS320LF2407A DSP controller include [3]: ① Event manager ② CAN interface ③ A/D channel analog-to-digital conversion ④ SPI serial peripheral interface ⑤ SCI serial communication interface ⑥ General bidirectional I/O pins. CCS2.2 is the latest version in the CCS series, with many convenient and powerful functions. This mainly includes: ① Support for loading multiple project files simultaneously ② Added single-step debugging commands ③ Enhanced compiler with stricter syntax checking ④ Support for compiling function files into library files by creating library projects. 3. Software Design of Embedded Systems 3.1 Porting us/OS-II to the 2407 The implementation of us/OS-II on the 2407 is the key to embedded system software design. The main work involves writing the three files related to the porting: OS_CPU.H, OS_CPU_A.ASM, and OS_CPU_C.C, as well as correctly configuring OS_CFG.H. In the OS_CFG.H configuration, according to the actual needs of the embedded real-time system, the lowest priority OS_LOWEST_PRIO, the maximum number of task control blocks OS_MAX_EVENTS, and the maximum number of tasks OS_MAX_TASKS are set, and the required functions are selected and set. Writing the OS_CPU.H file mainly involves setting the following four macros: ① OS_ENTER_CRITICAL() ② OS_EXIT_CRITICAL() ③ OS_STK_GROWTH ④ OS_TASK_SW() Among them, OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() are settings for disabling and enabling interrupts. Since the C compiler in TMS320LF2407A can embed assembly language, this article sets: #define OS_ENTER_CRITICAL() asm("SETC INTM") //disable interrupts #define OS_EXIT_CRITICAL() asm("CLRC INTM") //enable interrupts OS_STK_GROWTH is about stack usage. Since the stack in TMS320LF2407A increments from low address to high address, this article sets: #define OS_STK_GROWTH 0 OS_TASK_SW() is used in task switching. Task switching essentially involves pushing the relevant register values ​​of the original task onto the stack for later restoration when the task is called again. This paper sets OS_TASK_SW() as the interrupt call software interrupt instruction OSCtxSw. The writing of the OS_CPU_C.C file includes writing the following 10 C language functions: ① OSTaskStkInit() ② OSTaskCreatHook() ③ OSTaskDelHook() ④ OSTaskSwHook() ⑤ OSTaskIdleHook() ⑥ OSTaskStatHook() ⑦ OSTimeTickHook() ⑧ OSIintHookBegin() ⑨ OSInitHookEnd() ⑩ OSTCBInitHook() In the real-time embedded system design in this paper, only the OSTaskStkInit() function is written. The function of OSTaskStkInit() is to initialize the task's stack structure and save the values ​​of all task registers onto the stack. The illustrative code for the OSTaskStkInit() function is shown below. OS_STK *OSTaskStkInit (void (*task) (void *pd), void *pdata, OS_STK *ptos, INT16U opt) {opt = opt; *ptos++ = (OS_STK)pdata; /* augument */ *ptos++ = (OS_STK)0; /* blank */ *ptos++ = (OS_STK)0x27FC;/* ST1 */ *ptos++ = (OS_STK)0x2600;/* ST0 */ *ptos++ = (OS_STK)0; /* ACCH */ *ptos++ = (OS_STK)0; /* ACCL */ *ptos++ = (OS_STK)0; /* PH */ *ptos++ = (OS_STK)0; /* PL /* ptos++ = (OS_STK)0; /* T */ ptos++ = (OS_STK)0; /* AR0 */ ptos++ = (OS_STK)0; /* AR2 */ ptos++ = (OS_STK)0; /* AR3 */ ptos++ = (OS_STK)0; /* AR4 */ ptos++ = (OS_STK)0; /* AR5 */ ptos++ = (OS_STK)0; /* AR6 */ ptos++ = (OS_STK)0; /* AR7 */ … … … return ptos; } The remaining 9 C language functions are only declared, without code, or to prevent the C compiler from issuing warnings, only simple pointer self-assignment programs are written. Writing the OS_CPU_A.ASM file involves writing the following four assembly language functions: ① OSStartHighRdy() ② OSCtxSw() ③ OSIntCtxSw() ④ OSTickISR(). Calling OSStartHighRdy() starts the highest priority task among the ready tasks. OSCtxSw() implements task switching; the vector address of the interrupt service routine, trap, or exception handler must point to OSCtxSw(). OSIntCtxSw() also implements task switching, but it does so within an interrupt service routine. OSTickISR() implements the clock tick function. After writing these functions, if the compilation succeeds and the code is loaded into the 2407 or external RAM, it indicates that us/OS-II has been successfully ported to the 2407. After successful porting, testing is required. Small programs such as lighting up indicator lights can be written as tasks and loaded into the DSP for execution. If the execution is successful, the embedded system software development can be carried out based on this program. 3.2 Intelligent Controller Software Design In this paper, the following functional programs were written as needed during software design, mainly including LCD display program, A/D sampling conversion program, protection algorithm, transient judgment protection program, filtering algorithm and effective value calculation, CAN communication transmission and reception, etc. [4]. After each functional program is written, multiple tasks are created, each task containing a functional program. Different priorities should be assigned to each task according to different actual situations. Among them, A/D sampling conversion and transient judgment protection have higher priority due to their high real-time requirements, while LCD display has the lowest priority due to its long delay time for human visual reading needs. The task priority is arranged as follows: A/D sampling conversion program > transient detection and protection program > filtering algorithm and RMS value calculation > protection algorithm > CAN communication transmission and reception > LCD display tasks are created using the function OSTaskCreateExt(). An example of creating a task is as follows: // Create task: INT8U OSTaskCreate (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT8U prio) Where task is a pointer to the task code; pdata is a pointer to the parameters passed to the task when execution begins; ptos is a pointer to the top of the stack allocated to the task; and prio is the priority assigned to the task. //Task example code: void Task (void *pdata) { While (1) {/***Code written according to actual function***/ OSTimeDly(INT16U ticks); //Task delay} } When the task is deprived of CPU use, us/OS-II uses the task control block OS_TCB to save the state of the task. 4. Experiment The experimental prototype designed in this paper was first debugged in the laboratory, and then debugged on-site at the enterprise test station. The main test items include LCD display, measurement, protection characteristic test, CAN bus communication between the host computer and the controller, etc. The test results show that the intelligent controller designed in this paper realizes the functions of measurement, protection, communication and monitoring, has good real-time performance, and the indicators meet the expected requirements. 5. Conclusion In order to realize the communication and intelligence of low-voltage circuit breakers, this paper developed a new type of intelligent controller based on DSP and embedded real-time operating system us/OS-II. It not only realizes the basic functions of the circuit breaker, but also improves the operating efficiency of DSP and the reliability of controller due to the use of us/OS-II embedded real-time operating system. References: [1] Bao Jianrong, Li Luwei. Design and implementation of embedded network access module based on single-chip microcomputer. [2] Jean J. Labrosse, translated by Shao Beibei et al. Embedded real-time operating system us/OS-II (2nd edition). Beijing: Beijing University of Aeronautics and Astronautics Press. 2003 edition. [3] TI, translated by Xu Kejun et al. CPU and peripherals of TMS320LF/LC24 series DSP. Beijing: Tsinghua University Press. 2004 edition. [4] Liu Heping, Yan Liping et al. Structure, principle and application of TMS320LF240x DSP [M]. Beijing: Beijing University of Aeronautics and Astronautics Press. 2002,4.
Read next

CATDOLL 138CM Kara (TPE Body with Soft Silicone Head)

Height: 138cm Weight: 26kg Shoulder Width: 30cm Bust/Waist/Hip: 65/61/76cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22