A method, device and medium for determining electrical angle based on FPGA

By utilizing RAM lookup tables and encoder resolution conversion processing in FPGA, combined with time-sharing multiplexing technology, the problems of long time and low accuracy in FPGA electrical angle calculation are solved, high-precision sine and cosine value calculation is achieved, and the accuracy of electrical angle and resource utilization efficiency are improved.

CN115542807BActive Publication Date: 2025-09-05SHENZHEN INVT ELECTRIC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211200097.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-29
Publication Date
2025-09-05
Estimated Expiration
2042-09-29

Smart Images

  • Figure CN115542807B_ABST
    Figure CN115542807B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, and medium for determining electrical angles based on an FPGA, applicable to the field of intelligent motor control technology. Based on an existing lookup table, this method obtains corresponding sine and cosine address indices and address index supplementary values ​​according to the RAM lookup table and the encoder resolution to expand the data. Furthermore, through the principle of time-sharing multiplexing, these two values ​​are used to determine initial sine and cosine values. Finally, a final sine and cosine value is determined to improve the accuracy of the sine and cosine values ​​obtained through electrical angle processing, thereby increasing the precision of the electrical angle. Compared to existing methods that only use a lookup table to obtain sine and cosine values, the present invention utilizes fewer FPGA resources to compensate for the small amount of data in the table to expand the data, thereby obtaining sine and cosine values ​​with higher precision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of intelligent motor control, and in particular to a method, device and medium for determining an electrical angle based on FPGA. Background Art

[0002] After a field-programmable gate array (FPGA) reads the encoder's real-time position, a common method for calculating the sine and cosine values ​​of the electrical angle corresponding to the encoder's real-time position is to pass the data to an Advanced RISC Machines (ARM) processor or a Digital Signal Processor (DSP) microprocessor to obtain the sine and cosine values, which are then transmitted to the FPGA. Alternatively, a cordic subroutine can be written in the FPGA to obtain the sine and cosine values ​​of the electrical angle corresponding to the real-time position, or the data can be obtained using the FPGA's built-in sine and cosine lookup table.

[0003] Of the common methods mentioned above, the first two are complex, requiring feedback or internal algorithm execution, resulting in long calculation and execution times. While the latter method addresses the long calculation times of the first two methods, the built-in sine and cosine lookup table is limited by the FPGA's logic resources and the table's limited data size. Consequently, the resulting sine and cosine values ​​are less accurate and experience significant fluctuations.

[0004] Therefore, how to improve the accuracy of the electrical angle sine and cosine values ​​obtained by FPGA is an urgent problem that needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of the present invention is to provide a method, device and medium for determining electrical angle based on FPGA, which utilizes less FPGA resources to make up for the small amount of data in the table to expand the data and obtain sine and cosine values ​​with higher precision.

[0006] In order to solve the above technical problems, the present invention provides a method for determining electrical angle based on FPGA, comprising:

[0007] Obtaining encoder position values ​​of the encoder, and performing compensation processing on the encoder position values ​​to obtain various compensated position values;

[0008] Each compensation position value is converted according to the RAM lookup table and the resolution of the encoder to obtain the corresponding sine and cosine address index and address index supplement value;

[0009] The corresponding initial sine and cosine values ​​and sine and cosine correction values ​​are obtained by processing the sine and cosine address indexes and address index supplementary values ​​corresponding to each compensation position value through time-division multiplexing;

[0010] Through time-division multiplexing, the corresponding initial sine and cosine values ​​are corrected according to the sine and cosine correction values ​​to obtain the final sine and cosine values ​​corresponding to the compensated position values.

[0011] Preferably, the process of establishing the RAM lookup table includes:

[0012] Get the sine or cosine value of a fixed number of points;

[0013] Perform fixed-point processing according to the sine value or cosine value of each fixed point to obtain the corresponding sine value table or cosine value table;

[0014] Store the sine value table or cosine value table in the FPGA's RAM to create a lookup table.

[0015] Preferably, performing compensation processing on the encoder position value to obtain each compensated position value includes:

[0016] The encoded position value is subjected to park transformation compensation angle and inverse park transformation compensation angle to obtain the corresponding first compensation position value and second compensation position value.

[0017] Preferably, each compensation position value is converted according to the RAM lookup table and the resolution of the encoder to obtain the corresponding sine and cosine address index and address index supplement value, including:

[0018] Determine the data conversion byte table for each compensation position value according to the lookup table and the resolution of the encoder;

[0019] Determine the sine and cosine address indexes and address index supplementary values ​​according to each compensation position value in the data conversion byte table;

[0020] Correspondingly, the data conversion byte table for each compensation position value is determined according to the lookup table and the resolution of the encoder, including:

[0021] Obtain the number of sine and cosine values ​​in the lookup table of the RAM to determine the corresponding sine and cosine values, where the sine and cosine values ​​in the lookup table are sine values ​​or cosine values. When the lookup table is a sine value, the cosine value is obtained by offsetting the sine value in the lookup table.

[0022] Obtain the electrical angle range in the lookup table and the number of bits corresponding to the encoder resolution. If the encoder resolution is not an exponent of 2, amplify the encoder value to obtain an exponent close to 2 to obtain the number of bits corresponding to the encoder resolution.

[0023] A data conversion byte table of the current compensation position value is determined according to the sine and cosine values, the electrical angle range, and the number of bits, wherein the current compensation position value is the first compensation position value or the second compensation position value.

[0024] Preferably, determining the sine and cosine address indexes and the address index supplementary values ​​according to the respective compensation position values ​​in the data conversion byte table includes:

[0025] Determine the number of lookup table sector index bits in the data conversion byte table according to the electrical angle range;

[0026] Determine the number of lookup table address index bits following the number of lookup table sector index bits in the data conversion byte table according to the number of sine and cosine values;

[0027] Determine the number of bits in the data conversion byte table other than the number of bits of the lookup table sector index and the number of bits of the lookup table address index as the lookup table angle correction value;

[0028] The data obtained after obtaining the current compensation position value and performing binary processing is input into the data conversion byte table as conversion data;

[0029] The sine and cosine address indexes and address index supplementary values ​​of the current compensation position value are determined in the conversion data according to the corresponding number of lookup table sector index bits and the position of the lookup table angle correction value.

[0030] Preferably, the sine and cosine address indexes and address index supplementary values ​​corresponding to the compensation position values ​​are processed by time-division multiplexing to obtain the corresponding initial sine and cosine values ​​and sine and cosine correction values, including:

[0031] Obtain the mapped electrical angle value corresponding to each compensation value;

[0032] According to the electrical angle corresponding to each mapped electrical angle value and the address index supplementary value, a table lookup process is performed to obtain the corresponding initial sine and cosine values ​​and sine and cosine supplementary calculated values;

[0033] The sine and cosine correction deviation values ​​are obtained by performing a difference process on the supplementary sine and cosine calculation values ​​and the initial sine and cosine values, wherein the sine and cosine correction deviation values ​​include a sine correction deviation value and a cosine correction deviation value;

[0034] The corresponding sine-cosine correction value is determined by the relationship between the sine-cosine correction deviation value, the correction coefficient and the number of data shift bits, where the number of data shift bits is determined according to the relationship between the number of sine-cosine values ​​stored in the lookup table, the number of bits of the encoder's resolution and the number of bits of the lookup table sector index.

[0035] Preferably, by time-division multiplexing, the corresponding initial sine and cosine values ​​are corrected according to the sine and cosine correction values ​​to obtain the final sine and cosine values ​​corresponding to the compensated position values, including:

[0036] The current initial sine and cosine values ​​and the current sine and cosine correction values ​​are added together to obtain the corresponding final sine and cosine values.

[0037] In order to solve the above technical problems, the present invention further provides a device for determining electrical angle based on FPGA, comprising:

[0038] The compensation module is used to obtain the encoder position value of the encoder and perform compensation processing on the encoder position value to obtain each compensated position value;

[0039] A first determination module is used to convert each compensation position value according to the RAM lookup table and the resolution of the encoder to obtain a corresponding sine and cosine address index and an address index supplement value;

[0040] A second determination module is configured to process the sine and cosine address indexes and address index supplementary values ​​corresponding to the compensation position values ​​through time-division multiplexing to obtain corresponding initial sine and cosine values ​​and sine and cosine correction values;

[0041] The third determination module is configured to correct the corresponding initial sine and cosine values ​​according to the sine and cosine correction values ​​through time division multiplexing to obtain final sine and cosine values ​​corresponding to the compensated position values.

[0042] In order to solve the above technical problems, the present invention further provides a device for determining electrical angle based on FPGA, comprising:

[0043] memory for storing computer programs;

[0044] The processor is configured to implement the steps of the above-mentioned method for determining the electrical angle based on FPGA when executing the computer program.

[0045] In order to solve the above technical problems, the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the method for determining the electrical angle based on FPGA as described above are implemented.

[0046] The present invention provides a method for determining electrical angle based on an FPGA, comprising: obtaining an encoder position value from an encoder, and compensating the encoder position value to obtain each compensated position value; converting each compensated position value according to a RAM lookup table and the encoder resolution to obtain a corresponding sine-cosine address index and address index supplement value; processing the sine-cosine address index and address index supplement value corresponding to each compensated position value through time-sharing multiplexing to obtain a corresponding initial sine-cosine value and a sine-cosine correction value; and correcting each corresponding initial sine-cosine value according to each sine-cosine correction value through time-sharing multiplexing to obtain a final sine-cosine value corresponding to each compensated position value. Based on an existing lookup table, this method obtains corresponding sine-cosine address indexes and address index supplement values ​​according to the RAM lookup table and the encoder resolution to expand data, further determines the initial sine-cosine value using the two values, and finally determines the final sine-cosine value to improve the accuracy of the sine-cosine value obtained through electrical angle processing, thereby improving the precision of the electrical angle. Compared with the existing method of obtaining sine and cosine values ​​by only looking up a table, the present invention utilizes fewer FPGA resources to make up for the small amount of data in the table to expand the data, thereby obtaining sine and cosine values ​​with higher precision. At the same time, it is based on FPGA execution, shortening the execution time and improving resource utilization.

[0047] In addition, the present invention also provides a device and medium for determining electrical angle based on FPGA, which has the same beneficial effects as the above-mentioned device for determining electrical angle based on FPGA. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0049] Figure 1 A flowchart of a method for determining an electrical angle based on FPGA provided by an embodiment of the present invention;

[0050] Figure 2 A structural diagram of a device for determining electrical angle based on FPGA provided by an embodiment of the present invention;

[0051] Figure 3 A structural diagram of another device for determining electrical angle based on FPGA provided by an embodiment of the present invention;

[0052] Figure 4 A structural diagram of a device for determining electrical angle based on FPGA provided in an embodiment of the present invention;

[0053] Figure 5This is a processing timing diagram of a device for determining electrical angle based on FPGA provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.

[0055] The core of the present invention is to provide a method, device and medium for determining electrical angle based on FPGA, which utilizes less FPGA resources to make up for the small amount of table data to expand the data and obtain sine and cosine values ​​with higher precision.

