Real-time test method and system for intelligent automobile motor controller algorithm
By using the MFO algorithm in the automotive motor control system to optimize the motor controller algorithm and perform it in real time on the target machine, the problem of not being able to test the motor control system in advance is solved, real-time testing and optimization of the motor controller algorithm is realized, and production efficiency is improved.
Patent Information
- Application Number
- CN202510116514.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-09
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
During the automobile production process, the availability test of the motor control system cannot be carried out in advance, resulting in a long development and testing cycle, which may damage the hardware and cause waste of costs.
The real-time test method of the intelligent automobile motor controller algorithm is adopted, and the motor controller algorithm is optimized through the MFO algorithm and executed in real time on the target machine. The dual-core real-time system and Simulink-RT core are used to convert the algorithm into electrical signal control motors through the integrated board, and the algorithm is tested and iteratively optimized.
Real-time testing and optimization of the motor controller algorithm is realized, reducing the time and cost of motor controller production, and improving production and development efficiency.
Smart Images

Figure CN119960429A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a real-time testing method and system for an intelligent automobile motor controller algorithm, belonging to the technical field of automobile motor control. Background Art
[0002] With the continuous development of new energy vehicles, green industries have gradually become one of the important forces to promote economic and social development. As one of the cores of new energy vehicles, the development and testing of motor controllers is particularly important in the vehicle production process. In the traditional motor controller algorithm development and testing process, if pure mathematical simulation is used, the reliability of the test results is limited because the real controlled object is not introduced. The waterfall serial development method must be integrated after the controller and the underlying algorithm are developed. The development and testing cycle is long, and if the algorithm is unreliable, the hardware may be damaged, resulting in a waste of cost. Summary of the invention
[0003] The purpose of the present invention is to overcome the deficiencies in the prior art and provide a real-time testing method and system for an intelligent automobile motor controller algorithm to solve the problem that the motor control system cannot be tested for availability in advance during the automobile production process.
[0004] To achieve the above object, the present invention is implemented by adopting the following technical solutions:
[0005] In a first aspect, the present invention provides a real-time testing method for an intelligent automobile motor controller algorithm, comprising:
[0006] The motor controller algorithm pre-written in the host machine is optimized through the MFO algorithm;
[0007] Transfer the optimized motor controller algorithm from the host machine to the target machine;
[0008] On the target machine, the received motor controller algorithm is executed in real time using the dual-core real-time system and the Simulink-RT kernel, where the execution order of the motor controller algorithm is scheduled based on the half-partition scheduling algorithm;
[0009] The integrated board installed on the target machine converts the motor controller algorithm executed in real time into electrical signals to control the motor of the controlled vehicle;
[0010] The operation of the motor controller algorithm is tested in real time through the controlled vehicle motor, and the motor control parameters are returned to the host machine for iterative optimization until the optimal motor control parameters are obtained, thereby obtaining the optimal motor controller algorithm and completing the test.
[0011] Furthermore, the dual-core real-time system is implemented by transplanting the Xenomai real-time patch in the Linux kernel and adapting relevant configuration options, compiling, packaging and testing, specifically including: using the patch tool to apply the Xenomai real-time patch to the mainline Linux kernel; configuring the Xenomai kernel, and selecting a call in the Linux system to start the Xenomai real-time kernel.
[0012] Furthermore, the method for connecting the host machine and the target machine includes:
[0013] In the Simulink Real-Time Explorer on the host machine, set the IP address, network card model, and communication protocol, write the configured Simulink Real-Time real-time simulation kernel to the boot disk and start the target machine, connect the host machine and the target machine with a network cable, and configure the corresponding IP addresses in the Simulink Real-Time Explorer on both machines to establish a connection between the host machine and the target machine.
[0014] Furthermore, the execution order of the motor controller algorithm is scheduled based on a half-division scheduling algorithm, including:
[0015] Dividing the tasks of executing the motor controller algorithm into real-time tasks and non-real-time tasks based on the EDF-os algorithm, wherein the tasks include a deadline and a task period;
[0016] The execution order of real-time tasks is determined according to their deadlines, where:
[0017] A set of real-time tasks τ i Has the following properties:
[0018] Worst execution time C i : The maximum time required to complete the task;
[0019] Relative deadline D i : The time point when the task must be completed;
[0020] Minimum release interval P i :τ i The maximum P required between the two releases i time interval;
[0021] Task τ i =(α i ,C i(LK) ,C i(HC) ,T i );
[0022] Among them, α i Indicates the level of the task, α iIncludes low key level mode LK and high key level mode HC; C i(LK) , C i(Hc) They represent the worst execution time of tasks at the corresponding level; α i = LK when C i(LK) =C i(HC) , represents a low-level task; α i =HC when C i(LK) <C i(HC) Indicates a high-level task; T i Indicates the task cycle;
[0023] In the initial low-key level mode, the task is to press C i(LK) Execution, if the task execution time in high criticality mode is higher than C i(LK) , switch the mode to high key level mode and press C i(Hc) Execute the task, the task execution time of the low criticality mode remains unchanged; the corresponding utilization rate of the task is u i ,have The sum of all task utilizations in low criticality mode is U LK It is expressed as:
[0024]
[0025] When switching to the high-criticality level mode, the corresponding utilization rate changes with the high-criticality level execution time. At this time, the sum of the task utilization rates is expressed as:
[0026]
[0027] Task τ i In a system with N homogeneous processors = {P1, P2, ..., P N}Shares i,n for:
[0028]
[0029] Processor P N Processing task τ i Load L i,n for:
[0030]
[0031] Analyze historical data of tasks based on machine learning models to predict the distribution frequency of real-time tasks and non-real-time tasks, task execution processing time, and kernel resource requirements, wherein the kernel resource requirements include the ratio of resource demand peak to mean, and kernel real-time load status;
[0032] Based on the distribution frequency of the real-time tasks and non-real-time tasks, the task execution processing time, and the ratio of the resource demand peak to the mean, the real-time tasks in the high-criticality mode are marked as core fixed tasks, specifically:
[0033] If the task τ i The corresponding s i,n =u i , indicating that the task can be completely divided among processors P N If it is above, it becomes a core fixed task;
[0034] A dynamic real-time event task allocation matrix is constructed based on the real-time load status of the kernel, and non-real-time tasks in low-criticality mode are marked as migratable tasks, specifically:
[0035] If the task τ i The corresponding s i,n i , and L i,n When it is not 1, it means that the task cannot be completely divided among processors P. N above, it is called a transferable task;
[0036] For other tasks not affected by real-time tasks, the original division status is maintained;
[0037] A semi-partitioned scheduling algorithm based on the pre-implanted RM algorithm is used to process periodic real-time tasks, wherein the RM algorithm is used to assign priorities based on the period of the tasks to determine the execution order of the real-time tasks in the semi-partitioned scheduling algorithm;
[0038] In the partition scheduling area, high-priority real-time tasks directly seize resources for execution when the cycle arrives;
[0039] Based on the RM algorithm priority rules, determine the schedulability of the migration task, specifically:
[0040] In low criticality mode: if the migration task on the same processor is higher than the fixed task; or there are multiple migration tasks or fixed tasks on the same processor, the migration task selects the processor that is not the first selected processor to execute with the highest priority, and the fixed task determines the priority according to the EDF algorithm;
[0041] In high-criticality mode: if there is a high-level task on the same processor as the fixed task, its priority is the highest. If they are both low-level or high-level tasks, their priorities are determined by deadline. If there are multiple migration tasks on the same processor, the task that selects the processor other than the first selected processor will be executed with the highest priority.
[0042] Furthermore, the method also includes: using the C-MEX-S-function in Matlab to write drivers for each module on the integrated board, so that it can convert digital signals from the target machine into analog signals, and encapsulate them into graphical modules and import them into the Simulink library.
[0043] Furthermore, the method also includes tailoring the Linux system, specifically: running the Matlab / Simulink environment, analyzing the current calling degree of each Linux kernel module through a system call tracking tool, extracting the kernel calling situation related to the Matlab / Simulink running environment, finding the kernel module with extremely low calling correlation, automatically adding error code to its source code, obtaining the abnormal source code processing file, recompiling and running the test in a virtual machine, until a tailored Linux system with a small size and meeting the requirements of stably running the Matlab / Simulink environment on the target machine is obtained.
[0044] Furthermore, the host machine and the target machine are computers that can run Matlab / Simulink environment and comply with TCP / IP protocol.
[0045] In a second aspect, the present invention provides a real-time testing system for an intelligent automobile motor controller algorithm, comprising:
[0046] The host machine is used to write the motor controller algorithm of the controlled vehicle in the Simulink environment; wherein the motor controller algorithm is optimized by the MFO algorithm;
[0047] The target machine is connected to the host machine and is used to receive and run the motor controller algorithm transmitted by the host machine;
[0048] The dual-core real-time system and Simulink-RT kernel are installed on the target machine to execute the motor controller algorithm in real time. The execution order of the motor controller algorithm is scheduled based on the half-partition scheduling algorithm.
[0049] The integrated board is installed on the target machine, connected to the target machine through the PCIE bus, and connected to the controlled vehicle motor. It is used to convert the motor controller algorithm executed by the dual-core real-time system into an electrical signal to control the controlled vehicle motor. The controlled vehicle motor tests the operation of the motor controller algorithm in real time, and returns the control parameters of the motor to the host machine for iterative optimization until the optimal motor control parameters are obtained, thereby obtaining the optimal motor controller algorithm and completing the test.
[0050] Furthermore, the device also includes: a dual-machine real-time communication system for realizing rapid data transmission between the host machine and the target machine.
[0051] Furthermore, the Simulink-RT kernel is used to process real-time simulation and testing. The Simulink-RT kernel provides a lightweight and portable real-time kernel. The real-time kernel enables the target machine to receive the motor controller algorithm transmitted from the host machine through the TCP / IP protocol via Ethernet.
[0052] Compared with the prior art, the present invention has the following beneficial effects:
[0053] The present invention provides a real-time testing method and system for an intelligent automobile motor controller algorithm. The method transfers a motor controller algorithm generated by a host machine to a target machine, and then drives the motor controller algorithm by an integrated board carried on the target machine. The target machine implements the execution of the algorithm through a driving circuit to control a controlled motor. The motor controller algorithm is re-optimized and re-tested by feedback of control parameters of the motor from the controlled automobile. There is no need to wait for the physical motor controller to be fully produced before testing the motor controller algorithm, which greatly reduces the time and cost of motor controller production and improves the production and development efficiency of the motor controller. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 A schematic diagram of the structure of a dual-core real-time system provided by an embodiment of the present invention;
[0055] Figure 2 A flow chart of a real-time testing method for an intelligent automobile motor controller algorithm provided by an embodiment of the present invention;
[0056] Figure 3 Schematic diagram of a real-time test system for an intelligent automobile motor controller algorithm provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0057] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.
[0058] Embodiment 1: This embodiment introduces a real-time testing method for an intelligent automobile motor controller algorithm, comprising:
[0059] The motor controller algorithm pre-written in the host machine is optimized through the MFO algorithm;
[0060] Transfer the optimized motor controller algorithm from the host machine to the target machine;
[0061] On the target machine, the received motor controller algorithm is executed in real time using the dual-core real-time system and the Simulink-RT kernel, where the execution order of the motor controller algorithm is scheduled based on the half-partition scheduling algorithm;
[0062] The integrated board installed on the target machine converts the motor controller algorithm executed in real time into electrical signals to control the motor of the controlled vehicle;
[0063] The operation of the motor controller algorithm is tested in real time through the controlled vehicle motor, and the motor control parameters are returned to the host machine for iterative optimization until the optimal motor control parameters are obtained, thereby obtaining the optimal motor controller algorithm and completing the test.
[0064] The real-time testing method for the intelligent automobile motor controller algorithm provided in this embodiment specifically involves the following steps:
[0065] like Figure 3 As shown, this embodiment provides a real-time testing system for an intelligent automobile motor controller algorithm, the system comprising: a host machine, a target machine, an integrated board installed on the target machine and a controlled motor of a controlled automobile, the target machine being equipped with a dual-core real-time system and a Simulink-RT kernel.
[0066] The host machine is connected to the target machine, the target machine is connected to the integrated board through a PCIE bus, and the integrated board is connected to a controlled motor of a controlled car through a designed driving circuit.
[0067] The control algorithm of the controlled motor is written by the host machine in the Simlulink environment and transmitted to the target machine through the TCP / IP protocol. The dual-core real-time system and Simulink-RT kernel on the target machine can execute the real-time algorithm through the integrated board, and then driven by the drive circuit on the integrated board, providing electrical signals in real time to control the controlled vehicle motor;
[0068] The host machine and the target machine in this embodiment can both run the Matlab / Simulink environment and comply with the TCP / IP protocol.
[0069] Configure the corresponding IP addresses in the Simulink Real-Time Explorer of the host and target machines to form a dual-machine connection. Set the IP address, network card model, and communication protocol in the Simulink Real-Time Explorer of the host machine, write the configured Simulink Real-Time real-time simulation kernel to the boot disk and start the target machine.
[0070] The Simulink-RT kernel is a real-time kernel used to handle real-time simulation and testing. It can provide a lightweight and portable real-time kernel. The Simulink-RT kernel can transmit the motor controller algorithm from the host machine to the target machine through the TCP / IP protocol via Ethernet.
[0071] Before installing the integrated board, the C-MEX-S-function in Matlab is used to write drivers for each module on the integrated board, so that it can convert digital signals from the target machine into analog signals; and using the encapsulation of the S-function, it is encapsulated into a graphical module and imported into the Simulink library for easy reuse and classification.
[0072] like Figure 1 As shown, the dual-core real-time system includes the Linux kernel and the Xenomai real-time kernel. By transplanting the Xenomai real-time patch in the Linux kernel, adapting the relevant configuration options, compiling, packaging and testing, it can handle real-time tasks and non-real-time tasks. It includes: using the patch tool to apply the Xenomai real-time patch to the mainline micro Linux kernel; configuring the Xenomai kernel, selecting and calling it in the Linux kernel, and starting the Xenomai real-time kernel.
[0073] The Linux kernel involves system tailoring, including:
[0074] Linux kernel runs Matlab / Simulink environment, and uses system call tracking tools to track and analyze the calling degree of each Linux kernel module, extract the kernel calling situation related to Matlab / Simulink running environment, and improve the accuracy of data through repeated analysis;
[0075] Based on the obtained kernel call situation, find the kernel module with extremely low call correlation in the Linux kernel module, automatically add error code to its source code, and obtain the abnormal source code processing file; recompile the abnormal source code file, import it into the virtual machine, run it, and give it the Simulink operating environment to test whether it can stably run the Matlab / Simulink environment;
[0076] Repeat the above steps to obtain a Linux kernel that is small in size and can maintain a stable Matlab / Simlink environment on the target machine.
[0077] The dual-core real-time system is used to improve the target machine to test the receiving algorithm, which includes a topological transformation of the EDF-os algorithm (Earliest Deadline First-Offset Scheduling, which takes into account the offset of the task on the basis of the earliest deadline first algorithm EDF) in the semi-partitioned scheduling algorithm of the mixed critical system, including:
[0078] S1. Define parameters
[0079] Based on the EDF-os algorithm, relevant parameters are clearly defined; tasks with time constraints, including deadlines and task cycles, are classified as real-time tasks; tasks without time constraints are classified as non-real-time tasks; the execution order of tasks is arranged according to their deadlines, and the tasks with closer deadlines have higher priorities.
[0080] A set of real-time tasks τ i Has the following properties:
[0081] Worst execution time C i : The maximum time required to complete the task;
[0082] Relative deadline D i : The time point when the task must be completed;
[0083] Minimum release interval R i :τ i A minimum time interval is required between releases;
[0084] The received task τ in the dual-core real-time system i =(α i ,C i(LK) ,C i(HC) ,T i );
[0085] Among them, α i Indicates the level of the task, α i Includes low key level mode LK and high key level mode HC; C i(LK) , C i(Hc) They represent the worst execution time of tasks at the corresponding level; α i = LK when C i(LK) =C i(HC) , represents a low-level task; α i =HC when C i(LK) <C i(HC) Indicates a high-level task; T i Indicates the task cycle.
[0086] The dual core real-time system is in initial low critical level mode, and the task is to press C i(LK) Execution, if the execution time of the high-criticality task is higher than C i(LK) , then switch the mode to high key level and press C i(Hc) Execute tasks, the execution time of low-criticality tasks remains unchanged; further introduce task utilization u i , to measure the algorithm's utilization of dual-core real-time system resources and processors. The utilization definitions in the two modes are
[0087] The sum of all task utilizations in low criticality mode is expressed as:
[0088]
[0089] When switching to the high-criticality level mode, the corresponding utilization rate changes with the high-criticality level execution time. At this time, the sum of the task utilization rates is expressed as:
[0090]
[0091] Task τ i In a system with N homogeneous processors = {P N = {P1,P2,…,P N}}Shares i,n for:
[0092] ∑ 1≤n≤N s i,n =u i (3);
[0093] Processor P N Processing task τ i Load L i,n for:
[0094]
[0095] S2, based on the EDF-os algorithm, the topological task division stage task analysis is carried out, and the real-time tasks and non-real-time tasks are further classified and analyzed. The specific contents are as follows:
[0096] S2.1 Analyze historical data based on machine learning models and predict the distribution frequency of real-time tasks and non-real-time tasks, task execution processing time, and kernel resource requirements; establish a task perception and classification engine based on the analysis results of the machine learning model; classify and identify the real-time and non-real-time tasks of the historical vehicle system, and when the dual-core real-time system starts running and receives real-time signals, quickly analyze and match similar historical data through task identification, so as to quickly classify the real-time tasks received by the dual-core real-time system into corresponding critical levels;
[0097] S2.2 Based on the intelligent prediction and classification engine established in S2.1, for real-time high-criticality tasks, the historical data output is analyzed based on the machine learning model, and the historical execution time fluctuations, resource demand peak and average ratio and other multi-dimensional factors are marked as core fixed events; through the definition of core fixed events, the dual-core real-time system is guaranteed to quickly identify and execute key tasks during operation;
[0098] If the task τ i The corresponding s i,n =u i, indicating that the task can be completely divided among processors P N If it is above, it becomes a core fixed task;
[0099] S2.3 For sudden real-time tasks, the tasks can be migrated to the nearest idle processor core based on the job boundary migration rule; the execution processing priority of the migratable tasks is higher than the core fixed time described in S2.2, and the migrating tasks based on the job boundary migration rule perform corresponding data processing by entering the migration task execution function;
[0100] If the task τ i The corresponding s i< u i , and L i,n When it is not 1, it means that the task cannot be completely divided among processors P. N above, it is called a transferable task;
[0101] S2.4 For non-real-time low-criticality tasks, according to the real-time load status of the system kernel, that is, in S1, the sum of the utilization rates of all tasks in the low-criticality mode in formula (1) is U LK , Formula (2) switches to the sum of task utilization in high criticality mode U HC , Formula (4) Processor task load L i,n , analyze the real-time load status of the dual-core real-time system processor and assign tasks to corresponding matrix positions according to the real-time load status of the processor core to construct a dynamic real-time event task allocation matrix;
[0102] Matrix element a NI Indicates processor P N With the task τ i The distribution relationship, if the distribution is a NI =1, if not assigned then a NI =0;
[0103] Then the task allocation matrix A can be expressed as:
[0104]
[0105] S2.5 After completing S2.1-S2.4 for processing rules of different types of tasks, the task perception and classification engine constructed based on the machine learning model analysis of historical data described in S2.1 will maintain the original classification status for other tasks not affected by real-time tasks to reduce system resource consumption;
[0106] S2.6 Introducing the backup scheduling algorithm
[0107] The RM algorithm can be embedded in the semi-partitioning scheduling algorithm to handle periodic real-time tasks. The RM algorithm assigns priorities based on the period of the task to determine the execution order of the real-time tasks in the semi-partitioning scheduling algorithm;
[0108] In the partition scheduling area, high-priority real-time tasks directly seize resources for execution when the cycle arrives; at the same time, based on the RM algorithm priority rules, the schedulability of the migration task is determined; this scheduling algorithm module is used as a backup algorithm to cooperate with the original kernel scheduling algorithm in the dual-core real-time system to schedule real-time tasks on the processor, providing a guarantee mechanism for system task scheduling;
[0109] S3, dual-core real-time system task scheduling mode
[0110] After completing the topological task division and related rule formulation of the EDF-os algorithm in S1-2, based on the worst task execution time described in S1, the task flow under the kernel scheduling algorithm in the dual-core real-time system includes two dual-core real-time system task scheduling modes: low criticality level mode and high criticality level mode. The dual criticality level mode distinguishes different task priorities to achieve efficient processing of real-time tasks: the task priority rules of low criticality level mode and high criticality level mode are as follows:
[0111] In low-level mode: migration tasks on the same processor have higher priority than fixed tasks; if there are multiple migration tasks or fixed tasks on the same processor, the migration task selects the processor that is not the first selected processor and executes it with the highest priority, and the fixed task determines its priority according to the kernel scheduling algorithm configured by the dual-core real-time system.
[0112] In high-level mode: if there is a high-level task on the same processor, the fixed task has the highest priority. If they are both low-level or high-level tasks, their priorities are determined by deadline. If there are multiple migration tasks on the same processor, the task that selects the processor other than the first selected processor will be executed with the highest priority.
[0113] S4. Real-time task scheduling and allocation
[0114] The dual-core real-time system receives the real-time task transmitted by the vehicle body sensor, and based on the core scheduling algorithm and scheduling rules described in steps S1-S3, schedules and allocates the real-time task to the processor in the dual-core real-time system for fast task processing and next stage execution.
[0115] The contents involved in the above embodiment are described below in conjunction with a preferred embodiment.
[0116] This embodiment provides a real-time test method for an automobile motor control system based on an MFO algorithm (Moth-Flame Optimization Algorithm is a new type of group intelligent optimization algorithm). The MFO algorithm can iterate known parameters according to set rules, which is suitable for the present invention, and the motor controller algorithm needs to be repeatedly tested. According to the MFO algorithm, the present invention can be used on the host machine to iterate the algorithm to be tested multiple times, and then the iterated algorithm is transferred to the target machine using Ethernet and SimulinkRT. The target machine controls the controlled motor and obtains the performance of the algorithm execution. Repeat this step until the optimal motor control parameters are reached, which is characterized by the following specific steps:
[0117] Step S1, PI fuzzy controller, comprising:
[0118] S1.1 Input and output variable determination
[0119] According to the parameters required by the PI fuzzy controller, appropriate input variables are selected to reflect the operating status of the motor so that the fuzzy controller can make reasonable control decisions based on this information. At the same time, appropriate output variables are determined to correct the key parameters of the PI controller to achieve the optimal control effect of the motor.
[0120] Select the speed error of the motor in is the given mechanical angular velocity) and the rate of change of speed error As the input variable of the fuzzy controller, the output variable is the proportional coefficient correction value ΔK of the PI controller p And the integral coefficient correction ΔK i ;
[0121] S1.2 Fuzzification
[0122] The precise input and output variables are converted into fuzzy sets so that fuzzy logic can be used for reasoning and control, enabling the controller to process information with uncertainty and fuzziness and better adapt to the complex characteristics of the motor control system.
[0123] According to the input and output variables determined in S1.1, set e, ec, Δk p and ΔK i Fuzzy sets; for example, e and ec can be divided into seven fuzzy sets {NB, NM, NS, ZO, PS, PM, PB}, and the domain can be set according to the actual operation of the motor. For example, the domain of e is [-e max ,e max ], the domain of ec is [-ec max ,ec max ]; Output ΔK p and ΔKi The fuzzy sets of can also be divided similarly, and the domain is determined based on experience and actual debugging;
[0124] S1.3 Formulation of fuzzy rule table
[0125] Based on the experience and knowledge of motor control, including the technical manuals provided by the motor manufacturer, the debugging records of similar motor control systems in the past, and relevant practice summaries, a logical relationship between the input variables (speed error and speed error change rate) and the output variables (proportional coefficient correction and integral coefficient correction) is established, so that the fuzzy controller can make reasonable control decisions based on the input fuzzy information and achieve effective control of the motor.
[0126] According to the relationship between the input and output variables in S1.1, a fuzzy rule table is formulated based on motor control experience. The rule table reflects the basic principles and experience of motor control. For example, when the speed error is large and the error change rate is also large (such as when the motor starts), the proportional coefficient and integral coefficient should be greatly increased to quickly increase the motor speed; when the speed error is close to zero and the error change rate is also small, the proportional coefficient and integral coefficient should be appropriately reduced to avoid overshoot in the system. The establishment of the fuzzy rule table enables the fuzzy controller to simulate human control thinking, flexibly adjust the control strategy according to the actual operation of the motor, improve the adaptability and robustness of the motor control system, and ensure that the motor can operate stably and have good performance under various working conditions.
[0127] S1.4 Fuzzy reasoning and clarification
[0128] In order to improve the accuracy of the fuzzy set, the Mamdani fuzzy reasoning method is used to obtain ΔK p and ΔK i The fuzzy output is then clarified using the centroid method to obtain the actual correction amount.
[0129] Step S2, optimization based on the MFO algorithm, includes:
[0130] S2.1 Determination of parameters to be optimized
[0131] It is necessary to identify which parameters in the PI fuzzy controller have a key impact on the motor control performance, and take these parameters as the objects to be optimized so as to find the optimal parameter combination through the MFO algorithm and improve the overall performance of the motor control system.
[0132] According to the parameters related to the input and output variables in the fuzzy controller in S1, such as the parameters of the e and ec membership functions (such as the key point values of the division domain) and some key coefficients in the fuzzy rule table (the rule table can be encoded) are used as the parameters to be optimized. Suppose the parameter vector to be optimized is X = (X = {x1, x2, ..., x m}), where m is the number of parameters to be optimized.
[0133] S2.2 Fitness function design
[0134] According to the input and output parameters and fuzzy table in S1, a standard for measuring the quality of motor controller parameters is established so that the MFO algorithm can guide the search direction according to the fitness value and find the parameter combination that makes the motor control system perform best. The fitness function is introduced:
[0135]
[0136] Where, σ is the speed overshoot, t s To adjust the time, e ss is the steady-state error, i d (k), i q (k) is the d-axis and q-axis current at different times, and ω1-ω5 are weight coefficients, which are set according to the importance attached to different performance indicators.
[0137] S3 Figure 2 As shown in Figure 2, MFO algorithm parameter setting and optimization process
[0138] S3.1 Set the parameters of the MFO algorithm: population size N, maximum number of iterations T, spiral constant b, etc.
[0139] S3.2 Initialize the position of the moth population, that is, randomly initialize the parameter vector to be optimized X = {x1, x2, ..., x m}.
[0140] S3.3 applies the parameters to the PI fuzzy motor control algorithm.
[0141] S3.4 The target machine executes the algorithm, controls the controlled motor, obtains the performance indicators of the motor, and calculates the fitness value Fitness.
[0142] S3.5 determines whether the error and performance indicators meet the requirements. If they do, the target optimization controller algorithm is obtained. If not, S3.6 is executed.
[0143] S3.6 Update the flame (current optimal solution) position: find the moth position with the smallest fitness value as the flame position
[0144] Moth position update: Update the formula according to the moth position Update the moth position, where t is a random number uniformly distributed between [-1, 1]. S3.4 is then executed again until the error and performance indicators meet the requirements.
[0145] The present invention discloses a real-time algorithm testing technology. By building a dual-machine real-time communication system, the algorithm generated by the host machine can be transferred to the target machine using the TCP / IP protocol and Simulink-RT. The algorithm is then driven by the integrated board on the target machine. The target machine implements the execution of the algorithm through the driving circuit to control the controlled motor. Compared with the traditional automobile motor controller algorithm testing method, the present method has stronger real-time performance. The host machine receives the feedback signal of the controlled automobile motor, so that the algorithm can be re-optimized and re-tested in real time. There is no need to wait for the physical motor controller to be fully produced before testing the algorithm of the motor control system. This effectively reduces the time and cost of motor controller production and improves the production and development efficiency of the motor controller.
[0146] Embodiment 2: This embodiment provides a real-time testing system for an intelligent automobile motor controller algorithm, comprising:
[0147] The host machine is used to write the motor controller algorithm of the controlled vehicle in the Simulink environment; wherein the motor controller algorithm is optimized by the MFO algorithm;
[0148] The target machine is connected to the host machine and is used to receive and run the motor controller algorithm transmitted by the host machine;
[0149] The dual-core real-time system and the Simulink-RT kernel are mounted on the target machine and used for real-time execution of the motor controller algorithm; wherein the execution order of the motor controller algorithm is scheduled based on the half-partition scheduling algorithm; the Simulink-RT kernel is used for processing real-time simulation and testing, and the Simulink-RT kernel provides a lightweight and portable real-time kernel, and the real-time kernel enables the target machine to receive the motor controller algorithm transmitted from the host machine through the TCP / IP protocol through Ethernet;
[0150] An integrated board is installed on the target machine, connected to the target machine through a PCIE bus, and connected to the controlled vehicle motor, and is used to convert the motor controller algorithm executed by the dual-core real-time system into an electrical signal to control the controlled vehicle motor, wherein the controlled vehicle motor tests the operation of the motor controller algorithm in real time, and returns the control parameters of the motor to the host machine for iterative optimization until the optimal motor control parameters are obtained, thereby obtaining the optimal motor controller algorithm and completing the test;
[0151] A dual-machine real-time communication system is used to achieve fast data transmission between the host machine and the target machine.
[0152] The specific functions of the above components are implemented by referring to the relevant contents of the method in Example 1 and will not be elaborated here.
[0153] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A real-time testing method for an intelligent automobile motor controller algorithm, characterized in that: include: The motor controller algorithm pre-written in the host machine is optimized through the MFO algorithm; Transfer the optimized motor controller algorithm from the host machine to the target machine; On the target machine, the received motor controller algorithm is executed in real time using the dual-core real-time system and the Simulink-RT kernel, where the execution order of the motor controller algorithm is scheduled based on the half-partition scheduling algorithm; The integrated board installed on the target machine converts the motor controller algorithm executed in real time into electrical signals to control the motor of the controlled vehicle; The operation of the motor controller algorithm is tested in real time through the controlled vehicle motor, and the motor control parameters are returned to the host machine for iterative optimization until the optimal motor control parameters are obtained, thereby obtaining the optimal motor controller algorithm and completing the test.
2. The real-time testing method of the intelligent automobile motor controller algorithm according to claim 1 is characterized in that: The dual-core real-time system is implemented by transplanting the Xenomai real-time patch in the Linux kernel and adapting relevant configuration options, compiling, packaging and testing, specifically including: using the patch tool to apply the Xenomai real-time patch to the mainline Linux kernel; configuring the Xenomai kernel, and selecting and calling it in the Linux system to start the Xenomai real-time kernel.
3. The real-time testing method of the intelligent automobile motor controller algorithm according to claim 1 is characterized in that: The method for connecting the host machine and the target machine comprises: In the Simulink Real-Time Explorer on the host machine, set the IP address, network card model, and communication protocol, write the configured Simulink Real-Time real-time simulation kernel to the boot disk and start the target machine, connect the host machine and the target machine with a network cable, and configure the corresponding IP addresses in the Simulink Real-Time Explorer on both machines to establish a connection between the host machine and the target machine.
4. The real-time testing method of the intelligent automobile motor controller algorithm according to claim 1 is characterized in that: The execution order of the motor controller algorithm is scheduled based on a half-partition scheduling algorithm, including: Dividing the tasks of executing the motor controller algorithm into real-time tasks and non-real-time tasks based on the EDF-os algorithm, wherein the tasks include a deadline and a task period; The execution order of real-time tasks is determined according to their deadlines, where: A set of real-time tasks τ i Has the following properties: Worst execution time C i : The maximum time required to complete the task; Relative deadline D i : The time point when the task must be completed; Minimum release interval P i :τ i The maximum P required between the two releases i time interval; Task τ i =(α i , C i(LK) , C i(HC) , T i ); Among them, α i Indicates the level of the task, α i Includes low key level mode LK and high key level mode HC; C i(LK) , C i(Hc) They represent the worst execution time of tasks at the corresponding level; α i = LK when C i(LK) =C i(HC) , represents a low-level task; α i =HC when C i(LK) <C i(HC) Indicates a high-level task; T i Indicates the task cycle; In the initial low-key level mode, the task is to press C i(LK) Execution, if the task execution time in high criticality mode is higher than C i(LK) , switch the mode to high key level mode and press C i(Hc) Execute the task, the task execution time of the low criticality mode remains unchanged; the corresponding utilization rate of the task is u i ,have The sum of all task utilizations in low criticality mode is U LK It is expressed as: When switching to the high-criticality level mode, the corresponding utilization rate changes with the high-criticality level execution time. At this time, the sum of the task utilization rates is expressed as: Task τ i In a system with N homogeneous processors = {P1, P2, ..., P N }Shares i,n for: Processor P N Processing task τ i Load L i,n for: Analyze historical data of tasks based on machine learning models to predict the distribution frequency of real-time tasks and non-real-time tasks, task execution processing time, and kernel resource requirements, wherein the kernel resource requirements include the ratio of resource demand peak to mean, and kernel real-time load status; Based on the distribution frequency of the real-time tasks and non-real-time tasks, the task execution processing time, and the ratio of the resource demand peak to the mean, the real-time tasks in the high-criticality mode are marked as core fixed tasks, specifically: If the task τ i The corresponding s i,n =u i , indicating that the task can be completely divided among processors P N If it is above, it becomes a core fixed task; A dynamic real-time event task allocation matrix is constructed based on the real-time load status of the kernel, and non-real-time tasks in low-criticality mode are marked as migratable tasks, specifically: If the task τ i The corresponding s i,n i , and L i,n When it is not 1, it means that the task cannot be completely divided among processors P. N above, it is called a transferable task; For other tasks not affected by real-time tasks, the original division status is maintained; A semi-partitioned scheduling algorithm based on the pre-implanted RM algorithm is used to process periodic real-time tasks, wherein the RM algorithm is used to assign priorities based on the period of the tasks to determine the execution order of the real-time tasks in the semi-partitioned scheduling algorithm; In the partition scheduling area, high-priority real-time tasks directly seize resources for execution when the cycle arrives; Based on the RM algorithm priority rules, determine the schedulability of the migration task, specifically: In low criticality mode: if the migration task on the same processor is higher than the fixed task; or there are multiple migration tasks or fixed tasks on the same processor, the migration task selects the processor that is not the first selected processor to execute with the highest priority, and the fixed task determines the priority according to the EDF algorithm; In high-criticality mode: if there is a high-level task on the same processor as the fixed task, its priority is the highest. If they are both low-level or high-level tasks, their priorities are determined by deadline. If there are multiple migration tasks on the same processor, the task that selects the processor other than the first selected processor will be executed with the highest priority.
5. The real-time testing method of the intelligent automobile motor controller algorithm according to claim 1 is characterized in that: The method also includes: using C-MEX-S-functions in Matlab to write drivers for various modules on the integrated board, so that the modules can convert digital signals from the target machine into analog signals, and encapsulate them into graphical modules and import them into the Simulink library.
6. The real-time testing method of the intelligent automobile motor controller algorithm according to claim 2 is characterized in that: The method also includes tailoring the Linux system, specifically: running the Matlab / Simulink environment, analyzing the calling degree of each current Linux kernel module through a system call tracking tool, extracting the kernel calling situation related to the Matlab / Simulink running environment, finding the kernel module with extremely low calling correlation, automatically adding error code to its source code, obtaining an abnormal source code processing file, recompiling and running a test in a virtual machine, until a tailored Linux system with a small size and meeting the requirements of stably running the Matlab / Simulink environment on a target machine is obtained.
7. The real-time testing method of the intelligent automobile motor controller algorithm according to claim 1 is characterized in that: The host machine and the target machine are computers that can run Matlab / Simulink environment and comply with TCP / IP protocol.
8. A real-time test system for intelligent automobile motor controller algorithm, characterized in that: include: The host machine is used to write the motor controller algorithm of the controlled vehicle in the Simulink environment; wherein the motor controller algorithm is optimized by the MFO algorithm; A target machine, connected to the host machine, for receiving and running the motor controller algorithm transmitted by the host machine; The dual-core real-time system and Simulink-RT kernel are installed on the target machine to execute the motor controller algorithm in real time. The execution order of the motor controller algorithm is scheduled based on the half-partition scheduling algorithm. The integrated board is installed on the target machine, connected to the target machine through the PCIE bus, and connected to the controlled vehicle motor. It is used to convert the motor controller algorithm executed by the dual-core real-time system into an electrical signal to control the controlled vehicle motor. The controlled vehicle motor tests the operation of the motor controller algorithm in real time, and returns the control parameters of the motor to the host machine for iterative optimization until the optimal motor control parameters are obtained, thereby obtaining the optimal motor controller algorithm and completing the test.
9. The real-time testing system for the intelligent automobile motor controller algorithm according to claim 8 is characterized in that: The device also includes: a dual-machine real-time communication system for realizing rapid data transmission between the host machine and the target machine.
10. The real-time testing system for the intelligent automobile motor controller algorithm according to claim 8, characterized in that: The Simulink-RT kernel is used to process real-time simulation and testing. The Simulink-RT kernel provides a lightweight and portable real-time kernel. The real-time kernel enables the target machine to receive the motor controller algorithm transmitted from the host machine through the TCP / IP protocol via Ethernet.