Application of μCOS-II in Brushless DC Motor Position Servo System

Application of Integrated MC/OS- in Brushless DC Motor Position Servo System Liu Weiguo Hu Yashan Liu Chaofang Institute of Rare Earth Permanent Magnet Motor and Control Technology, Northwestern Polytechnical University, Xi'an 710072) Brush DC Motor Position Servo System This system makes full use of DSP peripherals The simplification of hardware systems that are both faster and faster, while PC/OS-I can minimize the software development cycle.

0Overview TMS320F240 (hereinafter abbreviated as F240) is a fixed-point DSP applied to the field of motion control by T1 company. It has fast operation speed, rich peripheral equipment, powerful functions, and low price, and has become an ideal microprocessor for motor control applications. High-performance digital servo systems provide the means to achieve. However, when it is applied to a more complex system, it has to perform tasks such as sampling calculation, control, and communication at the same time. It is not possible to have a real-time multitasking operating system. PC/OS- is a type of open-source preemptive real-time multitasking operating system. Most of the source code is written in highly portable ANSI C. Microprocessor-related parts are written in assembly language. The parts written in assembly language have been minimized due to only about 200 lines of hardware-related code, and the comments are very clear, so that PC/OS- can be easily ported to the microprocessor, including the F240 processor. The combination of F240 and PC/OS- makes the hardware design and software design of position servo system very simple, can greatly reduce the development difficulty and shorten the software development cycle. 1 System hardware configuration The hardware system is mainly driven by power* MOSFET inverter circuit and logic control circuit and necessary protection circuit composition, also includes the current, speed and displacement detection function necessary to complete the position servo function. Its system hardware structure is shown as this system uses F240 as the main control unit Rotary position sensor Hall sensor, the output of which is sent to the F240's fast capture unit (CAP module). Using the query method or interrupt method, the F240 will know the current rotor position and change the PWM waveform control method to control the ACRT internal affairs manager. The module (EV) will generate the six PWM waveforms required by the brushless DC motor to perform the proper commutation, thus completing the motor control and driving the DSP in addition to the basic function of the brushless DC motor control drive. System fault detection and system protection and position loop speed loop current loop three-loop control . The implementation of the three-loop control law and algorithm is implemented within the F240. In order to improve the rapidity of the system, a current loop must be added. The current detection circuit detects the magnitude of the current flowing through the brushless DC motor and sends it to the A/D converter module of the F240 for processing. F240 obtains a current position signal 0f after receiving a position signal from the outside and 0g from the position sensor. Through a certain control algorithm, the drive/mode 2 servo system software software is designed based on the above hardware. The correct hardware system is the premise of software design. This system adopts MC/OS-real-time multi-task omnibus system programming, which is different from the usual front-end and back-end system programming ideas. The less complex little systems are generally designed as front-end and back-end system applications are an endless loop in the cycle. Call the corresponding function to complete the corresponding operation, this part is called the background behavior, and the interrupt service program handles asynchronous events. This part is called foreground behavior. However, when the situation is more complicated, it is generally easier to use a proper operating system to reduce system development, making it easier to develop applications. MC/OS- is an embedded real-time operating system MC/OS that is suitable for the development of small and medium-sized projects. It is an open-source embedded real-time multitasking operating system. It can be ported to many processors, including the F240 we use. Its source code can be tailored to reduce MC/OS-required memory space (RAM and ROM) with high stability and reliability. Since 1992, many people in the world have used MC/OS-I in various fields such as camera industry medical equipment, audio equipment, engine control, network equipment, highway telephone systems, automatic teller machines, industrial robots, etc. Wait.

In order to realize the application in the multi-tasking operating system MC/OS-based F240 position servo system, the first task is to realize the MC/OS-porting on the F240 so that the real-time kernel can run on the F240. The migration of MC/OS- is relatively simple. It is relatively simple to migrate MC/OS-. It is mainly to modify the internal mechanism of the three files OSCPU.HOSCPU related to the processor, and to know how to implement the scheduling between tasks and the pushing of system stack data. Ejection is extremely important for successful transplantation.