[0056] In order to enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0057] It should be noted that the FPGA-based electrical angle determination method provided by the present invention can be applied to general-purpose servo drives and closed-loop vector inverters, performing vector closed-loop control by reading the electrical angle via an encoder. The electrical angle is the actual spatial geometric angle. The angle 360° / p occupied by each pair of motor poles on the stator inner circle refers to the actual spatial geometric angle, which is called the mechanical angle. In motors with four or more poles, the mechanical angle occupied by a pair of poles is often defined as 360 electrical degrees. This is because the induced potential in the winding changes over one cycle of 360°. For a two-pole motor, the electrical and mechanical angles occupied by the stator inner circle are equal, both 360°. For a p-pole motor, the total electrical angle of the stator inner circle is 360°·p, but the mechanical angle remains 360°. Therefore, the relationship between the two is: electrical angle = mechanical angle × number of pole pairs.

[0058] Figure 1 A flowchart of a method for determining an electrical angle based on FPGA is provided in an embodiment of the present invention. Figure 1 As shown, the method includes:

[0059] S11: Obtaining the encoder position value of the encoder, and performing compensation processing on the encoder position value to obtain various compensated position values;

[0060] It is understood that the motor control cycle can be the encoder sampling cycle, and the encoder is sampled within a control cycle to obtain the encoder position value. In the embodiments of the present invention, the encoder type is not limited and can be a photoelectric encoder, a communication-type absolute encoder, or other encoders. The sampling process corresponding to different encoders will be different. For example, a photoelectric encoder obtains the encoder position value count by quadrupling the A and B pulses and then accumulating the data; a communication-type absolute encoder obtains the encoder position value count through communication analysis.

[0061] The obtained encoder position value is compensated to obtain various compensated position values. Specifically, the compensation process can be obtained based on the compensation of the motor and the electrical angle, or the compensation value can be determined based on the relationship between the speed delay and the time. The corresponding compensation conditions are different, and the compensation values ​​obtained are different. This is not limited here and can be set according to actual conditions. In order to perform park and inverse park transformations during closed-loop vector control, as a preferred embodiment, the encoder position value is compensated to obtain various compensated position values, including:

[0062] The encoded position value is subjected to park transformation compensation angle and inverse park transformation compensation angle to obtain the corresponding first compensation position value and second compensation position value.

[0063] Specifically, the position value count needs to be compensated based on the control loop delay and the actual operating conditions of the motor. The corresponding first and second compensated position values ​​are obtained through park and inverse park transformations. Changes in the time constant reflect angle delays or advances, which can be compensated for through angle compensation.

[0064] S12: converting each compensation position value according to the RAM lookup table and the resolution of the encoder to obtain the corresponding sine and cosine address index and address index supplement value;

[0065] Specifically, the establishment of the RAM lookup table is based on the sine and cosine values. For example, for 0-360°, the lookup table corresponds to the sine value or cosine value set for 0-360°. It should be noted that the sine value is set in the lookup table, and then the offset is performed according to the angle or the cosine value is set again according to the sine value. In other words, the current lookup table is a sine value after sine processing or a cosine value after cosine processing. As an embodiment, the process of establishing the RAM lookup table includes:

[0066] Get the sine or cosine value of a fixed number of points;

[0067] Perform fixed-point processing according to the sine value or cosine value of each fixed point to obtain the corresponding sine value table or cosine value table;

[0068] Store the sine value table or cosine value table in the FPGA's RAM to create a lookup table.

[0069] The fixed-point sine or cosine value can be used as the number of sine or cosine values. Regarding fixed-point processing, it should be noted that it often encounters the problem of floating-point fixed-point processing in algorithm processing. Therefore, for fixed-point processing, the integer multiples can be expanded based on the decimal to obtain the corresponding integer multiples, or the integer multiples can be expanded (or shifted) to truncate the bit width to obtain the corresponding sine value table or cosine value table and store it in RAM.

[0070] In addition, each compensation position value is individually looked up in a table based on the resolution of the encoder to obtain the corresponding sine and cosine address indexes and address index supplementary values. Combining the first and second compensation position values ​​after compensation, the first compensation position value is used to obtain the sine address index and sine angle correction value, and the cosine address index and cosine angle correction value through table lookup; the second compensation value is used to obtain the sine address index and sine angle correction value, and the cosine address index and cosine angle correction value through table lookup.

[0071] S13: Processing the sine and cosine address indexes and address index supplementary values ​​corresponding to each compensation position value by time-division multiplexing to obtain corresponding initial sine and cosine values ​​and sine and cosine correction values;

[0072] Specifically, time division multiplexing (TDM) uses the same physical connection to transmit different signals at different times, achieving multi-channel transmission. In networks, it is used to transmit multiple data channels using a single line. TDM uses time as the parameter for signal segmentation and transmission. Therefore, it is crucial that each signal does not overlap on the time axis, allowing different signals to be transmitted at different times.

[0073] The entire transmission time is divided into non-overlapping time intervals, also known as time slots. Time-division multiplexing technology allocates these time slots to each signal source, allowing each time slot to be occupied by only one signal. Time-division multiplexing enables multiple signals to be transmitted on a single circuit by interleaving portions of each signal over time. At any given moment on the circuit, only one signal is present. Time-division multiplexing is suitable for the transmission of digital signals. Because digital signals have a finite number of discrete values, time-division multiplexing is widely used in digital communication systems, including computer networks.

