A pulse width modulation data mapping method, circuit, device and storage medium

By comparing the input PWM data with the data in the special point storage device and updating the register, the interpolation counter is used to realize the mapping of PWM data, which solves the complexity problem of PWM duty cycle mapping in the existing technology and improves the control accuracy and speed of electronic equipment. .

CN118381491BActive Publication Date: 2024-09-13HANGZHOU RUIMENG TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410808447.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-09-13
Estimated Expiration
2044-06-21

AI Technical Summary

Technical Problem

The existing technology cannot realize simple mapping of PWM data corresponding to any pulse width modulation (PWM) duty cycle, resulting in low control accuracy of electronic equipment.

Method used

By comparing the input PWM data with the data in the special point storage device, updating the data in the register, and using the interpolation counter to perform counting, the mapping of any PWM duty cycle is realized, thereby controlling the electronic device.

Benefits of technology

It achieves more accurate and faster control of electronic equipment, simplifies the mapping process of PWM data, and improves control accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118381491B
    Figure CN118381491B
Patent Text Reader

Abstract

The embodiment of the present application discloses a pulse width modulation data mapping method, circuit, device and storage medium. The method includes: comparing input PWM data with data in a first horizontal coordinate storage register and data in a second horizontal coordinate storage register to obtain a comparison result; updating data in the first horizontal coordinate storage register, data in the second horizontal coordinate storage register, data in the first vertical coordinate storage register and data in the second vertical coordinate storage register according to the first comparison result or the second comparison result; controlling an interpolation counter to perform corresponding counting according to input PWM data, updated data in the first horizontal coordinate storage register and updated data in the second horizontal coordinate storage register; obtaining output PWM data according to the value of the interpolation counter and the updated data in the second vertical coordinate storage register, so that the mapping of any PWM data can be realized more simply.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a pulse width modulation data mapping method, circuit, device and storage medium. Background Art

[0002] Pulse Width Modulation (PWM) is a very effective technology that uses the digital output of a microprocessor to control analog circuits. It is widely used in measurement, communication, power control and conversion, and other fields.

[0003] In actual applications, the input PWM duty cycle and the output PWM duty cycle do not necessarily need to have a linear correspondence. For example, when the input PWM duty cycle reaches 90%, if you want the motor to turn off, you need to change the input PWM duty cycle to 0%. In this way, a way to map the input PWM duty cycle is needed so that there is no need to manually change the input PWM duty cycle in real time during actual applications.

[0004] However, currently, it is impossible to implement the mapping of PWM data corresponding to any PWM duty cycle, and the mapping method of PWM data is relatively complex, which results in low control accuracy of the electronic device. Summary of the invention

[0005] In view of this, the embodiments of the present application disclose a pulse width modulation data mapping method, circuit, device and storage medium, which can more simply realize the mapping of PWM data corresponding to any PWM duty cycle, thereby achieving more accurate control of electronic equipment.

[0006] The technical solutions provided by the embodiments of this application are as follows:

[0007] In a first aspect, an embodiment of the present application provides a pulse width modulation curve mapping method, the method comprising:

[0008] Compare the input pulse width modulation (PWM) data with the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register to obtain a comparison result; wherein the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register are taken from the horizontal coordinate of a special point in a special point storage device, the special point storage device sequentially stores a plurality of special points, the horizontal coordinate of the special point represents the PWM data before mapping, and the vertical coordinate of the special point represents the PWM data after mapping;

[0009] If the comparison result is the first comparison result or the second comparison result, update the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register according to the first comparison result or the second comparison result; the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, and the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register;

[0010] According to the input PWM data, the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register, the interpolation counter is controlled to perform corresponding counting; wherein the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register are the horizontal coordinates of the first special point and the second special point adjacent to each other among the plurality of special points, the data in the updated first vertical coordinate storage register and the data in the updated second vertical coordinate storage register are the vertical coordinates of the first special point and the second special point, and the input PWM data is greater than the horizontal coordinate of the first special point and less than the horizontal coordinate of the second special point;

[0011] Output PWM data is obtained according to the value of the interpolation counter and the updated data in the second ordinate storage register, and the output PWM data is used to control the electronic device.

[0012] In a possible implementation manner, if the comparison result is not the first comparison result or the second comparison result, the method further includes:

[0013] Controlling the interpolation counter to perform corresponding counting according to the input PWM data, the data in the first horizontal coordinate storage register, and the data in the second horizontal coordinate storage register;

[0014] Output PWM data is obtained according to the value of the interpolation counter and the data in the second ordinate storage register.

[0015] In a possible implementation, the interpolation counter includes: a first interpolation counter and a second interpolation counter, wherein the second interpolation counter is a counter with a sign bit;

[0016] The step of controlling the interpolation counter to perform corresponding counting according to the input PWM data, the updated data in the first horizontal coordinate storage register, and the updated data in the second horizontal coordinate storage register comprises:

[0017] Control the first interpolation counter to add one each time, the second interpolation counter correspondingly adds (DATAin -X2); the DATA in represents the input PWM data, and X2 represents the data in the updated second horizontal coordinate storage register;

[0018] When the first interpolation counter counts to a first count value, the second interpolation counter is controlled to stop counting, and the first interpolation counter is reset to zero; the first count value is Y1-Y2; Y1 represents the data in the updated first ordinate storage register, and Y2 represents the data in the updated second ordinate storage register;

[0019] Controlling the first interpolation counter to correspondingly subtract (X1-X2) each time when the first interpolation counter is added by one; the X1 represents the data in the updated first abscissa storage register;

[0020] The step of obtaining output PWM data according to the value of the interpolation counter and the updated data in the second ordinate storage register comprises:

[0021] When the sign bit of the second interpolation counter changes from 0 to 1, output PWM data is obtained according to the value of the first interpolation counter and the data in the updated second ordinate storage register;

[0022] or,

[0023] The step of controlling the interpolation counter to perform corresponding counting according to the input PWM data, the data in the first horizontal coordinate storage register, and the data in the second horizontal coordinate storage register comprises:

