Low-power inverter based on software and hardware combination and debugging method thereof
By adopting a combination of software and hardware design in a small-power inverter, using PID and neural network controller to adjust the inverter state in real time, the problem of unstable output of traditional inverter circuits is solved, and higher stability and reliability are achieved sex.
Patent Information
- Application Number
- CN202411480170.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-02-11
AI Technical Summary
It is difficult for traditional inverter circuits to adjust the frequency and amplitude of the output sinusoidal AC voltage, and the output is not stable enough.
It adopts a small-power inverter design based on software and hardware combination, including power supply module, full-bridge inverter circuit, LC filter circuit and control module. The control module uses PID controller and neural network controller to monitor and adjust the working status of the inverter in real time, and adjust the control signals in real time through the pre-trained neural network model.
The stability and reliability of the inverter output voltage frequency and amplitude are realized, and the dynamic adjustment can be achieved according to changes in the external environment, reducing manufacturing costs, and improving the overall performance of the inverter.
Smart Images

Figure CN119420195A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an inverter, and in particular to a low-power inverter based on software and hardware combination and a debugging method thereof. Background Art
[0002] With the rapid development of society and economy, new energy sources such as photovoltaic and wind energy are becoming more and more popular among people, and power is needed when using various household appliances. The most common AC power supply is provided by the public power grid, but with the rapid development of production and life, many people have special self-requirements for electrical equipment in the public power grid. The power supply method of directly taking electricity from the public power grid can no longer meet the needs of people's production and life. Among the most common power sources in life, dry batteries, photovoltaic cells, etc. are all DC power supplies. When this part of the AC load needs to be powered, in order to meet this part of the demand, an inverter power supply is needed, and the core part worth studying is the inverter circuit.
[0003] An inverter circuit is a device that converts direct current into alternating current. With the rapid development of society and technology, the application occasions of inverter circuits are gradually increasing. For example, with the promotion of solar energy entering people's field of vision, solar energy and vehicle power supply cannot be used directly, so an inverter circuit is needed for conversion. In this context, it is necessary to study low-power inverter circuits.
[0004] Traditional inverter circuits are usually composed of an inverter bridge, a control circuit, and a filter circuit. However, such traditional inverter circuits are usually difficult to adjust the frequency and amplitude of the output sinusoidal AC voltage, and the frequency and amplitude of the output sinusoidal AC voltage are not stable enough. Summary of the invention
[0005] In order to overcome the above defects of the prior art, the present invention aims to provide a low-power inverter based on the combination of software and hardware and a debugging method thereof, so that the low-power inverter can maintain a stable working state in practical applications to ensure the normal operation of the power system. To achieve the above purpose, the present invention provides the following solutions:
[0006] According to a first aspect of the present invention, a low-power inverter based on software and hardware combination is provided. The low-power inverter comprises:
[0007] The power supply module includes a DC / DC step-down conversion circuit and a step-down voltage stabilizing chip; the DC / DC step-down conversion circuit is used to convert a fixed input DC voltage into a variable DC voltage; the step-down voltage stabilizing chip is used to step down and stabilize the variable DC voltage to obtain a required output DC voltage;
[0008] A full-bridge inverter circuit, used for converting a set DC voltage output by the power supply module into an AC voltage in response to the control signal;
[0009] An LC filter circuit, used for filtering the AC voltage to obtain a filtered output AC voltage;
[0010] The control module includes a PID controller and a neural network controller; the PID controller is used to generate a control signal; the neural network controller is used to obtain real-time status information of the inverter and adjust the control signal in real time according to the real-time status information through a pre-trained neural network model.
[0011] Furthermore, the inverter status information includes: the output DC voltage of the power supply module, the frequency, amplitude and switching state of the AC voltage of the full-bridge inverter circuit, the state of the LC filter circuit and the inverter temperature.
[0012] Furthermore, the control module is also used to obtain historical status information of the inverter, and train the neural network model according to the historical status information of the inverter to obtain a pre-trained neural network model.
[0013] Furthermore, the training of the neural network model includes:
[0014] Preprocessing the historical status information of the inverter, and dividing the preprocessed data into a training set and a verification set;
[0015] Constructing a BP neural network, including determining the number of hidden layers of the BP neural network, setting parameters of the BP neural network and initializing the parameters; the parameters include the number of input vector elements, the number of hidden layer neurons, the initial value of each layer weight matrix, the learning rate, and the inertia coefficient;
[0016] Input the training set into the constructed BP neural network, and according to the parameters of the current BP neural network, use the forward propagation algorithm of the BP neural network to calculate the input and output of each layer of neurons, so that the output layer of the BP neural network outputs the proportional parameter kp, integral parameter ki, differential parameter kd parameters used to adjust the PID controller, and calculate the output u(k) of the PID controller;
[0017] The current error e(k) is calculated based on u(k) and the output sampling value d(k) of the PID controller. The error performance function is obtained based on e(k). The gradient of each weight matrix to the error performance function is calculated layer by layer from the output layer of the BP neural network. The weight matrix of each layer is updated using the steepest descent method to complete an iterative training.
[0018] Repeat multiple iterations of training until the value of the error performance function is minimum or less than a threshold, and obtain a pre-trained neural network model;
[0019] Use the validation set to validate the pre-trained neural network model.
[0020] Furthermore, the DC / DC step-down conversion circuit includes: a switch, a diode, an inductor, a capacitor and an output resistor; the positive electrode of the input DC voltage is connected to the negative electrode of the diode via the switch, and the negative electrode of the input DC voltage is respectively connected to the positive electrode of the diode, the first end of the capacitor and the first end of the output resistor; the negative electrode of the diode is also respectively connected to the second end of the capacitor and the second end of the output resistor via the inductor; the output DC voltage is obtained from the two ends of the output resistor.
[0021] Furthermore, the step-down voltage regulator chip adopts the LM2596 step-down voltage regulator chip, the control module includes the STC12C5608AD control chip, and the full-bridge inverter circuit includes the L298 H-bridge motor driver chip.
[0022] Furthermore, the LC filter circuit includes a filter capacitor, a filter inductor and a resistor; the output end of the full-bridge inverter circuit is grounded via the filter capacitor and connected to the first end of the resistor via the filter inductor; the second end of the resistor is grounded; and the filtered output AC voltage is output from both ends of the resistor.
[0023] According to a second aspect of the present invention, a debugging method for a low-power inverter based on a combination of software and hardware as described in the first aspect of the present invention is provided. The method comprises the following steps:
[0024] The control module is realized by using the STC12C5608AD control chip, and the core of the 51 series single-chip microcomputer is selected by Keil software to write the main program and interrupt program for the STC12C5608AD control chip;
[0025] Perform functional debugging on the written program.
[0026] Further, the main program is used to manage the mutually exclusive operation and data assignment process of the two units in the STC12C5608AD control chip, and includes:
[0027] Initialization phase: Initialize the PCA timer and A / D conversion unit, and set the switching flag exflag to 0;
[0028] Main program judgment stage: judge whether the current switching flag exflag is 0. If the current switching flag exflag is 0, activate unit m0 and deactivate unit m1; if the current switching flag exflag is 1, activate unit m1 and deactivate unit m0;
[0029] Processing stage: Check whether the currently activated unit is interrupted. If not, continue to check whether the currently activated unit is interrupted. If an interrupt occurs, use the sine table to assign a value to the corresponding CCAPM, and check whether the sine table is traversed after the assignment. If the traversal is completed, make the currently activated unit output 0, activate another unit, and switch the value of the current switching flag exflag. If the traversal is not completed, continue to check whether the currently activated unit is interrupted.
[0030] Further, the interrupt program is used to manage the counter interrupt in the STC12C5608AD control chip and update the relevant register value, and includes:
[0031] Clearing stage: Starting from the interrupt entry, the carry flag CF and interrupt flag CCF1 related to the interrupt counter or capture / compare register CCAP1 are cleared, the capture / compare register CCAP1 is reassigned, and the high register CH and low register CL of the interrupt counter are cleared to ensure that the interrupt counter starts from zero;
[0032] Interrupt judgment stage: add 1 to the interrupt count counter and check whether the interrupt count reaches the preset threshold; if the interrupt count does not reach the preset threshold, return to wait for the next interrupt; if it reaches the preset threshold, clear the interrupt count counter and write the required pulse width value into the capture / compare register CCAP0H to control the pulse width modulation PWM output and return from interrupt.
[0033] Compared with the prior art, the present invention has the following beneficial effects:
[0034] 1. By setting a PID controller and a neural network controller in the control module, the PID controller generates a control signal, and the neural network controller adjusts the control signal in real time according to the real-time status information through a pre-trained neural network model. The working state of the inverter can be monitored and adjusted in real time, and dynamic adjustments can be made according to changes in the external environment to improve the stability and reliability of the inverter.
[0035] 2. The design of software and hardware combination can reduce the manufacturing cost as much as possible while ensuring the performance of the inverter. Specifically, the sine wave inverter design of the present invention uses the single-chip microcomputer STC12C5608AD as the control core, and its function is to convert DC to AC. The inverter power supply is composed of a full-bridge inverter circuit to form the main circuit of the system. The LM2596 voltage regulator provides a voltage-stabilized power supply part for the single-chip microcomputer, and the STC12C5608AD controls the drive circuit. The inverter part adopts the single-chip microcomputer digital SPWM control mode to control the L298 H-bridge motor driver chip to generate SPWM waves, and an LC filter circuit is added to the output end of the L298 to generate a sine wave, which enhances the reliability and safety of the power supply, and the circuit structure is simple and compact, small in size, and can reduce manufacturing costs.
[0036] 3. By analyzing the output waveform of the system, adjusting the frequency and output voltage amplitude, it becomes a sine wave after inversion. By analyzing the waveform diagram of the debugging system under different conditions, it can be seen that the output waveform is good, and the sinusoidal AC voltage frequency waveform diagram can be output stably. The output AC voltage range after filtering is 5V-40V, the frequency variation range is 0-500HZ, and the amplitude varies between 1 / 10 and 9 / 10 of the total amplitude, which basically achieves the expected results. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a structural block diagram of a low-power inverter based on software and hardware combination of the present invention;
[0038] Figure 2 A schematic diagram of the training process of the neural network model of the present invention;
[0039] Figure 3 This is the single chip microcomputer pin diagram of the STC12C5608AD control chip used in the present invention;
[0040] Figure 4 A circuit structure diagram of a DC / DC step-down conversion circuit used in the present invention;
[0041] Figure 5 It is a main program flow chart of the debugging method of a low-power inverter based on software and hardware combination of the present invention;
[0042] Figure 6 The interrupt program flow chart of the debugging method of a low-power inverter based on the combination of software and hardware of the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The embodiments described in this application are only part of the embodiments of the present invention, not all of them. Based on the spirit of the present invention, other embodiments obtained by ordinary technicians in this field without creative work are all within the scope of protection of the present invention.
[0044] Example 1
[0045] This embodiment provides a low-power inverter based on the combination of software and hardware. Figure 1 , the power inverter comprises:
[0046] The power supply module includes a DC / DC step-down conversion circuit and a step-down voltage stabilizing chip; the DC / DC step-down conversion circuit is used to convert a fixed input DC voltage into a variable DC voltage; the step-down voltage stabilizing chip is used to step down and stabilize the variable DC voltage to obtain a required output DC voltage;
[0047] A full-bridge inverter circuit, used for converting a set DC voltage output by the power supply module into an AC voltage in response to the control signal;
[0048] An LC filter circuit, used for filtering the AC voltage to obtain a filtered output AC voltage;
[0049] The control module includes a PID controller and a neural network controller; the PID controller is used to generate a control signal; the neural network controller is used to obtain real-time status information of the inverter and adjust the control signal in real time according to the real-time status information through a pre-trained neural network model.
[0050] In this embodiment, by setting a PID controller and a neural network controller in the control module, the PID controller generates a control signal, and the neural network controller adjusts the control signal in real time according to the real-time status information through a pre-trained neural network model. The working state of the inverter can be monitored and adjusted in real time, and dynamic adjustments can be made according to changes in the external environment to improve the stability and reliability of the inverter.
[0051] The inverter status information includes: the output DC voltage of the power supply module, the frequency, amplitude and switching state of the AC voltage of the full-bridge inverter circuit, the state of the LC filter circuit and the inverter temperature.
[0052] Preferably, the control module is also used to obtain historical status information of the inverter, and train the neural network model according to the historical status information of the inverter to obtain a pre-trained neural network model.
[0053] Specifically, training a neural network model includes:
[0054] Step 1: preprocess the historical status information of the inverter, and divide the preprocessed data into a training set and a verification set.
[0055] Specifically, the preprocessing may include operations such as data cleaning and normalization of the historical status information.
[0056] Step 2, constructing a BP neural network, including determining the number of hidden layers of the BP neural network, setting and initializing the parameters of the BP neural network; the parameters include the number of input vector elements, the number of hidden layer neurons, the weight matrix of each layer, the learning rate, and the inertia coefficient.
[0057] Among them, the BP (back propagation) neural network includes an input layer, an output layer and one or more hidden layers between the input layer and the output layer. The role of the hidden layer is to abstract the features of the input data into another dimensional space, showing more abstract features for better linear division. The neurons in the hidden layer, like the neurons in the input layer and the output layer, have activation functions, which enable them to handle nonlinear problems and improve the expressive power and prediction accuracy of the model. The weight matrix is continuously adjusted during the neural training process to optimize the performance of the network. The learning rate is a crucial hyperparameter that determines the magnitude of the update of the model parameters at each iteration. The role of the inertia coefficient (or momentum term) is to introduce a memory function so that the weight update not only depends on the current gradient information, but also takes into account the direction of the previous weight update.
[0058] As an example, this embodiment sets the BP neural network to have three layers.
[0059] Step 3: Input the data in the training set into the constructed BP neural network. According to the parameters of the current BP neural network, calculate the input and output of each layer of neurons, so that the output layer of the BP neural network can adjust the proportional parameter kp, integral parameter ki, and differential parameter kd of the PID controller, and calculate the expected output value u(k) of the PID controller.
[0060] As an example, the output of the output layer of the BP neural network is:
[0061]
[0062] in, Represent the outputs of the input layer, hidden layer, and output layer respectively; Represent the input of the hth neuron in the output layer and hidden layer respectively; f (3) (·),f (2)(·) denotes the activation functions of the output layer and the hidden layer respectively; They represent the weight matrices of the output layer and the hidden layer respectively; i=1, 2, …n represents the i-th element of the input vector of the BP neural network; j=1, 2, …s represents the ordinal number of the neuron in the hidden layer.
[0063] Calculating the expected output value u(k) of the PID controller by using the proportional parameter kp, the integral parameter ki, and the differential parameter kd is a conventional technical means involved in traditional PID controllers and will not be elaborated here.
[0064] Step 4: Calculate the current error e(k) based on u(k) and the output sampling value d(k) of the PID controller, obtain the error performance function based on e(k), calculate the gradient of each weight matrix to the error performance function layer by layer from the output layer of the BP neural network forward, and use the steepest descent method to update the weight matrix of each layer to complete an iterative training.
[0065] Among them, the error performance function E(k) can be expressed as:
[0066]
[0067] The gradient of the error performance function is:
[0068]
[0069] in, is the local error of the output layer, sgn(·) is the sign function;
[0070] Using the back propagation learning algorithm with momentum update, the output layer weight update rule is:
[0071]
[0072] Among them, α is the inertia coefficient and μ is the learning rate.
[0073] The update rule of the hidden layer weights can be derived by the same method as follows:
[0074]
[0075] Step 5: Repeat the iterative training for multiple times until the value of the error performance function is minimum or less than the threshold, and obtain the pre-trained neural network model.
[0076] Step 6: Use the validation set to verify the pre-trained neural network model.
[0077] In this way, by using the adaptive learning process of the BP neural network and constantly updating the weight matrix, the PID parameters can be adjusted faster and better, thereby ensuring the stability of the frequency and amplitude of the inverter output voltage.
[0078] Preferably, Figure 4 As shown, the DC / DC step-down conversion circuit includes: a switch S, a diode VD, an inductor L, a capacitor C and an output resistor R; the positive electrode of the input DC voltage Vi is connected to the negative electrode of the diode VD via the switch S, and the negative electrode of the input DC voltage Vi is respectively connected to the positive electrode of the diode VD, the first end of the capacitor C and the first end of the output resistor R; the negative electrode of the diode VD is also respectively connected to the second end of the capacitor C and the second end of the output resistor R via the inductor L; the output DC voltage Vo is obtained from the two ends of the output resistor R.
[0079] This DC / DC step-down conversion circuit is actually a two-stage DC-DC-AC power conversion solution, which can convert the DC input voltage into a DC voltage through a DC / DC step-down conversion, and at the same time convert it into an AC voltage through a DC / AC inverter. This design of the DC / DC step-down conversion circuit has the advantages of small size and high efficiency.
[0080] Preferably, the step-down voltage regulator chip adopts the LM2596 step-down voltage regulator chip. The LM2596 chip is a common voltage regulator that can manage a single-chip integrated circuit by stepping down the power supply. It has good linear function and accurate load regulation characteristics, and can output various voltages less than 37V that meet the requirements. In addition, the interior of the LM2596 can also contain a more complete protection circuit and a circuit design that can stabilize the voltage. Due to these excellent characteristics, it is used for DC-DC power conversion in the present invention, and its maximum output current is 3A. Taking the above advantages into consideration, it can perfectly play the step-down function and the function of powering the single-chip microcomputer in this design, thereby realizing the role of constant voltage output.
[0081] The difference between the present invention and the prior art is that the control module preferably includes a STC12C5608AD control chip. This STC12C5608AD control chip is a relatively new generation of 8051 single-chip microcomputer, which has many advantages, such as a relatively high-speed AD conversion function, but it has only 20 or 28 pins, so the overall volume of the single-chip microcomputer as the main device can be reduced. The instruction code is completely compatible with the traditional 8051 single-chip microcomputer, but under the effect of the universal crystal oscillator frequency, its maximum working speed can reach about 12 times that of the traditional 51 single-chip microcomputer, and it has the same reset circuit and RC clock circuit as the traditional one. As an upgraded version of the traditional 51, its main features are super strong anti-interference ability, ultra-low power loss, and relatively easy simulation and convenient programming on the system, and it can be made impossible to decrypt on this basis. Its single-chip microcomputer pins are as follows Figure 3As shown. The STC12C5608AD microcontroller adds some functions to the traditional 51 microcontroller. The traditional 8051 microcontroller has the disadvantages of not having a strong driving ability and being unable to drive large currents. The STC12C5608AD microcontroller has a strong ability to drive large currents. It can drive large currents without being damaged, and can ensure the reliability of operation, which enhances the performance of the previous 51 microcontrollers. When the traditional I / O port of the traditional 8051 microcontroller outputs 0 to the outside, the I / O port must be set to 1 to read the external state. However, the traditional 8051 microcontroller can change from low to high. The instruction usually ends in 12 clocks, and its action time is slowed down. However, the STC12 series microcontroller usually changes from low to high in 4 clocks, and the corresponding time is faster than the traditional one. The clock normally used by this new series of A / D conversion is the normal system clock generated internally. If used in this way, the conversion speed can be increased to reduce the power consumption of the system, thereby playing the role of speeding up the response time. The STC12C5A60S2 series of microcontrollers provide 10 interrupt request sources in response to their functional requirements, including external interrupt 0 ( / INT0), timer 0 interrupt, external interrupt 1 ( / INT1), timer 1 interrupt, serial port 1 interrupt, A / D conversion interrupt, low voltage detection interrupt, PCA interrupt, serial port 2 interrupt and SPI interrupt. Its interrupt request should have the ability to handle external emergency events, and it can also require the CPU to suspend the current work to handle the corresponding emergency events.
[0082] The software design of the control module uses Keil software. Since Keil's library does not include STC series microcontrollers, but the internal core of STC and 51 series microcontrollers is basically the same, the 51 core can be selected.
[0083] Part of the SPWM program is as follows:
[0084] #include<STC12C56xx.h>
[0085] #define uchar unsigned char
[0086] #define uint unsigned int
[0087] Uchar code pwm
[51] ={0,16,31,47,63,78,93,108,122,136,149,162,174,185,196,206,
[0088] 215,223,230,237,242,246,250,252,254,255,254,252,250,246,242,237,
[0089] 230,223,215,206,196,185,174,162,149,136,122,108,93,78,63,47,
[0090] 31,16,0
[0091] }; / / Inverse sine change
[0092] uchar code pwm1
[51] ={0,14,28,43,57,71,84,97,110,123,135,146,157,167,177,186,
[0093] 194,201,208,213,218,222,225,228,229,230,229,228,225,222,218,213,
[0094] 208,201,194,186,177,167,157,146,135,123,110,97,84,71,57,43,
[0095] 28,14,0
[0096] }; / / Inverse sine change 9 / 10 voltage
[0097] uchar code pwm2
[51] ={0,12,25,38,50,63,75,86,98,109,119,130,139,148,157,165,
[0098] 172,178,184,189,194,197,200,202,203,204,203,202,200,197,194,189,
[0099] 184,178,172,165,157,148,139,130,119,109,98,86,75,63,50,38,
[0100] 25,12,0
[0101] }; / / Inverse sine change 8 / 10 voltage
[0102] uchar code pwm3
[51] ={0,11,22,33,44,55,65,76,86,95,105,114,122,130,137,144,
[0103] 151,156,161,166,170,173,175,177,178,179,178,177,175,173,170,166,
[0104] 161,156,151,144,137,130,122,114,105,95,86,76,65,55,44,33,
[0105] 22,11,0
[0106] }; / / Inverse sine change 7 / 10 voltage
[0107] Preferably, the full-bridge inverter circuit includes an L298 H-bridge motor driver chip. Strictly speaking, L298 is a simple chip driven by an H-bridge motor. It can be used for a full-bridge inverter circuit and can drive two two-phase motors or a four-phase motor at the same time. The system can directly use the I / O input of the single-chip microcomputer in this sense to realize the forward and reverse rotation of the motor and the control of the motor rotation speed, thereby achieving the regulation purpose of the present invention, that is, to drive the DC motor. The L298 module has always been equipped with an L7805 voltage regulator chip, so it can output a 5V voltage to drive the 5V circuit required by the single-chip microcomputer, so that it can achieve the power supply function. Moreover, its circuit is very simple and convenient to use.
[0108] Preferably, the LC filter circuit includes a filter capacitor, a filter inductor and a resistor; the output end of the full-bridge inverter circuit is grounded via the filter capacitor and connected to the first end of the resistor via the filter inductor; the second end of the resistor is grounded; and the filtered output AC voltage is output from both ends of the resistor.
[0109] Through the LC filter circuit set up as above, the unwanted signal generated by the AC interference will be absorbed by the inductor L, thereby preventing the signal from receiving other interference, so that the required current can be output.
[0110] The sine wave inverter of the present invention is designed with a single-chip microcomputer STC12C5608AD as the control core, and its function is to convert direct current into alternating current. The inverter power supply is composed of a full-bridge inverter circuit to form a system main circuit, an LM2596 voltage stabilizer provides a voltage-stabilized power supply part for the single-chip microcomputer, and the drive circuit is controlled by STC12C5608AD. The inverter part adopts a single-chip microcomputer digital SPWM control mode to control an L298 H-bridge motor drive chip to generate an SPWM wave, and an LC filter circuit is added at the output end of the L298 to generate a sine wave, thereby enhancing the reliability and safety of the power supply, and the circuit structure is simple and compact, the volume is small, and the manufacturing cost can be reduced.
[0111] By analyzing the output waveform of the system, adjusting the frequency and output voltage amplitude, it becomes a sine wave after inversion. By analyzing the waveform diagram of the debugging system under different conditions, it can be seen that the output waveform is good and the sinusoidal AC voltage frequency waveform diagram can be output stably. The output AC voltage range after filtering is 5V-40V, the frequency range is 0-500HZ, and the amplitude varies between 1 / 10 and 9 / 10 of the total amplitude, which basically achieves the expected results.
[0112] Example 2
[0113] This embodiment provides a debugging method of a low-power inverter based on software and hardware combination of the present invention. The method comprises the following steps:
[0114] Step 1: Use STC12C5608AD control chip as the control module, and use Keil software to select the kernel of 51 series single-chip microcomputer to write the main program and interrupt program for the STC12C5608AD control chip.
[0115] The main program is used to manage the mutually exclusive operation and data assignment process of two units (for example, unit 0 and unit 1) in the STC12C5608AD control chip. Figure 5 ,The main program specifically includes the initialization phase, the main program judgment phase and the ,processing phase.
[0116] The initialization phase includes: initializing the PCA timer and the A / D conversion unit, and setting the switching flag exflag to 0;
[0117] The main program judgment phase is the core of the main program, and the focus is on the judgment of exflag, which determines which module is activated for processing. The main program judgment phase includes: judging whether the current switching flag exflag is 0, if the current switching flag exflag is 0, then activate unit m0 and deactivate unit m1; if the current switching flag exflag is 1, then activate unit m1 and deactivate unit m0;
[0118] The processing stage includes: checking whether the currently activated unit is interrupted, if not, continue to check whether the currently activated unit is interrupted; if an interruption occurs, use the sine table to assign a value to the corresponding CCAPM, and check whether the sine table is traversed after the assignment. If the traversal is completed, the currently activated unit outputs 0, activates another unit, and switches the value of the current switching flag exflag. If the traversal is not completed, continue to check whether the currently activated unit is interrupted.
[0119] Among them, assigning values using a sine table means arranging the sine values corresponding to different angles (usually radians or degrees) in a certain order and storing them in an array, list or table for quick search and use.
[0120] This design of the main program ensures that only one unit or module is executing at any time, and the other unit or module is in a waiting state, realizing the alternating operation between different units or modules, thereby making the control of the full-bridge inverter circuit more accurate, safe and stable.
[0121] Furthermore, the interrupt program is used to manage the counter interrupt in the STC12C5608AD control chip and update the relevant register values. Figure 6 ,The interrupt procedure generally includes the clearing stage and the interrupt judgment stage.
[0122] The clearing phase includes: starting from the interrupt entry, clearing the carry flag CF and interrupt flag CCF1 related to the interrupt counter or the capture / compare register CCAP1, reassigning the capture / compare register CCAP1, and clearing the high register CH and low register CL of the interrupt counter to ensure that the interrupt counter starts from zero;
[0123] The interrupt judgment stage includes: adding 1 to the interrupt count counter and checking whether the interrupt count reaches the predetermined threshold N; if the interrupt count does not reach the predetermined threshold N, returning to wait for the next interrupt; if it reaches the predetermined threshold N, clearing the interrupt count counter and writing the required pulse width value into the capture / compare register CCAP0H to control the pulse width modulation PWM output and return from the interrupt.
[0124] This design of the interrupt program can improve the system's real-time and responsiveness, optimize the program structure and improve maintainability, realize multi-tasking and resource sharing, and support the control and management of complex systems, thereby making the control of the full-bridge inverter circuit more accurate, safe and stable.
[0125] Step 2: Debug the functions of the written program.
[0126] This step mainly includes: adjusting the sine wave through an oscilloscope, adjusting the oscilloscope connection circuit, observing the change of the sine wave period by increasing the frequency, observing the change of the sine wave period by reducing the frequency, adjusting the amplitude change by adjusting the output voltage, the amplitude changes between 1 / 10 and 9 / 10, recording and debugging the waveform change, and realizing power inversion. Preferably, the power is changed by adjusting the voltage and frequency, the output voltage range is 5V-40V, and the frequency range is 0-500HZ.
[0127] In summary, the present invention discloses a low-power inverter design based on the combination of software and hardware. Compared with the prior art, the present invention has the following beneficial effects:
[0128] 1. By setting a PID controller and a neural network controller in the control module, the PID controller generates a control signal, and the neural network controller adjusts the control signal in real time according to the real-time status information through a pre-trained neural network model. The working state of the inverter can be monitored and adjusted in real time, and dynamic adjustments can be made according to changes in the external environment to improve the stability and reliability of the inverter.
[0129] 2. The design of software and hardware combination can reduce the manufacturing cost as much as possible while ensuring the performance of the inverter. Specifically, the sine wave inverter design of the present invention uses the single-chip microcomputer STC12C5608AD as the control core, and its function is to convert DC to AC. The inverter power supply is composed of a full-bridge inverter circuit to form the main circuit of the system. The LM2596 voltage regulator provides a voltage-stabilized power supply part for the single-chip microcomputer, and the STC12C5608AD controls the drive circuit. The inverter part adopts the single-chip microcomputer digital SPWM control mode to control the L298 H-bridge motor driver chip to generate SPWM waves, and an LC filter circuit is added to the output end of the L298 to generate a sine wave, which enhances the reliability and safety of the power supply, and the circuit structure is simple and compact, small in size, and can reduce manufacturing costs.
[0130] 3. By analyzing the output waveform of the system, adjusting the frequency and output voltage amplitude, it becomes a sine wave after inversion. By analyzing the waveform diagram of the debugging system under different conditions, it can be seen that the output waveform is good, and the sinusoidal AC voltage frequency waveform diagram can be output stably. The output AC voltage range after filtering is 5V-40V, the frequency variation range is 0-500HZ, and the amplitude varies between 1 / 10 and 9 / 10 of the total amplitude, which basically achieves the expected results.
[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A low-power inverter based on software and hardware combination, characterized in that: include: The power supply module includes a DC / DC step-down conversion circuit and a step-down voltage stabilization chip; the DC / DC step-down conversion circuit is used to convert a fixed input DC voltage into a variable DC voltage; the step-down chip is used to step down and stabilize the variable DC voltage to obtain a required output DC voltage; A full-bridge inverter circuit, used for converting a set DC voltage output by the power supply module into an AC voltage in response to a control signal; The LC filter circuit is used to filter the AC voltage to obtain a filtered output AC voltage; The control module includes a PID controller and a neural network controller; the PID controller is used to generate a control signal; the neural network controller is used to obtain real-time status information of the inverter and adjust the control signal in real time according to the real-time status information through a pre-trained neural network model.
2. The low-power inverter based on software and hardware combination according to claim 1 is characterized in that: The inverter status information includes: the output DC voltage of the power supply module, the frequency, amplitude and switching state of the AC voltage of the full-bridge inverter circuit, the state of the LC filter circuit and the inverter temperature.
3. The low-power inverter based on software and hardware combination according to claim 1 is characterized in that: The control module is also used to obtain historical status information of the inverter, and train the neural network model according to the historical status information of the inverter to obtain a pre-trained neural network model.
4. The low-power inverter based on software and hardware combination according to claim 3 is characterized in that: The training of the neural network model comprises: Preprocessing the historical status information of the inverter, and dividing the preprocessed data into a training set and a verification set; Constructing a BP neural network, including determining the number of hidden layers of the BP neural network, setting parameters of the BP neural network and initializing the parameters; the parameters include the number of input vector elements, the number of hidden layer neurons, the initial value of each layer weight matrix, the learning rate, and the inertia coefficient; Input the training set into the constructed BP neural network, and according to the parameters of the current BP neural network, use the forward propagation algorithm of the BP neural network to calculate the input and output of each layer of neurons, so that the output layer of the BP neural network outputs the proportional parameter kp, integral parameter ki, differential parameter kd parameters used to adjust the PID controller, and calculate the output u(k) of the PID controller; The current error e(k) is calculated based on u(k) and the output sampling value d(k) of the PID controller. The error performance function is obtained based on e(k). The gradient of each weight matrix to the error performance function is calculated layer by layer from the output layer of the BP neural network. The weight matrix of each layer is updated using the steepest descent method to complete an iterative training. Repeat multiple iterations of training until the value of the error performance function is minimum or less than a threshold, and obtain a pre-trained neural network model; Use the validation set to validate the pre-trained neural network model.
5. The low-power inverter based on software and hardware combination according to claim 1 is characterized in that: The DC / DC step-down conversion circuit includes: a switch, a diode, an inductor, a capacitor and an output resistor; the positive electrode of the input DC voltage is connected to the negative electrode of the diode via the switch, and the negative electrode of the input DC voltage is respectively connected to the positive electrode of the diode, the first end of the capacitor and the first end of the output resistor; the negative electrode of the diode is also respectively connected to the second end of the capacitor and the second end of the output resistor via the inductor; the output DC voltage is obtained from the two ends of the output resistor.
6. The low-power inverter based on software and hardware combination according to claim 1, characterized in that: The step-down voltage regulator chip adopts the LM2596 step-down voltage regulator chip, the control module includes the STC12C5608AD control chip, and the full-bridge inverter circuit includes the L298 H-bridge motor drive chip.
7. The low-power inverter based on software and hardware combination according to claim 1 is characterized in that: The LC filter circuit includes a filter capacitor, a filter inductor and a resistor; the output end of the full-bridge inverter circuit is grounded via the filter capacitor and connected to the first end of the resistor via the filter inductor; the second end of the resistor is grounded; and the filtered output AC voltage is output from both ends of the resistor.
8. A debugging method for a low-power inverter based on software and hardware combination as claimed in any one of claims 1 to 7, characterized in that: The steps include: The control module is realized by using the STC12C5608AD control chip, and the core of the 51 series single-chip microcomputer is selected by Keil software to write the main program and interrupt program for the STC12C5608AD control chip; Perform functional debugging on the written program.
9. The debugging method according to claim 8, characterized in that: The main program is used to manage the mutually exclusive operation and data assignment process of the two units in the STC12C5608AD control chip, including: Initialization phase: Initialize the PCA timer and A / D conversion unit, and set the switching flag exflag to 0; Main program judgment stage: judge whether the current switching flag exflag is 0. If the current switching flag exflag is 0, activate unit m0 and deactivate unit m1; if the current switching flag exflag is 1, activate unit m1 and deactivate unit m0; Processing stage: Check whether the currently activated unit is interrupted. If not, continue to check whether the currently activated unit is interrupted. If an interrupt occurs, use the sine table to assign a value to the corresponding CCAPM, and check whether the sine table is traversed after the assignment. If the traversal is completed, make the currently activated unit output 0, activate another unit, and switch the value of the current switching flag exflag. If the traversal is not completed, continue to check whether the currently activated unit is interrupted.
10. The debugging method according to claim 8, characterized in that: The interrupt program is used to manage the counter interrupt in the STC12C5608AD control chip and update the relevant register value, including: Clearing stage: Starting from the interrupt entry, the carry flag CF and interrupt flag CCF1 related to the interrupt counter or capture / compare register CCAP1 are cleared, the capture / compare register CCAP1 is reassigned, and the high register CH and low register CL of the interrupt counter are cleared to ensure that the interrupt counter starts from zero; Interrupt judgment stage: add 1 to the interrupt count counter and check whether the interrupt count reaches the preset threshold; if the interrupt count does not reach the preset threshold, return to wait for the next interrupt; if it reaches the preset threshold, clear the interrupt count counter and write the required pulse width value into the capture / compare register CCAP0H to control the pulse width modulation PWM output and return from interrupt.