Digital twin communication method for electric vehicle motor
Through the combination of Raspberry Pi and digital twin technology, data acquisition and communication problems of electric vehicle motor systems are solved, real-time monitoring and intelligent control are realized, and the real-time and user experience of the system are improved.
Patent Information
- Application Number
- CN202510689004.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-08-29
AI Technical Summary
Traditional electric vehicle motor systems have inconvenient data acquisition and insufficient real-time performance, and existing data communication systems cannot achieve efficient monitoring and intelligent control.
Using Raspberry Pi and digital twin technology, the motor MCU and Raspberry Pi are connected through CAN communication, and Ethernet is established to connect the Raspberry Pi and the cloud server, data processing is used using the digital twin model, and the motor operation is monitored in real time on the Labview visualization platform, combining database storage and TCP protocol for data transmission.
Real-time monitoring and intelligent control of electric vehicle motor systems is realized, the efficiency and performance of the system is improved, remote management and fault diagnosis support is provided, and user experience is improved.
Smart Images

Figure CN120567883A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of motors, and in particular relates to a digital twin communication method for electric vehicle motors. Background Art
[0002] With the increasing popularity of electric vehicles, motor monitoring and control have become increasingly important. Traditional electric vehicle motor systems typically rely on decentralized sensors and controllers for monitoring and control, resulting in issues such as inconvenient data collection and insufficient real-time performance. Furthermore, existing data communication systems face challenges in the electric vehicle sector, hindering efficient monitoring and intelligent control of motor operating conditions. Summary of the Invention
[0003] This invention aims to address the challenges of the prior art by proposing a digital twin communication method for electric vehicle motors. Combining Raspberry Pi and digital twin technology, this method can be used to implement real-time monitoring, analysis, and intelligent control of the operating status of electric vehicle motors, thereby improving system efficiency and performance.
[0004] The present invention is implemented through the following technical solutions. The present invention proposes a digital twin communication method for electric vehicle motors, the method comprising:
[0005] CAN communication connection between the motor MCU and the Raspberry Pi: The motor MCU and the Raspberry Pi use CAN communication to simulate the actual vehicle system;
[0006] Ethernet connection between the Raspberry Pi and the cloud server: The Raspberry Pi and the cloud server are connected via Ethernet. Ensure that both parties are on the same local area network or connected via the Internet.
[0007] Data processing: Data processing is performed on the receiving program of the cloud server. The "socket.recv()" function is used to receive data sent by the Raspberry Pi. A "break" statement is also attached. If no data or data stream is received, the `break` statement will terminate the current loop. During the data processing process, the raw data is generated and displayed through the built digital twin model.
[0008] Database establishment: The database is used to store various data in the digital twin model. After the data is decoded in the cloud program, the function "pymysql.connect()" provided by the pymysql module is used to connect to the MySQL database in Python;
[0009] Labview visualization platform: View the real-time operation results of the electric vehicle motor system on the Labview visualization platform.
[0010] Furthermore, the motor MCU sends the real-time collected motor operation data to the Raspberry Pi in the form of a string (str) data type via CAN communication; after the Raspberry Pi receives these raw string data, it converts them into a byte type for subsequent Ethernet data communication with the cloud server.
[0011] Furthermore, a communication protocol is established between the motor MCU and the Raspberry Pi. A TCP-based server socket is created using Python, specifying the use of IPv4 protocol. By creating this TCP server socket object, the server listens for client connection requests and establishes a TCP connection with the client for communication.
[0012] Furthermore, the "bind()" function is used to bind the socket to a specific IP address and port number; the IP address and port number are unified to ensure accurate connection between them; when the IP addresses are not under the same subnet mask or the port numbers are not unified, the connection is unsuccessful and closed.
[0013] Furthermore, the listen() function is used to listen for connection requests. Setting it to 1 means that the server can queue up at most one client connection request. If multiple clients try to connect to the server but the connection queue is full, subsequent connection requests will be rejected or wait until there is a vacancy in the queue.
[0014] Furthermore, the `accept()` function receives the client's connection request, establishes a connection, and exchanges data; when the connection is successful, the Raspberry Pi can successfully send the data to the console of the Python program in the cloud.
[0015] Furthermore, during data processing, the hexadecimal numbers are converted to decimal numbers as required, and these data are converted into the required motor operation data through a custom decoding function. At the same time, a data_displayed.csv file is generated, in which every 10th received data row is written in a clear-to-zero manner for subsequent reading by the Labview visualization platform.
[0016] Furthermore, through the connection with the Raspberry Pi and the cloud server, the Labview visualization platform can read the data_displayed.csv file to achieve the effect of receiving and displaying the real-time transmitted motor data.
[0017] The present invention also proposes an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the digital twin communication method for electric vehicle motors when executing the computer program.
[0018] The present invention also proposes a computer-readable storage medium for storing computer instructions, which, when executed by a processor, implement the steps of the digital twin communication method for electric vehicle motors.
[0019] Beneficial effects of the present invention:
[0020] To address the need for monitoring and controlling electric vehicle motor systems, this paper proposes a digital twin communication method for electric vehicle motors. A Raspberry Pi single-board computer (SBC) acts as a data transmission unit, analogous to an onboard domain controller (DC), transmitting data in real time to a cloud server. Combined with digital twin technology, this method enables real-time monitoring, data analysis, and intelligent control of electric vehicle motor systems. By utilizing a digital twin model and establishing a data communication system, this paper improves real-time operational feedback of electric vehicle motor systems and implements intelligent motor control, thereby promoting the development of new energy vehicle technologies.
[0021] The method described in this invention enables real-time monitoring of electric vehicle motor systems, including real-time collection and analysis of motor operating data, temperature, current, and other parameters. Users can adjust and manage the motor system through remote control, improving the efficiency and reliability of the electric vehicle system and enhancing the user experience and convenience. This invention incorporates digital twin technology, enabling the creation of precise digital models of the motor system, enabling highly accurate simulation and prediction of the actual system. This enhances the system's intelligence and provides powerful support for system optimization and fault diagnosis. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0023] Figure 1 This is the hardware architecture diagram of the electric vehicle motor digital twin communication method of the present invention.
[0024] Figure 2 The flowchart of the digital twin communication method for electric vehicle motors is shown in Figure 2.
[0025] Figure 3 This is a schematic diagram of the specific content of each data transmission.
[0026] Figure 4 This is the first example of the Labview visualization platform rendering.
[0027] Figure 5 This is the second example of the Labview visualization platform rendering. DETAILED DESCRIPTION
[0028] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0029] Combine Figure 1-Figure 5 The present invention proposes a digital twin communication method for electric vehicle motors, the method comprising:
[0030] CAN communication connection between the motor MCU and the Raspberry Pi: The motor MCU and the Raspberry Pi use CAN communication to simulate the actual vehicle system;
[0031] The motor MCU and the Raspberry Pi are physically connected via the CAN communication protocol. High-speed data transmission and reliable communication can be achieved via the CAN bus. The motor MCU collects real-time motor operating data (such as current, speed, temperature, etc.) Figure 3 The data (shown in the figure) is sent to the Raspberry Pi via CAN communication as a string (str) data type. Since the byte type is more efficient than the string type in data transmission, the Raspberry Pi converts the received raw string data into a byte type for subsequent Ethernet data communication with the cloud server. Considering the amount of motor data required by the system, the motor MCU is required to generate a 32-byte hexadecimal string each time it sends data. Since the Raspberry Pi does not have a CAN interface, an MCP2515 hardware add-on board is added to implement the Raspberry Pi's CAN bus communication function. At this point, the Raspberry Pi receives a 32-byte hexadecimal string each time the MCU sends data.
[0032] Ethernet connection between the Raspberry Pi and the cloud server: The Raspberry Pi and the cloud server are connected via Ethernet. Ensure that both parties are on the same local area network or connected via the Internet.
[0033] Establish a communication protocol between the motor MCU and the Raspberry Pi; use Python to create a TCP-based server-side socket, specifying the use of IPv4 protocol; by creating this TCP server-side socket object, listen for client connection requests on the server side and establish a TCP connection with the client for communication.
[0034] Use the "bind()" function to bind the socket to a specific IP address and port number; unify the IP address and port number to ensure accurate connection between them; when the IP addresses are not under the same subnet mask or the port numbers are not unified, the connection is unsuccessful and closed.
[0035] Use the listen() function to listen for connection requests. Setting it to 1 means that the server can queue up at most one client connection request. If multiple clients try to connect to the server, but the connection queue is full (the maximum number of connections set is 1), subsequent connection requests will be rejected or wait until there is a vacancy in the queue.
[0036] The `accept()` function receives the client's connection request, establishes a connection and exchanges data; the communication method diagram is as follows Figure 2 As shown in the figure. Once the connection is successful, the Raspberry Pi can successfully send data to the console of the Python program in the cloud.
[0037] Data processing: Data processing is performed on the receiving program of the cloud server. The "socket.recv()" function is used to receive data sent by the Raspberry Pi. A "break" statement is also attached. If no data or data stream is received, the `break` statement will terminate the current loop. During the data processing process, the raw data is generated and displayed through the built digital twin model.
[0038] In CAN communication, data transmission and parsing are typically performed using hexadecimal notation, ranging from 00 to FF (decimal 0 to 255). Therefore, during data processing, the hexadecimal numbers are converted to decimal as needed. A custom decoding function then converts this data into the required motor operating data (including current, temperature, speed, and other data). A file called "data_displayed.csv" is also generated, in which every tenth received data row is written with a clear-to-zero value for subsequent reading by the LabView visualization platform.
[0039] Establishment of digital twin model of motor: Based on the physical characteristics, operating data and related theories of the motor, this paper constructs a series of digital twin models of the motor in MATLAB. These digital twin models can fully reflect the operating status and performance of the motor under different working conditions. The digital twin model of the motor is divided into (1) parameter identification model; (2) field model including temperature field, electromagnetic field and loss field; the two parts are specifically:
[0040] (1) Parameter identification model based on least squares method: The parameter identification model of the permanent magnet synchronous motor is based on the least squares method. It aims to identify key parameters such as the stator resistance R, stator inductance L, and flux linkage λ of the motor through the input and output data of the motor. The discretized dynamic equation of the permanent magnet synchronous motor can be expressed in the dq coordinate system as follows:
[0041]
[0042] Among them U d,k 、U q,k is the voltage of dq axis at time k, i d,k 、i q,k is the current of dq axis at time k, T s is the sampling period, ω k is the motor angular velocity at time k.
[0043] The sum of the squares of the errors between the model prediction value and the actual measurement value is taken as the objective function J, that is,
[0044]
[0045] The gradient vector of J is Use the gradient descent method to gradually update the parameters until convergence. The iterative formula is:
[0046]
[0047] Where α is the learning rate, which controls the step size of the parameter update. The update process is repeated until convergence is achieved. By following these steps, the parameters R, L, and λ can be gradually optimized to minimize the objective function J. The resulting parameter estimates can be used for accurate modeling and control of the permanent magnet synchronous motor.
[0048] (2) Field model based on finite element data order reduction (ROM) method: By using a method combining finite element data order reduction and neural network fitting in MATLAB, efficient and accurate analysis of temperature field, electromagnetic field and loss field can be achieved, and rapid prediction can be performed under all working conditions.
[0049] First, the finite element method is used to perform detailed numerical simulations of the temperature, electromagnetic, and loss fields. This step generates a large amount of high-dimensional data. The continuous domain is discretized into a finite number of elements to solve the partial differential equations. For the analysis of the temperature, electromagnetic, and loss fields, the finite element analysis can be expressed as:
[0050] Ku=f
[0051] Where K is the stiffness matrix, which represents the system's resistance to deformation or field changes; u is the unknown field variable vector, such as temperature, magnetic flux, or electric potential; and f is the load vector, which represents the external action or source term.
[0052] To reduce computational complexity, high-dimensional data is mapped to a low-dimensional space by extracting the main modes or eigenvectors. The data reduction method uses principal component analysis (PCA), whose goal is to find a set of orthogonal basis vectors (principal components) that maximizes the variance of the data projection on these basis vectors. The mathematical representation of PCA is:
[0053] X=U∑V T
[0054] Where X is the original data matrix; U is the left singular vector matrix whose column vectors are the principal components; ∑ is a diagonal matrix whose diagonal elements are singular values, representing the variance of each principal component; V is the right singular vector matrix whose column vectors are the coordinates of the data in the principal component space.
[0055] Next, a neural network model is constructed and trained using the reduced-order data as input. The neural network learns the mapping between input features and output field distributions, enabling rapid prediction of the motor's operating conditions. Once the model is trained, real-time motor operating data collected by the motor digital twin communication system can be used as input in practical applications to rapidly predict the distribution of the motor's temperature, electromagnetic, and loss fields, eliminating the need for re-running time-consuming finite element analysis.
[0056] Database creation: The database stores various data within the digital twin model, providing a structured and secure way to store collected motor data. After the data is decoded in the cloud program, Python uses the "pymysql.connect()" function provided by the pymysql module to connect to the MySQL database. Other functions in the pymysql library can also be used to read, write, and delete data.
[0057] Labview visualization platform: View the real-time operation results of the electric vehicle motor system on the Labview visualization platform.
[0058] By connecting with the Raspberry Pi and the cloud server, the Labview visualization platform can read the data_displayed.csv file to achieve the effect of receiving and displaying the real-time transmitted motor data. See the effect diagram. Figure 4 、 Figure 5In LabView, you can view key motor parameters such as motor current, speed, and torque, as well as the real-time waveforms of the three-phase current. By establishing a link with MATLAB, you can run the temperature and magnetic field cloud mapping programs in MATLAB in real time to generate real-time temperature and magnetic field cloud maps of the motor. Finally, by connecting to a surveillance camera, you can view the motor's operating status in LabView.
[0059] This invention applies digital twin technology to electric vehicle motor systems, enabling real-time monitoring and data integration, providing a more convenient platform for subsequent data analysis and intelligent control. It establishes an IoT hardware architecture consisting of a "controller → Raspberry Pi → cloud server," enabling remote data transmission and cloud storage. This connection allows users to remotely monitor and manage the motor system, enhancing the system's intelligence and internet-based capabilities.
[0060] The present invention also proposes an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the digital twin communication method for electric vehicle motors when executing the computer program.
[0061] The present invention also proposes a computer-readable storage medium for storing computer instructions, which, when executed by a processor, implement the steps of the digital twin communication method for electric vehicle motors.
[0062] The memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus RAM (DRRAM). It should be noted that the memory of the methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0063] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a high-density digital video disc (DVD)), or a semiconductor medium (eg, a solid state disc (SSD)).
[0064] During implementation, each step of the above method can be completed by an integrated logic circuit of the hardware in the processor or by instructions in the form of software. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in conjunction with its hardware. To avoid repetition, it will not be described in detail here.
[0065] It should be noted that the processor in the embodiments of the present application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiment can be completed by an integrated logic circuit of the hardware in the processor or by instructions in the form of software. The above processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The various methods, steps, and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0066] The above is a detailed introduction to the digital twin communication method for electric vehicle motors proposed in the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A digital twin communication method for electric vehicle motors, characterized in that: The method comprises: CAN communication connection between the motor MCU and the Raspberry Pi: The motor MCU and the Raspberry Pi use CAN communication to simulate the actual vehicle system; Ethernet connection between the Raspberry Pi and the cloud server: The Raspberry Pi and the cloud server are connected via Ethernet. Ensure that both parties are on the same local area network or connected via the Internet. Data processing: Data processing is performed on the receiving program of the cloud server. The "socket.recv()" function is used to receive data sent by the Raspberry Pi. A "break" statement is also added. If no data or data stream is received, the `break` statement will terminate the current loop. During the data processing process, the raw data is generated and displayed through the built digital twin model. Database establishment: The database is used to store various data in the digital twin model. After the data is decoded in the cloud program, the "pymysql.connect()" function provided by the pymysql module is used to connect to the MySQL database in Python. Labview visualization platform: View the real-time operation results of the electric vehicle motor system on the Labview visualization platform.
2. The method according to claim 1, characterized in that The motor MCU sends the real-time motor operation data collected in the form of a string (str) data type to the Raspberry Pi via CAN communication. After receiving the raw string data, the Raspberry Pi converts it into a byte type for subsequent Ethernet data communication with the cloud server.
3. The method according to claim 1, characterized in that Establish a communication protocol between the motor MCU and the Raspberry Pi; use Python to create a TCP-based server-side socket, specifying the use of IPv4 protocol; by creating this TCP server-side socket object, listen for client connection requests on the server side and establish a TCP connection with the client for communication.
4. The method according to claim 3, characterized in that Use the "bind()" function to bind the socket to a specific IP address and port number; unify the IP address and port number to ensure accurate connection between them; when the IP addresses are not under the same subnet mask or the port numbers are not unified, the connection is unsuccessful and closed.
5. The method according to claim 4, characterized in that Use the "listen()" function to listen for connection requests. Setting it to `1` means that the server can queue up at most one client connection request; if multiple clients try to connect to the server but the connection queue is full, subsequent connection requests will be rejected or wait until there is a vacancy in the queue.
6. The method according to claim 5, characterized in that The `accept()` function receives the client's connection request, establishes a connection, and exchanges data. Once the connection is successful, the Raspberry Pi can successfully send data to the console of the Python program in the cloud.
7. The method according to claim 1, characterized in that During data processing, the hexadecimal numbers are converted to decimal numbers as required, and these data are converted into the required motor operation data through a custom decoding function. At the same time, a data_displayed.csv file is generated, in which every 10th received data row is written in a clear-to-zero manner for subsequent reading by the Labview visualization platform.
8. The method according to claim 7, characterized in that By connecting with the Raspberry Pi and the cloud server, the Labview visualization platform can read the data_displayed.csv file to receive and display the motor data transmitted in real time.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
10. A computer-readable storage medium for storing computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.