[0074] Through time-division multiplexing, the sine address index and sine angle correction value corresponding to the first compensation position value are processed to obtain an initial sine value. The cosine address index and cosine angle correction value corresponding to the first compensation position value are processed to obtain an initial cosine value. The sine address index and sine angle correction value corresponding to the second compensation position value are processed to obtain an initial sine value. The cosine address index and cosine angle correction value corresponding to the second compensation position value are processed to obtain an initial cosine value.

[0075] The correction values ​​corresponding to the first compensated position value are the sine correction value and the cosine correction value. Similarly, the correction values ​​corresponding to the second compensated position value are the sine correction value and the cosine correction value. Using time-division multiplexing, one time period is used to process the acquisition of the sine address index and sine angle correction value of the first compensated position value, and one time period is used to process the acquisition of the cosine address index and cosine angle correction value of the first compensated position value. Similarly, two time periods are used to process the second compensated position value.

[0076] S14: Correcting the corresponding initial sine and cosine values ​​according to the sine and cosine correction values ​​through time-division multiplexing to obtain final sine and cosine values ​​corresponding to the compensation position values.

[0077] In step S13, according to the initial sine value, initial cosine value, sine correction value and cosine correction value obtained by time-sharing multiplexing, the initial sine value corresponding to the sine correction value is corrected according to time-sharing multiplexing to obtain the final sine value, and the initial cosine value corresponding to the cosine correction value is corrected to obtain the final cosine value.

[0078] An embodiment of the present invention provides a method for determining electrical angle based on an FPGA, comprising: obtaining an encoder position value from an encoder and compensating the encoder position value to obtain each compensated position value; converting each compensated position value according to a RAM lookup table and the encoder resolution to obtain a corresponding sine-cosine address index and address index supplement value; processing the sine-cosine address index and address index supplement value corresponding to each compensated position value through time-sharing multiplexing to obtain a corresponding initial sine-cosine value and a sine-cosine correction value; and correcting each corresponding initial sine-cosine value according to each sine-cosine correction value through time-sharing multiplexing to obtain a final sine-cosine value corresponding to each compensated position value. Based on the existing lookup table, this method obtains corresponding sine-cosine address indexes and address index supplement values ​​according to the RAM lookup table and the encoder resolution to expand the data, further determines the initial sine-cosine value using the two values, and finally determines the final sine-cosine value to improve the accuracy of the sine-cosine value obtained through electrical angle processing, thereby improving the precision of the electrical angle. Compared with the existing method of obtaining sine and cosine values ​​by only looking up a table, the present invention utilizes fewer FPGA resources to make up for the small amount of data in the table to expand the data, thereby obtaining sine and cosine values ​​with higher precision. At the same time, it is based on FPGA execution, shortening the execution time and improving resource utilization.

[0079] Based on the above embodiment, step S12 converts each compensation position value according to the RAM lookup table and the encoder resolution to obtain the corresponding sine and cosine address index and address index supplement value, including:

[0080] Determine the data conversion byte table for each compensation position value according to the lookup table and the resolution of the encoder;

[0081] Determine the sine and cosine address indexes and address index supplementary values ​​according to each compensation position value in the data conversion byte table;

[0082] Correspondingly, the data conversion byte table for each compensation position value is determined according to the lookup table and the resolution of the encoder, including:

[0083] Obtain the number of sine and cosine values ​​in the lookup table of the RAM to determine the corresponding sine and cosine values, where the sine and cosine values ​​in the lookup table are sine values ​​or cosine values. When the lookup table is a sine value, the cosine value is obtained by offsetting the sine value in the lookup table.

[0084] Obtain the electrical angle range in the lookup table and the number of bits corresponding to the encoder resolution. If the encoder resolution is not an exponent of 2, amplify the encoder value to obtain an exponent close to 2 to obtain the number of bits corresponding to the encoder resolution.

[0085] A data conversion byte table of the current compensation position value is determined according to the sine and cosine values, the electrical angle range, and the number of bits, wherein the current compensation position value is the first compensation position value or the second compensation position value.

[0086] Specifically, the data conversion byte table for each compensation position value is determined by the lookup table and the encoder resolution. The data conversion byte table represents the number of input data bits corresponding to the current compensation position value, for example, a 17-bit table. This is determined based on table parameters of the lookup table, such as the number of sine and cosine values ​​in the lookup table and the electrical angle range.

[0087] As an embodiment, the corresponding sine and cosine data are determined according to the number of sine and cosine values. It should be noted that there is currently only one lookup table, which is a sine value or a cosine value. When the lookup table is a sine value, the corresponding cosine value is obtained by biasing the sine value.

[0088] Obtain the electrical angle range and the number of bits corresponding to the encoder resolution from the lookup table. The electrical angle range is 0-K°, where K is 90*m and m is 1, 2, or 4. There are no restrictions within a lookup table. The encoder resolution is 2 raised to the power of Z. If the encoder resolution is not a power of 2, scale the encoder value to the nearest multiple of 2 to obtain a power of 2. The Z value is determined by the current loop scaling, for example, 16, 17, or 18. The sine and cosine values ​​are 2 raised to the power of n.

[0089] The data conversion byte table for the current compensation position value is determined based on the sine and cosine values, electrical angle range, and number of bits. The number of bits determines the number of bytes in the data conversion byte table for the current compensation position value. For example, if the encoder resolution has 17 bits, the data converted from the current compensation position value is 17 bits. The converted data consists of Z-1, Z-2…ZS, ZS-1…ZSn, ZSn-1…1,0.

[0090] As a preferred embodiment, the data conversion byte table of the current compensation position value is determined according to the sine and cosine values, the electrical angle range, and the number of bits, specifically including:

[0091] Determine the number of sector indexes corresponding to the high-order digits according to the range value of the electrical angle range;