In the F240, a timer 1 cycle interrupt T1PNT or a real-time interrupt RTI can be used as the clock tick source. The clock beat frequency is generally around 10Hzr 100Hz and the software interrupt is used as the task switching interrupt service routine.

After the code migration is complete, the next step is to test the kernel to test itself, or to run some simple tasks and clock tick service routines. Once the multitasking schedule has been successfully run, a real-time multitasking operating system platform is established. .

2.2 Multi-Task Operating System Flow The entire software flow is shown as below. The OSInU() function is used to initialize MC/OS-all variables and data structures. OSInit() also creates an idle task, which is always in a ready state. The idle task OSTaskidle() has the lowest priority, ie OSLOWESTPRIO has a statistical task OSTaskST() if it has a statistics task, and it is allowed to enter the ready state. At the same time, 4 data structure buffers are initialized according to the system configuration, including Task control block buffers, event buffers, queue buffers, and memory buffers. The Create Task Process section is primarily used to create user tasks. OSStart() is used to start multitasking. Before starting MC/OS-, the user must create at least one application task. When calling OSStarL(), OSStart() finds the control block of the highest priority task created by the user from the task ready list, and then calls the high priority ready task start function OSSLarLHighRdy() function OS-SLarLHighRdy() to give the highest priority The value held in the task stack in the task bounces back into the CPU register and executes an interrupt return instruction. The interrupt return instruction enforces the task code, and then the clock beat interrupt function is initialized in the highest priority task, and task scheduling can be performed later.

The main task is to rationally serve the system to complete the task F240 to complete the following tasks: generate six PWM waveforms driving the brushless DC motor; sample the given position signal and feedback the position signal and position closed loop Adjustment; calculation of the speed value and speed closed-loop adjustment; sampling the current flowing through the brushless DC motor and current loop adjustment.

2.3.1 Fault Detection and Protection The protection here refers mainly to overcurrent protection. When the current flowing through the brushless DC motor is too high, the fault signal is effectively low and the power to the F240 will be interrupted by the PDPINT. The timer comparator output signal will immediately change to a high-impedance state, blocking the 6 PWM outputs and turning off the inverter. All switch tubes of the variable circuit play a protective role.

2.3.2 Drive of Brushless DC Motor There are two ways to generate PWM waveforms for driving the brushless DC motor. One is to use the query method and the other is to use the interrupt method. If the query method is used, most of the CPU time is wasted on querying the current rotor position signal, which makes it unreasonable. Therefore, the system uses an interrupt method. First, at the beginning of the main program, start the brushless DC motor, and then realize the change of the motor in the capture interrupt. In the capture interrupt program, first set the corresponding pin of the CAP as an ordinary IO port function and set it as the input mode. Take the current rotor position signal. Based on the current rotor position signal, it is determined which of the two power transistors should be turned on to determine the value of the PWM output mode control word ACTR. The event manager (EV) outputs the PWM waveform that meets the requirements, completes the electronic commutation of the brushless DC motor, and then resumes the capture function of the corresponding pin of the CAP. Finally, the interrupt flag bit is cleared and the capture interrupt routine ends.

2.3.3 Position Loop Speed ​​Loop and Current Loop Implementation Overcurrent protection and brushless DC motor drive are implemented using interrupts. Different from these, the position loop, speed loop, and current loop all use task scheduling. In this task, the position loop has the highest priority, the speed loop takes precedence, and the current has the lowest priority. In a three-loop control system, the periodicity of the current loop speed loop and position loop differ by an order of magnitude. In this system, it is assumed that 30 speed loop adjustments are performed, followed by a speed loop adjustment, and after 10 speed loops, a position loop adjustment is performed.

The main task of implementing the position loop of the position loop is to acquire a given position signal and position signal fed back, and then pass a certain algorithm, such as a traditional PI algorithm, a fuzzy control algorithm, etc., to give the speed value of the intermediate loop speed loop. In this system, both the given position signal and the feedback signal are analog quantities. After passing through the signal processing circuit, they are sent to the pins of the A/D converter in the F240. Because the position loop is the highest priority among all tasks. Tasks, so when the system starts multi-task scheduling, the first task of the schedule is that the PositionTask() interrupt is placed after the system initialization function OSInit() and before the multi-tasking system start function OSStart() is called. The potential danger here is that clock tick interrupts may occur before MC/OS-n starts the first task. At this time, MC/OS- is in an uncertain state and the user application may crash in this system. We start the clock tick interrupt before the for(;) statement in the PositionTask() routine, ie before the infinite loop, using the F240 real-time interrupt RTI interrupt tick beat interrupt.