[0024] Control the first interpolation counter to add one each time, the second interpolation counter correspondingly adds (DATA in -X2'); the DATA in represents the input PWM data, and X2' represents the data in the second horizontal coordinate storage register;

[0025] When the first interpolation counter counts to a second count value, the second interpolation counter is controlled to stop counting, and the first interpolation counter is reset to zero; the second count value is Y1'-Y2'; the Y1' represents the data in the first ordinate storage register, and the Y2' represents the data in the second ordinate storage register;

[0026] Controlling the first interpolation counter to subtract (X1'-X2') correspondingly each time when the first interpolation counter is added by one; the X1' represents the data in the first horizontal coordinate storage register;

[0027] The step of obtaining output PWM data according to the value of the interpolation counter and the data in the second ordinate storage register comprises:

[0028] When the sign bit of the second interpolation counter changes from 0 to 1, output PWM data is obtained according to the value of the first interpolation counter and the data in the second ordinate storage register.

[0029] In a possible implementation, the interpolation counter includes: a first interpolation counter and a second interpolation counter, and updating the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register according to the first comparison result or the second comparison result includes:

[0030] When the first interpolation counter counts to a third count value, the value of the coordinate point mark counter is updated according to the first comparison result or the second comparison result to obtain an updated value;

[0031] The data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register are updated using the special point corresponding to the update value.

[0032] In a possible implementation, when the first interpolation counter counts to a third count value, updating the value of the coordinate point mark counter according to the first comparison result or the second comparison result to obtain an updated value includes:

[0033] When the first interpolation counter counts to a third count value, if the comparison result is the first comparison result, the value of the coordinate point mark counter is increased by 1 to obtain an updated value;

[0034] The updating of the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register by using the special point corresponding to the update value includes:

[0035] Update the data in the second horizontal coordinate storage register to the data in the first horizontal coordinate storage register, update the data in the second vertical coordinate storage register to the data in the first vertical coordinate storage register, update the data in the first horizontal coordinate storage register to the horizontal coordinate of the special point corresponding to the updated value, and update the data in the first vertical coordinate storage register to the vertical coordinate of the special point corresponding to the updated value;

[0036] or,

[0037] When the first interpolation counter counts to a third count value, updating the value of the coordinate point mark counter according to the first comparison result or the second comparison result to obtain an updated value includes:

[0038] When the first interpolation counter counts to a third count value, if the comparison result is the second comparison result, subtract one from the value of the coordinate point mark counter to obtain an updated value;

[0039] The updating of the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register by using the special point corresponding to the update value includes:

[0040] Update the data in the first horizontal coordinate storage register to the data in the second horizontal coordinate storage register, update the data in the first vertical coordinate storage register to the data in the second vertical coordinate storage register, update the data in the second horizontal coordinate storage register to the horizontal coordinate of the special point corresponding to the updated value, and update the data in the second vertical coordinate storage register to the vertical coordinate of the special point corresponding to the updated value.

[0041] In a possible implementation, before comparing the input PWM data with the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register to obtain a comparison result, the method further includes:

[0042] Initialize data in a first abscissa storage register, data in a second abscissa storage register, data in a first ordinate storage register, and data in a second ordinate storage register using a first special point among the plurality of special points;

[0043] The input PWM data is stored in an external data storage register.

[0044] In a possible implementation, if the comparison result is a first comparison result, the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, and the output PWM data is obtained according to the value of the interpolation counter and the updated data in the second vertical coordinate storage register, including:

[0045] The output PWM data is calculated by the following formula:

[0046] DATA out =Y2+△y-1;

[0047] If the comparison result is the second comparison result, and the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register, the output PWM data is obtained according to the value of the interpolation counter and the updated data in the second vertical coordinate storage register, including:

[0048] The output PWM data is calculated by the following formula:

[0049] DATA out =Y2-△y+1;

[0050] Among them, the DATA ou t represents the output PWM data, Y2 represents the data in the updated second ordinate storage register, and Δy is the value of the interpolation counter.

[0051] In a second aspect, an embodiment of the present application provides a pulse width modulation curve mapping circuit, the circuit comprising: a first abscissa storage register, a second abscissa storage register, a first ordinate storage register, a second ordinate storage register, and an interpolation counter;

[0052] The first horizontal coordinate storage register, the second horizontal coordinate storage register, the first vertical coordinate storage register and the second vertical coordinate storage register are used to update data according to the first comparison result or the second comparison result if the comparison result is the first comparison result or the second comparison result; wherein the comparison result is obtained by comparing the input pulse width modulation PWM data with the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register, the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register, the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register are taken from the horizontal coordinate of a special point in a special point storage device, the special point storage device sequentially stores a plurality of special points, the horizontal coordinate of the special point represents the PWM data before mapping, and the vertical coordinate of the special point represents the PWM data after mapping;

[0053] The interpolation counter is used to perform corresponding counting according to the input PWM data, the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register if the comparison result is the first comparison result or the second comparison result; wherein the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register are the horizontal coordinates of the first special point and the second special point adjacent to each other among the multiple special points, the data in the updated first vertical coordinate storage register and the data in the updated second vertical coordinate storage register are the vertical coordinates of the first special point and the second special point, and the input PWM data is greater than the horizontal coordinate of the first special point and less than the horizontal coordinate of the second special point;

[0054] The interpolation counter is used to determine the value of the interpolation counter after the interpolation counter performs the corresponding counting; the value of the interpolation counter is used to determine the output PWM data together with the data in the updated second vertical coordinate storage register, and the output PWM data is used to control the electronic device.

[0055] In a third aspect, an embodiment of the present application provides a pulse width modulation curve mapping device, comprising:

[0056] A memory for storing instructions;

[0057] A processor is used to execute the instructions in the memory to perform the pulse width modulation curve mapping method described in any one of the first aspects above.

[0058] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a computer, enables the computer to execute the pulse width modulation curve mapping method described in any one of the first aspects above.

[0059] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the pulse width modulation curve mapping method described in any one of the first aspects above.

[0060] Based on the above technical solution, this application has the following beneficial effects:

[0061] The embodiment of the present application discloses a pulse width modulation data mapping method, circuit, device and storage medium. The method includes: comparing input PWM data with data in a first horizontal coordinate storage register and data in a second horizontal coordinate storage register to obtain a comparison result; if the comparison result is a first comparison result or a second comparison result, updating data in the first horizontal coordinate storage register, data in the second horizontal coordinate storage register, data in the first vertical coordinate storage register and data in the second vertical coordinate storage register according to the first comparison result or the second comparison result; controlling an interpolation counter to perform corresponding counting according to input PWM data, updated data in the first horizontal coordinate storage register and updated data in the second horizontal coordinate storage register; and obtaining output PWM data according to the value of the interpolation counter and the updated data in the second vertical coordinate storage register. It can be seen that in the embodiment of the present application, by storing multiple special points including PWM data before mapping and PWM data after mapping in a special point storage device, the interpolation counter can be controlled to perform corresponding counting based on the special points to implement corresponding interpolation operations, thereby implementing mapping of PWM data corresponding to any PWM duty cycle, and thus achieving more accurate control of electronic devices. Moreover, by controlling the interpolation counter to perform corresponding counting, the value of the interpolation counter can be used to determine the output PWM data, so that the input PWM data can be mapped to the output PWM data more simply, thereby more simply realizing the mapping of PWM data, and further realizing faster control of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the disclosed drawings without paying any creative work.

[0063] Figure 1 A flowchart of a pulse width modulation data mapping method disclosed in an embodiment of the present application;

[0064] Figure 2 A flowchart of another pulse width modulation data mapping method disclosed in an embodiment of the present application;

[0065] Figure 3 A schematic diagram of a pulse width modulation data mapping circuit disclosed in an embodiment of the present application;

[0066] Figure 4 A schematic diagram of an input PWM curve and an output PWM curve disclosed in an embodiment of the present application;

[0067] Figure 5A schematic diagram of a mapping curve disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0068] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0069] See also Figure 1 , a flow chart of a pulse width modulation data mapping method disclosed in an embodiment of the present application, the method comprising:

[0070] S101 . Compare input PWM data with data in a first horizontal coordinate storage register and data in a second horizontal coordinate storage register to obtain a comparison result.

[0071] Among them, the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register are taken from the horizontal coordinate of the special point in the special point storage device. The special point storage device stores multiple special points in sequence. The horizontal coordinate of the special point represents the PWM data before mapping, and the vertical coordinate of the special point represents the PWM data after mapping.

[0072] In the embodiment of the present application, the PWM data is a transformed form of the PWM duty cycle represented by a digital signal. In the special point storage device, the horizontal coordinate of the N-1th special point is less than the horizontal coordinate of the Nth special point and less than the horizontal coordinate of the N+1th special point, and N is a positive integer. The special point storage device can be a memory or a register, etc. The memory can be an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), etc., and the embodiment of the present application does not limit this.

[0073] S102: If the comparison result is the first comparison result or the second comparison result, update the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register according to the first comparison result or the second comparison result.

[0074] Among them, the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, indicating that the slope is positive; the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register, indicating that the slope is negative.

[0075] S103 , controlling the interpolation counter to perform corresponding counting according to the input PWM data, the updated data in the first horizontal coordinate storage register, and the updated data in the second horizontal coordinate storage register.