[0092] Determine the number of lookup table address indexes based on the sine and cosine values;

[0093] Determine the number of bytes of output data in the data conversion byte table according to the number of bits;

[0094] A data conversion byte table is formed according to the number of bytes, the number of sector indexes, and the number of lookup table address indexes.

[0095] Correspondingly, the sine and cosine address indexes and address index supplementary values ​​are determined in the data conversion byte table according to each compensation position value, including:

[0096] Determine the number of lookup table sector index bits in the data conversion byte table according to the electrical angle range;

[0097] Determine the number of lookup table address index bits following the number of lookup table sector index bits in the data conversion byte table according to the number of sine and cosine values;

[0098] The number of bits in the data conversion byte table minus the number of bits of the lookup table sector index and the number of bits of the lookup table address index is determined as the lookup table angle correction value;

[0099] The data obtained after obtaining the current compensation position value and performing binary processing is input into the data conversion byte table as conversion data;

[0100] The sine and cosine address indexes and address index supplementary values ​​of the current compensation position value are determined in the conversion data according to the corresponding number of lookup table sector index bits and the position of the lookup table angle correction value.

[0101] Specifically, the number of lookup table sector index bits is determined according to the electrical angle range. When K is 90, the lookup table sector index S is the high 2 bits of count1 and count2, that is, bit (z-1) to bit (z-2); when K is 180, the lookup table sector index S is 1; when K is 360, the lookup table sector index S is 0.

[0102] The number of lookup table address index bits is determined based on the number of sine and cosine values. The lookup table sector index is bit (ZSn) to bit (ZS-1) of count1 and count2. The remaining bits in the data conversion byte table are the lookup table angle correction values, which are bit 0 to bit (ZS-1-n) of count1 and count2, as shown in Table 1:

[0103] Table 1 Data conversion byte table

[0104]

[0105] The data input value obtained after binary processing of the current compensation position value is stored in the data conversion byte table as the conversion data. For example, the position value is 8, its binary value is 1000, and its data in the 17-bit data conversion byte table is 00000000000001000; if the electrical angle is 90, the sector index S is 00.

[0106] The sine and cosine address indexes and address index supplement values ​​are determined in the conversion data based on the corresponding lookup table sector index bit number and the position of the angle correction value. The address index is determined by the number n of sine and cosine values. For example, if n = 9, the address index is 9 bits of data, which in the above example is 9 zeros, and the angle correction value is 001000.

[0107] As an implementation, the RAM table stores 2^9 = 512 data points, corresponding to 2^17 of the sine value of the electrical angle from 0 to 90°. The encoder has a 17-bit resolution, or 131072. The value count read at any motor position is then converted to count1 and count2 after park and depark angle compensation. The count value is then converted to a range of 0 to 131071.

[0108] The processing of count1 and count2 values ​​is shown in Table 2:

[0109] Table 2 Data conversion byte table for n=9, K=90, Z=17

[0110]

[0111] The RAM table stores 2^10 = 1024 data points, corresponding to the sine value of 2^17 for angles from 0 to 180° electrical angle. The encoder has a 17-bit resolution, or 131072. The value count read at any motor position is then converted to count1 and count2 after park and depark angle compensation. The count is then converted to a range of 0 to 131071.

[0112] The processing of count1 and count2 values ​​is shown in Table 3:

[0113] Table 3 Data conversion byte table for n=10, K=180, Z=17

[0114]

[0115] The current sine and cosine address indexes only include a sine address index or a cosine address index. If the lookup table is a sine value, it represents the sine address index. Similarly, the cosine value is obtained by offsetting the sine value, and then the cosine address index is obtained based on the cosine value. The address index supplementary value is the lookup table angle correction value or the address index supplementary value. For count1 and count2, the sine and cosine address indexes and address index supplementary values ​​sin_address, cos_address, sin_address_max, and cos_address_max are used.

[0116] The embodiment of the present invention provides a method for converting each compensation position value according to the RAM lookup table and the resolution of the encoder to obtain the corresponding sine and cosine address index and address index supplement value. On the basis of the original lookup table, the corresponding sine and cosine address index and address index supplement value are obtained according to the RAM lookup table and the resolution of the encoder to expand the data, and the initial sine and cosine values ​​are further determined by the two values. Finally, the final sine and cosine values ​​are determined to improve the accuracy of the sine and cosine values ​​obtained by electrical angle processing and improve the accuracy of the electrical angle.

[0117] Based on the above embodiment, step S13 processes the sine and cosine address indexes and address index supplementary values ​​corresponding to the compensation position values ​​by time-division multiplexing to obtain the corresponding initial sine and cosine values ​​and sine and cosine correction values, including:

[0118] Obtain the mapped electrical angle value corresponding to each compensation position value;

[0119] Perform sine and cosine processing on the electrical angles corresponding to the mapped electrical angle values ​​and the address index supplementary values ​​to obtain the corresponding initial sine and cosine values ​​and sine and cosine supplementary calculated values;

[0120] The sine and cosine value correction deviation values ​​are obtained by performing a difference process on the supplementary sine and cosine calculated values ​​and the initial sine and cosine values, wherein the sine and cosine value correction deviation values ​​include a sine value correction deviation value and a cosine value correction deviation value;

[0121] The corresponding sine-cosine correction value is determined by the relationship between the sine-cosine correction deviation value, the correction coefficient and the number of data shift bits, where the number of data shift bits is determined according to the relationship between the number of sine-cosine values ​​stored in the lookup table, the number of bits of the encoder's resolution and the number of bits of the lookup table sector index.

