Motor parameter monitoring method and device, computer equipment and storage medium
By dynamically adjusting the sampling interval and alternating data storage and transmission of data by dynamically adjusting the sampling interval and dual-channel registers, the problems of unstable communication and insufficient data storage in high-voltage motor applications are solved, and high-frequency motor parameter acquisition and stable data transmission are realized, supporting real-time control and performance optimization of the motor.
Patent Information
- Application Number
- CN202411618430.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-03-28
AI Technical Summary
In high-voltage motor applications, the serial communication baud rate of the low-performance MCU is disturbed, resulting in unstable communication. The RAM capacity of the low-performance MCU is limited, which cannot meet the needs of large data parameter storage, resulting in less sample data for motor parameter monitoring and difficulty in evaluating controller performance.
The data transmission time is calculated by the bit rate, and the sampling interval is dynamically adjusted to achieve synchronization of the sampling frequency and data transmission; the data is alternately stored and transmitted by dual-channel registers to realize the parallel operation of data acquisition and transmission; the upper computer monitors and transmits motor parameters in real time through the periodic data request mechanism.
It realizes high-frequency motor parameter acquisition and stable data transmission on low-cost MCUs, ensuring the continuity and real-time nature of data flow, supporting real-time control and performance optimization of motors, and improving system responsiveness and stability.
Smart Images