[0076] Among them, the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register are the horizontal coordinates of the first special point and the second special point adjacent to each other among the multiple special points, the data in the updated first vertical coordinate storage register and the data in the updated second vertical coordinate storage register are the vertical coordinates of the first special point and the second special point, and the input PWM data is greater than the horizontal coordinate of the first special point and less than the horizontal coordinate of the second special point.

[0077] It should be noted that the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register are the horizontal coordinates of the adjacent first special point and the second special point among the multiple special points, and the data in the updated first vertical coordinate storage register and the data in the updated second vertical coordinate storage register are the vertical coordinates of the first special point and the second special point. It can be understood that: the data in the updated first horizontal coordinate storage register is the horizontal coordinate of the first special point, the data in the updated second horizontal coordinate storage register is the horizontal coordinate of the second special point, the data in the updated first vertical coordinate storage register is the vertical coordinate of the first special point, and the data in the updated second vertical coordinate storage register is the vertical coordinate of the second special point, or, the data in the updated first horizontal coordinate storage register is the horizontal coordinate of the second special point, the data in the updated second horizontal coordinate storage register is the horizontal coordinate of the first special point, the data in the updated first vertical coordinate storage register is the vertical coordinate of the second special point, and the data in the updated second vertical coordinate storage register is the vertical coordinate of the first special point.

[0078] S104 , obtaining output PWM data according to the value of the interpolation counter and the updated data in the second ordinate storage register.

[0079] The output PWM data is used to control an electronic device, which may be a motor, etc. In a possible implementation, the output PWM data may be used to control a switching frequency of a metal oxide semiconductor field effect transistor (MOSFET) switch of the motor.

[0080] It should be noted that the value of the interpolation counter refers to the current value of the interpolation counter after the interpolation counter performs the corresponding counting.

[0081] It can be seen that in the embodiment of the present application, by storing multiple special points including PWM data before mapping and PWM data after mapping in a special point storage device, the interpolation counter can be controlled to perform corresponding counting based on the special points to implement corresponding interpolation operations, thereby realizing the mapping of PWM data corresponding to any PWM duty cycle, and thus realizing more accurate control of the electronic device. Moreover, by controlling the interpolation counter to perform corresponding counting, the value of the interpolation counter can be used to determine the output PWM data, so that the input PWM data can be mapped to the output PWM data more simply, thereby realizing the mapping of PWM data more simply, and thus realizing faster control of the electronic device.

[0082] See also Figure 2 , a flow chart of another pulse width modulation data mapping method disclosed in an embodiment of the present application, the method comprising:

[0083] S201, using a first special point among a plurality of special points, to initialize data in a first horizontal coordinate storage register, data in a second horizontal coordinate storage register, data in a first vertical coordinate storage register, and data in a second vertical coordinate storage register.

[0084] Because the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register are 0 by default after power-on reset, they need to be initialized first and assigned initial values. In the embodiment of the present application, the horizontal coordinate of the first special point among multiple special points can be stored in the first horizontal coordinate storage register and the second horizontal coordinate storage register, respectively, to assign initial values ​​to the first horizontal coordinate storage register and the second horizontal coordinate storage register; the vertical coordinate of the first special point among multiple special points can be stored in the first vertical coordinate storage register and the second vertical coordinate storage register, respectively, to assign initial values ​​to the first vertical coordinate storage register and the second vertical coordinate storage register. Among them, the first special point is a special point with a horizontal coordinate of 0.

[0085] The interpolation counter in the embodiment of the present application may include: a first interpolation counter and a second interpolation counter. The first interpolation counter can be controlled to perform counting. When the first interpolation counter counts to the third count value, the value of the coordinate point mark counter is increased by one. At this time, the value of the coordinate point mark counter changes from 0 to 1, which means that the coordinate point obtained from the special point storage device is (x1, y1), and x1 is stored in the first horizontal coordinate storage register and the second horizontal coordinate storage register, and y1 is stored in the first vertical coordinate storage register and the second vertical coordinate storage register. Then at the next clock edge, the first interpolation counter is controlled to return to zero, and at this time the state machine state=0. Among them, state=0 represents the initialization of a linear interpolation calculation.

[0086] In the embodiment of the present application, the third count value can be determined according to the number of bits of the first interpolation counter. For example, if the first interpolation counter is a 9-bit counter, the third count value is 2 9 -1=511. It is to be understood that the above is only an exemplary description and should not be construed as limiting the embodiments of the present application.

[0087] S202, storing the input PWM data into an external data storage register.

[0088] In the embodiment of the present application, the input PWM data can be latched into the external data storage register when the state machine state=0. It should be noted that only one data is stored in the external data storage register, namely the current input PWM data, and the input PWM data can be a certain point in the external input PWM curve. The input PWM data is obtained by converting the external input PWM duty cycle into a value according to the number of bits of the external data storage register.

[0089] In the implementation of the present application, by initializing the first horizontal coordinate storage register, the second horizontal coordinate storage register, the first vertical coordinate storage register, the second vertical coordinate storage register and the external data storage register, PWM data mapping can be better achieved.

[0090] S203 , comparing the input PWM data with the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register to obtain a comparison result.

[0091] It should be noted that S203 is the same as the above-mentioned S101, so it is not described again.

[0092] S204 , if the comparison result is the first comparison result or the second comparison result, update the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register according to the first comparison result or the second comparison result.

[0093] In the implementation of the present application, S204 may include: when the first interpolation counter counts to the third count value, updating the value of the coordinate point mark counter according to the first comparison result or the second comparison result to obtain an updated value; using the special point corresponding to the updated value to update the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register. In this way, by updating the value of the coordinate point mark counter corresponding to the comparison result, the corresponding special point can be obtained more accurately, and the update of the data in the register can be realized more accurately.

[0094] In a possible implementation, when the first interpolation counter counts to the third count value, if the comparison result is the first comparison result, and the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, the value of the coordinate point mark counter is increased by one to obtain an updated value; the data in the second horizontal coordinate storage register is updated to the data in the first horizontal coordinate storage register, the data in the second vertical coordinate storage register is updated to the data in the first vertical coordinate storage register, the data in the first horizontal coordinate storage register is updated to the horizontal coordinate of the special point corresponding to the updated value, and the data in the first vertical coordinate storage register is updated to the vertical coordinate of the special point corresponding to the updated value. In this way, according to the size relationship between the PWM data and the data in the first horizontal coordinate storage register, the value of the coordinate point mark counter is updated accordingly, so as to ensure that the accurate special point can be obtained later, and the data in the first horizontal coordinate storage register and the data in the first vertical coordinate storage register are accurately updated, so as to ensure that the interpolation counter can count accurately, and further ensure that the final value of the interpolation counter can be used to determine the output PWM data.

[0095] It should be noted that updating the data in the second horizontal coordinate storage register with the data in the first horizontal coordinate storage register means updating the data in the second horizontal coordinate storage register with the data in the first horizontal coordinate storage register. For example, if the data in the first horizontal coordinate storage register is a, then after the data in the second horizontal coordinate storage register is updated with the data in the first horizontal coordinate storage register, the updated data in the second horizontal coordinate storage register is a. It can be understood that the above is only an exemplary description and should not be construed as limiting the embodiments of the present application.

[0096] In the embodiment of the present application, the first horizontal coordinate storage register can first obtain the horizontal coordinate of the special point corresponding to the updated value from the storage device, and then update the data in the first horizontal coordinate storage register to the horizontal coordinate of the special point corresponding to the updated value; the first vertical coordinate storage register can first obtain the vertical coordinate of the special point corresponding to the updated value from the storage device, and then update the data in the first vertical coordinate storage register to the vertical coordinate of the special point corresponding to the updated value.