[0122] Specifically, the mapped electrical angle value corresponding to each compensation position value is obtained, and the initial sine and cosine values ​​and the sine and cosine supplementary calculated values ​​are obtained according to the electrical angle corresponding to each mapped electrical angle value and the address index supplementary value.

[0123] Combined with the above example, the compensation position value is 8, its corresponding electrical angle value is set to 1°, its initial sine value is sin1°=0, and its initial cosine value is cos1°≈0. That is, the corresponding lookup table value D1 is obtained in sequence base (Basic sine calculation value), D2 base (Cosine basic calculation value), D1 sup (sine supplementary calculated value), D2 sup (Cosine supplementary calculation value), the entire calculation process is calculated under the control of the start_shift_buf shift controller.

[0124] Then, the sine and cosine value correction deviation is obtained by performing a difference process on the supplementary sine and cosine calculated values ​​and the initial sine and cosine values. The calculation formula is as follows:

[0125] Error1=D1 sup -D1 base

[0126] Error 2=D2 sup -D2 base

[0127] Error 1 and Error 2 are the sine correction deviation and cosine correction deviation, respectively.

[0128] As a preferred embodiment, the corresponding sine-cosine correction value is determined based on the relationship between the sine-cosine correction deviation value, the correction coefficient, and the number of data shift bits, specifically including:

[0129] Determine the number of data shift bits based on the relationship between the number of sine and cosine values, the number of bits of the encoder's resolution, and the number of bits of the lookup table sector index;

[0130] Multiply the sine and cosine correction deviation values ​​by the correction coefficient to obtain the initial correction value;

[0131] Multiply the initial correction value by the number of data shift bits to obtain the sine and cosine correction values;

[0132] Correspondingly, the number of data shift bits is determined according to the relationship between the number of sine and cosine values, the number of bits of the encoder resolution, and the number of bits of the lookup table sector index, including:

[0133] Determine the corresponding power of 2 based on the number of sine and cosine values;

[0134] Subtract the number of bits of the lookup table sector index from the number of bits of the encoder resolution to get the initial shift bit number;

[0135] Subtract the power number from the initial shift number to get the data shift number;

[0136] Accordingly, the corresponding sine and cosine correction values ​​are determined according to the relationship between the sine and cosine correction deviation value, the correction coefficient, and the number of data shift bits. The formula is as follows:

[0137] Z1=Error 1*K err_calib >>>(ZSn)

[0138] Z2=Error 2*K err_calib >>>(ZSn)

[0139] Where Z1 and Z2 are correction values, (ZSn) is the number of data shift bits, which is equal to the number of bits of the angle deviation correction coefficient, Z represents the number of bits of the encoder resolution, S represents the number of bits of the lookup table sector index, and n represents the power of 2 of the number of sine and cosine values ​​in the lookup table.

[0140] In step S14, the corresponding initial sine and cosine values ​​are corrected according to the sine and cosine correction values ​​to obtain the final sine and cosine values ​​corresponding to the compensated position values ​​through time division multiplexing, including:

[0141] The current initial sine and cosine values ​​and the current sine and cosine correction values ​​are added together to obtain the corresponding final sine and cosine values.

[0142] Specifically, the basic sine and cosine calculated values ​​are corrected to obtain the corrected basic sine and cosine calculated values. The calculation formula is as follows:

[0143] R' sin =D1 base +Z1

[0144] R' cos =D2 base +Z2

[0145] Among them, R' sin , R' cos are the sine and cosine values ​​before adding the sign.

[0146] For example, the resolution of the motor encoder is 17 bits, which means that the motor generates 2 17 =131072 count values. If the motor has one pair of poles, the corresponding electrical angle is 0-360°. The current compensation position value is 16626, and the corresponding mapping electrical angle is The sin and cos values ​​corresponding to the electrical angle are divided according to Table 1. The lookup table stores 1024 points, corresponding to the sin (0-90°) Q17 value. The parameters of the lookup table are n = 10, Z = 17, K = 90°, and the number of lookup table sector index bits is S = 2, ZSn = 5, that is, the lower 5 bits represent the lookup angle correction value, and the middle 10 bits represent the lookup table address index.

[0147] The sine and cosine data is 16626 (45.6647°). The binary representation of 16626 is 100000011110010, and the sector is 00, i.e., 0. The lookup table address index = 1000000111 (binary) = 519 (decimal). The lookup table angle correction value = 10010 (decimal) = 18 (binary). Its sin_address = 519, sin_address_max = 520; that is, the values ​​corresponding to the 519th and 520th in the lookup table, i.e., sin(90*519 / 1024)*2^17 = 93671, sin(90*520 / 1024)*2^17 = 93812; the basic sine calculation value D1 base =93671, sine supplementary calculation value D1 sup =93812, sine value correction deviation value Error1 = D1 sup -D1 base =93671-93812=141, correction value Z1=Error 1*K err_calib >>>(ZSn)=141*18 / 2 5 =79, sine and cosine values ​​before adding the sign R 's i =D1 base + Z1 = 93671 + 79 = 93750. The actual calculated sin value is sin(45.6647°)*2 17 = 93750. It can be seen that the lookup table values ​​obtained in the embodiment of the present invention are the same as the directly calculated sine and cosine values, and have higher accuracy.

[0148] The embodiment of the present invention provides a method for processing the sine-cosine address index and address index supplementary value corresponding to each compensation position value through time-sharing multiplexing to obtain the corresponding initial sine-cosine value and sine-cosine correction value. Through time-sharing multiplexing, the corresponding initial sine-cosine values ​​are corrected according to the sine-cosine correction value to obtain the final sine-cosine value corresponding to each compensation position value. By utilizing fewer FPGA resources, the small amount of data in the table is compensated to expand the data, and sine-cosine values ​​with higher precision are obtained. At the same time, based on FPGA execution and time-sharing multiplexing processing, the execution time is shortened and resource utilization is improved.

