A multi-shaft direct current motor PID control experiment teaching system
By using the NI ELVIS II+ platform and LabVIEW software, combined with Hall encoders and TB6612 motor driver modules, the PID parameter adjustment and control process visualization of multi-axis DC motors was realized. This solved the problems of programming complexity and speed measurement inaccuracy in DC motor PID control at the university level, and improved the effectiveness of experimental teaching.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING INST OF TECH
- Filing Date
- 2023-09-22
- Publication Date
- 2026-04-28
AI Technical Summary
In existing technologies, PID control schemes for DC motors at the university level are usually based on microcontrollers, which are troublesome to program and debug, and the dynamic visualization of the control process is not easy, making it difficult to achieve multi-angle PID parameter adjustment and speed measurement accuracy.
Using the NI ELVIS II+ platform and LabVIEW software, PID control of a multi-axis DC motor is achieved through voltage or PWM signals. Combined with a Hall encoder and TB6612 motor driver module, arbitrary adjustment of PID parameters and visualization of the control process are realized.
It enables precise control and dynamic visualization of DC motor speed, enhances students' practical skills, and is suitable for experimental teaching and practical control applications.
Smart Images

Figure CN117153036B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of photoelectric detection, automatic control and virtual instruments, and in particular to an experimental teaching system for PID control of multi-axis DC motors using the NI ELVIS virtual instrument teaching platform. Background Technology
[0002] With the development of science and technology and the demands of various fields, automatic control technology has been widely applied in industrial production, automatic detection, military equipment, aerospace, and other fields. Courses such as Automatic Control Technology, Optoelectronic Instruments, and Electronics Experiments are important foundational courses in engineering colleges. Experiments are an essential component in cultivating students' engineering practice abilities. Through experiments, students can deepen their understanding of automatic control technology concepts and better connect theory with practice.
[0003] Virtual instrument technology utilizes high-performance modular hardware combined with efficient and flexible software to perform various testing, measurement, and automation applications. The NI ELVIS virtual instrument teaching and experimental system, offered by National Instruments, integrates the functions of instruments such as variable power supplies, oscilloscopes, and signal generators, achieving the integration of teaching instruments, data acquisition, and experimental design.
[0004] In engineering practice, there are often various situations where it is necessary to measure and control the speed. For the speed control of DC motors, the solution at the university level is usually based on a microcontroller. The motor driver performs PID control on the motor. The PID program and various control parameters need to be programmed and burned into the microcontroller, which is troublesome to program and debug. Moreover, it is not easy to achieve dynamic visualization of the control process. Summary of the Invention
[0005] To address the problems existing in current technologies, the purpose of this invention is to propose a teaching experimental system for multi-axis DC motor PID control using the NI ELVIS platform. This system enables arbitrary adjustment of PID parameters and visualization of the control process, allowing university students to implement PID control of two DC motors from multiple perspectives, thus applying classroom theory to practice. Simultaneously, the system features photoelectric speed measurement to compare the speed measured by the Hall sensor at the motor's tail, ensuring the accuracy of the speed measurement.
[0006] To achieve the above objectives, the present invention provides a multi-axis DC motor PID control experimental teaching system, comprising a computer (1) equipped with LabVIEW, an NI ELVIS II+ platform (2), and a multi-axis DC motor experimental device. The multi-axis DC motor experimental device includes a first DC motor (3) with a first Hall encoder (31), a second DC motor (4) with a second Hall encoder (41), and a TB6612 motor driver module (5). The experimental teaching system performs PID control on the speeds of the two DC motors separately through voltage signals, or performs PID control on the speeds of the two DC motors simultaneously through PWM signals.
[0007] When the speed of the two DC motors is controlled by PID control using voltage signals, the positive terminal of the power supply line of the first DC motor (3) is connected to the 0-12V variable power supply pin SUPPLY+ of the NI ELVIS II+ platform (2), and the A-phase output of the first Hall encoder (31) on the first DC motor (3) is connected to the gate pin CTR0_GATE of the counter 0 of the NI ELVIS II+ platform (2); the positive terminal of the power supply line of the second DC motor (4) is connected to the -12-0V variable power supply pin SUPPLY- of the NI ELVIS II+ platform (2), and the A-phase output of the second Hall encoder (41) on the second DC motor (4) is connected to the gate pin CTR1_GATE of the counter 1 of the NI ELVIS II+ platform (2); the power supply lines of the first Hall encoder (31) and the second Hall encoder (41) are both connected to the +5V pin of the NI ELVIS II+ platform (2); the negative terminals of the power supply lines of the first DC motor (3) and the second DC motor (4), and the ground wires of the first Hall encoder (31) and the second Hall encoder (41) are all connected to the NI ELVIS II+ platform (2). The ground pin of the II+ platform (2); the speed measurement and PID control of the two motors are performed by computer;
[0008] When the speed of two DC motors is simultaneously controlled by PID using the PMW signal, all signal lines of the first DC motor (3) and the second DC motor (4) are connected to the motor A and B interfaces of the TB6612 motor driver module (5) through the terminal blocks respectively; the AIN1 and AIN2 pins of the TB6612 motor driver module (5) are input signals to control the rotation direction of the first DC motor (3). AIN1 is connected to the digital output port DIO0 of the NI ELVIS II+ platform (2), and AIN2 is connected to the digital output port DIO1 of the NI ELVIS II+ platform (2); the BIN1 and BIN2 pins of the TB6612 motor driver module (5) are also input signals to control the rotation direction of the second DC motor (4). BIN1 is connected to the digital output port DIO2 of the NI ELVIS II+ platform (2), and BIN2 is connected to the digital output port DIO3 of the NI ELVIS II+ platform (2); the STBY pin of the TB6612 motor driver module (5) is the module's work / standby selection port, connected to the NI ELVIS II+ platform (2). The digital output port DIO4 of the II+ platform (2); the PWMA and PWMB pins of the TB6612 motor driver module (5) are input pins, which are used to drive the first DC motor (3) and the second DC motor (4) respectively, and are connected to the programmable interface PFI6 pin of the NI ELVIS II+ platform (2) to drive the two motors to rotate simultaneously; E1A and E1B of the TB6612 motor driver module (5) are the signal line outputs of the first Hall encoder (31), and E2A and E2B of the TB6612 motor driver module (5) are the signal line outputs of the second Hall encoder (41), so that E1A is connected to the gate pin CTR1_GATE of the counter 1 of the NI ELVIS II+ platform (2); the speed measurement and PID control of the two motors are performed simultaneously by the computer.
[0009] Furthermore, the speeds of the two DC motors are controlled by PID control using voltage signals, specifically including the following steps:
[0010] Step S11: The LabVIEW speed measurement program is set to counter frequency acquisition, the measurement method is set to low frequency with one counter, and the starting edge is the rising edge. The pulse signal frequency of the first Hall encoder (31) on the first DC motor (3) and the pulse signal frequency of the second Hall encoder (41) on the second DC motor (4) are acquired by the NI ELVIS II+ platform (2). The motor speed is calculated by the following formula:
[0011]
[0012] Where n is the rotational speed, in revolutions per minute, f is the signal frequency, in Hz, and p is the encoder resolution;
[0013] Step S12: The speeds of the first DC motor (3) and the second DC motor (4) are calibrated, and the measurement results are fitted to obtain the voltage-speed relationship;
[0014] Step S13: Input the desired speeds of the first DC motor (3) and the second DC motor (4) in the control interface and transmit them to the LabVIEW control program as the target values for speed regulation;
[0015] Step S14: Run the program to tune the proportional, integral, and derivative parameters of the PID control program written in LabVIEW, and input the tuning results into the program interface.
[0016] Step S15: Obtain the rotational speed information through the LabVIEW rotational speed measurement program, feed it back to the LabVIEW control program, compare it with the target value to obtain the deviation, adjust it through the LabVIEW control program, calculate the output voltage control quantity according to the calibrated voltage-speed relationship, send the voltage control quantity to the NI ELVIS II+ platform (2) and output voltage, thereby adjusting the motor speed to achieve the target value.
[0017] Furthermore, in step S12, the speeds of the first DC motor (3) and the second DC motor (4) are calibrated. The motor speed control range is set to 3V to 3V lower than the rated voltage of the motor. The motor speed is measured every 0.1V interval, and the measurement results are fitted to obtain the voltage-speed relationship.
[0018] Furthermore, the speeds of the two DC motors are simultaneously controlled by PID control using PWM signals, specifically including the following steps:
[0019] S21: The LabVIEW speed measurement program is set to counter frequency acquisition, the measurement method is set to low frequency with 1 counter, the starting edge is the rising edge, the pulse signal frequency of the first Hall encoder (31) is acquired through the NI ELVIS II+ platform (2), and the motor speed is calculated by the following formula;
[0020]
[0021] S22: The speed of the first DC motor (3) is calibrated, and the relationship between the duty cycle and speed of the PWM signal is obtained by fitting experimental data;
[0022] S23: Input the desired speeds of the first DC motor (3) and the second DC motor (4) in the control interface and transmit them to the LabVIEW control program as the target values for speed regulation;
[0023] S24: Run the program to tune the proportional, integral, and derivative parameters of the PID control program written in LabVIEW, and then input the tuned parameters into the program interface.
[0024] S25: Obtain the speed information through the LabVIEW speed measurement program, feed it back to the LabVIEW control program, compare it with the target value to obtain the deviation, adjust it through the control program, calculate the duty cycle of the output PWM signal according to the calibrated duty cycle-voltage relationship, send this duty cycle to the NI ELVIS II+ platform (2) to change the output waveform, and adjust the two motors at the same time to achieve the target speed.
[0025] Furthermore, in step S21, the PWM signal is output by the NI ELVIS II+ platform (2) and set to the counter pulse frequency output mode. The frequency remains unchanged during the control process, and the motor speed is controlled by adjusting the duty cycle.
[0026] Furthermore, in step S22, the speed of the first DC motor (3) is calibrated. The duty cycle range of the PWM signal controlling the motor speed is set to 0.15-0.95. The motor speed is measured once every 0.05 intervals, and the measurement results are fitted to obtain the duty cycle-speed relationship. Since the first DC motor (3) and the second DC motor (4) are controlled to rotate at the same time, and the two motors are of the same model, only the first DC motor (3) needs to be calibrated.
[0027] Furthermore, in step S21, the specific method for performing PID control on the speeds of the two DC motors using PWM signals includes setting the motor rotation direction and the working state of the TB6612 motor driver module (5) to digital output and output in high and low level form.
[0028] Furthermore, the digital output ports DIO0 / DIO2 of the NI ELVIS II+ platform (2) output a high level, and DIO1 / DIO3 output a low level, so that the first DC motor (3) / second DC motor (4) rotates forward, and vice versa; the digital output port DIO4 of the NI ELVIS II+ platform (2) outputs a high level, and the TB6612 motor driver module (5) is in working mode.
[0029] The use of virtual instruments in this invention for measurement and control is particularly convenient. It enables dynamic display of the control process and allows for data acquisition and signal generation using virtual instrument hardware. This combination of virtual and real technologies makes it suitable not only for experimental teaching but also for practical control applications. Attached Figure Description
[0030] Figure 1 This is a schematic diagram of the structure of the present invention;
[0031] Figure 2 This is a structural diagram of a multi-axis DC motor experimental setup.
[0032] Figure 3 This is a voltage-speed fitting curve for driving a motor using voltage.
[0033] Figure 4 The dynamic response diagrams show the PID control of the speed of the two motors using voltage.
[0034] Figure 5 The duty cycle-speed fitting curve for driving a motor using a PWM signal;
[0035] Figure 6 The dynamic response diagram shows the simultaneous PID control of the speed of two motors using a PWM signal.
[0036] The reference numerals in the attached figures are as follows: 1-Computer equipped with LabVIEW, 2-NI ELVIS II+ platform, 3-First DC motor, 4-Second DC motor, 5-TB6612 motor driver module, 6-Slotted photoelectric sensor, 7-Tachometer code disk, 31-First Hall encoder, 41-Second Hall encoder. Detailed Implementation
[0037] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0038] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0039] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0040] The NI Teaching Lab Virtual Instrumentation Kit (NI ELVIS II+ Platform) is a modular engineering teaching lab solution specifically developed for educational institutions. Educators can leverage this platform's hands-on approach to help students master experimental skills. The NI ELVIS II+ is compact and integrates 12 of the most commonly used lab instruments, including oscilloscopes, digital multimeters, function generators, variable power supplies, and Bode plot analyzers. It allows for plug-and-play USB connection of a PC to various measurement tools and the building of circuits on detachable prototyping boards.
[0041] The following combination Figures 1-6 Specific embodiments of the present invention will be described in detail below. It should be understood that the specific embodiments described herein are for illustrative and explanatory purposes only and are not intended to limit the present invention.
[0042] The structural principle diagram of the present invention is as follows: Figure 1 As shown, the structure of the multi-axis DC motor experimental device is as follows: Figure 2 As shown, the present invention provides an experimental teaching system for PID control of a multi-axis DC motor, comprising three parts: a computer (1) equipped with LabVIEW, an NI ELVIS II+ platform (2), and a multi-axis DC motor experimental device. The multi-axis DC motor experimental device includes a first DC motor (3) with a first Hall encoder (31) and a second DC motor (4) with a second Hall encoder (41), a TB6612 motor driver module (5), a slotted photoelectric sensor (6), and a speed measuring encoder (7). The experimental teaching system can perform PID control on the speed of the two DC motors separately through voltage signals, and can also perform PID control on the speed of the two DC motors simultaneously through PWM signals.
[0043] In this embodiment, two MG370 DC motors with Hall encoders are used as examples. The speed of the two DC motors is controlled separately by PID control using voltage signals, or the speed of the two DC motors is controlled simultaneously by PID control using PWM signals. The specific implementation method is as follows:
[0044] 1. PID control of the speed of two DC motors using voltage signals:
[0045] Connect the circuit before the experiment:
[0046] The positive terminal of the power supply line of the first DC motor 3 is connected to the variable power supply pin SUPPLY+ of the NI ELVIS II+ platform 2.
[0047] The first Hall encoder 31A phase output on the first DC motor 3 is connected to the gate pin CTR0_GATE of the counter 0 of the NI ELVIS II+ platform 2;
[0048] The positive terminal of the power supply line for the second DC motor 4 is connected to the variable power supply pin SUPPLY- of the NI ELVIS II+ platform 2.
[0049] The output of the second Hall encoder 41A on the second DC motor 4 is connected to the gate pin CTR1_GATE of the counter 1 on the NI ELVIS II+ platform 2;
[0050] The power lines for both the first Hall encoder 31 and the second Hall encoder 41 are connected to the +5V pin of the NI ELVIS II+ platform 2.
[0051] The negative terminals of the power supply lines of the first DC motor 3 and the second DC motor 4, as well as the ground lines of the first Hall encoder 31 and the second Hall encoder 41, are all connected to the GROUND pin of the NI ELVIS II+ platform 2.
[0052] The speed measurement and PID control of two motors are performed by writing a measurement and control program on a computer. The implementation steps are as follows:
[0053] Step S11: The LabVIEW speed measurement program is set to counter frequency acquisition, the measurement method is set to low frequency with one counter, and the starting edge is a rising edge. The pulse signal frequencies of the first Hall encoder 31 and the second Hall encoder 41 are acquired through the NI ELVIS II+ platform 2, and the motor speed is calculated using the following formula:
[0054]
[0055] Where n is the rotational speed, in revolutions per minute, f is the signal frequency, in Hz, and p is the encoder resolution;
[0056] Step S12: Calibrate the speeds of the first DC motor 3 and the second DC motor 4. The motor speed control range is set to 3-9V. Measure the motor speed every 0.1V interval and fit the measurement results. Taking the first DC motor 3 as an example, the voltage-speed curve obtained after calibration is as follows: Figure 3 As shown, the voltage-speed relationship is:
[0057]
[0058] Where n is the rotational speed, in revolutions per minute, and V is the voltage, in volts;
[0059] Step S13: Input the desired speeds of the first DC motor 3 and the second DC motor 4 in the control interface, for example, set the speeds to 100 rpm, and send them to the LabVIEW control program as the target values for speed regulation.
[0060] Step S14: Run the program and adjust the proportional K of the PID control program written in LabVIEW. p Integral T i Differential T d By tuning the three parameters, a K parameter with good control performance can be obtained. p T i T d After adjustment, K p T i T d The optimal values are 0.25, 0.001, and 0.001, which can be input into the program interface.
[0061] Step S15: Obtain the rotational speed information through the LabVIEW rotational speed measurement program, feed it back to the LabVIEW control program, compare it with the target value to obtain the deviation, adjust it through the LabVIEW control program, calculate the output voltage control quantity based on the voltage-speed relationship obtained in step S12, send the voltage control quantity to NI ELVIS II+ platform 2 and output voltage to adjust the motor speed to achieve the target value, as detailed below:
[0062] Step S151: In the LabVIEW control interface, change the desired speed of the first DC motor 3 or the second DC motor 4. For example, set the desired speed of the first DC motor 3 to 76 rpm. After reaching the speed, set the desired speed of the first DC motor 3 to 146 rpm and observe the PID control process and response. At the set speed, the first DC motor 3 can correctly adjust its speed and track the set value. The result is as follows. Figure 4 As shown in (a); the desired speed of the second DC motor 4 was set to 155 rpm. After reaching the speed, the desired speed of the second DC motor 4 was then set to 93 rpm. The PID control process and response were observed. Under the set speed, the second DC motor 4 was also able to correctly adjust the speed and track the set value. The results are as follows. Figure 4 As shown in (b);
[0063] Step S152: Click the stop button on the program interface to end the experiment. At the same time, clear the data acquisition task in the software and release the hardware connection.
[0064] The speed of the two DC motors is controlled by PID control using voltage signals. The speed can be set as needed during the tuning process. This embodiment uses 100 rpm for illustration.
[0065] II. Simultaneous PID control of the speed of two DC motors using PWM (Pulse Width Modulation) signals:
[0066] Connect the circuit before the experiment:
[0067] All signal lines of the first DC motor 3 and the second DC motor 4 are connected to the motor A and B interfaces of the TB6612 motor driver module 5 respectively through terminal blocks.
[0068] The AIN1 of the TB6612 motor driver module 5 is connected to the digital output port DIO0 of the NI ELVIS II+ platform 2, and the AIN2 of the TB6612 motor driver module 5 is connected to the digital output port DIO1 of the NI ELVIS II+ platform 2.
[0069] The BIN1 of the TB6612 motor driver module 5 is connected to the digital output port DIO2 of the NI ELVIS II+ platform 2, and the BIN2 of the TB6612 motor driver module 5 is connected to the digital output port DIO3 of the NI ELVIS II+ platform 2.
[0070] The STBY pin of the TB6612 motor driver module 5 is connected to the digital output port DIO4 of the NI ELVIS II+ platform 2;
[0071] The PWMA and PWMB pins of the TB6612 motor driver module 5 are used to drive the first DC motor 3 and the second DC motor 4, respectively, and are connected to the programmable interface PFI6 pin of the NI ELVIS II+ platform 2.
[0072] E1A and E1B of the TB6612 motor driver module 5 are the signal line outputs of the first Hall encoder 31, and E2A and E2B are the signal line outputs of the second Hall encoder 41. Only E1A is connected to the gate pin CTR1_GATE of the counter 1 of the NI ELVIS II+ platform 2.
[0073] The implementation steps are as follows:
[0074] Step S21: The LabVIEW speed measurement program is set to counter frequency acquisition, the measurement method is set to low frequency with one counter, and the starting edge is a rising edge. The pulse signal frequency of the first Hall encoder 31 is acquired through the NI ELVIS II+ platform 2, and the motor speed is calculated using the following formula:
[0075]
[0076] Where n is the rotational speed, in revolutions per minute, f is the signal frequency, in Hz, and p is the encoder resolution;
[0077] The PWM signal is output from the NI ELVIS II+ platform 2 and set to counter pulse frequency output mode. The initial frequency is 1000Hz and the initial duty cycle is 0.95. The frequency remains constant during the control process, and the duty cycle is adjustable. It is used to control the motor speed. This PWM signal is controlled by the counter CTR0 and output from the programmable interface PFI6 pin.
[0078] The rotation direction of the motor and the working state of the TB6612 motor driver module 5 are set to digital output, i.e., high and low level form; when the digital output port DIO0 of the NI ELVIS II+ platform 2 outputs a high level and DIO1 outputs a low level, the first DC motor 3 rotates forward, and vice versa; the second DC motor 4 is the same; when DIO4 outputs a high level, the TB6612 motor driver module 5 is in working mode.
[0079] Step S22: Calibrate the speed of the first DC motor 3. Set the duty cycle range of the PWM signal controlling the motor speed to 0.15-0.95. Measure the motor speed every 0.05 intervals. Fit the measurement results to obtain the duty cycle-speed relationship as follows: Figure 5 As shown, the relationship is:
[0080]
[0081] Where n is the rotational speed, in revolutions per minute, and a is the duty cycle;
[0082] Step S23: Select forward rotation in the control interface, input the desired speed of the first DC motor 3 and the second DC motor 4, for example, set the speed to 100 rpm, and send it to the LabVIEW control program as the target value for speed regulation;
[0083] Step S24: Run the program and adjust the proportional K of the PID control program written in LabVIEW. p Integral T i Differential T d The three parameters are tuned; after tuning, K p T i T d The optimal values are 0.5, 0.001, and 0.003, which are input into the program interface.
[0084] Step S25: Obtain the rotational speed information through the LabVIEW rotational speed measurement program, feed it back to the LabVIEW control program, compare it with the target value to obtain the deviation, adjust it through the LabVIEW control program, calculate the duty cycle of the output PWM signal according to the calibrated duty cycle-voltage relationship, and send this duty cycle to the NI ELVIS II+ platform 2 to change the output waveform, thereby simultaneously adjusting both motors to achieve the target rotational speed, as detailed below:
[0085] Step S251: In the program interface, change the desired speed of the first DC motor 3 and the second DC motor 4. For example, set the desired speed to 151 rpm for both. After reaching the desired speed, set the desired speed to 95 rpm and observe the PID control process and response. At the set speed, the two DC motors rotate synchronously, correctly adjust the speed, track the set value, and the dynamic response result is as follows: Figure 6 As shown;
[0086] Step S252: Click the stop button on the program interface to end the experiment. At the same time, clear the data acquisition task in the software and release the hardware connection.
[0087] The speed of two DC motors is simultaneously controlled by PID control using PWM signals. The speed can be set as needed during tuning; this embodiment only uses 100 rpm. The PWM signal frequency and initial duty cycle are also set as needed; this embodiment only uses a frequency of 1000 Hz and an initial duty cycle of 0.95.
[0088] The above embodiments use two MG370 DC motors with Hall encoders as examples. This invention is also applicable to any other model of DC motor with encoders.
[0089] Thirdly, in this invention, the motor speed can also be measured by using a slotted photoelectric sensor in conjunction with an encoder. Taking a DC motor with a Hall encoder, model MG370, as an example, the specific implementation method is as follows:
[0090] The speed measuring encoder 7 is installed on the drive shaft of the first DC motor 3 and needs to be placed inside the U-shaped slot of the slotted photoelectric sensor 6. The frequency of the output signal is measured, and the motor speed can be calculated. The following steps are included:
[0091] Step S31: Connect the experimental circuit. Connect the power supply terminal of the slot-type photoelectric sensor 6 to the +5V pin of the NI ELVIS II+ platform 2. Connect the output signal terminal of the slot-type photoelectric sensor 6 to the analog signal input terminal AI0+ of the NI ELVIS II+ platform 2. Connect the ground of the slot-type photoelectric sensor 6 to the analog signal input terminal AI0- of the NI ELVIS II+ platform 2.
[0092] Step S32: Measure the frequency of the output signal of the slotted photoelectric sensor 6 using the virtual oscilloscope built into the NI ELVIS II+ platform 2 on the computer, and calculate the motor speed using the following formula:
[0093]
[0094] Where n is the rotational speed in revolutions per minute (rpm), f is the signal frequency, and p = 10 is the resolution of the speed measuring encoder. The speed measuring encoder is designed with 10 light-transmitting holes, therefore its resolution is 10.
[0095] Step S33: Perform PID control on the first DC motor 3 using a voltage signal. For example, if the input voltage of the first DC motor 3 is 5V, the motor speed is obtained through the first Hall encoder 31 built into the first DC motor 3. At the same time, use the virtual oscilloscope in the NI ELVISmx software built into the NI ELVIS II+ platform 2 to measure the frequency of the output signal of the slot-type photoelectric sensor 6, calculate the motor speed, and compare the speeds obtained by the two sensors to ensure the accuracy of the speed measurement program through the motor's built-in Hall encoder.
[0096] In this invention, the AIN1, AIN2, BIN1, BIN2, and STBY pins of the TB6612 motor driver module 5 can be connected to any five of the 24 digital output ports of the NI ELVIS II+ platform 2, and the counters CTR0 and CTR1 can be used interchangeably. The program interface, digital signal generation, PWM signal generation and duty cycle change, voltage output, data acquisition, and dynamic display of the control process of the experimental teaching system are all implemented based on LabVIEW development software. The output terminal and ground terminal of the slotted photoelectric sensor 6 can be connected to one of the eight analog input ports of the NI ELVIS II+ platform 2.
[0097] The beneficial effects of this invention are as follows:
[0098] (1) This invention is based on the NI ELVIS II+ platform and is implemented using the graphical programming tool LabVIEW. In the experiment, a variety of information exchange and processing technologies such as analog signal output, digital signal output, pulse waveform generation, pulse frequency acquisition, and data processing are used, which enables college students to receive comprehensive training and enhance their skills during the experiment.
[0099] (2) The present invention designs and manufactures a multi-axis DC motor experimental device and a speed measuring encoder. Through different wiring methods, three independent experiments can be completed. The experimental device has a multi-functional practical effect.
[0100] (3) For speed control of DC motors, university-level solutions typically use a microcontroller as the core, employing a motor driver to perform PID control on the motor. The PID program and various control parameters need to be programmed and burned into the microcontroller, which is cumbersome to program and debug, and makes it difficult to achieve dynamic visualization of the control process. This invention utilizes virtual instrument technology and adopts a combination of virtual and real methods to achieve arbitrary adjustment of PID parameters and visualization of the control process.
[0101] (4) The present invention is suitable for PID control of any DC motor with an encoder. The encoder can be a Hall encoder, a photoelectric encoder or any type of encoder.
[0102] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A multi-axis DC motor PID control experimental teaching system, comprising a computer (1) equipped with LabVIEW, an NI ELVIS II+ platform (2), and a multi-axis DC motor experimental device, wherein the multi-axis DC motor experimental device comprises a first DC motor (3) with a first Hall encoder (31), a second DC motor (4) with a second Hall encoder (41), and a TB6612 motor driver module (5); the experimental teaching system performs PID control on the speed of the two DC motors separately through voltage signals, or performs PID control on the speed of the two DC motors simultaneously through PWM signals; The multi-axis DC motor experimental device also includes a slotted photoelectric sensor (6) and a speed measuring code disk (7). The speed measuring code disk (7) is installed on the drive shaft of the first DC motor (3) and placed inside the U-shaped slot of the slotted photoelectric sensor (6). The power supply terminal of the slotted photoelectric sensor (6) is connected to the +5V pin of the NI ELVIS II+ platform (2), the output signal terminal is connected to the analog signal input terminal AI0+ of the NI ELVIS II+ platform (2), and the ground is connected to the analog signal input terminal AI0- of the NI ELVIS II+ platform (2). This is used to obtain the motor speed through the first Hall encoder (31) built into the first DC motor (3), and to measure the frequency of the output signal of the slotted photoelectric sensor (6) and calculate the motor speed using the virtual oscilloscope of the NI ELVIS II+ platform (2). The speeds obtained by the two sensors are compared to ensure the accuracy of the motor's built-in Hall encoder speed measurement program. in, When the speed of the two DC motors is controlled by PID control using voltage signals, the positive terminal of the power supply line of the first DC motor (3) is connected to the 0-12V variable power supply pin SUPPLY+ of the NI ELVIS II+ platform (2), and the A-phase output of the first Hall encoder (31) on the first DC motor (3) is connected to the gate pin CTR0_GATE of the counter 0 of the NI ELVIS II+ platform (2); the positive terminal of the power supply line of the second DC motor (4) is connected to the -12-0V variable power supply pin SUPPLY- of the NI ELVIS II+ platform (2), and the A-phase output of the second Hall encoder (41) on the second DC motor (4) is connected to the gate pin CTR1_GATE of the counter 1 of the NI ELVIS II+ platform (2); the power supply lines of the first Hall encoder (31) and the second Hall encoder (41) are both connected to the +5V pin of the NI ELVIS II+ platform (2); the negative terminals of the power supply lines of the first DC motor (3) and the second DC motor (4), and the ground wires of the first Hall encoder (31) and the second Hall encoder (41) are all connected to the NI ELVIS II+ platform (2). The ground pin of the II+ platform (2); the computer performs speed measurement and PID control on the two motors respectively; When the speed of two DC motors is simultaneously controlled by PID using the PMW signal, all signal lines of the first DC motor (3) and the second DC motor (4) are connected to the motor A and B interfaces of the TB6612 motor driver module (5) through the terminal blocks respectively; the AIN1 and AIN2 pins of the TB6612 motor driver module (5) are input signals to control the rotation direction of the first DC motor (3). AIN1 is connected to the digital output port DIO0 of the NI ELVIS II+ platform (2), and AIN2 is connected to the digital output port DIO1 of the NI ELVIS II+ platform (2); the BIN1 and BIN2 pins of the TB6612 motor driver module (5) are also input signals to control the rotation direction of the second DC motor (4). BIN1 is connected to the digital output port DIO2 of the NI ELVIS II+ platform (2), and BIN2 is connected to the digital output port DIO3 of the NI ELVIS II+ platform (2); the STBY pin of the TB6612 motor driver module (5) is the module's work / standby selection port, connected to the NI ELVIS II+ platform (2). The digital output port DIO4 of the II+ platform (2); The PWMA and PWMB pins of the TB6612 motor driver module (5) are input pins, used to drive the first DC motor (3) and the second DC motor (4) respectively. They are also connected to the programmable interface PFI6 pin of the NI ELVIS II+ platform (2) to drive the two motors to rotate simultaneously. The E1A and E1B pins of the TB6612 motor driver module (5) are the signal line outputs of the first Hall encoder (31), and the E2A and E2B pins of the TB6612 motor driver module (5) are the signal line outputs of the second Hall encoder (41). Only E1A is connected to the gate pin CTR1_GATE of the counter 1 of the NI ELVIS II+ platform (2). The computer performs speed measurement and PID control on the two motors simultaneously.
2. The multi-axis DC motor PID control experimental teaching system according to claim 1, characterized in that, The speed of two DC motors is controlled by PID control using voltage signals, specifically including the following steps: Step S11: The LabVIEW speed measurement program is set to counter frequency acquisition, the measurement method is set to low frequency with one counter, and the starting edge is the rising edge. The pulse signal frequency of the first Hall encoder (31) on the first DC motor (3) and the pulse signal frequency of the second Hall encoder (41) on the second DC motor (4) are acquired by the NI ELVIS II+ platform (2). The motor speed is calculated by the following formula: ; Where n is the rotational speed, in revolutions per minute, f is the signal frequency, in Hz, and p is the encoder resolution; Step S12: The speeds of the first DC motor (3) and the second DC motor (4) are calibrated, and the measurement results are fitted to obtain the voltage-speed relationship; Step S13: Input the desired speeds of the first DC motor (3) and the second DC motor (4) in the control interface and transmit them to the LabVIEW control program as the target values for speed regulation; Step S14: Run the program to tune the proportional, integral, and derivative parameters of the PID control program written in LabVIEW, and input the tuned results into the program interface. Step S15: Obtain the rotational speed information through the LabVIEW rotational speed measurement program, feed it back to the LabVIEW control program, compare it with the target value to obtain the deviation, adjust it through the LabVIEW control program, calculate the output voltage control quantity according to the calibrated voltage-speed relationship, send the voltage control quantity to the NI ELVIS II+ platform (2) and output voltage, thereby adjusting the motor speed to achieve the target value.
3. The multi-axis DC motor PID control experimental teaching system according to claim 2, characterized in that, In step S12, the speeds of the first DC motor (3) and the second DC motor (4) are calibrated. The motor speed control range is set to 3V to 3V lower than the rated voltage of the motor. The motor speed is measured every 0.1V interval, and the measurement results are fitted to obtain the voltage-speed relationship.
4. The multi-axis DC motor PID control experimental teaching system according to claim 1, characterized in that, The PID control of the speed of two DC motors using PWM signals includes the following steps: S21: The LabVIEW speed measurement program is set to counter frequency acquisition, the measurement method is set to low frequency with 1 counter, the starting edge is rising edge, the pulse signal frequency of the first Hall encoder (31) is acquired through the NI ELVIS II+ platform (2), and the motor speed is calculated by the following formula; ; Where n is the rotational speed, in revolutions per minute, f is the signal frequency, in Hz, and p is the encoder resolution; S22: Control the first DC motor (3) and the second DC motor (4) to rotate simultaneously, and the two motors have the same model and the same speed. Only the speed of the first DC motor (3) is calibrated, and the relationship between the duty cycle of the PWM signal and the speed is obtained by fitting experimental data. S23: Input the desired speed of the first DC motor (3) and the second DC motor (4) in the control interface and transmit it to the LabVIEW control program as the target value for speed regulation; S24: Run the program to tune the proportional, integral, and derivative parameters of the PID control program written in LabVIEW, and input the tuned results into the program interface. S25: Obtain the speed information through the LabVIEW speed measurement program, feed it back to the LabVIEW control program, compare it with the target value to obtain the deviation, adjust it through the control program, calculate the duty cycle of the output PWM signal according to the calibrated duty cycle-voltage relationship, send this duty cycle to the NI ELVIS II+ platform (2) to change the output waveform, and adjust the two motors at the same time to achieve the target speed.
5. The multi-axis DC motor PID control experimental teaching system according to claim 4, characterized in that, In step S21, the NI ELVIS II+ platform (2) outputs a PWM signal, which is set to the counter pulse frequency output mode. The frequency remains constant during the control process, and the motor speed is controlled by adjusting the duty cycle.
6. The multi-axis DC motor PID control experimental teaching system according to claim 5, characterized in that, The PWM signal is controlled by counter CTR0 and output from the programmable interface PFI6 pin.
7. The multi-axis DC motor PID control experimental teaching system according to claim 4, characterized in that, In step S22, the speed of the first DC motor (3) is calibrated. The duty cycle range of the PWM signal controlling the motor speed is set to 0.15-0.
95. The motor speed is measured once every 0.05 intervals. The measurement results are fitted to obtain the duty cycle-speed relationship.
8. The multi-axis DC motor PID control experimental teaching system according to claim 4, characterized in that, In step S21, the motor rotation direction and the working state of the TB6612 motor driver module (5) are set to digital output and output in high and low level form.
9. The multi-axis DC motor PID control experimental teaching system according to claim 7, characterized in that, The digital output ports DIO0 / DIO2 of the NIELVIS II+ platform (2) output a high level, and DIO1 / DIO3 output a low level. The first DC motor (3) / second DC motor (4) rotates forward, and the first DC motor (3) / second DC motor (4) rotates in reverse.
10. The multi-axis DC motor PID control experimental teaching system according to claim 9, characterized in that, The digital output port DIO4 of the NIELVIS II+ platform (2) outputs a high level, and the TB6612 motor driver module (5) is in working mode.
Citation Information
Patent Citations
Motor speed control experiment platform based on rapid control prototype and method
CN109243285A
Module for experiment to demonstrate principle of automatic control
CN201741312U