As there are only two registers related to the RTI interrupt, configuring the RTI for the real-time interrupt count register RTICNT and the real-time interrupt control register RTI-CR is as simple as setting the interrupt enable bit RTTINA in the RTICR and setting the real-time interrupt prescaler bit. RTIPS2-RTIS() determines the frequency of real-time interrupts. We schedule the position loop as a task. The following is a list of programs for this task.

Initializes the clock tick interrupt function; the amount of signal sent after completion of the speed loop acquires the ADC resource; sends the A/D sampling start command, samples the given position signal and the feedback position signal; performs the position closed-loop algorithm and gives the speed value; , Add the following code in the code area of ​​the main program creation task; // Create a location loop task to create a function of the task. The first parameter passed is the name of the task, that is, the second address of the task's entry address is the pointer passed to the task's parameter when the task starts execution, the third parameter is the stack pointer allocated to the task, and the fourth The parameter is the priority assigned to the task.

After the above code is added, the location loop task is added to the operating system.

In this task code, when waiting for ADC resources and waiting for the semaphore given by the speed loop, the task of the PositionTask() will be suspended. At this time, it will switch to the other highest priority ready task running speed. The realization speed ring of the ring is the middle ring in the three-ring control system, its given value is the output of the position, the feedback value is the rotational speed of the current brushless DC motor, and the output is the given value of the inner ring current loop. For this purpose, the rotational speed of the motor must be measured to obtain the rotational speed from the signal of the rotor position sensor. If the brushless DC motor is of the 2 pole pair, 12 electronic commutation must be performed, and the motor can only be turned for a fixed time. The number of phases in the brushless DC motor is counted, so that the motor speed can also be calculated and counted. The amount of change in time to find the speed of the program list for the speed loop task below: voidpositionTask (void * pdata) / / speed loop task / to prevent compile error for (;) current value of the inner loop current loop; (SpeedLoop);// Sending semaphores to the position loop, scheduling position tasks At the same time, add the following code in the code area of ​​the main program creation task: / Create a speed loop task After adding the above code, add the speed loop task to the operating system to the current loop The implementation of the current loop is an inner loop in a three-loop control system. Its regulation period is generally very short, assuming a period of 15 (Ps in order to avoid Magnetic noise, select the PWM waveform switching frequency is 20kHz, that is, the timing period is 5 (Ps when the timer interrupt three times, the current closed-loop, change the value of the timer compare register, that is, change the duty cycle of the PWM waveform, so as to achieve changes The purpose of passing the motor current is the following program list of the current loop task: /prevent the compile error for(;) to obtain the ADC resource; send the A/D sampling start command, sample the given position signal and feedback the position signal; wait for A/ D sampling end; read A / D conversion results; release ADC resources; current loop algorithm, given the duty cycle size, change the value of the PWM control word ACTR; current loop number plus 1; (CurrentLoop); / to speed When the ring sends a signal, it schedules the speed loop task. At the same time, add the following code in the code area of ​​the main program creation task: / Create a current loop task After adding the above code, the current loop task is added to the operating system.

3Conclusion (Continued on page 29), there is a pulsating torque phenomenon, which presents a periodic commutation torque ripple The most obvious 1 line voltage waveform

Freestanding Bathtub Faucet

Floor Mounted Tub Filler with Hand Shower with 360 Degree Swivel.The hoses come with a nylon-braided exterior that protects against chemical corrosion (commonly caused by detergent) and rusting. Easy operation single handle design allows flow rate and temperature control in single hand. Handheld Shower head and high arch 360 degree swivel bath tub faucet change in one second through diverting valve knob.

Freestanding Bathtub Faucet,Bathroom Tub Faucets,Freestanding Bath Taps,Freestanding Bathtub Faucets

HESHAN CAIZUN SANITRAYWARE CO.,LTD , https://www.caizunsanitaryware.com