Design of a Fuzzy Control System for DC Motors Based on LabVIEW
2026-04-06 08:33:08··#1
Abstract: A speed control system for a small DC motor is implemented using a fuzzy control algorithm. The fuzzy controller is designed using LabVIEW's fuzzy controller design tool, and real-time speed acquisition and motor speed control are accomplished using the NI-PCI6251 data acquisition card. Practical operation shows that the system has advantages such as small overshoot, short settling time, and low oscillation. Keywords: LabVIEW; fuzzy control; rotating speed control; data acquisition card Fuzzy control technology is a computer digital control based on fuzzy set theory, fuzzy linguistic variables, and fuzzy logic reasoning. It first appeared in the 1960s and has developed rapidly in the following decades. Currently, fuzzy control technology is widely used in the control field. LabVIEW is a graphical programming language for instrument measurement and control, which, together with data acquisition cards or other external devices, can easily form a computer-based measurement and control system. While the traditional PID control method for DC motors can effectively control motor speed, it suffers from relatively poor dynamic performance, long recovery time, large overshoot, and difficulty in parameter tuning. Fuzzy control technology, which emerged in the 1960s, can overcome these shortcomings to some extent. This design utilizes LabVIEW software combined with fuzzy control algorithms to implement a fuzzy control system for the speed of a brushed DC motor on NI's ELVIS experimental platform. Actual testing shows that the fuzzy control performance is quite ideal. 1 System Composition The system structure block diagram is shown in Figure 1. In Figure 1: SP is the speed setpoint; PV is the speed feedback value; e is the speed deviation, and is the rate of change of speed deviation; K1 and K2 are proportional factors. The system requires corresponding peripheral hardware circuits for the DC motor power supply and speed measurement; other parts are implemented by the computer through software programming. The system hardware circuit diagram is shown in Figure 2. Opto-isolators are used to acquire speed pulse signals, which are then sent to the computer via a data acquisition card. The data acquisition card used is the NI-PCI6251. The PCI6251 has two analog output ports, two counters, and 16 analog input ports. In this design, its analog output port AO is used to generate the motor control voltage. Since the output current of the 6251's analog output port is insufficient to drive the DC motor, a current amplifier circuit needs to be added to the AO port. The counter port CTR0 is used to measure the cycle of the speed signal generated by the photoelectric sensor to obtain the actual speed of the motor. [align=center] Figure 2 System Hardware Wiring Diagram[/align] [align=center] Figure 3 Fuzzy Controller Structure[/align] 2 Fuzzy Controller Design The fuzzy controller consists of four parts: fuzzification, rule base, fuzzy inference, and defuzzification, as shown in Figure 3. The functions of each part are as follows: fuzzification converts the precise input quantity into a fuzzy quantity; the rule base is a set of control rules obtained based on expert experience or other methods; the inference mechanism interprets and applies the expert experience in the rule base to achieve optimal control; and defuzzification converts the fuzzy inference conclusion into a precise output quantity. LabVIEW's Control Toolkit provides a graphical design tool for fuzzy controllers, which is very easy to use. This tool currently only supports four linguistic input variables and one linguistic output variable, with a maximum of nine sub-fuzzy sets under each linguistic variable. It also only supports four membership functions: triangular, trapezoidal, sigmoid, and z-type, which is fewer than what is offered by the Matlab Control Toolbox, but it is sufficient for general fuzzy controller design. In this design, a commonly used 2D fuzzy controller is chosen, with two input variables: the speed error *e* and the rate of change of the speed error, and one output variable: the voltage increment. In the actual design, since the rate of change of the speed error tends to infinity when a given speed change occurs, the rate of change of the actual motor speed is used instead. Furthermore, for ease of fuzzification of the input variables, the two input variables are multiplied by appropriate coefficients K1 and K2. Based on experimental data, if the motor speed is controlled within the range of 0-4000 r/min, nine fuzzy sets are defined on their universes of discourse for the speed error and output voltage increment: {NL (negative maximum), NB (negative large), NM (negative medium), MS (negative small), ZO (zero), PS (positive small), PM (positive medium), PB (positive large), PL (positive maximum)}, with universes of discourse of {-4, -3, -2, -1, 0, 1, 2, 3, 4}. For the rate of change of speed, five fuzzy sets are defined on their universes of discourse: {NM (negative large), MS (negative small), ZO (zero), PS (positive small), PM (positive large)}, with universes of discourse of {-2, -1, 0, 1, 2}. The control rules are established as shown in Table 1. The typical Mamdani (Max-Min) inference method is selected for fuzzy inference, and the CoM (Center of Maximum) method is selected for defuzzification. After the fuzzy controller design is completed, it is stored in .fc format for easy calling by the main program. Table 1 Input/Output Control Rules Table 3 Parameter Optimization and Rule Adjustment Before actually running the fuzzy controller, it is necessary to study the controller's input/output characteristics and optimize the controller. LabVIEW's Fuzzy Controller Design Toolkit provides this function. In I/O Characteristic, you can observe the control rules applied by the controller and the inference results under a given input condition. Based on experience, you can judge whether the result meets the control requirements. If not, you can modify the parameters of the corresponding membership function or the control rules accordingly until the output meets the expected requirements. [align=center] Figure 4 Program Flowchart[/align] 4. Software Design LabVIEW is a graphical programming language, which makes the program development process relatively easy. The program flowchart is shown in Figure 7. It should be noted that: 1) The program uses the Express Control to complete the periodic measurement and DC voltage output. This control is a quick operation control for the data acquisition card provided by LabVIEW 7.0 and later versions, making program development easier. 2) Since the speed measurement signal is generated by a photoelectric isolation sensor mounted on the motor shaft with a protruding blade, the signal changes for one cycle per revolution of the motor, so the speed n (r/min) = 60/T. 3) The input variables and corresponding input variable names of the Fuzzy Controller node must have the same name in the program; the Load Fuzzy Controller node loads the preceding .fc file. The file path can be specified in the input control of the Load Fuzzy Controller node or at runtime. 4) The speed change rate in the program is replaced by the difference between two adjacent actual speed samples, with a proportionality coefficient K2 of 1/500. Since the sampling time is equal, this replacement is feasible. 5) Since the controller output is an incremental voltage output, an accumulation is needed to determine the final motor control voltage. The program uses a register within a while loop to accumulate the voltage increment. 6) The real-time motor speed and the given speed are displayed in the same real-time recording graph. [align=center]Figure 5 System Operation Front Panel[/align] 5 System Operation and Result Analysis The system operation and front panel display are shown in Figure 8. Observing the system operation results in the real-time recording graph, it can be seen that the overshoot of the control system is less than 10% when the given speed suddenly increases or decreases, the adjustment time is less than 1 second, the steady-state error is also relatively ideal, and it can recover quickly when subjected to input disturbances, showing strong disturbance suppression capability and good adaptability. At the same time, it can also be clearly observed that the system has a certain delay, which is due to the time required for data acquisition and program execution, resulting in relatively poor real-time control. The way to improve this is to use a dedicated field controller. The project management function provided in LabVIEW8 can easily download the program designed on the host computer to the field control instrument to improve the real-time performance of the control. 6 Conclusion By using virtual instrument software combined with a control toolkit, a fuzzy control system for a DC motor can be realized very quickly. The design demonstrates some advantages of fuzzy control technology in the field of control, such as the fact that it is not necessary to establish a precise mathematical model of the system during the design process, the selection of control parameters is relatively easy, and the actual control performance is good. The innovations of this paper are: 1. Applying fuzzy control algorithms to a DC motor speed control system and implementing it using virtual instruments simplifies the controller design process, making it easier to implement and port. 2. Using LabVIEW 8 and Control Toolkit, a visual graphical interface and control program are designed to dynamically adjust the DC motor's power supply voltage, giving the speed control system advantages such as small overshoot, short settling time, and small oscillation. Funding: Hubei Provincial Department of Education Teaching Research Project 20050354. References: [1] Kevin M. Passino & Stephen Yurkovich. Fuzzy Control [M]. Beijing: Tsinghua University Press, 2001. [2] National Instruments, PID Control Toolset Manual, November 11, 2001, pp. 53-152. [3] Zhang Quanzhuang, Application of Fuzzy Neural Network Control in DC Motor Control, Electrical Engineering Technology, 2003, 12, pp. 40 [4] Yang Yongmei, Chen Ning. Design and Simulation of Fuzzy Self-Tuning PID Parameter Controller Based on Matlab, Microcomputer Information, 2005, 21(12-1): 61-63.