BLDCM parameter optimization method based on PLC and BP neural network
阅读说明:本技术 基于plc与bp神经网络的bldcm参数优化方法 (BLDCM parameter optimization method based on PLC and BP neural network ) 是由 高琦昕 朱铖 周立波 张永 于 2020-04-29 设计创作,主要内容包括:本发明公开了一种基于PLC与BP神经网络的BLDCM参数优化方法。该方法步骤为:将多个PLC模块组建为PLC工业以太网;建立无刷直流电机在同步参考模型下的离散电压方程,确定神经网络的输入、输出量,并确定电机参考转速和电压、电流的变化范围;采集不同转速下电机电压、电流,发送至无刷直流电机离散电压方程生成输出值,输出值与输入值对应组合成BP神经网络的训练样本;将归一化处理后的训练样本输入已构建的BP神经网络模型中进行离线学习,得到符合要求的权值;在BP神经网络与PLC工业以太网之间建立联络,并交互实时信息;将系统与上位机进行组态,确保系统能够接受转速指令。本发明具有动态特性好、鲁棒性强的优点。(The invention discloses a BLDCM parameter optimization method based on a PLC and a BP neural network. The method comprises the following steps: building a plurality of PLC modules into a PLC industrial Ethernet; establishing a discrete voltage equation of the brushless direct current motor under a synchronous reference model, determining the input and output quantity of a neural network, and determining the reference rotating speed of the motor and the variation range of voltage and current; collecting motor voltage and current at different rotating speeds, sending the motor voltage and current to a brushless direct current motor discrete voltage equation to generate output values, and correspondingly combining the output values and the input values into a training sample of a BP neural network; inputting the training samples after normalization processing into the constructed BP neural network model for off-line learning to obtain a weight meeting the requirement; establishing contact between the BP neural network and the PLC industrial Ethernet, and interacting real-time information; and configuring the system and an upper computer to ensure that the system can receive a rotating speed instruction. The method has the advantages of good dynamic characteristic and strong robustness.)
1. A BLDCM parameter optimization method based on a PLC and a BP neural network is characterized by comprising the following steps:
step 1, building a plurality of PLC modules into a PLC industrial Ethernet;
step 2, establishing a discrete voltage equation of the brushless direct current motor under a synchronous reference model, determining the input quantity and the output quantity of a neural network, and determining the reference rotating speed of the motor and the variation range of voltage and current;
step 3, collecting motor voltage and current at different rotating speeds, sending the collected data to a discrete voltage equation of the brushless direct current motor to generate output values, and correspondingly combining the output values and the input values to form a training sample of the BP neural network;
step 4, constructing a BP neural network model;
step 5, normalizing the training samples in the step 3, inputting the training samples after normalization processing into the constructed BP neural network model for off-line learning, and obtaining the weight meeting the requirements;
step 6, establishing contact between the BP neural network and the PLC industrial Ethernet, and interacting real-time information;
and 7, configuring the system and the upper computer to ensure that the system can receive a rotating speed instruction.
2. The method for optimizing parameters of a BLDCM based on a PLC and a BP neural network of claim 1, wherein the step 1 comprises constructing a plurality of PLC modules as a PLC industrial ethernet, specifically:
and building the PLC industrial Ethernet by utilizing a plurality of PLC modules through a switch.
3. The BLDCM parameter optimization method based on the PLC and BP neural network as claimed in claim 1, wherein the discrete voltage equation of the brushless DC motor under the synchronous reference model in step 2 is specifically:
where R is the stator impedance, TsIs the sampling time, L is the d-and q-axis inductances, edsAnd eqsBack electromotive force of d-axis and q-axis, respectively, ids[k]、iqs[k]D and q axis currents i to be output at this timeds[k-1]、iqs[k-1]D, q-axis currents, omega, at the last sampling instantr[k-1]Angular velocity, v, at the last sampling instantds[k-1]、vqs[k-1]The voltage of the alternating current and direct current axes at the last acquisition moment;
the sum of the second term and the third term on the right of the equal sign in the equation only contains three detectable variables ids、iqsAnd ωrThese two terms are therefore considered as functions of the state variables, and the equation is then expressed as:
function fd(ids,iq,ωr) And fq(ids,iqs,ωr) Expressing the nonlinear dynamic equation of the brushless DC motor, thus establishing a three-layer neural network model, ids[k-1]、iqs[k-1]、ωr[k-1]As input to the BP neural network, fd(ids,iq,ωr) And fq(ids,iqs,ωr) As an output.
4. The BLDCM parameter optimization method based on the PLC and the BP neural network as claimed in claim 3, wherein the step 3 collects motor voltage and current at different rotation speeds, and sends the collected data to the discrete voltage equation of the brushless DC motor to generate an output value, and the output value and the input value are correspondingly combined to form a training sample of the BP neural network, specifically as follows:
according to the set step length and the set interval, the motor voltage and current under different rotating speeds are collected through the traversal value range, the collected data are sent to a nonlinear dynamic equation in a discrete voltage equation of the brushless direct current motor to generate output values, and the output values and the input values are correspondingly combined to form a training sample of the BP neural network.
5. The BLDCM parameter optimization method based on the PLC and the BP neural network as claimed in claim 3, wherein the construction of the BP neural network model in step 4 is as follows:
the BP neural network model is a three-layer feedforward neural network and is formed by an empirical formula of nodes of an implicit layer
6. The method for optimizing parameters of a BLDCM based on PLC and BP neural network of claim 3, wherein the training samples in step 5 are normalized according to the following formula:
in the formula, xminIs the smallest number, x, in the data seriesmaxIs the maximum number in the sequence, x is the data before normalization, and y is the data after normalization.
7. The method for optimizing parameters of a BLDCM based on a PLC and a BP neural network of claim 1, wherein the training samples after normalization processing in step 5 are inputted into a constructed BP neural network model for offline learning, specifically as follows:
(1) combining the input and output after normalization processing into a sample sequence (X, Y);
(2) determining the number of nodes of input layer, hidden layer and output layer initiallyConnecting weight omega of input layer and hidden layerijConnection weight ω between hidden layer and output layerjkGiving a learning rate;
(3) solving the hidden layer output H:
wherein HjIs the hidden layer output of the j-th layer, xjThe number of nodes in the hidden layer is j, j is the number of nodes in the hidden layer, and i is the number of nodes in the input layer;
hidden layer excitation function
(4) Calculating an output layer prediction output G:
wherein G iskThe prediction output of the k layer is obtained, and k is the number of output layer nodes;
(5) calculating a prediction error E from the predicted output G and the desired output Y:
where E is the prediction error, YkDesired output for k layer;
(6) starting from an output layer, calculating according to a gradient descent method, adjusting the weight layer by layer, taking the step length as eta, and adopting an adjustment formula as follows:
wherein, ω (t +1) and ω (t) are respectively the connection weight calculated by t +1 and t times of adjustment;
and finally, after iteration, determining the weight of each neuron of the BP neural network.
8. The method for optimizing parameters of BLDCM based on PLC and BP neural network of claim 1, wherein step 6 establishes communication between BP neural network and PLC industrial ethernet network, specifically as follows:
and determining that the BP neural network is matched with the communication protocol of the PLC industrial Ethernet so as to ensure that data can be transmitted between the BP neural network and the PLC industrial Ethernet, thereby realizing the real-time optimization of the parameters.
9. The method for optimizing parameters of a BLDCM based on a PLC and a BP neural network of claim 1, wherein the step 7 configures the system and the upper computer to ensure that the system can receive a rotation speed command, specifically:
and determining that the communication protocols of the PLC industrial Ethernet and the upper computer are matched so as to ensure that data can be transmitted between the PLC industrial Ethernet and the upper computer, thereby realizing the sending of system instructions.
Technical Field
The invention belongs to the technical field of direct current brushless motor control, and particularly relates to a BLDCM parameter optimization method based on a PLC and a BP neural network.
Background
The brushless DC motor is a motor widely used in various modern electrical systems, and has the advantages of small volume, light weight, excellent speed regulation performance and the like. The driving system matched with the system needs the capability of quick response, and can quickly track when the external condition changes, and the conventional control driving system with fixed parameters cannot meet the requirement.
The neural network is formed by connecting a plurality of simple neurons, and simulates the working characteristics and the organization functions of the human brain. The method can realize the approximation of any nonlinear function, can realize the change of self-learning along with the change of environmental conditions, and has strong quick tracking and timely response capability.
A PLC (Programmable Logic Controller) control system is an electronic device designed for industrial production, which uses a Programmable memory for storing programs therein, executing user-oriented instructions such as Logic operation, sequence control, timing, counting, and arithmetic operation, and controlling various types of machinery or production processes through digital or analog input/output.
When the parameters of the traditional control system with fixed parameters of the brushless direct current motor are changed, the preset parameters of the controller are difficult to adapt to new running conditions, and the control system has the characteristics of poor dynamic characteristics and robustness and difficult data transmission.
Disclosure of Invention
The invention aims to provide a BLDCM parameter optimization method based on a PLC and a BP neural network, which has good dynamic characteristics and robustness.
The technical solution for realizing the purpose of the invention is as follows: a BLDCM parameter optimization method based on a PLC and a BP neural network comprises the following steps:
step 1, building a plurality of PLC modules into a PLC industrial Ethernet;
step 2, establishing a discrete voltage equation of the brushless direct current motor under a synchronous reference model, determining the input quantity and the output quantity of a neural network, and determining the reference rotating speed of the motor and the variation range of voltage and current;
step 3, collecting motor voltage and current at different rotating speeds, sending the collected data to a discrete voltage equation of the brushless direct current motor to generate output values, and correspondingly combining the output values and the input values to form a training sample of the BP neural network;
step 4, constructing a BP neural network model;
step 5, normalizing the training samples in the step 3, inputting the training samples after normalization processing into the constructed BP neural network model for off-line learning, and obtaining the weight meeting the requirements;
step 6, establishing contact between the BP neural network and the PLC industrial Ethernet, and interacting real-time information;
and 7, configuring the system and the upper computer to ensure that the system can receive a rotating speed instruction.
Further, in step 1, the building of the plurality of PLC modules into the PLC industrial ethernet specifically includes:
and building the PLC industrial Ethernet by utilizing a plurality of PLC modules through a switch.
Further, in step 2, the discrete voltage equation of the brushless dc motor under the synchronous reference model specifically includes:
where R is the stator impedance, TsIs the sampling time, L is the d-and q-axis inductances, edsAnd eqsBack electromotive force of d-axis and q-axis, respectively, ids[k]、iqs[k]D and q axis currents i to be output at this timeds[k-1]、iqs[k-1]D, q-axis currents, omega, at the last sampling instantr[k-1]Is the last oneAngular velocity at the moment of sampling, vds[k-1]、vqs[k-1]The voltage of the alternating current and direct current axes at the last acquisition moment;
the sum of the second term and the third term on the right of the equal sign in the equation only contains three detectable variables ids、iqsAnd ωrThese two terms are therefore considered as functions of the state variables, and the equation is then expressed as:
function fd(ids,iq,ωr) And fq(ids,iqs,ωr) Expressing the nonlinear dynamic equation of the brushless DC motor, thus establishing a three-layer neural network model, ids[k-1]、iqs[k-1]、ωr[k-1]As input to the BP neural network, fd(ids,iq,ωr) And fq(ids,iqs,ωr) As an output.
Further, in step 3, the voltage and the current of the motor at different rotating speeds are collected, the collected data are sent to a discrete voltage equation of the brushless direct current motor to generate output values, and the output values and the input values are correspondingly combined to form a training sample of the BP neural network, which specifically comprises the following steps:
according to the set step length and the set interval, the motor voltage and current under different rotating speeds are collected through the traversal value range, the collected data are sent to a nonlinear dynamic equation in a discrete voltage equation of the brushless direct current motor to generate output values, and the output values and the input values are correspondingly combined to form a training sample of the BP neural network.
Further, the constructing of the BP neural network model in step 4 is specifically as follows:
the BP neural network model is a three-layer feedforward neural network and is formed by an empirical formula of nodes of an implicit layer
Determining the number of nodes of the hidden layer, wherein a is a constant between 0 and 10, m is the number of nodes of the hidden layer, n is the number of nodes of the output layer, the number of nodes of the input layer corresponds to the input quantity, the number of nodes of the output layer corresponds to the output quantity, the hidden layer and the output layer in the BP neural network model both adopt log-sigmoid functions f (x), and the expression isFurther, step 5 normalizes the training samples in step 3, and the formula is as follows:
in the formula, xminIs the smallest number, x, in the data seriesmaxIs the maximum number in the sequence, x is the data before normalization, and y is the data after normalization.
Further, in step 5, the training samples after the normalization processing are input into the constructed BP neural network model for offline learning, specifically as follows:
(1) combining the input and output after normalization processing into a sample sequence (X, Y);
(2) determining the number of nodes l of the network input layer, the number of nodes m of the hidden layer and the number of nodes n of the output layer, and initializing the connection weight omega of the input layer and the hidden layerijConnection weight ω between hidden layer and output layerjkGiving a learning rate;
(3) solving the hidden layer output H:
wherein HjIs the hidden layer output of the j-th layer, xjThe number of nodes in the hidden layer is j, j is the number of nodes in the hidden layer, and i is the number of nodes in the input layer;
hidden layer excitation function
(4) Calculating an output layer prediction output G:
wherein G iskThe prediction output of the k layer is obtained, and k is the number of output layer nodes;
(5) calculating a prediction error E from the predicted output G and the desired output Y:
where E is the prediction error, YkDesired output for k layer;
(6) starting from an output layer, calculating according to a gradient descent method, adjusting the weight layer by layer, taking the step length as eta, and adopting an adjustment formula as follows:
wherein, ω (t +1) and ω (t) are respectively the connection weight calculated by t +1 and t times of adjustment;
and finally, after iteration, determining the weight of each neuron of the BP neural network.
Further, step 6 establishes a connection between the BP neural network and the PLC industrial ethernet network, specifically as follows:
and determining that the BP neural network is matched with the communication protocol of the PLC industrial Ethernet so as to ensure that data can be transmitted between the BP neural network and the PLC industrial Ethernet, thereby realizing the real-time optimization of the parameters.
Further, step 7, configuring the system and the upper computer to ensure that the system can receive a rotation speed command, specifically:
and determining that the communication protocols of the PLC industrial Ethernet and the upper computer are matched so as to ensure that data can be transmitted between the PLC industrial Ethernet and the upper computer, thereby realizing the sending of system instructions.
Compared with the prior art, the invention has the following remarkable advantages: (1) a BP neural network is added into the system and a vector control mode is adopted, so that the dynamic characteristics and robustness of the BP neural network can be greatly improved; (2) the PLC system can conveniently transmit and receive data, and the industrial Ethernet formed by the PLC system is convenient for later expansion and upgrading of the system.
Drawings
Fig. 1 is a schematic diagram of a PLC and BP neural network learning structure.
FIG. 2 is a schematic diagram of a BP neural network in the present invention.
Fig. 3 is a schematic diagram of the system architecture.
FIG. 4 is a diagram of a hardware layout and components provided by a method according to an embodiment of the invention.
Fig. 5 is a schematic diagram of a layout of a touch screen of a system and buttons according to an embodiment of the present invention.
Fig. 6 is a schematic diagram of a ladder program inside a CompactLogix automation programmable controller provided by the method of the embodiment of the present invention, wherein (a) is a schematic diagram of an initialization program, (b) is a schematic diagram of a motor rotation program, and (c) is a schematic diagram of a motor rotation optimization part program.
Fig. 7 is a schematic diagram of a ladder program inside the Micro850 programmable logic controller provided by the method according to the embodiment of the present invention, wherein (a) is a schematic diagram of a program of a sampling part of the photoelectric switch, (b) is a schematic diagram of a program of a sampling and counting part of the photoelectric switch, and (c) is a schematic diagram of a program of a counting part of the photoelectric switch.
Detailed description of the invention
With reference to fig. 1, the BLDCM parameter optimization method based on PLC and BP neural network includes the following steps:
step 1, building a plurality of PLC modules into a PLC industrial Ethernet;
step 2, establishing a discrete voltage equation of the brushless direct current motor under a synchronous reference model, determining the input quantity and the output quantity of a neural network, and determining the reference rotating speed of the motor and the variation range of voltage and current;
step 3, collecting motor voltage and current at different rotating speeds, sending the collected data to a discrete voltage equation of the brushless direct current motor to generate output values, and correspondingly combining the output values and the input values to form a training sample of the BP neural network;
step 4, constructing a BP neural network model;
step 5, normalizing the training samples in the step 3, inputting the training samples after normalization processing into the constructed BP neural network model for off-line learning, and obtaining the weight meeting the requirements;
step 6, establishing contact between the BP neural network and the PLC industrial Ethernet, and interacting real-time information;
and 7, configuring the system and the upper computer to ensure that the system can receive a rotating speed instruction.
Further, in step 1, the building of the plurality of PLC modules into the PLC industrial ethernet specifically includes:
and building the PLC industrial Ethernet by utilizing a plurality of PLC modules through a switch.
Further, in step 2, the discrete voltage equation of the brushless dc motor under the synchronous reference model specifically includes:
where R is the stator impedance, TsIs the sampling time, L is the d-and q-axis inductances, edsAnd eqsBack electromotive force of d-axis and q-axis, respectively, ids[k]、iqs[k]D and q axis currents i to be output at this timeds[k-1]、iqs[k-1]D, q-axis currents, omega, at the last sampling instantr[k-1]Angular velocity, v, at the last sampling instantds[k-1]、vqs[k-1]The voltage of the alternating current and direct current axes at the last acquisition moment;
the sum of the second term and the third term on the right of the equal sign in the equation only contains three detectable variables ids、iqsAnd ωrThese two terms are therefore considered as functions of the state variables, and the equation is then expressed as:
function fd(ids,iq,ωr) And fq(ids,iqs,ωr) Expressing the nonlinear dynamic equation of the brushless DC motor, thus establishing a three-layer neural network model, ids[k-1]、iqs[k-1]、ωr[k-1]As input to the BP neural network, fd(ids,iq,ωr) And fq(ids,iqs,ωr) As an output.
Further, in step 3, the voltage and the current of the motor at different rotating speeds are collected, the collected data are sent to a discrete voltage equation of the brushless direct current motor to generate output values, and the output values and the input values are correspondingly combined to form a training sample of the BP neural network, which specifically comprises the following steps:
according to the set step length and the set interval, the motor voltage and current under different rotating speeds are collected through the traversal value range, the collected data are sent to a nonlinear dynamic equation in a discrete voltage equation of the brushless direct current motor to generate output values, and the output values and the input values are correspondingly combined to form a training sample of the BP neural network.
Further, the constructing of the BP neural network model in step 4 is specifically as follows:
the BP neural network model is a three-layer feedforward neural network and is formed by an empirical formula of nodes of an implicit layer
Determining the number of nodes of the hidden layer, wherein a is a constant between 0 and 10, m is the number of nodes of the hidden layer, n is the number of nodes of the output layer, the number of nodes of the input layer corresponds to the input quantity, the number of nodes of the output layer corresponds to the output quantity, the hidden layer and the output layer in the BP neural network model both adopt log-sigmoid functions f (x), and the expression isFurther, step 5 normalizes the training samples in step 3, and the formula is as follows:
in the formula, xminIs the smallest number, x, in the data seriesmaxIs the maximum number in the sequence, x is the data before normalization, and y is the data after normalization.
Further, in step 5, the training samples after the normalization processing are input into the constructed BP neural network model for offline learning, specifically as follows:
(1) combining the input and output after normalization processing into a sample sequence (X, Y);
(2) determining the number of nodes l of the network input layer, the number of nodes m of the hidden layer and the number of nodes n of the output layer, and initializing the connection weight omega of the input layer and the hidden layerijConnection weight ω between hidden layer and output layerjkGiving a learning rate;
(3) solving the hidden layer output H:
wherein HjIs the hidden layer output of the j-th layer, xjThe number of nodes in the hidden layer is j, j is the number of nodes in the hidden layer, and i is the number of nodes in the input layer;
hidden layer excitation function
(4) Calculating an output layer prediction output G:
wherein G iskIs the predicted output of the k-th layer,k is the number of output layer sections;
(5) calculating a prediction error E from the predicted output G and the desired output Y:
where E is the prediction error, YkDesired output for k layer;
(6) starting from an output layer, calculating according to a gradient descent method, adjusting the weight layer by layer, taking the step length as eta, and adopting an adjustment formula as follows:
wherein, ω (t +1) and ω (t) are respectively the connection weight calculated by t +1 and t times of adjustment;
and finally, after iteration, determining the weight of each neuron of the BP neural network.
Further, step 6 establishes a connection between the BP neural network and the PLC industrial ethernet network, specifically as follows:
and determining that the BP neural network is matched with the communication protocol of the PLC industrial Ethernet so as to ensure that data can be transmitted between the BP neural network and the PLC industrial Ethernet, thereby realizing the real-time optimization of the parameters.
Further, step 7, configuring the system and the upper computer to ensure that the system can receive a rotation speed command, specifically:
and determining that the communication protocols of the PLC industrial Ethernet and the upper computer are matched so as to ensure that data can be transmitted between the PLC industrial Ethernet and the upper computer, thereby realizing the sending of system instructions.
The invention is described in further detail below with reference to the figures and the embodiments.