[0149] The above describes in detail various embodiments corresponding to the method for determining electrical angle based on FPGA. On this basis, the present invention also discloses a device for determining electrical angle based on FPGA corresponding to the above method. Figure 2 The structure diagram of a device for determining electrical angle based on FPGA provided by an embodiment of the present invention. Figure 2 As shown, the device for determining the electrical angle based on FPGA includes:

[0150] The compensation module 11 is used to obtain the encoder position value of the encoder and perform compensation processing on the encoder position value to obtain various compensated position values;

[0151] A first determination module 12 is configured to convert each compensation position value according to a lookup table in the RAM and a resolution of the encoder to obtain a corresponding sine and cosine address index and an address index supplement value;

[0152] The second determining module 13 is configured to process the sine and cosine address indexes and address index supplementary values ​​corresponding to the compensation position values ​​by time-division multiplexing to obtain corresponding initial sine and cosine values ​​and sine and cosine correction values;

[0153] The third determining module 14 is configured to correct the corresponding initial sine and cosine values ​​according to the sine and cosine correction values ​​through time division multiplexing to obtain final sine and cosine values ​​corresponding to the compensated position values.

[0154] Since the embodiments of the device part correspond to the above embodiments, the embodiments of the device part please refer to the description of the embodiments of the method part, and will not be repeated here.

[0155] For an introduction to the device for determining electrical angle based on FPGA provided by the present invention, please refer to the above method embodiment. The present invention will not be repeated here. It has the same beneficial effects as the above method for determining electrical angle based on FPGA.

[0156] Figure 3 A structural diagram of another device for determining electrical angle based on FPGA provided in an embodiment of the present invention, such as Figure 3 As shown, the device includes:

[0157] Memory 21, for storing computer programs;

[0158] The processor 22 is configured to implement the steps of the method for determining the electrical angle based on the FPGA when executing the computer program.

[0159] The device for determining electrical angle based on FPGA provided in this embodiment may include but is not limited to a tablet computer, a laptop computer, or a desktop computer.

[0160] Among them, the processor 22 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 22 can be implemented in at least one hardware form of a digital signal processor (DSP), an FPGA, and a programmable logic array (PLA). The processor 22 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 22 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 22 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.

[0161] The memory 21 may include one or more computer-readable storage media, which may be non-transitory. The memory 21 may also include high-speed random access memory, and non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 21 is at least used to store the following computer program 211, wherein, after the computer program is loaded and executed by the processor 22, it can implement the relevant steps of the method for determining the electrical angle based on FPGA disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 21 may also include an operating system 212 and data 213, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 212 may include Windows, Unix, Linux, etc. The data 213 may include but is not limited to data involved in the method for determining the electrical angle based on FPGA, etc.

[0162] In some embodiments, the device for determining electrical angle based on FPGA may further include a display screen 23 , an input / output interface 24 , a communication interface 25 , a power supply 26 , and a communication bus 27 .

[0163] Those skilled in the art will understand that Figure 3 The structure shown in the figure does not constitute a limitation on the device for determining an electrical angle based on FPGA, and may include more or fewer components than those shown in the figure.

[0164] The processor 22 implements the method for determining the electrical angle based on FPGA provided in any of the above embodiments by calling the instructions stored in the memory 21 .

[0165] For an introduction to the device for determining electrical angle based on FPGA provided by the present invention, please refer to the above method embodiment. The present invention will not be repeated here. It has the same beneficial effects as the above method for determining electrical angle based on FPGA.

[0166] Furthermore, the present invention also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by the processor 22 , the steps of the method for determining the electrical angle based on FPGA as described above are implemented.

[0167] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and executes all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0168] For an introduction to a computer-readable storage medium provided by the present invention, please refer to the above method embodiment, which will not be described in detail herein. It has the same beneficial effects as the above method for determining electrical angle based on FPGA.

[0169] As a preferred embodiment, the present invention provides a device for determining electrical angle based on FPGA processing timing diagram, Figure 4 A structural diagram of a device for determining electrical angle based on FPGA provided in an embodiment of the present invention. Figure 5 The present invention provides a device for determining electrical angle based on FPGA processing timing diagram, such as Figure 4 、 5 As shown, the timing diagram is obtained by combining the above-mentioned method for determining the electrical angle based on FPGA.

[0170] For an introduction to the device structure and processing timing diagram for determining electrical angle based on FPGA provided by the present invention, please refer to the above method embodiment. The present invention will not be repeated here. It has the same beneficial effects as the above method for determining electrical angle based on FPGA.

[0171] The above is a detailed introduction to a method for determining an electrical angle based on FPGA, a device for determining an electrical angle based on FPGA, and a medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and 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. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, the present invention can also be improved and modified in several ways, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.

[0172] It should also be noted that, in this specification, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.

Claims

1. A method for determining electrical angle based on FPGA, characterized in that: include: Acquiring encoder position values ​​of an encoder, and performing compensation processing on the encoder position values ​​to obtain respective compensated position values; Convert each of the compensation position values ​​according to the RAM lookup table and the resolution of the encoder to obtain a corresponding sine and cosine address index and address index supplement value; Processing the sine and cosine address indexes and the address index supplementary values ​​corresponding to the compensation position values ​​by time-division multiplexing to obtain corresponding initial sine and cosine values ​​and sine and cosine correction values; Through time-division multiplexing, the corresponding initial sine and cosine values ​​are corrected according to the sine and cosine correction values ​​to obtain final sine and cosine values ​​corresponding to the compensated position values.