[0097] For example, if the value of the coordinate point mark counter is n, add 1 to the value of the coordinate point mark counter to get the updated value n+1. At this time, the value of the coordinate point mark counter is n+1. The first horizontal coordinate storage register obtains the horizontal coordinate x of the n+1th special point from the storage device. n+1 , the first ordinate storage register obtains the ordinate y of the n+1th special point from the storage device n+1 The data in the second horizontal axis storage register will be updated to x n , the data in the second vertical coordinate storage register will be updated to y n , the data in the first horizontal coordinate storage register is updated to xn+1 , the data in the first vertical coordinate storage register will be updated to y n+1 It is to be understood that the above is merely an exemplary description and should not be construed as limiting the embodiments of the present application.

[0098] In a possible implementation, when the first interpolation counter counts to the third count value, if the comparison result is the second comparison result, and the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register, the value of the coordinate point mark counter is subtracted by one to obtain an updated value; the data in the first horizontal coordinate storage register is updated to the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register is updated to the data in the second vertical coordinate storage register, the data in the second horizontal coordinate storage register is updated to the horizontal coordinate of the special point corresponding to the updated value, and the data in the second vertical coordinate storage register is updated to the vertical coordinate of the special point corresponding to the updated value. In this way, according to the size relationship between the PWM data and the data in the second horizontal coordinate storage register, the value of the coordinate point mark counter is correspondingly updated to ensure that the accurate special point can be obtained later, and the data in the second horizontal coordinate storage register and the data in the second coordinate storage register are accurately updated, so as to ensure that the interpolation counter can count accurately, and further ensure that the final value of the interpolation counter can be used to determine the output PWM data.

[0099] In the embodiment of the present application, the second horizontal coordinate storage register can first obtain the horizontal coordinate of the special point corresponding to the updated value from the storage device, and then update the data in the second horizontal coordinate storage register to the horizontal coordinate of the special point corresponding to the updated value; the second vertical coordinate storage register can first obtain the vertical coordinate of the special point corresponding to the updated value from the storage device, and then update the data in the second vertical coordinate storage register to the vertical coordinate of the special point corresponding to the updated value.

[0100] For example, if the value of the coordinate point mark counter is n, subtract one from the value of the coordinate point mark counter to obtain the updated value n-1. At this time, the value of the coordinate point mark counter is n-1. The second horizontal coordinate storage register obtains the horizontal coordinate x of the n-1th special point from the storage device. n-1 The second ordinate storage register obtains the ordinate y of the n-1th special point from the storage device n-1 The data in the first horizontal axis storage register will be updated to x n , the data in the first vertical coordinate storage register will be updated to y n , the data in the second horizontal axis storage register is updated to x n-1 , the data in the second vertical coordinate storage register will be updated to y n-1 It is to be understood that the above is merely an exemplary description and should not be construed as limiting the embodiments of the present application.

[0101] S205 , controlling the interpolation counter to perform corresponding counting according to the input PWM data, the updated data in the first horizontal coordinate storage register, and the updated data in the second horizontal coordinate storage register.

[0102] The second interpolation counter in the embodiment of the present application is a counter with a sign bit.

[0103] In the embodiment of the present application, S205 may include:

[0104] a1. Control the first interpolation counter to increase by one each time, and the second interpolation counter to increase by one accordingly (DATA in -X2);DATA in represents the input PWM data, X2 represents the updated data in the second horizontal axis storage register;

[0105] a2. When the first interpolation counter counts to the first count value, the second interpolation counter is controlled to stop counting, and the first interpolation counter is reset to zero; the first count value is Y1-Y2; Y1 represents the data in the updated first ordinate storage register, and Y2 represents the data in the updated second ordinate storage register;

[0106] a3. Control the first interpolation counter to subtract (X1-X2) every time when it is added by one; X1 represents the data in the updated first horizontal coordinate storage register.

[0107] It should be noted that a1, a2, and a3 are executed sequentially.

[0108] In the embodiment of the present application, when the comparison result is the first comparison result or the second comparison result, the first interpolation counter and the second interpolation counter are controlled to execute the corresponding count in linkage to realize the corresponding interpolation count, so that the value of the subsequent first interpolation counter can be used to obtain the output PWM data. In this way, the overall operation is simple, and the mapping of the PWM data is converted from multiplication and division to addition and subtraction, which can more simply realize the mapping of the PWM data.

[0109] S206 , obtaining output PWM data according to the value of the interpolation counter and the updated data in the second ordinate storage register.

[0110] In the embodiment of the present application, S206 may include: a4. When the sign bit of the second interpolation counter changes from 0 to 1, output PWM data is obtained according to the value of the first interpolation counter and the updated data in the second ordinate storage register.

[0111] In a possible implementation, if the comparison result is a first comparison result, and the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, the output PWM data can be calculated by the following formula:

[0112] DATA out =Y2+△y-1;

[0113] If the comparison result is the second comparison result, the second comparison result is that the input PWM data is less than the data in the second abscissa storage register, the output PWM data can be calculated by the following formula:

[0114] DATA out =Y2-△y+1;

[0115] Among them, DATA out represents the output PWM data, Y2 represents the data in the updated second ordinate storage register, △y represents the change value of y under the current slope, that is, the increment of the output PWM data under the current slope, △y is the value of the first interpolation counter, △y=[(Y1-Y2) / (X1-X2)]*(DATA in -X2).

[0116] In the embodiment of the present application, the corresponding output PWM data can be calculated by different calculation formulas according to different comparison results. Moreover, the output PWM data can be obtained by the data in the updated second ordinate storage register and the value of the first interpolation counter, which can more simply realize the mapping of PWM data.

[0117] S207 , if the comparison result is not the first comparison result or the second comparison result, control the interpolation counter to perform corresponding counting according to the input PWM data, the data in the first horizontal coordinate storage register, and the data in the second horizontal coordinate storage register.

[0118] In the embodiment of the present application, S207 may include:

[0119] b1, control the first interpolation counter to add one each time, the second interpolation counter to add (DATA in -X2');DATA in represents the input PWM data, X2' represents the data in the second horizontal axis storage register;

[0120] b2. When the first interpolation counter counts to the second count value, the second interpolation counter is controlled to stop counting, and the first interpolation counter is reset to zero; the second count value is Y1'-Y2'; Y1' represents the data in the first ordinate storage register, and Y2' represents the data in the second ordinate storage register;

[0121] b3. Control the first interpolation counter to subtract (X1'-X2') from the second interpolation counter each time it adds one; X1' represents the data in the first horizontal coordinate storage register.

[0122] It should be noted that b1, b2 and b3 are executed in sequence.

[0123] In the embodiment of the present application, when the comparison result is not the first comparison result or the second comparison result, the first interpolation counter and the second interpolation counter are controlled to execute corresponding counting in linkage to realize corresponding interpolation counting, so that the value of the subsequent first interpolation counter can be used to obtain the output PWM data. In this way, the overall operation is simple, and the mapping of the PWM data is converted from multiplication and division to addition and subtraction, which can more simply realize the mapping of the PWM data.

[0124] S208 , obtaining output PWM data according to the value of the interpolation counter and the data in the second ordinate storage register.

[0125] In the embodiment of the present application, S208 may include: b4. When the sign bit of the second interpolation counter changes from 0 to 1, output PWM data is obtained according to the value of the first interpolation counter and the data in the second ordinate storage register.

[0126] It can be seen that the embodiment of the present application provides a solution for obtaining output PWM data when the comparison result is not the first comparison result or the second comparison result, making the overall technical solution more complete.

[0127] See also Figure 3 , is a pulse width modulation data mapping circuit disclosed in an embodiment of the present application, the circuit includes: a special point storage device, a coordinate point mark counter, an external data storage register, a first horizontal coordinate storage register, a second horizontal coordinate storage register, a first vertical coordinate storage register, a second vertical coordinate storage register, a state machine, a first interpolation counter, and a second interpolation counter. Among them, the special point storage device is respectively connected to the first horizontal coordinate storage register, the second horizontal coordinate storage register, the first vertical coordinate storage register, the second vertical coordinate storage register, and the coordinate point mark counter for communication, the state machine is respectively connected to the external data storage register, the first horizontal coordinate storage register, the second horizontal coordinate storage register, the first vertical coordinate storage register, the second vertical coordinate storage register, the first interpolation counter, and the second interpolation counter for communication, and the first interpolation counter is respectively connected to the second interpolation counter and the coordinate point mark counter for communication.

[0128] The external data storage register is used to latch the input PWM data. The data in the external data storage register is DATA in .

[0129] The first interpolation counter is used for counting, and the number of bits is determined by the number of bits of the output PWM data. The data in the first interpolation counter is recorded as CNTA.

[0130] The second interpolation counter with a sign bit is used to record the y growth amount under the current slope. The number of bits is determined by the number of bits of the output PWM data × 2 + 1. The data in the second interpolation counter is recorded as CNTB.

[0131] The coordinate point mark counter is used to record the position of the obtained special point, that is, the value of the coordinate point mark counter is n, and the horizontal coordinate of the obtained special point is x n , the vertical coordinate is y n .

[0132] The first horizontal coordinate storage register is used to store the horizontal coordinate data of the special point taken out from the special point storage device, or to store the data in the second horizontal coordinate storage register. The data in the first horizontal coordinate storage register is recorded as X1.

[0133] The second horizontal coordinate storage register is used to store the horizontal coordinate data of the special point taken out from the special point storage device, or to store the data in the first horizontal coordinate storage register. The data in the second horizontal coordinate storage register is recorded as X2.

[0134] The first ordinate storage register is used to store the ordinate data of the special point taken out from the special point storage device, or to store the data in the second ordinate storage register. The data in the first ordinate storage register is denoted as Y1.

[0135] The second ordinate storage register is used to store the ordinate data of the special point taken out from the special point storage device, or to store the data in the first ordinate storage register. The data in the second ordinate storage register is recorded as Y2.

[0136] The state machine's state=0 indicates the initialization of a linear interpolation calculation, state=3 indicates the intermediate value of the increment of the output PWM data, state=5 indicates the increment of the output PWM data, state=4 indicates the judgment that the slope is positive, and state=1 indicates the judgment that the slope is negative.

[0137] The pulse width modulation data mapping method in the above embodiment is applied to Figure 3 In the pulse width modulation data mapping circuit, the basic principle is explained below.

[0138] The horizontal coordinate and vertical coordinate of each special point on the mapping curve are stored in the special point storage device in order. The horizontal coordinate of the first point is x1 and the vertical coordinate is y1; the horizontal coordinate of the second point is x2 and the vertical coordinate is y2, and so on until the last point. Among them, the first special point must be a special point with a horizontal coordinate of 0. n+1 >x n >x n-1For points not given on the mapping curve, they are calculated by linear interpolation between two adjacent points.

[0139] Load the initial value into the first horizontal coordinate storage register, the second horizontal coordinate storage register, the first vertical coordinate storage register and the second vertical coordinate storage register. At this time, the first interpolation counter starts counting. When the first interpolation counter counts to the maximum value, the value of the coordinate point mark counter is added by 1. At this time, the value of the coordinate point mark counter changes from 0 to 1, which means that the special point taken out from the special point storage device is (x1, y1). Then x1 is stored in the first horizontal coordinate storage register and the second horizontal coordinate storage register, and y1 is stored in the first vertical coordinate storage register and the second vertical coordinate storage register. Then at the next clock edge, the first interpolation counter is reset to zero, and the state machine state=0.

[0140] When the state machine state=0, the external input PWM data DATA in Latched into the external data storage register. Then determine whether the slope is positive or negative.

[0141] When the data in the external data register DATA in When it is greater than the data X1 in the first horizontal coordinate storage register, it means that the slope is positive, and the state machine state=4. The first interpolation counter starts counting, and when the first interpolation counter reaches the maximum value, the coordinate point mark counter is increased by 1. Assume that after adding 1, the value of the coordinate point mark counter is n+1. First, store the data in the first horizontal coordinate storage register into the second horizontal coordinate storage register, and store the data in the first vertical coordinate storage register into the second vertical coordinate storage register. Then store the horizontal coordinate of the special point marked as n+1 into the first horizontal coordinate storage register, and store the vertical coordinate of the special point marked as n+1 into the first vertical coordinate storage register. This is equivalent to the data in the first horizontal coordinate storage register being x at this time. n+1 , the data in the first vertical coordinate storage register is y n+1 , the data in the second horizontal axis storage register is x n , the data in the second vertical coordinate storage register is y n Then at the next clock edge, the first interpolation counter is reset to zero, and the state machine state=3.

[0142] When the data in the external data register is DATA inWhen it is less than the data X2 in the second horizontal coordinate storage register, it means that the slope is negative, and the state machine state=1. The first interpolation counter starts counting, and when the first interpolation counter reaches the maximum value, the coordinate point mark counter is subtracted by 1. Assume that after subtracting 1, the value of the coordinate point mark counter is n-1. First, store the data in the second horizontal coordinate storage register into the first horizontal coordinate storage register, and store the data in the second vertical coordinate storage register into the first vertical coordinate storage register. Then store the horizontal coordinate of the special point marked as n-1 into the second horizontal coordinate storage register, and store the vertical coordinate of the special point marked as n-1 into the second vertical coordinate storage register. This is equivalent to the data in the second horizontal coordinate storage register being x at this time. n-1 , the data in the second vertical coordinate storage register is y n-1 , the data in the first horizontal axis storage register is x n , the data in the first vertical coordinate storage register is y n Then at the next clock edge, the first interpolation counter is reset to zero, and the state machine state=3.

[0143] When the state machine state=3, the first interpolation counter and the second interpolation counter start counting. Every time the first interpolation counter is added by 1, the corresponding second interpolation counter is +(DATA in -X2). When the value of the first interpolation counter = Y1-Y2, the second interpolation counter stops counting and keeps counting. At this time, the value of the second interpolation counter = (Y1-Y2) * (DATA in -X2). Then at the next clock edge, the first interpolation counter is reset to zero, and the state machine state = 5.

[0144] When the state machine state=5, the first interpolation counter starts counting and the second interpolation counter continues counting. Every time the first interpolation counter adds 1, the corresponding second interpolation counter is -(X1-X2). When the sign bit of the second interpolation counter is 1, that is, when the second interpolation counter is reduced to a negative number, the value of the first interpolation counter is the increment △y of the output PWM data under the current slope.

[0145] △y = [(Y1-Y2) / (X1-X2)]*(DATA in -X2)

[0146] When the slope is positive, the output PWM data DATA out =Y2+△y-1. When the slope is negative, the output PWM data DATA out =Y2-△y+1. At the next clock edge, the first interpolation counter is reset to zero, and the state machine state=0.

[0147] See also Figure 4, a schematic diagram of an input PWM curve and an output PWM curve disclosed in an embodiment of the present application. It can be understood that the horizontal coordinate of the coordinate point on the input PWM curve corresponds to the input PWM data, and the vertical coordinate of the coordinate point on the output PWM curve corresponds to the output PWM data, such as the input PWM data is the value corresponding to the duty cycle of 90%, and the output PWM data is the value corresponding to the duty cycle of 0%, etc. It should be noted that the maximum value is the third count value mentioned above, Figure 4 The MAX in is the time it takes for the first interpolation counter to count to the maximum value.

[0148] See also Figure 5 , is a schematic diagram of a mapping curve disclosed in an embodiment of the present application. The above-mentioned PWM data before mapping = P1×(2 a ), P1 represents Figure 5 PWM duty cycle before mapping, a represents the number of bits of the storage device, the above mapped PWM data = P2×(2 a ), P2 represents Figure 5 The PWM duty cycle after mapping in the middle. Generally, the following is selected Figure 5 The inflection point in is regarded as a special point. The following corresponds to Figure 5 The PWM data mapping process is described below.

[0149] If the actual external input duty cycle increases linearly from 0 to 100%, the mapping curve is: Figure 5 The mapping curve is shown. In the step of loading the initial value, X1=X2=the value corresponding to the PWM duty cycle of 0% before mapping, and Y1=Y2=the value corresponding to the duty cycle of 10% after mapping.

[0150] When the actual input duty cycle is greater than 0%, the slope is judged to be positive. At this time, the coordinate point mark counter is increased by 1, X2 = the value corresponding to the PWM duty cycle of 0% before mapping, X1 = the value corresponding to the PWM duty cycle of 20% before mapping, Y2 = the value corresponding to the PWM duty cycle of 10% after mapping, and Y1 = the value corresponding to the duty cycle of 10% after mapping. In the stage from 0% to 20%, since the actual input duty cycle is less than 20% but greater than 0%, the actual output duty cycle increases according to the above calculation method, but if the actual output duty cycle exceeds the mapped PWM duty cycle corresponding to the mapping curve by 10%, then the actual output duty cycle will remain unchanged at 10%.

[0151] When the actual input duty cycle is greater than 20%, the slope is judged to be positive. At this time, the coordinate point mark counter is increased by 1, X2 = the value corresponding to the PWM duty cycle of 20% before mapping, X1 = the value corresponding to the PWM duty cycle of 70% before mapping, Y2 = the value corresponding to the PWM duty cycle of 10% after mapping, and Y1 = the value corresponding to the PWM duty cycle of 90% after mapping. In the stage from 20% to 70%, since the actual input duty cycle is less than 70% but greater than 20%, the actual output duty cycle increases according to the above calculation method.

[0152] When the actual input duty cycle is greater than 70%, the slope is judged to be positive. At this time, the coordinate point mark counter is increased by 1, X2 = the value corresponding to the PWM duty cycle of 70% before mapping, X1 = the value corresponding to the PWM duty cycle of 90% before mapping, Y2 = the value corresponding to the PWM duty cycle of 90% after mapping, Y1 = the value corresponding to the PWM duty cycle of 90% after mapping. In the stage from 70% to 90%, the actual output duty cycle increases according to the above calculation method. If the actual output duty cycle exceeds the mapped PWM duty cycle of 90% corresponding to the mapping curve, the actual output duty cycle will remain unchanged at 90%.

[0153] When the actual input duty cycle is greater than 90%, the slope is judged to be positive. At this time, the coordinate point mark counter is increased by 1, X2 = the value corresponding to the PWM duty cycle of 90% before mapping, X1 = the value corresponding to the PWM duty cycle of 100% before mapping, Y2 = the value corresponding to the PWM duty cycle of 90% after mapping, and Y1 = the value corresponding to the PWM duty cycle of 0% after mapping. In the stage from 90% to 100%, the actual output duty cycle will remain unchanged at 0%.

[0154] It can be seen that in the embodiment of the present application, the mapping of PWM data corresponding to any PWM duty cycle can be achieved by setting multiple special points including PWM data before mapping and PWM data after mapping. Moreover, in the embodiment of the present application, by controlling the counts of the first interpolation counter and the second interpolation counter, the current value of the final first interpolation counter can be used to determine the output PWM data, so that the input PWM data can be mapped to the output PWM data more simply, thereby realizing the mapping of PWM data more simply. Moreover, the overall operation is simple, and the mapping of PWM data can be converted from multiplication and division to addition and subtraction, which can realize the mapping of PWM data more simply.

[0155] The embodiment of the present application further provides a pulse width modulation data mapping circuit, the circuit comprising: a first horizontal coordinate storage register, a second horizontal coordinate storage register, a first vertical coordinate storage register, a second vertical coordinate storage register, and an interpolation counter;

[0156] The first horizontal coordinate storage register, the second horizontal coordinate storage register, the first vertical coordinate storage register and the second vertical coordinate storage register are used to update data according to the first comparison result or the second comparison result if the comparison result is the first comparison result or the second comparison result; wherein the comparison result is obtained by comparing the input PWM data with the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register, the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register are taken from the horizontal coordinate of a special point in a special point storage device, the special point storage device sequentially stores a plurality of special points, the horizontal coordinate of the special point represents the pulse width modulation PWM data before mapping, and the vertical coordinate of the special point represents the PWM data after mapping;

[0157] The interpolation counter is used to perform corresponding counting according to the input PWM data, the data in the updated first horizontal coordinate storage register, and the data in the updated second horizontal coordinate storage register if the comparison result is the first comparison result or the second comparison result; wherein the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register are the horizontal coordinates of the first special point and the second special point adjacent to each other among the plurality of special points, the data in the updated first vertical coordinate storage register and the data in the updated second vertical coordinate storage register are the vertical coordinates of the first special point and the second special point, and the input PWM data is greater than the horizontal coordinate of the first special point and less than the horizontal coordinate of the second special point;

[0158] The interpolation counter is used to determine the value of the interpolation counter after the interpolation counter performs the corresponding counting; the value of the interpolation counter is used to determine the output PWM data together with the data in the updated second vertical coordinate storage register, and the output PWM data is used to control the electronic device.

[0159] It can be seen that in the embodiment of the present application, by storing multiple special points including PWM data before mapping and PWM data after mapping in a special point storage device, the interpolation counter can be controlled to perform corresponding counting based on the special points to implement corresponding interpolation operations, thereby realizing the mapping of PWM data corresponding to any PWM duty cycle, and thus realizing more accurate control of the electronic device. Moreover, by controlling the interpolation counter to perform corresponding counting, the value of the interpolation counter can be used to determine the output PWM data, so that the input PWM data can be mapped to the output PWM data more simply, thereby realizing the mapping of PWM data more simply, and thus realizing faster control of the electronic device.

[0160] In a possible implementation, the interpolation counter in the pulse width modulation data mapping circuit provided in the embodiment of the present application is further used to perform corresponding counting according to the input PWM data, the data in the first horizontal coordinate storage register, and the data in the second horizontal coordinate storage register if the comparison result is not the first comparison result or the second comparison result;

[0161] The interpolation counter is further used to determine the value of the interpolation counter after the interpolation counter performs corresponding counting; the value of the interpolation counter is used to determine the output PWM data together with the data in the second ordinate storage register.

[0162] In a possible implementation, in the pulse width modulation data mapping circuit provided in the embodiment of the present application, the interpolation counter includes: a first interpolation counter and a second interpolation counter, wherein the second interpolation counter is a counter with a sign bit;

[0163] The second interpolation counter is used to add (DATA in -X2); the DATA in represents the input PWM data, and X2 represents the data in the updated second horizontal coordinate storage register;

[0164] The second interpolation counter is further used to stop counting when the first interpolation counter counts to a first count value; the first count value is Y1-Y2; the Y1 represents the data in the updated first ordinate storage register, and the Y2 represents the data in the updated second ordinate storage register;

[0165] The first interpolation counter is used to reset to zero when the first interpolation counter counts to a first count value;

[0166] The second interpolation counter is further used for correspondingly subtracting (X1-X2) each time the first interpolation counter is added by one; X1 represents the data in the updated first horizontal coordinate storage register;

[0167] The first interpolation counter is further used to determine the value of the first interpolation counter when the sign bit of the second interpolation counter changes from 0 to 1; the value of the first interpolation counter is used to determine the output PWM data together with the data in the updated second ordinate storage register;

[0168] or,

[0169] The second interpolation counter is used to add (DATA in -X2'); the DATAin represents the input PWM data, and X2' represents the data in the second horizontal coordinate storage register;

[0170] The second interpolation counter is further used to stop counting when the first interpolation counter counts to a second count value; the second count value is Y1'-Y2'; the Y1' represents the data in the first ordinate storage register, and the Y2' represents the data in the second ordinate storage register;

[0171] The first interpolation counter is used to reset to zero when the first interpolation counter counts to a first count value;

[0172] The second interpolation counter is further configured to correspondingly subtract (X1'-X2') from the second interpolation counter each time the first interpolation counter is incremented by one; the X1' represents the data in the first abscissa storage register;

[0173] The first interpolation counter is also used to determine the value of the first interpolation counter when the sign bit of the second interpolation counter changes from 0 to 1; the value of the first interpolation counter is used to determine the output PWM data together with the data in the second ordinate storage register.

[0174] In a possible implementation, the pulse width modulation data mapping circuit provided in the embodiment of the present application further includes: a coordinate point marking counter, and the interpolation counter includes: a first interpolation counter and a second interpolation counter;

[0175] The coordinate point mark counter is used to update the value of the coordinate point mark counter according to the first comparison result or the second comparison result to obtain an updated value when the first interpolation counter counts to a third count value;

[0176] The first horizontal coordinate storage register, the second horizontal coordinate storage register, the first vertical coordinate storage register and the second vertical coordinate storage register are specifically used to perform data update using the special point corresponding to the update value.

[0177] In a possible implementation, in the pulse width modulation data mapping circuit provided in the embodiment of the present application, the coordinate point mark counter is specifically used to, when the first interpolation counter counts to a third count value, if the comparison result is the first comparison result, and the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, add one to the value of the coordinate point mark counter to obtain an updated value;

[0178] The first horizontal coordinate storage register is specifically used to update the data in the first horizontal coordinate storage register to the horizontal coordinate of the special point corresponding to the updated value;

[0179] The first ordinate storage register is specifically used to update the data in the first ordinate storage register to the ordinate of the special point corresponding to the update value;

[0180] The second horizontal coordinate storage register is specifically used to update the data in the second horizontal coordinate storage register to the data in the first horizontal coordinate storage register;

[0181] The second vertical coordinate storage register is specifically used to update the data in the second vertical coordinate storage register to the data in the first vertical coordinate storage register;

[0182] or,

[0183] The coordinate point mark counter is specifically used for, when the first interpolation counter counts to a third count value, if the comparison result is the second comparison result, and the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register, subtracting one from the value of the coordinate point mark counter to obtain an updated value;

[0184] The first horizontal coordinate storage register is specifically used to update the data in the first horizontal coordinate storage register to the data in the second horizontal coordinate storage register;

[0185] The first vertical coordinate storage register is specifically used to update the data in the first vertical coordinate storage register to the data in the second vertical coordinate storage register;

[0186] The second horizontal coordinate storage register is specifically used to update the data in the second horizontal coordinate storage register to the horizontal coordinate of the special point corresponding to the updated value;

[0187] The second ordinate storage register is specifically used to update the data in the second ordinate storage register to the ordinate of the special point corresponding to the update value.

[0188] In a possible implementation, in the pulse width modulation data mapping circuit provided in the embodiment of the present application, if the comparison result is a first comparison result, the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, the output PWM data is calculated by the following formula:

[0189] DATA out =Y2+△y-1;

[0190] If the comparison result is the second comparison result, and the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register, the output PWM data is calculated by the following formula:

[0191] DATA out =Y2-△y+1;

[0192] Among them, the DATA out represents the output PWM data, Y2 represents the data in the updated second ordinate storage register, △y represents the change value of y under the current slope, and △y is the value of the first interpolation counter.

[0193] In a possible implementation, the pulse width modulation data mapping circuit provided in the embodiment of the present application further includes: an external data storage register;

[0194] The first horizontal coordinate storage register, the second horizontal coordinate storage register, the first vertical coordinate storage register and the second vertical coordinate storage register are further used to perform data initialization using the first special point among the multiple special points;

[0195] The external data storage register is used to store the input PWM data.

[0196] Furthermore, an embodiment of the present application also provides a pulse width modulation data mapping device, comprising:

[0197] A memory for storing instructions;

[0198] The processor is used for executing the instructions in the memory to perform any one implementation method of the pulse width modulation data mapping method.

[0199] Furthermore, an embodiment of the present application also provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes any one of the implementation methods of the above-mentioned pulse width modulation data mapping method.

[0200] Furthermore, an embodiment of the present application also provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes any one of the implementation methods of the above-mentioned pulse width modulation data mapping method.

[0201] It can be known from the description of the above implementation mode that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., including several instructions for enabling a computer device (which can be a personal computer, a server, or a network communication device such as a media gateway, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.

[0202] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0203] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0204] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0205] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A pulse width modulation data mapping method, characterized in that: The method comprises: Compare the input pulse width modulation (PWM) data with the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register to obtain a comparison result; wherein the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register are taken from the horizontal coordinate of a special point in a special point storage device, the special point storage device sequentially stores a plurality of special points, the horizontal coordinate of the special point represents the PWM data before mapping, and the vertical coordinate of the special point represents the PWM data after mapping; If the comparison result is the first comparison result or the second comparison result, update the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register according to the first comparison result or the second comparison result; the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, and the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register; According to the input PWM data, the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register, the interpolation counter is controlled to perform corresponding counting; wherein the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register are the horizontal coordinates of the first special point and the second special point adjacent to each other among the plurality of special points, the data in the updated first vertical coordinate storage register and the data in the updated second vertical coordinate storage register are the vertical coordinates of the first special point and the second special point, and the input PWM data is greater than the horizontal coordinate of the first special point and less than the horizontal coordinate of the second special point; Obtaining output PWM data according to the value of the interpolation counter and the data in the updated second ordinate storage register, wherein the output PWM data is used to control the electronic device; The interpolation counter includes: a first interpolation counter and a second interpolation counter, wherein the second interpolation counter is a counter with a sign bit; The step of controlling the interpolation counter to perform corresponding counting according to the input PWM data, the updated data in the first horizontal coordinate storage register, and the updated data in the second horizontal coordinate storage register comprises: Control the first interpolation counter to add one each time, the second interpolation counter correspondingly adds (DATA in -X2); the DATA in represents the input PWM data, and X2 represents the data in the updated second horizontal coordinate storage register; When the first interpolation counter counts to a first count value, the second interpolation counter is controlled to stop counting, and the first interpolation counter is reset to zero; the first count value is Y1-Y2; Y1 represents the data in the updated first ordinate storage register, and Y2 represents the data in the updated second ordinate storage register; Controlling the first interpolation counter to correspondingly subtract (X1-X2) each time when the first interpolation counter is added by one; the X1 represents the data in the updated first abscissa storage register; The step of obtaining output PWM data according to the value of the interpolation counter and the updated data in the second ordinate storage register comprises: When the sign bit of the second interpolation counter changes from 0 to 1, output PWM data is obtained according to the value of the first interpolation counter and the data in the updated second ordinate storage register; If the comparison result is the first comparison result, obtaining output PWM data according to the value of the interpolation counter and the updated data in the second ordinate storage register comprises: The output PWM data is calculated by the following formula: DATA out =Y2+△y-1; If the comparison result is the second comparison result, obtaining output PWM data according to the value of the interpolation counter and the data in the updated second ordinate storage register comprises: The output PWM data is calculated by the following formula: DATA out =Y2-△y+1; Among them, the DATA out represents the output PWM data, the Y2 represents the data in the updated second ordinate storage register, and the △y is the value of the interpolation counter.

