A PWM current automatic calibration circuit and method
By introducing pull-up resistors in the operational amplifier and recording the DC bias voltage, and using a microprocessor to automatically calculate the feedback current, the problem of insufficient PWM current accuracy is solved, achieving automatic calibration without manual operation or equipment, and improving the control accuracy of the controller.
Patent Information
- Application Number
- CN202211307742.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-25
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2042-10-25
AI Technical Summary
In the prior art, there is an error between the feedback current monitored by the microprocessor MCU and the set target output current, resulting in insufficient PWM current accuracy. In addition, the existing calibration method requires manual operation and special equipment, which is costly.
Automatic calibration is achieved by introducing pull-up resistors in the operational amplifier and recording the DC bias voltage during initialization, and using a microprocessor to automatically calculate the difference between the feedback current and the target output current, thereby adjusting the duty cycle of the PWM current.
Automatic calibration of PWM current is achieved, which improves current accuracy, reduces costs, and eliminates the need for manual operation and special equipment.
Smart Images

Figure CN115657456B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of engineering machinery, and particularly relates to a PWM current automatic calibration circuit and method. BACKGROUND
[0002] With the continuous development of precision and intelligent construction of engineering machinery, electric control has become a future development trend of the engineering machinery industry. The current engineering machinery controllers on the market all use PWM ports for proportional valve control. The PWM current output by the PWM port is mainly used to drive the valve core opening of the proportional valve, thereby controlling the output pressure of the proportional valve. The PWM current range is usually 0-3000 mA, and the number of channels is usually 12 or even more. Since the PWM current and the proportional valve output pressure have a certain relationship, the accuracy of the PWM current means the accuracy of the proportional valve output pressure, so the PWM current needs to achieve a certain accuracy in the range of 0-3000 mA to meet the application requirements of electric control.
[0003] The principle of driving the proportional valve by the PWM port of the microprocessor is usually as shown in Figure 1 . First is the driving process. After the microprocessor MCU receives the set target output current instruction, the corresponding PWM port outputs a PWM wave of 3.3V or 5V with a certain duty ratio, which is amplified by a power amplifier to output a PWM wave of 24V or even higher voltage. The current generated by the PWM wave drives the externally connected proportional valve after passing through the sampling resistor, and finally flows to the ground. The feedback process is that the sampling resistor converts the load current into a voltage, which is amplified by an operational amplifier and then output to the ADC port of the microprocessor MCU for sampling calculation and monitoring. Finally, the difference between the monitored feedback current and the target output current is compared to adjust the duty ratio of the PWM wave by PID, thereby changing the proportional valve current. However, when the feedback current monitored by the microprocessor MCU is consistent with the set target output current, there is still a certain error between the actual output current and the set target output current, which is caused by factors such as sampling resistor error, operational amplifier gain error, and operational amplifier bias error in the feedback circuit.
[0004] In the prior art, in order to reduce the errors caused by sampling resistance, operational amplifier gain, operational amplifier bias and the like, the selection and material management of the sampling resistance and the operational amplifier are usually strengthened. The parameters of the sampling resistance are relatively intuitive, and in order to reduce the error of the sampling resistance, a sampling resistance with small resistance value, high precision, low temperature drift and large power can be selected. The operational amplifier usually adopts an integrated circuit chip dedicated to current amplification, which is various in type and complex in parameter, and the prices of different operational amplifiers are quite different. In order to improve the measurement accuracy of the PWM feedback current of the controller, a current amplification dedicated amplifier with high linearity and zero bias error can be selected to reduce the influence of the gain and bias error of the operational amplifier. However, there are few operational amplifiers with high linearity, wide amplification range and zero bias error on the current market, and the price is relatively high. Therefore, the current dedicated amplifier with high performance parameters is adopted, and the disadvantages are that the selection is difficult, the types of materials are limited, and the cost of materials is high.
[0005] Since the bias errors of different operational amplifiers are usually different, independent calibration is required, and therefore a good calibration method is also a way to improve the PWM current accuracy. A PWM current automatic calibration system is disclosed in the Chinese utility model patent with the application number 201922486521.3, which comprises a power supply, a proportional valve group, a calibration instrument, a CAN analyzer, a terminal and a device to be calibrated. The calibration instrument and the calibration software can be used to automatically calibrate the multi-point output of the multi-channel PWM port of the controller after the corresponding wiring harness is connected, thereby improving the efficiency of manual calibration. Although the aforementioned PWM current automatic calibration system can eliminate the bias error generated by the internal circuit of the controller through the external calibration system of the controller, manual operation is still required, and special calibration equipment and software need to be purchased. SUMMARY
[0006] In view of the above problems, the present application provides a PWM current automatic calibration circuit and method, which is low in cost and simple in implementation, and can realize automatic calibration of PWM current without calibration equipment and manual operation.
[0007] In order to achieve the above technical purposes and effects, the present application realizes the following technical solutions:
[0008] In a first aspect, the present application provides a PWM current automatic calibration circuit, comprising an operational amplifier with a CF pin, an upper pull resistor, a sampling resistor, a power amplifier and a microprocessor.
[0009] The inverting terminal and the non-inverting terminal of the operational amplifier are connected to the two ends of the sampling resistor respectively, and the output terminal is connected to the ADC port of the microprocessor.
[0010] One end of the upper pull resistor is connected to the CF pin of the operational amplifier, and the other end is connected to the power supply VCC of the operational amplifier.
[0011] The PWM port of the microprocessor is connected with the input end of the power amplifier, the output end of the power amplifier is connected with one end of the sampling resistor, and the other end of the sampling resistor is used for being connected with the load.
[0012] Optionally, when the input voltage of the operational amplifier is V i , the output voltage of the operational amplifier measured by the ADC port of the microprocessor is:
[0013] V o = V i × M + V +
[0014] wherein, V o is the output voltage of the operational amplifier measured by the ADC port, V + is the DC bias voltage of the operational amplifier, and M is the linear amplification multiple of the operational amplifier.
[0015] Optionally, the pull-up resistor is a mega-ohm pull-up resistor.
[0016] Optionally, the DC bias voltage of the operational amplifier ranges from 1 mV to 300 mV.
[0017] Optionally, when the microprocessor is initialized, the input voltage of the operational amplifier is 0, the output voltage of the operational amplifier measured by the ADC port of the microprocessor is the DC bias voltage V + of the operational amplifier, and the DC bias voltage V + is always positive and is saved by the microprocessor.
[0018] Optionally, the sampling resistor collects the load current and converts it into voltage and inputs it into the operational amplifier, the microprocessor calculates the feedback current based on the output voltage of the operational amplifier measured by the ADC port and the DC bias voltage of the operational amplifier, and the feedback current calculation formula is:
[0019]
[0020] wherein, I is the feedback current, V o is the output voltage of the operational amplifier measured by the ADC port, V + is the DC bias voltage of the operational amplifier, and R is the resistance value of the sampling resistor.
[0021] Optionally, the microprocessor compares the feedback current with the target output current, and adjusts the duty cycle of the PWM current output by the PWM port according to the comparison result, so that the output current of the PWM current automatic calibration circuit is equal to the target output current.
[0022] Optionally, the sampling resistor has a resistance of 0.05 ohm.
[0023] In a second aspect, the application provides a PWM current automatic calibration method, comprising:
[0024] Initializing the PWM current automatic calibration circuit according to any one of the first aspect, the input voltage of the operational amplifier is 0, and the output voltage of the operational amplifier is measured and saved by using the ADC port of the microprocessor, the output voltage of the operational amplifier is the DC bias voltage of the operational amplifier, and the DC bias voltage is always positive;
[0025] The PWM current is output by using the PWM port of the microprocessor, the PWM current is amplified by the power amplifier, and then input to the load through the sampling resistor;
[0026] The load current is collected by using the sampling resistor and converted into voltage and then input to the operational amplifier, and the feedback current is calculated by the microprocessor based on the output voltage of the operational amplifier measured by the ADC port and the DC bias voltage of the operational amplifier;
[0027] The feedback current is compared with the target output current by using the microprocessor, and the duty cycle of the PWM current output by the PWM port of the microprocessor is adjusted according to the comparison result, so that the output current of the PWM current automatic calibration circuit is equal to the target output current.
[0028] Optionally, the feedback current calculation formula is:
[0029]
[0030] Wherein, I is the feedback current, V o is the output voltage of the operational amplifier measured by the ADC port, V + is the DC bias voltage of the operational amplifier, R is the resistance of the sampling resistor, and M is the linear amplification multiple of the operational amplifier.
[0031] Compared with the prior art, the application has the following advantages:
[0032] By adding a pull-up resistor to the operational amplifier with CF pin and recording the DC bias voltage of the operational amplifier in initialization, the PWM feedback current can be automatically calibrated at startup, the PWM current output precision of the PWM port is improved, and the control precision of the controller to the load (such as proportional valve) is improved. Compared with the existing technology, the PWM current precision improvement method is low in cost, simple in implementation, and can realize automatic calibration of PWM current without calibration equipment and manual operation. BRIEF DESCRIPTION OF DRAWINGS
[0033] In order to make the content of the present application more easily and clearly understood, the present application is further described in detail below according to specific embodiments and in conjunction with the accompanying drawings, in which:
[0034] Figure 1 The schematic diagram for the principle of driving the proportional valve by the PWM port of the controller in the prior art;
[0035] Figure 2 The circuit diagram of the DC bias voltage circuit of one embodiment of the present application;
[0036] Figure 3 The flowchart of the PWM current automatic calibration method of one embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the protection scope of the present application.
[0038] The application principle of the present application is described in detail below in conjunction with the accompanying drawings.
[0039] Embodiment 1
[0040] The present application provides a PWM current automatic calibration circuit, as shown in the figure, comprising: an operational amplifier with a CF pin, a pull-up resistor, a sampling resistor, a power amplifier and a microprocessor; Figure 2
[0041] The inverting terminal and the non-inverting terminal of the operational amplifier are respectively connected to the two ends of the sampling resistor, and the output terminal thereof is connected to the ADC port of the microprocessor;
[0042] One end of the pull-up resistor is connected to the CF pin of the operational amplifier, and the other end is connected to the power supply VCC of the operational amplifier; the CF pin is a low-pass filter pin; in the specific implementation process, the operational amplifier can be selected as a current amplifier with a model number AD8213, but the operational amplifier of the present application is not limited to this chip, and other operational amplifiers with a CF pin can also be selected;
[0043] The microprocessor is an MCU in Figure 1 The PWM port thereof is connected to the input terminal of the power amplifier, the output terminal of the power amplifier is connected to one end of the sampling resistor, and the other end of the sampling resistor is used to be connected to a load; in the specific implementation process, the resistance value of the sampling resistor can be set to 0.05 ohm, and the resistance value of the sampling resistor can also be set to other values, which is specifically set according to actual needs.
[0044] In actual application, the PWM current automatic calibration circuit in the embodiment of the present invention exists in the form of a controller, which is connected to the load through the PWM port to output a control signal to the load. Figure 1 .
[0045] In a specific implementation of the embodiment of the present invention, since there is a resistor grounded in the CF pin of the operational amplifier, it can be divided with the pull-up resistor (external resistor) to realize the signal output by the sampling resistor (the input voltage is V i ) is introduced into the DC bias before the signal is amplified after low-pass filtering, realizing the output voltage of the operational amplifier = input voltage × linear amplification factor + DC bias voltage V + , DC bias voltage V + The pull-up resistor in the embodiment of the present invention should be neither too large nor too small. If it is too large, the DC bias voltage V + It may be a negative value. If it is too small, it will reduce the amplification range of the operational amplifier. Usually, a pull-up resistor above the megohm level is selected to ensure that the output voltage of the operational amplifier voltage regulator is always greater than 0V. After selecting a suitable pull-up resistor, assuming that the linear amplification factor of the operational amplifier is M, when the input voltage is V i When the output voltage of the operational amplifier measured by the ADC port of the microprocessor is:
[0046] V o =V i ×M+V +
[0047] Among them, V o is the output voltage of the operational amplifier measured at the ADC port, V + is the DC bias voltage of the operational amplifier, and M is the linear amplification factor of the operational amplifier. In a specific application, the DC bias voltage of the operational amplifier has a value range of 1 to 300 mV.
[0048] When the microprocessor is initialized, the input voltage of the operational amplifier is 0, and the output voltage of the operational amplifier measured by the ADC port of the microprocessor is the DC bias voltage V + , and is stored by the microprocessor, the DC bias voltage V + Always positive.
[0049] In a specific implementation of the embodiment of the present invention, the sampling resistor collects the load current and converts it into a voltage before inputting it into the operational amplifier. The microprocessor calculates the feedback current based on the output voltage of the operational amplifier measured by the ADC port and the DC bias voltage of the operational amplifier. The feedback current calculation formula is:
[0050]
[0051] Wherein, I is the feedback current, V o is the output voltage of the operational amplifier measured by the ADC port, V + is the DC bias voltage of the operational amplifier, R is the resistance value of the sampling resistor, and M is the linear amplification multiple of the operational amplifier.
[0052] The microprocessor compares the feedback current with the target output current and adjusts the duty cycle of the PWM current output by the PWM port according to the comparison result, so that the output current of the PWM port of the PWM current automatic calibration circuit is equal to the target output current.
[0053] The specific working process of the PWM current automatic calibration circuit in the embodiment of the application will be described in detail in combination with a specific implementation.
[0054] The sampling resistor, the pull-up resistor and the operational amplifier in the embodiment of the application are defined as the DC bias voltage circuit. In actual application, since the number of loads is several, the DC bias voltage circuit consistent with the number of loads is required, and the number of ADC ports on the microprocessor is consistent with the number of loads.
[0055] When the microprocessor is powered on, the input voltage of the operational amplifier is 0V, at this time, each ADC port on the microprocessor and the data buffer are initialized first, then the voltage values of each ADC port are sampled multiple times and the average values are calculated, and finally the average voltage values of each ADC port are stored in the data buffer array of the corresponding port as the DC bias voltage of each ADC port. Since the bias error of each operational amplifier is inconsistent, the DC bias voltage values stored in each port are actually different, which are respectively denoted as V +1 , V +2 , thereby indirectly recording the DC bias voltage (i.e. bias error information) of each operational amplifier during the power-on initialization process.
[0056] The sampling resistor in each DC bias voltage circuit collects the corresponding load current and converts it into voltage and inputs it to the corresponding operational amplifier, the microprocessor calculates the feedback current based on the output voltage of the operational amplifier measured by the ADC port and the DC bias voltage of the operational amplifier, and the feedback current calculation formula is I = (V - V
[0057]
[0058] The microprocessor compares the feedback current with the target output current, and adjusts the duty cycle of the PWM current output by the PWM port according to the comparison result, so that the output current of the PWM current automatic calibration circuit is equal to the target output current.
[0059] Embodiment 2
[0060] The PWM current automatic calibration method provided in the embodiments of the present application comprises the following steps of: Figure 3
[0061] The PWM current automatic calibration circuit is initialized, the input voltage of the operational amplifier is 0, the output voltage of the operational amplifier is measured and saved by the ADC port of the microprocessor, the output voltage is the DC bias voltage of the operational amplifier, and the DC bias voltage is always positive;
[0062] The PWM current is output by the PWM port of the microprocessor, the PWM current is amplified by the power amplifier, and then input to the load through the sampling resistor;
[0063] The load current is collected by the sampling resistor and converted into a voltage, and then input to the operational amplifier, the feedback current is calculated by the microprocessor based on the output voltage of the operational amplifier measured by the ADC port and the DC bias voltage of the operational amplifier;
[0064] The microprocessor compares the feedback current with the target output current, and adjusts the duty cycle of the PWM current output by the PWM port according to the comparison result, so that the output current of the PWM current automatic calibration circuit is equal to the target output current.
[0065] The feedback current calculation formula is as follows:
[0066]
[0067] Wherein, I is the feedback current, V o is the output voltage of the operational amplifier measured by the ADC port, V + is the DC bias voltage of the operational amplifier, R is the resistance value of the sampling resistor, and M is the linear amplification multiple of the operational amplifier.
[0068] The specific working process of the PWM current automatic calibration method in the embodiments of the present application will be described in detail in combination with a specific embodiment.
[0069] The sampling resistor, the pull-up resistor and the operational amplifier in the embodiments of the present application are defined as the DC bias voltage circuit. In actual application process, since the number of loads is several, the DC bias voltage circuit consistent with the number of loads is required, and the number of ADC ports on the microprocessor is consistent with the number of loads.
[0070] When the microprocessor is powered on, the input voltage of the operational amplifier is 0V, at this time, the microprocessor is initialized first, and then the voltage value of each ADC port and the data buffer are initialized, and then the voltage value of each ADC port is sampled multiple times and the average value is calculated, and finally the average voltage value of each ADC port is stored in the data buffer array of the corresponding port as the DC bias voltage of each ADC port. Because the bias error of each operational amplifier is inconsistent, the DC bias voltage value stored in each port is actually different, and is respectively recorded as V +1 、V +2 ···, thereby indirectly recording the DC bias voltage (i.e. bias error information) of each operational amplifier during the power-on initialization process.
[0071] The sampling resistor in each DC bias voltage circuit collects the corresponding load current and converts it into a voltage, which is then input to the corresponding operational amplifier. The microprocessor calculates the feedback current based on the output voltage of the operational amplifier measured by the ADC port and the DC bias voltage of the operational amplifier. The feedback current calculation formula is I1, I2,..., the feedback current value of each ADC port is:
[0072]
[0073] The microprocessor compares the feedback current with the target output current, and adjusts the duty cycle of the PWM current output by the corresponding PWM port according to the comparison result, so that the output current of the PWM automatic calibration circuit is equal to the target output current.
[0074] The above shows and describes the basic principles and main features of the present application and the advantages of the present application. Those skilled in the art should understand that the present application is not limited to the above embodiments, and the above embodiments and descriptions in the specification are only to illustrate the principles of the present application. Without departing from the spirit and scope of the present application, various changes and improvements can be made to the present application, and these changes and improvements all fall within the scope of the claimed present application. The scope of protection of the present application is defined by the appended claims and their equivalents.
Claims
1. A PWM current automatic calibration circuit, characterized in that: include: Operational amplifier with CF pin, pull-up resistor, sampling resistor, power amplifier and microprocessor; The inverting terminal and the non-inverting terminal of the operational amplifier are respectively connected to the two ends of the sampling resistor, and the output terminal thereof is connected to the ADC port of the microprocessor; One end of the pull-up resistor is connected to the CF pin of the operational amplifier, and the other end is connected to the power supply VCC of the operational amplifier; The PWM port of the microprocessor is connected to the input end of the power amplifier, the output end of the power amplifier is connected to one end of the sampling resistor, and the other end of the sampling resistor is used to be connected to a load; When the input voltage of the operational amplifier is V i When the output voltage of the operational amplifier measured by the ADC port of the microprocessor is: V o =V i ×M+V + Among them, V o is the output voltage of the operational amplifier measured at the ADC port, V + is the DC bias voltage of the operational amplifier, M is the linear amplification factor of the operational amplifier; The pull-up resistor is a megohm-level pull-up resistor; The sampling resistor collects the load current and converts it into a voltage before inputting it into the operational amplifier. The microprocessor calculates the feedback current based on the output voltage of the operational amplifier measured by the ADC port and the DC bias voltage of the operational amplifier. The feedback current calculation formula is: Where I is the feedback current, V o is the output voltage of the operational amplifier measured at the ADC port, V + is the DC bias voltage of the operational amplifier, R is the resistance of the sampling resistor, and M is the linear amplification factor of the operational amplifier.
2. The PWM current automatic calibration circuit according to claim 1, characterized in that: The DC bias voltage of the operational amplifier has a value range of 1-300mV.
3. The PWM current automatic calibration circuit according to claim 1, wherein: When the microprocessor is initialized, the input voltage of the operational amplifier is 0, and the output voltage of the operational amplifier measured by the ADC port of the microprocessor is the DC bias voltage V + , and is stored by the microprocessor, the DC bias voltage V + Always positive.
4. The PWM current automatic calibration circuit according to claim 1, characterized in that: The microprocessor compares the feedback current with the target output current and adjusts the duty cycle of the PWM current output by the PWM port according to the comparison result, so that the output current of the PWM current automatic calibration circuit is equal to the target output current.
5. The PWM current automatic calibration circuit according to claim 1, characterized in that: The resistance of the sampling resistor is 0.05 ohm.
6. A PWM current automatic calibration method, characterized in that: include: Initializing the PWM current automatic calibration circuit according to any one of claims 1 to 5, wherein the input voltage of the operational amplifier is 0, and the output voltage of the operational amplifier is measured and saved using the ADC port of the microprocessor, wherein the output voltage of the operational amplifier is the DC bias voltage of the operational amplifier, and the DC bias voltage is always positive; outputting the PWM current using the PWM port of the microprocessor, and the PWM current is amplified by the power amplifier and then sent to the load through the sampling resistor; The load current is collected by a sampling resistor and converted into a voltage before being input into an operational amplifier. The microprocessor calculates the feedback current based on the output voltage of the operational amplifier measured by the ADC port and the DC bias voltage of the operational amplifier. The feedback current is compared with the target output current by a microprocessor, and the duty cycle of the PWM current output by the PWM port of the microprocessor is adjusted according to the comparison result, so that the output current of the PWM current automatic calibration circuit is equal to the target output current.
7. The PWM current automatic calibration method according to claim 6, characterized in that: The feedback current calculation formula is: Where I is the feedback current, V o is the output voltage of the operational amplifier measured at the ADC port, V + is the DC bias voltage of the operational amplifier, R is the resistance of the sampling resistor, and M is the linear amplification factor of the operational amplifier.
Citation Information
Patent Citations
PWM current automatic calibration system
CN211402692U
Current sampling circuit and motor
CN203011991U