2. The method for determining electrical angle based on FPGA according to claim 1, characterized in that: The process of establishing the RAM lookup table includes: Get the sine or cosine value of a fixed number of points; Performing fixed-point processing on the sine value or the cosine value of each fixed point number to obtain a corresponding sine value table or cosine value table; The sine value table or the cosine value table is stored in the RAM of the FPGA to establish the lookup table.

3. The method for determining electrical angle based on FPGA according to claim 1, characterized in that: The compensating the encoder position value to obtain each compensated position value includes: The encoder position value is subjected to park transformation compensation angle and inverse park transformation compensation angle to obtain corresponding first compensation position value and second compensation position value.

4. The method for determining electrical angle based on FPGA according to claim 3, characterized in that: The converting of each of the compensation position values ​​according to the RAM lookup table and the resolution of the encoder to obtain the corresponding sine and cosine address indexes and address index supplementary values ​​includes: Determine a data conversion byte table for each of the compensation position values ​​according to the lookup table and the resolution of the encoder; Determining the sine and cosine address indexes and the address index supplementary values ​​according to each of the compensation position values ​​in the data conversion byte table; Correspondingly, the data conversion byte table for determining each of the compensation position values ​​according to the lookup table and the resolution of the encoder includes: Obtaining the number of sine and cosine values ​​in the lookup table of the RAM to determine corresponding sine and cosine values, wherein the sine and cosine values ​​in the lookup table are sine values ​​or cosine values, and when the lookup table is the sine value, obtaining the cosine value by offsetting the sine value in the lookup table; Obtaining the electrical angle range in the lookup table and the number of bits corresponding to the resolution of the encoder, wherein if the resolution of the encoder is not an exponent of 2, amplifying the encoder value to obtain an exponent close to 2 to obtain the number of bits corresponding to the resolution of the encoder; A data conversion byte table for a current compensation position value is determined according to the sine and cosine values, the electrical angle range, and the number of bits, wherein the current compensation position value is the first compensation position value or the second compensation position value.

5. The method for determining electrical angle based on FPGA according to claim 4, characterized in that: The determining the sine-cosine address index and the address index supplemental value according to each compensation position value in the data conversion byte table includes: Determine the number of lookup table sector index bits in the data conversion byte table according to the electrical angle range; Determine the number of lookup table address index bits following the lookup table sector index bit in the data conversion byte table according to the number of sine and cosine values; Determine in the data conversion byte table the number of bits other than the number of bits of the lookup table sector index and the number of bits of the lookup table address index as the lookup table angle correction value; The data obtained by obtaining the current compensation position value and performing binary processing is input into the data conversion byte table as conversion data; The sin-cos address index of the current compensation position value and the address index supplement value are determined in the conversion data according to the corresponding number of bits of the lookup table sector index and the position of the lookup table angle correction value.

6. The method for determining electrical angle based on FPGA according to claim 5, characterized in that: The processing of the sine-cosine address index and the address index supplementary value corresponding to each of the compensation position values ​​by time-division multiplexing to obtain the corresponding initial sine-cosine value and sine-cosine correction value includes: Obtaining a mapped electrical angle value corresponding to each of the compensation position values; Perform table lookup processing according to the electrical angle corresponding to each of the mapped electrical angle values ​​and the address index supplementary value to obtain the corresponding initial sine and cosine values ​​and sine and cosine supplementary calculated values; Performing a difference process between the supplementary sine and cosine calculated values ​​and the initial sine and cosine values ​​to obtain a sine and cosine correction deviation value, wherein the sine and cosine correction deviation value includes a sine correction deviation value and a cosine correction deviation value; The corresponding sine-cosine correction value is determined by the relationship between the sine-cosine correction deviation value, the correction coefficient and the number of data shift bits, wherein the number of data shift bits is determined based on the relationship between the number of sine-cosine values ​​stored in the lookup table, the number of bits of the encoder's resolution and the number of bits of the lookup table sector index.

7. The method for determining electrical angle based on FPGA according to claim 6, characterized in that: The method of correcting the corresponding initial sine and cosine values ​​according to the sine and cosine correction values ​​to obtain final sine and cosine values ​​corresponding to the compensated position values ​​by time-division multiplexing includes: The current initial sine and cosine values ​​and the current sine and cosine correction values ​​are added to obtain the corresponding final sine and cosine values.

8. A device for determining electrical angle based on FPGA, characterized in that: include: a compensation module, configured to obtain an encoder position value of an encoder, and perform compensation processing on the encoder position value to obtain various compensated position values; A first determination module is configured to convert each of the compensation position values ​​according to a lookup table in the RAM and a resolution of the encoder to obtain a corresponding sine and cosine address index and an address index supplement value; A second determining module is configured to process the sine and cosine address indexes and the address index supplementary values ​​corresponding to the compensation position values ​​by time-division multiplexing to obtain corresponding initial sine and cosine values ​​and sine and cosine correction values; The third determining module is configured to correct the corresponding initial sine and cosine values ​​according to the sine and cosine correction values ​​through time division multiplexing to obtain final sine and cosine values ​​corresponding to the compensated position values.

9. A device for determining electrical angle based on FPGA, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the method for determining an electrical angle based on an FPGA as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for determining an electrical angle based on an FPGA according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Motor and motor data analysis method, device and system

    CN111464107A

  • Self-calibration device of magnetoelectric encoder

    CN114001768A