2. The pulse width modulation data mapping method according to claim 1, characterized in that: If the comparison result is not the first comparison result or the second comparison result, the method further includes: Controlling the interpolation counter to perform corresponding counting according to the input PWM data, the data in the first horizontal coordinate storage register, and the data in the second horizontal coordinate storage register; Output PWM data is obtained according to the value of the interpolation counter and the data in the second ordinate storage register.

3. The method according to claim 2, characterized in that If the comparison result is not the first comparison result or the second comparison result, controlling the interpolation counter to perform corresponding counting according to the input PWM data, the data in the first horizontal coordinate storage register, and the data in the second horizontal coordinate storage register includes: Control the first interpolation counter to add one each time, the second interpolation counter correspondingly adds (DATA in -X2'); the DATA in represents the input PWM data, and X2' represents the data in the second horizontal coordinate storage register; When the first interpolation counter counts to a second count value, the second interpolation counter is controlled to stop counting, and the first interpolation counter is reset to zero; the second count value is Y1'-Y2'; the Y1' represents the data in the first ordinate storage register, and the Y2' represents the data in the second ordinate storage register; Controlling the first interpolation counter to subtract (X1'-X2') correspondingly each time when the first interpolation counter is added by one; the X1' represents the data in the first horizontal coordinate storage register; The step of obtaining output PWM data according to the value of the interpolation counter and the data in the second ordinate storage register comprises: When the sign bit of the second interpolation counter changes from 0 to 1, output PWM data is obtained according to the value of the first interpolation counter and the data in the second ordinate storage register.

4. The method according to claim 1, characterized in that The interpolation counter includes: a first interpolation counter and a second interpolation counter, and updating the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register according to the first comparison result or the second comparison result includes: When the first interpolation counter counts to a third count value, the value of the coordinate point mark counter is updated according to the first comparison result or the second comparison result to obtain an updated value; The data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register are updated using the special point corresponding to the update value.

5. The method according to claim 4, characterized in that When the first interpolation counter counts to a third count value, updating the value of the coordinate point mark counter according to the first comparison result or the second comparison result to obtain an updated value includes: When the first interpolation counter counts to a third count value, if the comparison result is the first comparison result, the value of the coordinate point mark counter is increased by 1 to obtain an updated value; The updating of the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register by using the special point corresponding to the update value includes: Update the data in the second horizontal coordinate storage register to the data in the first horizontal coordinate storage register, update the data in the second vertical coordinate storage register to the data in the first vertical coordinate storage register, update the data in the first horizontal coordinate storage register to the horizontal coordinate of the special point corresponding to the updated value, and update the data in the first vertical coordinate storage register to the vertical coordinate of the special point corresponding to the updated value; or, When the first interpolation counter counts to a third count value, updating the value of the coordinate point mark counter according to the first comparison result or the second comparison result to obtain an updated value includes: When the first interpolation counter counts to a third count value, if the comparison result is the second comparison result, subtract one from the value of the coordinate point mark counter to obtain an updated value; The updating of the data in the first horizontal coordinate storage register, the data in the second horizontal coordinate storage register, the data in the first vertical coordinate storage register, and the data in the second vertical coordinate storage register by using the special point corresponding to the update value includes: Update the data in the first horizontal coordinate storage register to the data in the second horizontal coordinate storage register, update the data in the first vertical coordinate storage register to the data in the second vertical coordinate storage register, update the data in the second horizontal coordinate storage register to the horizontal coordinate of the special point corresponding to the updated value, and update the data in the second vertical coordinate storage register to the vertical coordinate of the special point corresponding to the updated value.

6. The method according to claim 1, characterized in that Before comparing the input PWM data with the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register to obtain a comparison result, the method further includes: Initialize data in a first abscissa storage register, data in a second abscissa storage register, data in a first ordinate storage register, and data in a second ordinate storage register using a first special point among the plurality of special points; The input PWM data is stored in an external data storage register.

7. A pulse width modulation data mapping circuit, characterized in that: The circuit comprises: a first abscissa storage register, a second abscissa storage register, a first ordinate storage register, a second ordinate storage register and an interpolation counter; The first horizontal coordinate storage register, the second horizontal coordinate storage register, the first vertical coordinate storage register and the second vertical coordinate storage register are used to update data according to the first comparison result or the second comparison result if the comparison result is the first comparison result or the second comparison result; wherein the comparison result is obtained by comparing the input pulse width modulation PWM data with the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register, the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register, the data in the first horizontal coordinate storage register and the data in the second horizontal coordinate storage register are taken from the horizontal coordinate of a special point in a special point storage device, the special point storage device sequentially stores a plurality of special points, the horizontal coordinate of the special point represents the PWM data before mapping, and the vertical coordinate of the special point represents the PWM data after mapping; The interpolation counter is used to perform corresponding counting according to the input PWM data, the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register if the comparison result is the first comparison result or the second comparison result; wherein the data in the updated first horizontal coordinate storage register and the data in the updated second horizontal coordinate storage register are the horizontal coordinates of the first special point and the second special point adjacent to each other among the multiple special points, the data in the updated first vertical coordinate storage register and the data in the updated second vertical coordinate storage register are the vertical coordinates of the first special point and the second special point, and the input PWM data is greater than the horizontal coordinate of the first special point and less than the horizontal coordinate of the second special point; The interpolation counter is used to determine the value of the interpolation counter after the interpolation counter performs the corresponding counting; the value of the interpolation counter is used to determine the output PWM data together with the data in the updated second ordinate storage register, and the output PWM data is used to control the electronic device; The interpolation counter includes: a first interpolation counter and a second interpolation counter, wherein the second interpolation counter is a counter with a sign bit; The second interpolation counter is used to add (DATA in -X2); the DATA in represents the input PWM data, and X2 represents the data in the updated second horizontal coordinate storage register; The second interpolation counter is further used to stop counting when the first interpolation counter counts to a first count value; the first count value is Y1-Y2; the Y1 represents the data in the updated first ordinate storage register, and the Y2 represents the data in the updated second ordinate storage register; The first interpolation counter is used to reset to zero when the first interpolation counter counts to a first count value; The second interpolation counter is further used for correspondingly subtracting (X1-X2) each time the first interpolation counter is added by one; X1 represents the data in the updated first horizontal coordinate storage register; The first interpolation counter is further used to determine the value of the first interpolation counter when the sign bit of the second interpolation counter changes from 0 to 1; the value of the first interpolation counter is used to determine the output PWM data together with the data in the updated second ordinate storage register; If the comparison result is a first comparison result, and the first comparison result is that the input PWM data is greater than the data in the first horizontal coordinate storage register, the output PWM data is calculated by the following formula: DATA out =Y2+△y-1; If the comparison result is the second comparison result, and the second comparison result is that the input PWM data is less than the data in the second horizontal coordinate storage register, the output PWM data is calculated by the following formula: DATA out =Y2-△y+1; Among them, the DATA out represents the output PWM data, Y2 represents the data in the updated second ordinate storage register, △y represents the change value of y under the current slope, and △y is the value of the first interpolation counter.

8. A pulse width modulation data mapping device, characterized in that: include: A memory for storing instructions; A processor, configured to execute the instructions in the memory to perform the pulse width modulation data mapping method according to any one of claims 1 to 6.

9. A computer-readable storage medium comprising instructions, which, when executed on a computer, enables the computer to execute the pulse width modulation data mapping method according to any one of claims 1 to 6.