Current Sampling Method, Chip, and Sampling Device for Motor Phase Current
By determining sector edges in motor control and changing duty cycles and channel modes, the problem of current sampling distortion in sector-shaped areas is solved, and effective phase current acquisition and sampling efficiency improvement in sector-shaped areas is achieved.
Patent Information
- Application Number
- CN202111080891.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-15
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2041-09-15
AI Technical Summary
The existing motor control methods cannot fully acquire the phase current signal in the sector-shaped area, resulting in current sampling distortion and inefficiency.
By determining whether the current period waveform falls on the edge of the sector, determining and storing the first duty cycle and the conversion channel mode, the waveform is transformed using the direct memory access mode to construct a phase current sampling area.
Effectively obtain phase current at the edge of the sector area, reduce current sampling distortion, and improve sampling efficiency.
Smart Images

Figure CN114019223B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of motor control, and particularly to a method for sampling current, a chip, and a sampling device for motor phase current. Background Art
[0002] Generally, with the increasing demand for the convenience and accuracy of motors, when a motor is running, users often hope to quickly and accurately control the motor to meet the user experience during operation.
[0003] Generally, when a motor is running, mainstream motors usually collect current, and based on the collected current, their control methods all use the method of field-oriented control (FOC) to control the motor, that is, use the FOC algorithm to control the motor.
[0004] Currently, because the FOC algorithm requires single-resistance sampling and needs to obtain the phase current within a pulse-width modulation (PWM) period. Since the current sampling area within a pulse period includes a non-sector area and a sector area, when the FOC algorithm is usually used, this results in an inability to fully obtain the phase current signal at the sector edge, such as in the sector area. Summary of the Invention
[0005] A first aspect of an embodiment of the present application provides a method for sampling current. The sampling method includes: determining that the current cycle waveform falls on the sector edge; if the current cycle waveform is on the sector edge, for the channel where the phase current cannot be collected, determining a first duty ratio and a transformed channel mode; storing the first duty ratio and the transformed channel mode in a buffer, and enabling the direct memory access mode; transforming a partial area of the waveform according to the first duty ratio and the transformed channel mode; and obtaining the phase current based on the deformed waveform.
[0006] A second aspect of an embodiment of the present application provides a chip, which includes:
[0007] A judgment module, configured to judge whether the current cycle waveform or the waveform of the next cycle of the current cycle falls on the sector edge;
[0008] A channel configuration module, connected to the judgment module, configured to configure the channel corresponding to the current cycle waveform according to the first duty ratio and the transformed channel mode in the corresponding channel register, or configured to configure the channel corresponding to the waveform of the next cycle according to the second duty ratio and the original channel mode in the corresponding channel register;
[0009] A storage module, connected to the channel configuration module, configured to store the first duty ratio and the transformed channel mode in a buffer, or store the second duty ratio and the original channel mode in a buffer;
[0010] An enabling module, connected to the storage module, is used to enable the direct memory access mode, transfer the first duty cycle and the transformation channel mode from the buffer to the corresponding channel register to transform a partial area of the current cycle waveform, or transfer the second duty cycle and the original channel mode from the buffer to the corresponding channel register to restore a partial area of the next cycle waveform according to the standard waveform.
[0011] A waveform transformation module, connected to the enabling module, is used to, when it is determined that the current cycle waveform falls on the sector edge, transform a partial area of the current cycle waveform for the channels where the phase current cannot be collected according to the first duty cycle and the transformation channel mode.
[0012] A waveform restoration module, connected to the enabling module, is used to, when it is determined that the next cycle waveform falls on the sector edge, determine that the next cycle waveform is the standard waveform, and restore a partial area of the next cycle waveform according to the second duty cycle and the original channel mode according to the standard waveform.
[0013] A phase current acquisition module, connected to the waveform transformation module or the waveform restoration module, is used to acquire the phase current based on the transformed current cycle waveform or acquire the phase current of the restored next cycle waveform.
[0014] A third aspect of the embodiments of the present application provides a sampling device for motor phase current. The sampling device includes: a motor, a processor, a current collector, and a memory. The current collector and the processor are both connected to the motor. A computer program is stored in the memory. The processor is used to execute the computer program to implement the sampling method provided in the first aspect of the embodiments of the present application to transform or restore the pulse width modulation waveform generated by the motor so that the current collector can acquire the phase current.
[0015] The beneficial effects of the present application are as follows: Different from the prior art, for the current phase current sampling method in motor control, the present application determines and stores the first duty cycle and the transformation channel mode for the channels where the phase current cannot be collected when it is determined that the current cycle waveform falls on the sector edge, enables the direct memory access mode, and transforms a partial area of the current cycle waveform according to the first duty cycle and the transformation channel mode, so as to meet the condition for obtaining the phase current sampling to obtain the phase current at the edge of the fan-shaped area, thereby reducing the current sampling distortion and improving the efficiency of current sampling. Description of the Drawings
[0016] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0017] Figure 1 It is a schematic flowchart of the first embodiment of the current sampling method of the present application;
[0018] Figure 2 is the present application Figure 1 a specific flowchart of step S11 in;
[0019] Figure 3 is the present application Figure 2 another specific flowchart of step S11 in;
[0020] Figure 4 is the present application Figure 1 a schematic flowchart of a specific embodiment after step S15 in;
[0021] Figure 5 is a specific flowchart of determining the corresponding number of phases of the present application;
[0022] Figure 6 is a schematic flowchart of a specific embodiment of the current sampling method of the present application;
[0023] Figure 7 is Figure 6 a schematic diagram of the pulse transformation process of a specific embodiment in;
[0024] Figure 8 is a schematic structural diagram of an embodiment of the chip of the present application;
[0025] Figure 9 is a schematic structural diagram of the sampling device for the motor phase current of the present application. Specific Embodiments
[0026] In the following description, for the purpose of illustration rather than limitation, specific details such as specific system structures and technologies are presented to thoroughly understand the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.
[0027] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups.
[0028] It should also be understood that the terminology used in this application specification is for the purpose of describing particular embodiments only and is not intended to limit this application. As used in this application specification and the appended claims, unless the context clearly dictates otherwise, the singular forms "a", "an" and "the" are intended to include the plural forms.
[0029] It should be further understood that the term "and / or" used in this application specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0030] As used in this specification and the appended claims, the term "if" can be interpreted, depending on the context, as "when", "once", "in response to determining" or "in response to detecting". Similarly, the phrase "if determined" or "if [the described condition or event] is detected" can be interpreted, depending on the context, as meaning "once determined", "in response to determining", "once [the described condition or event] is detected" or "in response to detecting [the described condition or event]".
[0031] To illustrate the technical solution of this application, the following will be described by way of specific embodiments. This application provides a method for sampling current, taking a pulse waveform as an example. Please refer to Figure 1 , Figure 1 is a schematic flow chart of the first embodiment of the current sampling method of this application. The sampling method specifically includes the following steps:
[0032] S11: Determine whether the current cycle waveform falls on the sector edge;
[0033] The pulse period, also known as the pulse period, is actually the time taken for one pulse. Generally speaking, it can correspond to the pulse width. From an academic perspective, the pulse width is the time width during which the current or voltage changes regularly with time.
[0034] The current sampling area within one pulse period includes a non-sector area and a sector area. Generally, as long as the pulse width meets a certain width condition during the pulse period, the phase current can be obtained in the non-sector area, but the phase current cannot be obtained in the special sector area.
[0035] To obtain the phase current in the sector region, generally in the motor control system, it is necessary to judge the current cycle waveform to determine whether the current cycle waveform falls on the sector edge. Specifically, it can be determined whether the pulse waveform of the current cycle falls on the sector edge, where the sector edge here refers to a special sector region.
[0036] S12: For the channels where the phase current cannot be collected, determine the first duty cycle and the transformation channel mode;
[0037] When the current cycle waveform is on the sector edge, it means that the phase current cannot be collected through the channel corresponding to the current cycle waveform at this time. If the phase current cannot be collected, the motor operation cannot be effectively controlled. In order to better control the motor even at the sector edge, waveform transformation is required. Thus, it is necessary to determine the transformation channel mode and the first duty cycle. Among them, the transformation channel mode can also be understood as the waveform shape, and the first duty cycle is the duty cycle of the channel.
[0038] Among them, the duty cycle is the ratio of the time occupied by the pulse to the total time within a continuous working time. Its extended meaning: In a periodic phenomenon, the ratio of the time duration after a certain phenomenon occurs to the total time.
[0039] S13: Store the first duty cycle and the transformation channel mode in the buffer, and enable the direct memory access mode;
[0040] After determining the first duty cycle and the transformation channel mode, the first duty cycle and the transformation channel mode can be stored in the buffer to update the buffer, that is, store the first duty cycle and the transformation channel mode of the phase channel in the buffer, and enable the direct memory access (DMA) mode. When the current cycle waveform needs to be transformed, the DMA transports the buffer parameters to transform the current cycle waveform. Among them, the buffer parameters at least include two parameters, namely the duty cycle and the channel mode. Specifically, for example, the first duty cycle and the transformation channel mode.
[0041] S14: According to the first duty cycle and the transformation channel mode, transform a partial region of the current cycle waveform;
[0042] Generally, the current cycle waveform can be transformed according to the first duty cycle and the transformation channel mode. Specifically, a partial region of the current cycle waveform can be transformed to construct a phase current sampling region. For example, the pulse width modulation (PWM) waveform can be controlled by the DMA method to be deformed, so as to construct a phase current sampling region.
[0043] Furthermore, a waveform phase shift scheme can also be adopted to implement on the early AC7801x MCU products, or the next-generation products can use PWM to flip twice within one rising and falling cycle to construct the required phase current sampling area, reducing the current sampling distortion during single-resistance operation and reducing current noise. Specific details are not limited here.
[0044] S15: Obtain the phase current.
[0045] Based on the transformed current cycle waveform, a current sampling area capable of collecting the phase current can be constructed, thereby obtaining the phase current. For example, one of the two-phase currents can be collected in the non-sector area, and the other phase current needs to be collected in the sector area. Of course, there can be other combinations, which are not limited here.
[0046] Therefore, for the current phase current sampling method in motor control, when it is determined that the current cycle waveform falls on the sector edge, for the channels where the phase current cannot be collected, the first duty cycle and the transformation channel mode are determined and stored, and the direct memory access mode is enabled. According to the first duty cycle and the transformation channel mode, waveform transformation is performed on a partial area of the current cycle waveform, so that the conditions for obtaining the phase current sampling are met at the sector edge to obtain the phase current, thereby reducing current sampling distortion and improving the efficiency of current sampling.
[0047] Furthermore, to determine that the current cycle waveform falls on the sector edge, please refer to Figure 2 , Figure 2 which is a specific flowchart of step S11 in this application, specifically including the following steps: Figure 1 S21: Determine whether the flag of the sector edge is set to 1;
[0048] To determine the sector edge, it is necessary to detect the sector edge corresponding to the current cycle waveform. Specifically, it can be determined whether the current cycle waveform falls on the sector edge by determining whether the flag of the sector edge is set to 1.
[0049] If it is set to 1, indicating that the current cycle waveform falls on the sector edge, then proceed to step S22, that is, determine that the current cycle waveform falls on the sector edge; if it is not set to 1, for example, 0, indicating that the current cycle waveform does not fall on the sector edge, then proceed to step S23, that is, determine that the current cycle waveform does not fall on the sector edge.
[0050] If it is set to 1, indicating that the current cycle waveform falls on the sector edge, then enter step S22, that is, determine that the current cycle waveform falls on the sector edge; if it is not set to 1, such as 0, indicating that the current cycle waveform does not fall on the sector edge, then enter step S23, that is, determine that the current cycle waveform does not fall on the sector edge.
[0051] Furthermore, in addition, to determine that the current cycle waveform falls on the sector edge, please refer to Figure 3 , Figure 3 which is another specific flowchart of step S11 in this application, specifically including the following steps: Figure 1 S21: Determine whether the flag of the sector edge is set to 1;
[0052] S31: Based on the pulse width of the current cycle waveform, calculate whether the width between two sampling points of the phase current meets a preset sampling width;
[0053] Generally, within a pulse modulation period, the generated current cycle waveform occupies a certain width within the pulse modulation period. Generally, a preset sampling width is set in the motor system for current sampling within this preset sampling width. Additionally, based on the pulse width of the generated current cycle waveform, which can also be the time when the pulse is generated, calculate whether the width between two sampling points of the phase current meets the preset sampling width to determine the acquired phase current.
[0054] If it is determined that the preset sampling width is met, proceed to step 32, that is, determine that the current cycle waveform does not fall on the sector edge, and the phase current can be sampled; if it is determined that the preset sampling width is not met, proceed to step 33, that is, determine that the current cycle waveform falls on the sector edge, the phase current cannot be sampled, and a partial area of the current cycle waveform needs to be transformed.
[0055] Among them, based on the determined first duty cycle and transformation channel mode, transform a partial area of the current cycle waveform, specifically including:
[0056] On the one hand, the first duty cycle and the transformation channel mode can be used to transform a partial area of the current cycle waveform in at least one of the ways of flipping, hollowing, or compensating, that is, on the current cycle waveform, it is at least one of flipping, hollowing, and compensating of the current cycle waveform.
[0057] On the other hand, while determining the first duty cycle and the transformation channel mode, directly enable the direct memory access mode. Therefore, the already enabled direct memory access method can also be used to transfer the first duty cycle and the transformation channel mode from the buffer to the channel register to configure the channels of the corresponding phase, so as to realize the transformation of a partial area of the current cycle waveform.
[0058] Furthermore, after transforming a partial area of the current cycle waveform, the sampling method further includes:
[0059] Furthermore, please refer to Figure 4 , Figure 4 is another specific flowchart after step S15 in this application Figure 1 In the next cycle waveform of the current cycle waveform, this current sampling method specifically further includes the following steps:
[0060] S41: Determine whether the next cycle waveform of the current cycle waveform falls on the sector edge;
[0061] If the waveform of the next period falls on the sector edge, it can be known that the waveform of the next period is the same as the waveform after transformation of the current period waveform, and then directly enter step S42, that is, obtain the phase current.
[0062] If the waveform of the next period does not fall on the sector edge, enter step S43. It can be known that the waveform of the next week is a standard waveform, and the waveform of the next period needs to be restored to the standard waveform, and then enter step S44 to update the parameters of the buffer to the second duty ratio and the original channel mode.
[0063] Specifically, use the direct memory access method to transfer the second duty ratio and the original channel mode in the buffer to the channel register; so as to use DMA to transfer the first duty ratio and the transformed channel mode in the buffer to replace the second duty ratio and the original channel mode to configure the channels of the corresponding phase.
[0064] Furthermore, use the second duty ratio and the original channel mode to configure the channels of the corresponding phase to restore the waveform of the next period according to the standard waveform. Specifically, it further includes:
[0065] On the one hand, the channels of the corresponding phase can be configured using the second duty ratio and the original channel mode to directly restore the waveform of the next period according to the standard waveform.
[0066] On the other hand, the second duty ratio and the original channel mode can also be used to restore the partial area of the waveform of the next period to the standard waveform in at least one of the ways of flipping, hollowing or compensating, so that the waveform of the next period is restored to the original standard shape and restored to the waveform at the non-sector edge. For example, when transforming, hollowing is performed and restored to the original shape without hollowing.
[0067] In addition, it is worth noting that the second duty ratio is used in the recovery process, which is different from the first duty ratio. That is, the duty ratio is stored in a covering manner in the buffer, and each time it is transformed, the duty ratio is updated once. In this way, it will neither affect the recovered waveform nor reduce the data volume stored in the buffer and transferred by DMA. The channel mode stores the original channel mode or the transformed channel mode, and the mode that needs to be transformed each time can be stored in a covering manner. In this way, the storage space can be saved.
[0068] Furthermore, it can be determined whether the corresponding phase is single-phase or multi-phase. Please refer to Figure 5 , Figure 5 is a specific flow schematic diagram for the present application to determine the number of corresponding phases; among them, the waveform transformation of each phase in the single-phase waveform or multi-phase waveform can respectively sample the phase current by using the current sampling method as described above.
[0069] S51: Obtain the flag position of the corresponding phase;
[0070] Generally, the current cycle waveform or the next cycle waveform can set the flag position to determine the number of corresponding phases. For example, if the corresponding phase of the previous cycle waveform is single-phase, the flag position corresponding to the single-phase can be obtained; if the corresponding phase of the previous cycle waveform is multi-phase, the flag position corresponding to the multi-phase can be obtained.
[0071] S52: Determine whether the flag setting is the same as the first preset value corresponding to the single-phase or the second preset value corresponding to the multi-phase;
[0072] Specifically, the previous cycle waveform or the next cycle waveform corresponding phase is provided with the first preset value corresponding to the single-phase or the second preset value corresponding to the multi-phase, which is used to judge the obtained flag position of the corresponding phase, so as to distinguish the dimension of the corresponding phase.
[0073] S53: If it is determined that the flag setting is the same as the first preset value corresponding to the single-phase, determine that the corresponding phase is single-phase;
[0074] Specifically, the single-phase waveform samples the phase current by using the current sampling method as described above.
[0075] S54: If it is determined that the flag setting is the same as the second preset value corresponding to the multi-phase, determine that the corresponding phase is multi-phase.
[0076] Among them, the multi-phase includes at least two phases, and each phase waveform transformation in the multi-phase waveform samples the phase current by using the current sampling method as described above.
[0077] Next, further in combination with the following text, the current sampling method based on the pulse waveform of the present application will be described in detail in combination with specific application scenarios. The motor includes three phases of PWM_V, PWM_W, and PWM_U. The motor control single-resistance sampling mechanism samples the two-phase current analog-to-digital conversion data (ADC, analog / digital converter) within one PWM waveform. However, under certain sector boundary conditions, only one-way current ADC data can be obtained, and the PWM waveform needs to be deformed to construct the current sampling area. Through the DMA transfer PWM configuration method, the DMA is automatically triggered to modify the PWM configuration within a specific window (i.e., the fan-shaped area) within one PWM cycle, so that the PWM waveform changes, thereby constructing the current sampling area.
[0078] Please refer to Figure 6 and Figure 7 , Figure 6 is the flow schematic diagram of a specific embodiment of the current sampling method of the present application; Figure 7 is Figure 6 the pulse transformation process schematic diagram of a specific embodiment in Figure 7 provides two sector edge scenarios of boundary1 and boundary2, as Figure 7As shown, when there is not enough black area in the ADC Sample for sampling, only one-phase current can be sampled or no phase current can be obtained at this time, and two-phase current signals cannot be obtained at the sector edge. Therefore, PWM waveform transformation is required to generate deformation in the middle part of the waveform, and two-phase current ADC data can be obtained on the deformed waveform. The application scenario of this specific embodiment includes the following steps:
[0079] S601: ③Interrupt the execution of the FOC algorithm to calculate the duty cycle and ADC sampling point for the next cycle;
[0080] As Figure 7 shown, it can be known that Figure 7 in it, COUNT is the cycle count value, which includes at least 7 modules: I, II, III, IV, V, VI, and VII. For the convenience of different display areas, numbers such as ①, ②, ③, ④, ⑤, and ⑥ are also set to mark the pulse period.
[0081] S602: Determine whether the current cycle waveform or the next cycle waveform falls on the sector edge;
[0082] Specifically, determine whether the current cycle waveform or the next cycle waveform falls on the sector edge. If so, it means the waveform falls on the sector edge, and go to step 612. If not, it means the waveform does not fall on the sector edge, and go to step 603.
[0083] In boundary1, Figure 7 in the middle part of the upper half, the corresponding pulse modulation waveforms of PWM_V and PWM_W are the same, while the corresponding pulse modulation waveform of PWM_U is different. Then, it can be seen from I_BUS that no phase current is sampled at the sector edge.
[0084] In boundary2, Figure 7 in the middle part of the lower half, the corresponding pulse modulation waveforms of PWM_U, PWM_V, and PWM_W are all different. Then, it can be seen from I_BUS that no phase current is sampled at the non-sector edge and the sector edge.
[0085] S603: Set the PWM duty cycle, ADC sampling point, and enable software trigger synchronization;
[0086] If it is in the normal sector, execute the conventional PWM control, such as the normal PWM configuration restoration operation in the process. The restoration is divided into two types. One is to restore the single-phase PWM channel, and the other is to restore the two-phase PWM channel. Determine whether it is a single-phase or two-phase transformation according to the flag bit, fill the duty cycle and PWM configuration to be restored into the Buffer array, wait for the hardware to request the DMA transfer event, and restore the PWM configuration in the specific window.
[0087] Set the PWM duty cycle, ADC sampling points, and enable software trigger synchronization. Specifically, the watchdog can be used to determine whether to call the DMA event after the fan-shaped area. Of course, it is not necessarily required to use the watchdog, and a piece of code in the program that triggers the call of the DMA event can also be used, which is not limited here.
[0088] S604: Sector edge flag == true;
[0089] When it is determined that the flag of the sector edge is true, it can be determined that the waveform of the next pulse period is a normal waveform, which means that this waveform needs to be restored to the standard waveform.
[0090] S605: Biphase transformation flag == true;
[0091] If the flag of the biphase transformation is true, then step S606 is entered, that is, the restored configuration of the biphase PWM channel is filled into the Buffer. Specifically, the third duty cycle and the original channel mode of the first phase corresponding to the biphase PWM channel, and the fourth duty cycle and the original channel mode of the second phase can be filled into the Buffer respectively. And step S609 is entered: clear the biphase transformation flag.
[0092] If the flag of the biphase transformation is false, then step S607 is entered: fill the restored configuration of the single-phase PWM channel into the Buffer. Specifically, the duty cycle and the original channel mode of the corresponding phase of the single-phase PWM channel can be filled into the Buffer. And step S610 is entered: clear the sector edge flag.
[0093] When it is determined that the flag of the sector edge is false, step S608 is entered, that is, the DMA request is prohibited, and step S610 is entered: clear the sector edge flag; after clearing the sector edge flag, then step S611 is entered: exit the interrupt;
[0094] When it is determined that the current cycle waveform or the next cycle waveform falls on the sector edge, the phase current cannot be collected, indicating that the waveform needs to be transformed, then step S612 is entered, that is, set the sector edge flag = true;
[0095] S613: Whether to transform the biphase PWM output;
[0096] Through motor control detection, it can be known that the current cycle waveform or the next cycle waveform falls on the sector edge and the waveform transformation process needs to be executed. Due to the diversity of waveforms, it is necessary to determine whether to transform the biphase PWM output at this time. If so, then step S620 is entered; if not, then step S614 is entered.
[0097] S614: Clear the biphase transformation flag;
[0098] Clearing the bipolar transformation flag indicates that it is currently a single-phase transformation. If it is a single-phase transformation, only the duty cycle of the corresponding single-phase PWM channel and the configuration of the transformation channel mode need to be set.
[0099] S615: Transform the PWM duty cycle value to obtain a PWM channel of one phase that needs to be boundary-processed and the corresponding duty cycle value.
[0100] Specifically, if the waveform falls on the sector edge, such as Figure 7 the right part of the upper half, adjust one of PWM_V or PWM_W for deformation. Hollow out the black solid part (by changing the channel value), and compensate the hollowed-out area to both ends of the waveform for pulling up to form a light-colored area to transform the waveform, so as to construct a reasonable phase current adoption area, and then the phase current of two samplings can be obtained.
[0101] S616: Fill the single-phase PWM channel configuration into the buffer.
[0102] If the flag bit is a single-phase transformation, fill the duty cycle corresponding to the single phase and the transformation channel mode configuration into the Buffer array, wait for the hardware to request the DMA transfer event, and restore the PWM configuration in a specific window.
[0103] S617: Enable the DMA request.
[0104] First put the channel value into the buffer array, that is, first put the duty cycle corresponding to the single phase and the transformation channel mode into the buffer array. Specifically, when the trigger event is triggered, through direct memory access, forced assignment is performed to obtain the duty cycle corresponding to the single phase and the transformation channel mode to deform the PWM.
[0105] S618: Transform some regions of the waveform according to the two parameters in the buffer.
[0106] Specifically, the two parameters in the buffer are the duty cycle corresponding to the single phase and the transformation channel mode. According to the duty cycle corresponding to the single phase and the transformed channel mode, some regions of the waveform are transformed in at least one of the ways of flipping, hollowing out or compensating, and the transformed waveform reflects at least one of the ways of flipping, hollowing out or compensating.
[0107] S619: Obtain the phase current based on the transformed waveform.
[0108] S620: Set the bipolar transformation flag = true.
[0109] If it is a two-phase transformation, it is necessary to set the PWM channels and configurations of both phases simultaneously, fill the duty cycle-related values into the Buffer array, enable the DMA request after the setting is completed, wait for the hardware to request the DMA transfer event, and restore the PWM configuration in a specific window.
[0110] S621: Transform the PWM duty ratio values to obtain the two-phase PWM channels and the corresponding duty ratio values that need to be boundary-processed;
[0111] Generally, according to the fifth duty cycle and the fifth transformation channel mode of one phase, transform the waveform of this one phase, and according to the sixth duty cycle and the sixth transformation channel mode of the other phase, transform the waveform of the other phase.
[0112] For example, as Figure 7 shown, does the width of the pulled-down area need to be less than the width of the PWM_U area? In Boundary2, because the area differences between PWM_U, PWM_V, and PWM_W are small and the I_BUS width is too narrow to sample the phase current, adjust any two of the three phases for deformation, and hollow out the black solid part (by changing the channel value). Among them, the hollowed-out area is compensated to both ends for pulling up to form a light-colored area, so that it can be sampled once in the first half cycle of the counting period and sampled again in the second half cycle of the counting period. In this way, the phase current of two samplings can be obtained.
[0113] S622: Fill the two-phase PWM channel configuration into the buffer;
[0114] If the flag bit is a two-phase transformation, configure the fifth duty cycle, the fifth transformation channel mode, the sixth duty cycle, and the sixth transformation channel mode into the Buffer array, wait for the hardware to request the DMA transfer event, that is, wait for the direct memory access mode to be enabled, and then enter step S617, that is, enable the DMA request, which will not be elaborated here.
[0115] Therefore, to implement the above control method, it is necessary for the chip hardware module to support the combination of software algorithms, such as hardware functions like PWM triggering the DMA event and DMA transferring the PWM configuration register. At the same time, the software cooperates with these hardware functions to execute the corresponding algorithms at specific timings to complete the target function.
[0116] In this way, the configuration steps can be reduced by simplifying the PWM configuration register, making the data volume transferred by the DMA smaller, and the control window of the PWM also increases accordingly. This motor control system is applicable to the FOC single-resistance motor algorithm control, and performs PWM waveform transformation through the hardware DMA transfer register configuration method, simplifies the software process, and improves the control real-time performance. Moreover, different on-chip peripheral modules can work together, expanding the application scenarios of the product.
[0117] In addition, a second aspect of the embodiments of the present application provides a chip 70. Please refer to Figure 8 , Figure 8 , which is a schematic structural diagram of an embodiment of the chip of the present application. The chip 70 includes:
[0118] A judgment module 71, configured to judge whether the waveform of the current cycle or the waveform of the next cycle of the current cycle falls on the sector edge;
[0119] A channel configuration module 72, connected to the judgment module 71, configured to configure the channel corresponding to the waveform of the current cycle according to the first duty ratio and the transformed channel mode in the corresponding channel register, or to configure the channel corresponding to the waveform of the next cycle according to the second duty ratio and the original channel mode in the corresponding channel register;
[0120] A storage module 73, connected to the channel configuration module 72, configured to store the first duty ratio and the transformed channel mode into a buffer, or to store the second duty ratio and the original channel mode into a buffer;
[0121] An enabling module 74, connected to the storage module 73, configured to enable the direct memory access mode, and transfer the first duty ratio and the transformed channel mode from the buffer to the corresponding channel register to transform a partial area of the waveform of the current cycle, or transfer the second duty ratio and the original channel mode from the buffer to the corresponding channel register to restore a partial area of the waveform of the next cycle according to the standard waveform;
[0122] A waveform transformation module 75, connected to the enabling module 74, configured to, when it is determined that the waveform of the current cycle falls on the sector edge, transform a partial area of the waveform of the current cycle for the channels where the phase current cannot be collected according to the first duty ratio and the transformed channel mode;
[0123] A waveform restoration module 76, connected to the enabling module 74, configured to, when it is determined that the waveform of the next cycle falls on the sector edge, determine that the waveform of the next cycle is the standard waveform, and restore a partial area of the waveform of the next cycle according to the standard waveform according to the second duty ratio and the original channel mode;
[0124] A phase current acquisition module 77, connected to the waveform transformation module 75 or the waveform restoration module 76, configured to acquire the phase current based on the transformed waveform of the current cycle, or to acquire the phase current of the restored waveform of the next cycle.
[0125] Please refer to Figure 9 , Figure 9It is a schematic structural diagram of the sampling device for the motor phase current of the present application. The third aspect of the present application provides a sampling device 80 for the motor phase current. Specifically, the sampling device 8 includes: a motor 81, a processor 82, a current collector 83, and a memory 84. Both the current collector 83 and the processor 82 are connected to the motor 81. A computer program 841 is stored in the memory 84. The processor 82 is used to execute the computer program 841 to implement the current sampling method of the first aspect of the embodiment of the present application, which will not be elaborated here again, so as to change the pulse width modulation waveform generated by the motor 81, so that the current collector can collect two-phase currents.
[0126] In addition, if it 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 such an understanding, the technical solution of the present application, in essence, 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. This computer software product is stored in a storage device and includes several instructions (computer programs) for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage device includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks or optical discs, and electronic devices such as computers, mobile phones, laptop computers, tablet computers, cameras, etc. with the above storage media.
[0127] The description of the execution process of the computer program in the computer-readable storage medium can refer to the description in the current sampling method embodiment of the sampling device for the motor phase current of the present application above, which will not be elaborated here again.
[0128] The above are only partial embodiments of the present application, and thus do not limit the protection scope of the present application. Any equivalent device or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.
Claims
1. A method for sampling current, characterized in that, The sampling method includes: Determine whether the current cycle waveform falls on the sector edge; If the current cycle waveform falls on the sector edge, for the channels where phase current cannot be collected, determine the first duty cycle and change the channel mode; Store the first duty cycle and the changed channel mode in the buffer, and enable the direct memory access mode; Transform a partial area of the current cycle waveform according to the first duty cycle and the changed channel mode; Obtain the phase current based on the transformed current cycle waveform; Wherein, the sampling method further includes: Determine whether the waveform of the next cycle of the current cycle falls on the sector edge; If the waveform of the next cycle does not fall on the sector edge, determine that the waveform of the next cycle is a standard waveform, and update the parameters of the buffer to the second duty cycle and the original channel mode; In addition, after updating the parameters of the buffer to the second duty cycle and the original channel mode, the sampling method further includes: Use the direct memory access method to transfer the second duty cycle and the original channel mode in the buffer to the channel register; Configure the channels corresponding to the phases by using the second duty cycle and the original channel mode, and restore the waveform of the next cycle according to the standard waveform.
2. The sampling method according to claim 1, wherein The transforming a partial area of the current cycle waveform according to the first duty cycle and the changed channel mode includes: Transform a partial area of the current cycle waveform in at least one of the ways of flipping, hollowing out or compensating by using the first duty cycle and the changed channel mode.
3. The sampling method according to claim 1, wherein The transforming a partial area of the current cycle waveform according to the first duty cycle and the changed channel mode includes: Use the enabled direct memory access method to transfer the first duty cycle and the changed channel mode from the buffer to the channel register to configure the channels corresponding to the phases, so as to realize the transformation of a partial area of the current cycle waveform.
4. The sampling method according to claim 1, wherein The configuring the channels corresponding to the phases by using the second duty cycle and the original channel mode, and restoring the waveform of the next cycle according to the standard waveform includes: Restore a partial area of the waveform of the next cycle in at least one of the ways of flipping, hollowing out or compensating according to the standard waveform by using the second duty cycle and the original channel mode.
5. The sampling method according to claim 1, wherein The determining whether the current cycle waveform falls on the sector edge includes: Based on the pulse width generating the current cycle waveform, calculate whether the width between two sampling points for obtaining the phase current meets a preset sampling width; If it is determined that the preset sampling width is met, determine that the current cycle waveform does not fall on the sector edge, and collect the phase current; If it is determined that the preset sampling width is not met, determine that the current cycle waveform falls on the sector edge, the phase current cannot be collected, and at the same time, the sector edge flag is set to 1.
6. The sampling method according to claim 5, wherein: The sampling method further includes: Obtaining the flag position of the corresponding phase; Determining whether the flag setting is the first preset value corresponding to a single phase or the second preset value corresponding to multiple phases; If it is determined that the flag setting is the same as the first preset value corresponding to the single phase, it is determined that the corresponding phase is a single phase, and the single-phase waveform uses the current sampling method according to any one of claims 1-5 to sample the phase current; If it is determined that the flag setting is the same as the second preset value corresponding to the multiple phases, it is determined that the corresponding phase is a multiple phase, and each phase waveform transformation in the multiple-phase waveform uses the current sampling method according to any one of claims 1-5 to sample the phase current.
7. A chip, characterized in that, The chip includes: A judgment module for judging whether the current cycle waveform or the waveform of the next cycle of the current cycle falls on the sector edge; A channel configuration module connected to the judgment module for configuring the channel corresponding to the current cycle waveform according to the first duty cycle and the transformed channel mode in the corresponding channel register, or for configuring the channel corresponding to the waveform of the next cycle according to the second duty cycle and the original channel mode in the corresponding channel register; A storage module connected to the channel configuration module for storing the first duty cycle and the transformed channel mode into the buffer, or storing the second duty cycle and the original channel mode into the buffer; An enabling module connected to the storage module for enabling the direct memory access mode to transfer the first duty cycle and the transformed channel mode from the buffer to the corresponding channel register to transform a partial area of the current cycle waveform, or transfer the second duty cycle and the original channel mode from the buffer to the corresponding channel register to restore a partial area of the waveform of the next cycle according to the standard waveform; A waveform transformation module connected to the enabling module for, when it is determined that the current cycle waveform falls on the sector edge, transforming a partial area of the current cycle waveform for the channels where the phase current cannot be collected according to the first duty cycle and the transformed channel mode; A waveform restoration module connected to the enabling module for, when it is determined that the waveform of the next cycle falls on the sector edge, determining that the waveform of the next cycle is the standard waveform and restoring a partial area of the waveform of the next cycle according to the standard waveform according to the second duty cycle and the original channel mode; A phase current acquisition module connected to the waveform transformation module or the waveform restoration module for acquiring the phase current based on the transformed current cycle waveform, or acquiring the phase current of the restored waveform of the next cycle.
8. A sampling device for the phase current of a motor, characterized in that, It includes: A motor, a processor, a current collector, and a memory. The current collector and the processor are both connected to the motor. A computer program is stored in the memory, and the processor is used to execute the computer program to implement the sampling method according to any one of claims 1-6 to transform or restore the pulse width modulation waveform generated by the motor, so that the current collector can collect the phase current.
Citation Information
Patent Citations
Single-current sampling type three-phase power conversion circuit
CN110912437A
Phase current measurements in a three phase inverter using a single common DC-link current sensor
US20090284194A1