Figure CN119718977A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of motor control technology, and in particular to a motor parameter monitoring method, device, computer equipment and storage medium. Background Art
[0002] When controlling a permanent magnet synchronous motor (PMSM), some key parameters need to be monitored, such as current, voltage, angle, speed, temperature, etc. By real-time monitoring of these parameters, operators can analyze the effect of motor control. At present, high-performance MCUs are generally used to send different parameters through serial ports in each PWM carrier cycle. Usually a baud rate of 4000Kbps is required to ensure that the parameters can be sent to the host computer in each PWM carrier cycle.
[0003] However, for high-voltage motor applications, the higher the baud rate, the greater the interference. In order to ensure stable communication, the communication baud rate of high-voltage products does not exceed 115Kbps, and in many cases the baud rate used is between 4.8K and 38.4Kbps. Moreover, many companies are still using low-performance MCUs, and the serial communication of low-performance MCUs often cannot reach 4000Kbps. This results in a long communication time, so the motor parameters can only be monitored through the Modbus register query method. At present, when monitoring two parameters, at most 2 to 3 data are obtained per second, and the sampled data is small, so it is difficult for operators to evaluate the performance of the controller through these parameters.
[0004] In addition, the RAM of low-performance MCU is only 4KB to 8KB, and the parameters that can be stored are limited, which cannot meet the needs of large-scale parameter storage. Therefore, it is necessary to design a real-time parameter monitoring of PMSM under the conditions of low-cost MCU and low baud rate. Therefore, the present invention proposes a motor parameter monitoring method, device, computer equipment and storage medium. Summary of the invention
[0005] The object of the present invention is to provide a motor parameter monitoring method, device, computer equipment and storage medium to solve the problems raised in the above background technology.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions: a motor parameter monitoring system, the operation method of the system comprising the following steps:
[0007] Step 1: Calculate the time of each data transmission by bit rate to achieve dynamic adjustment of sampling interval;
[0008] Step 2: Realize efficient data collection of MCU through alternating storage and transmission of dual-channel registers;
[0009] Step 3: Realize real-time monitoring and transmission of motor parameters through the host computer data request mechanism.
[0010] According to the above technical solution, the step of dynamically adjusting the sampling interval by calculating the time of each data transmission by bit rate includes:
[0011] By configuring the hardware timer, ensure that each overflow period is 500μs, and start the sampling operation each time the timer overflows;
[0012] Calculate the time required for each data transmission based on the current baud rate and dynamically adjust the sampling interval to match the timer overflow period;
[0013] The synchronization of sampling and transmission is achieved by adjusting the value of n.
[0014] According to the above technical solution, the step of calculating the time required for each data transmission according to the current baud rate and dynamically adjusting the sampling interval to match the timer overflow period includes:
[0015] By setting a control loop in the MCU, the current baud rate is obtained in real time, and the time required for each data transmission is calculated according to the current baud rate. The calculation formula for the transmission time is: Where data volume is the number of bytes of data to be sent, and baud rate is the current communication baud rate. When 200 bytes of data are to be sent and the current baud rate is 115Kbps, the transmission time is: Then, the time required for data transmission is calculated, and the value of n is adjusted according to the time, that is, When the transmission time is 17.4ms, the value of n is Therefore, the sampling interval will be adjusted to 35*500μs=17.5ms. Whenever the baud rate changes, the data transmission time is automatically recalculated and the sampling interval n is adjusted.
[0016] According to the above technical solution, the step of realizing efficient data acquisition of MCU by alternating storage and transmission of dual-channel registers includes:
[0017] Create two independent storage areas in the MCU, namely channel 1 and channel 2, and allocate sufficient memory space;
[0018] Use the current_channel flag to alternate between acquisition and transmission operations;
[0019] After each transmission is completed, the flag bit is switched so that the two channels perform acquisition and transmission functions alternately.
[0020] According to the above technical solution, the step of using the current_channel flag to alternately switch the acquisition and transmission operations includes:
[0021] Use the current_channel flag, 0 means channel 1 is collected and channel 2 is transmitted; 1 means channel 2 is collected and channel 1 is transmitted. In each sampling cycle, according to the flag current_channel, select the channel currently in the "collection" state to store the newly collected motor parameter data. When current_channel is 0, the sampled data is stored in the storage area of channel 1; when current_channel is 1, the data is stored in channel 2. At the same time, select the channel in the transmission state to send the data stored in the previous sampling cycle to the host computer. When current_channel is 0, the data of channel 2 will be transmitted to the host computer through the serial port; when current_channel is 1, the data of channel 1 will be sent. After completing a data transmission, the MCU detects the transmission completion status through transmission interruption or polling. After the transmission is completed, switch the current_channel flag.
[0022] According to the above technical solution, the step of implementing real-time monitoring and transmission of motor parameters through the host computer data request mechanism includes:
[0023] The host computer sends data requests to the MCU through a periodic data request mechanism and uses the Modbus communication protocol for communication;
[0024] According to the current channel flag bit, the MCU reads the motor parameter data from the register channel of the current transmission status and formats it into the data format required by the host computer;
[0025] After receiving the data packet, the host computer verifies and analyzes the data.
[0026] According to the above technical solution, the host computer sends a data request to the MCU through a periodic data request mechanism, and the steps of communicating using the Modbus communication protocol include:
[0027] A periodic data request mechanism is set in the host computer software. The host computer automatically sends data requests to the MCU within the set time interval. The Modbus communication protocol is used when sending data requests. At the same time, the MCU is configured to receive interrupts or polling mechanisms. When the data request signal from the host computer is detected, the current task is immediately interrupted and data response is prepared. Then the MCU reads the collected motor parameter data from the register channel of the current transmission status according to the current channel flag bit.
[0028] According to the above technical solution, the system includes:
[0029] The sampling frequency and transmission synchronization control module is used to calculate the time required for each data transmission according to the communication baud rate and dynamically adjust the motor sampling interval;
[0030] Dual-channel alternating data acquisition and transmission module, used to create two independent storage channels and perform data acquisition and transmission alternately;
[0031] The host computer real-time monitoring and data request module is used to periodically send data requests through the host computer, obtain motor parameter data from the MCU in real time, and parse and verify the data to complete the monitoring of the motor operation status.
[0032] According to the above technical solution, the sampling frequency and transmission synchronization control module includes:
[0033] The reference time and timer overflow period setting module is used to set the reference time of each motor parameter acquisition of the system to 500μs, and ensure that each overflow period is 500μs by configuring the MCU hardware timer;
[0034] The sampling interval adjustment module is used to adjust the sampling frequency when necessary, by changing the multiple n of the sampling interval to match different communication baud rates;
[0035] The baud rate dynamic adjustment module is used to obtain the current communication baud rate in real time and adjust the sampling interval by calculating the data transmission time.
[0036] According to the above technical solution, the dual-channel alternating data acquisition and transmission module includes:
[0037] Dual-channel register storage area creation module, used to create two independent storage areas in the MCU and allocate enough memory space for each channel;
[0038] The channel switching module is used to use the flag bit current_channel to control which channel is in the acquisition state and which channel is in the transmission state;
[0039] The acquisition and transmission alternating execution module is used to ensure that while one channel is acquiring data, another channel is transmitting data, thus avoiding conflicts between data acquisition and transmission.
[0040] Compared with the prior art, the beneficial effects achieved by the present invention are as follows: the present invention dynamically adjusts the sampling interval by setting the reference sampling time and the timer overflow period to ensure the synchronization of the sampling frequency and the data transmission; secondly, the dual-channel register is used to alternately store and transmit data, so as to realize the parallel operation of data acquisition and transmission, and improve the data processing efficiency of the MCU; finally, the host computer communicates with the MCU in real time through the periodic request mechanism, and realizes the real-time monitoring, data parsing and storage of the motor parameters by using the Modbus protocol, which provides a basis for further analysis and control optimization; the present invention realizes the high-frequency motor parameter acquisition and stable data transmission on the low-cost MCU, ensures the continuity and real-time nature of the data stream, and effectively supports the real-time control and performance optimization of the motor; at the same time, through the data monitoring and storage of the host computer, the motor parameter changes can be analyzed in time, which helps to improve the responsiveness and stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0042] In the attached picture:
[0043] Figure 1 is a flow chart of steps of a motor parameter monitoring method;
[0044] Figure 2 It is a schematic diagram of the module composition of a motor parameter monitoring system;
[0045] Figure 3 The invention relates to a motor parameter monitoring method, device, computer equipment and a timing diagram of parameter register operation in a storage medium. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] Embodiment 1:
[0048] Figure 1 This is a flow chart of a motor parameter monitoring method provided in Embodiment 1 of the present invention. This embodiment can be applied to the scenario of real-time motor parameter monitoring. This method can be executed by a motor parameter monitoring system provided in this embodiment. Figure 1 As shown, the method specifically comprises the following steps:
[0049] Step 1: Calculate the time of each data transmission by bit rate to achieve dynamic adjustment of sampling interval;
[0050] In an embodiment of the present invention, the reference time for each motor parameter acquisition of the system control is set to 500 μs. In the MCU, the hardware timer is configured to ensure that each overflow period is 500 μs. Each time the timer overflows, the sampling operation is started. At the same time, in order to avoid the sampling operation from conflicting with the next overflow period, it is necessary to ensure that the total time of each sampling operation (including data acquisition and processing) does not exceed 500 μs, or adjust the sampling interval as needed to match the timer overflow period, and then set the sampling interval to n*500 μs, where n is a multiple of the sampling interval, wherein the initial value of n is 1, indicating that sampling is performed every 500 μs. When the sampling frequency needs to be adjusted, the sampling interval can be extended or shortened by changing the value of n. For example, if n=2, sampling is performed every 1000 μs, and if n=3, sampling is performed every 1500 μs. By adjusting the value of n, the sampling frequency can be optimized according to different communication baud rates.
[0051] For example, the sampling interval needs to be dynamically adjusted according to different baud rates. The specific method is: by setting a control loop in the MCU, the current baud rate is obtained in real time, and the time required for each data transmission is calculated according to the current baud rate. The calculation formula for the transmission time is: Among them, the data volume is the number of data bytes to be sent, and the baud rate is the current communication baud rate, such as 115Kbps, 4.8Kbps. When 200 bytes (1600 bits) of data are to be sent and the baud rate is 115Kbps, the transmission time is: Then, the time required for data transmission is calculated, and the value of n is adjusted according to the time, that is, When the transmission time is 17.4ms, the value of n is Therefore, the sampling interval will be adjusted to 35*500μs=17.5ms to ensure that data transmission and sampling do not conflict. The synchronization of sampling and transmission is achieved by adjusting the value of n. In each cycle, sampling and data transmission operations need to be coordinated with each other to ensure that the next data collection can be carried out after each data transmission is completed. Whenever the baud rate changes, the data transmission time is automatically recalculated and the sampling interval n is adjusted.
[0052] Step 2: Realize efficient data collection of MCU through alternating storage and transmission of dual-channel registers;
[0053] In the embodiment of the present invention, two independent storage areas are created in the MCU, namely channel 1 and channel 2, and sufficient memory space is allocated. If 100 parameters are to be stored each time sampling, and each parameter is 2 bytes, each channel requires at least 200 bytes of storage space, and then the current_channel flag is used, 0 means channel 1 acquisition, channel 2 transmission; 1 means channel 2 acquisition, channel 1 transmission, in each sampling cycle, according to the flag current_channel, select the channel currently in the "acquisition" state to store the newly collected motor parameter data, when current_channel is 0, the sampled data is stored in the storage area of channel 1; when current_channel is 1, the data is stored in channel 2, and at the same time, another channel (the channel in the "transmission" state) is selected to send the data stored in the previous sampling cycle to the host computer;
[0054] For example, when current_channel is 0, the data of channel 2 will be transmitted to the host computer through the serial port; when current_channel is 1, the data of channel 1 will be sent. After completing a data transmission, the MCU detects the transmission completion status through transmission interruption or polling. After the transmission is completed, the current_channel flag is switched so that the two channels perform the "collection" and "transmission" functions alternately. For example:
[0055] If current_channel is 0, switch to 1 to make channel 2 perform sampling and channel 1 perform transmission;
[0056] If current_channel is 1, switch it to 0 to make channel 1 perform sampling and channel 2 perform transmission.
[0057] In this alternating manner, while one channel is acquiring new data, the other channel is transmitting data, ensuring that the acquisition and transmission processes do not conflict and the data flow is continuous.
[0058] Step 3: Realize real-time monitoring and transmission of motor parameters through the host computer data request mechanism.
[0059] In an embodiment of the present invention, a periodic data request mechanism is set in the upper computer software. The upper computer automatically sends a data request to the MCU within a set time interval. The Modbus communication protocol is used when sending the data request. At the same time, the MCU is configured to receive an interrupt or polling mechanism. When the data request signal of the upper computer is detected, the current task is immediately interrupted and a data response is prepared. Then, the MCU reads the collected motor parameter data from the register channel in the current "transmission" state according to the current channel flag bit. These data are the contents collected in the previous sampling cycle, and are formatted into the data format required by the upper computer. For example, the data can be organized into a group of 16-bit parameter values and encapsulated according to the frame structure of the Modbus protocol. Each data packet contains fields such as a start bit, a data bit, and a check bit. After the data is encapsulated, the MCU sends the formatted data to the upper computer through a serial port or other communication interface. After the transmission is completed, a "transmission completed" flag is sent to notify the upper computer that all the data has been sent.
[0060] For example, after receiving a complete data packet, the host computer will first check and parse it. The parsed motor parameter data will be used to monitor the operating status of the motor in real time. At the same time, the host computer will store the parsed data in a local database. By monitoring the data in real time, the system can observe the changes in key motor parameters (such as current, voltage, speed, etc.) over time, thereby effectively evaluating the responsiveness and stability of the motor control. If the analysis results show that there is a need, the host computer can also dynamically adjust the motor control parameters according to the monitoring data, thereby optimizing the overall performance of the system.
[0061] Embodiment 2:
[0062] A second embodiment of the present invention provides a motor parameter monitoring system. Figure 2 A schematic diagram of the module composition of a motor parameter monitoring system provided in the second embodiment of the present invention is shown in FIG. Figure 2 As shown, the system includes:
[0063] The sampling frequency and transmission synchronization control module is used to calculate the time required for each data transmission according to the communication baud rate and dynamically adjust the motor sampling interval;
[0064] Dual-channel alternating data acquisition and transmission module, used to create two independent storage channels (channel 1 and channel 2) and perform data acquisition and transmission alternately;
[0065] The host computer real-time monitoring and data request module is used to periodically send data requests through the host computer, obtain motor parameter data from the MCU in real time, and parse and verify the data to complete the monitoring of the motor operation status.
[0066] In some embodiments of the present invention, the sampling frequency and transmission synchronization control module includes:
[0067] The reference time and timer overflow period setting module is used to set the reference time of each motor parameter acquisition of the system to 500μs, and ensure that each overflow period is 500μs by configuring the MCU hardware timer;
[0068] The sampling interval adjustment module is used to adjust the sampling frequency when necessary, by changing the multiple n of the sampling interval (such as n=2 means sampling every 1000μs) to match different communication baud rates;
[0069] The baud rate dynamic adjustment module is used to obtain the current communication baud rate in real time and adjust the sampling interval by calculating the data transmission time.
[0070] In some embodiments of the present invention, the dual-channel alternating data acquisition and transmission module includes:
[0071] Dual-channel register storage area creation module, used to create two independent storage areas (channel 1 and channel 2) in the MCU, allocating enough memory space for each channel;
[0072] The channel switching module is used to use the flag bit current_channel to control which channel is in the acquisition state and which channel is in the transmission state;
[0073] The acquisition and transmission alternating execution module is used to ensure that while one channel is acquiring data, another channel is transmitting data, thus avoiding conflicts between data acquisition and transmission.
[0074] In some embodiments of the present invention, the host computer real-time monitoring and data request module includes:
[0075] The periodic data request module is used to implement the periodic data request mechanism in the host computer software. Within a predetermined time interval, the host computer sends a data request to the MCU to obtain the latest motor parameter data;
[0076] MCU response and transmission module, used to respond through interrupt or polling mechanism after MCU receives data request, and read the motor parameter data in the register channel of the current transmission status;
[0077] The host computer data analysis and real-time monitoring module is used to analyze and verify the data after the host computer receives the data, and store the analyzed motor parameters in the local database.
[0078] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0079] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A motor parameter monitoring method, characterized in that: The method comprises the following steps: Step 1: Calculate the time of each data transmission by bit rate to achieve dynamic adjustment of sampling interval; Step 2: Realize efficient data collection of MCU through alternating storage and transmission of dual-channel registers; Step 3: Realize real-time monitoring and transmission of motor parameters through the host computer data request mechanism.
2. A motor parameter monitoring method according to claim 1, characterized in that: The step of dynamically adjusting the sampling interval by calculating the time of each data transmission by bit rate comprises: By configuring the hardware timer, ensure that each overflow period is 500μs, and start the sampling operation each time the timer overflows; Calculate the time required for each data transmission based on the current baud rate and dynamically adjust the sampling interval to match the timer overflow period; The synchronization of sampling and transmission is achieved by adjusting the value of n.
3. A motor parameter monitoring method according to claim 2, characterized in that: The step of calculating the time required for each data transmission according to the current baud rate and dynamically adjusting the sampling interval to match the timer overflow period includes: By setting a control loop in the MCU, the current baud rate is obtained in real time, and the time required for each data transmission is calculated according to the current baud rate. The calculation formula for the transmission time is: Where data volume is the number of bytes of data to be sent, and baud rate is the current communication baud rate. When 200 bytes of data are to be sent and the current baud rate is 115Kbps, the transmission time is: Then, the time required for data transmission is calculated, and the value of n is adjusted according to the time, that is, When the transmission time is 17.4ms, the value of n is Therefore, the sampling interval will be adjusted to 35*500μs=17.5ms. Whenever the baud rate changes, the data transmission time is automatically recalculated and the sampling interval n is adjusted.
4. A motor parameter monitoring method according to claim 1, characterized in that: The step of realizing efficient data collection of MCU by alternately storing and transmitting dual-channel registers includes: Create two independent storage areas in the MCU, namely channel 1 and channel 2, and allocate sufficient memory space; Use the current_channel flag to alternate between acquisition and transmission operations; After each transmission is completed, the flag bit is switched so that the two channels perform acquisition and transmission functions alternately.
5. A motor parameter monitoring method according to claim 4, characterized in that: The step of using the current_channel flag to alternately switch between acquisition and transmission operations includes: Use the current_channel flag, 0 means channel 1 is collected and channel 2 is transmitted; 1 means channel 2 is collected and channel 1 is transmitted. In each sampling cycle, according to the flag current_channel, select the channel currently in the "collection" state to store the newly collected motor parameter data. When current_channel is 0, the sampled data is stored in the storage area of channel 1; when current_channel is 1, the data is stored in channel 2. At the same time, select the channel in the transmission state to send the data stored in the previous sampling cycle to the host computer. When current_channel is 0, the data of channel 2 will be transmitted to the host computer through the serial port; when current_channel is 1, the data of channel 1 will be sent. After completing a data transmission, the MCU detects the transmission completion status through transmission interruption or polling. After the transmission is completed, switch the current_channel flag.
6. A motor parameter monitoring method according to claim 1, characterized in that: The step of implementing real-time monitoring and transmission of motor parameters through a host computer data request mechanism includes: The host computer sends data requests to the MCU through a periodic data request mechanism and uses the Modbus communication protocol for communication; According to the current channel flag bit, the MCU reads the motor parameter data from the register channel of the current transmission status and formats it into the data format required by the host computer; After receiving the data packet, the host computer verifies and analyzes the data.
7. A motor parameter monitoring method according to claim 6, characterized in that: The host computer sends a data request to the MCU through a periodic data request mechanism, and the steps of communicating using the Modbus communication protocol include: A periodic data request mechanism is set in the host computer software. The host computer automatically sends data requests to the MCU within the set time interval. The Modbus communication protocol is used when sending data requests. At the same time, the MCU is configured to receive interrupts or polling mechanisms. When the data request signal from the host computer is detected, the current task is immediately interrupted and data response is prepared. Then the MCU reads the collected motor parameter data from the register channel of the current transmission status according to the current channel flag bit.
8. A motor parameter monitoring system, characterized in that: The system comprises: The sampling frequency and transmission synchronization control module is used to calculate the time required for each data transmission according to the communication baud rate and dynamically adjust the motor sampling interval; Dual-channel alternating data acquisition and transmission module, used to create two independent storage channels and perform data acquisition and transmission alternately; The host computer real-time monitoring and data request module is used to periodically send data requests through the host computer, obtain motor parameter data from the MCU in real time, and parse and verify the data to complete the monitoring of the motor operation status.
9. A motor parameter monitoring system according to claim 8, characterized in that: The sampling frequency and transmission synchronization control module includes: The reference time and timer overflow period setting module is used to set the reference time of each motor parameter acquisition of the system to 500μs, and ensure that each overflow period is 500μs by configuring the MCU hardware timer; The sampling interval adjustment module is used to adjust the sampling frequency when necessary, by changing the multiple n of the sampling interval to match different communication baud rates; The baud rate dynamic adjustment module is used to obtain the current communication baud rate in real time and adjust the sampling interval by calculating the data transmission time.
10. The motor parameter monitoring system according to claim 8, characterized in that: The dual-channel alternating data acquisition and transmission module comprises: Dual-channel register storage area creation module, used to create two independent storage areas in the MCU and allocate enough memory space for each channel; The channel switching module is used to use the flag bit current_channel to control which channel is in the acquisition state and which channel is in the transmission state; The acquisition and transmission alternating execution module is used to ensure that while one channel is acquiring data, another channel is transmitting data, thus avoiding conflicts between data acquisition and transmission.