Signal processing method, system, electronic device and storage medium
By using a timer with input capture function in the controller, the problems of high design costs, complex calculations and poor anti-interference capabilities in the prior art are solved, efficient signal analysis and error correction are achieved, and design costs are reduced. Improves signal accuracy and anti-interference ability.
Patent Information
- Application Number
- CN202211556535.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-06
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-12-06
AI Technical Summary
The prior art requires the use of special hardware modules when processing direction/pulse signals, resulting in high design costs, complex calculations and poor anti-interference capabilities, which easily cause calculation errors when interrupt preemption is not allowed.
By setting a timer with input capture function in the controller, the analysis and error correction of signals can be achieved, design costs can be reduced, and the accuracy of signal resolution and anti-interference ability can be improved.
It realizes efficient analysis and error correction signals without using special hardware modules, reduces design costs, improves signal resolution accuracy and anti-interference ability.
Smart Images

Figure CN115877761B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of signal processing technology, and in particular to a signal processing method, system, electronic device and storage medium. Background Art
[0002] Direction / pulse signal is a form of command input signal, which is widely used in the field of industrial control. In related technologies, the analysis of direction / pulse signal is realized by using microcontroller unit (MCU) or digital signal processor (DSP) with dedicated hardware modules, or by using complex programmable logic device (CPLD) or field programmable gate array (FPGA), or by using external interrupt and counter to realize signal analysis. This method will increase the hardware design cost, the calculation is more complicated, the signal's anti-interference ability is also relatively poor, and it is easy to cause calculation errors in some occasions where interrupt preemption is not allowed. Summary of the invention
[0003] The main purpose of the embodiments of the present application is to propose a signal processing method, system, electronic device and storage medium to solve the problems existing in the related technology. It can realize signal analysis and error correction without using dedicated hardware modules, and at the same time it can also improve the signal's anti-interference ability and reduce the design cost. The calculation process is simple and the applicability is wide.
[0004] To achieve the above-mentioned purpose, the first aspect of an embodiment of the present application proposes a signal processing method, which is applied to a controller, wherein a timer is provided in the controller, and the timer has an input capture function, and the method comprises: obtaining an input signal, and counting the pulse signals in the input signal in turn to obtain multiple count values; obtaining a capture result according to whether the timer captures the direction signal; obtaining an effective direction flag of the input signal, and judging whether to update the effective direction flag according to the capture result; calculating a pulse increment according to the capture result, the effective direction flag and the multiple count values; calculating an error compensation increment according to the capture result, the effective direction flag, the pulse increment and the multiple count values; judging whether the input signal is captured by a false trigger, and calculating the number of pulses of the input signal according to the judgment result and the pulse increment and the error compensation increment.
[0005] According to some embodiments of the present application, the count value includes a first count value, a second count value and a third count value; the pulse signals in the input signal are counted in sequence to obtain multiple count values, including: taking the count value of the timer during the current operation as the first count value; taking the previous count value of the timer during the current operation as the second count value; and taking the count value when the direction signal was captured most recently as the third count value.
[0006] According to some embodiments of the present application, determining whether to update the effective direction flag based on the capture result includes: if input capture occurs to the input signal, updating the effective direction flag; if input capture does not occur to the input signal, keeping the effective direction flag unchanged.
[0007] According to some embodiments of the present application, the pulse increment is calculated based on the capture result, the effective direction flag, and the multiple count values, including: if the input signal undergoes input capture and the effective direction flag is positive, the pulse increment is calculated based on the sum of the first count value and the second count value minus the multiple of the third count value; if the input signal undergoes input capture and the effective direction flag is negative, the pulse increment is calculated based on the multiple of the third count value minus the first count value and the second count value; if the input signal does not undergo input capture and the effective direction flag is positive, the pulse increment is calculated based on the first count value minus the second count value. If the input signal does not undergo input capture and the effective direction flag is negative, the pulse increment is calculated based on the second count value minus the first count value.
[0008] According to some embodiments of the present application, the error compensation increment is calculated based on the capture result, the effective direction flag, the pulse increment and the multiple count values, including: if the input signal undergoes input capture and the effective direction flag is positive, the error compensation increment is calculated by subtracting the third count value from the first count value; if the input signal undergoes input capture and the effective direction flag is negative, the error compensation increment is calculated by subtracting the first count value from the third count value; if the input signal does not undergo input capture, the error compensation increment is calculated by adding the error compensation increment at the previous moment to the pulse increment.
[0009] According to some embodiments of the present application, determining whether a capture false trigger occurs to the input signal, and calculating the number of pulses of the input signal based on the determination result and the pulse increment and the error compensation increment, include: if a capture false trigger occurs to the input signal, correcting the effective direction flag, and calculating the number of pulses of the input signal by adding the pulse increment to the previous number of pulses and subtracting a multiple of the error compensation increment; if a capture false trigger does not occur to the input signal, keeping the effective direction flag unchanged; and calculating the number of pulses of the input signal by adding the pulse increment to the previous number of pulses.
[0010] According to some embodiments of the present application, determining whether a capture false trigger occurs in the input signal includes: obtaining an input direction flag of a direction signal in the input signal; comparing the consistency between the input direction flag and the effective direction flag; if the current effective direction flag is consistent with the current input direction flag, determining that a capture false trigger does not occur in the input signal; if the number of consecutive inconsistencies between the current effective direction flag and the current input direction flag exceeds a preset number, determining that a capture false trigger occurs in the input signal. To achieve the above-mentioned purpose, the second aspect of the present application proposes a signal processing system, which includes: an input signal acquisition module, which is used to acquire an input signal and count the pulse signals in the input signal in turn to obtain multiple count values; a capture result acquisition module, which is used to obtain a capture result according to whether the timer captures the direction signal; an effective direction flag acquisition module, which is used to acquire the effective direction flag of the input signal and determine whether to update the effective direction flag according to the capture result; a pulse increment calculation module, which is used to calculate the pulse increment according to the capture result, the effective direction flag and the multiple count values; an error compensation increment calculation module, which is used to calculate the error compensation increment according to the capture result, the effective direction flag, the pulse increment and the multiple count values; a pulse number calculation module, which is used to determine whether the input signal is captured incorrectly, and calculate the number of pulses of the input signal according to the judgment result and the pulse increment and the error compensation increment.
[0011] To achieve the above-mentioned purpose, the third aspect embodiment of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the signal processing method described in any one of the first aspect embodiments of the present application when executing the computer program.
[0012] To achieve the above-mentioned objectives, the fourth aspect embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the signal processing method described in any one of the first aspect embodiments of the present application.
[0013] The present application proposes a signal processing method, system, electronic device and storage medium. By setting a timer with an input capture function in a controller, the signal can be analyzed and corrected without using a dedicated hardware module, thereby reducing the design cost, improving the accuracy of signal analysis, and having a simple calculation process and wide applicability. In addition, since when the direction signal is interfered with, if the effective direction flag is not corrected, the count value when the timer counts the pulse signal does not match the actual count value, the effective direction flag is corrected, and when the direction signal is interfered with, the number of pulses that matches the actual number can be obtained, thereby improving the anti-interference ability of the signal. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 is a schematic diagram of the steps of the signal processing method provided in an embodiment of the present application;
[0015] Figure 2 is a diagram for setting a timer count value in a signal processing method provided in an embodiment of the present application;
[0016] Figure 3 It is a schematic diagram of determining whether to update the effective direction flag provided by an embodiment of the present application;
[0017] Figure 4 is a flow chart of obtaining an input signal validity direction flag provided by an embodiment of the present application;
[0018] Figure 5 is a schematic diagram of the steps for calculating pulse increments provided in an embodiment of the present application;
[0019] Figure 6 yes Figure 5 The flowchart corresponding to the steps of calculating the pulse increment is shown;
[0020] Figure 7 yes Figure 5 An example diagram corresponding to the steps of calculating pulse increment is shown;
[0021] Figure 8 It is a step diagram for calculating the error compensation increment;
[0022] Fig. 9 yes Figure 8 A flow chart of calculating the error compensation increment is shown;
[0023] Fig.10 This is a step-by-step diagram of the method for calculating the number of pulses;
[0024] Fig.11 Fig.10 A flowchart showing the correction of the effective direction flag and the calculation of the pulse number;
[0025] Fig.12yes Fig.10 An example diagram of pulse number calculation provided by an embodiment of the present application is shown;
[0026] Fig.13 yes Fig.11 An example diagram of pulse number calculation is shown;
[0027] Fig.14 is a flow chart of the overall scheme of the signal processing method provided in the embodiment of the present application;
[0028] Fig.15 is a module schematic diagram of a signal processing system provided in an embodiment of the present application;
[0029] Fig.16 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0031] It should be noted that, although the functional modules are divided in the system schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0033] Direction / pulse signal is a form of command input signal, which is widely used in the field of industrial control. In related technologies, the analysis of direction / pulse signal is realized by using microcontroller unit (MCU) or digital signal processor (DSP) with dedicated hardware modules, or by using complex programmable logic device (CPLD) or field programmable gate array (FPGA), or by using external interrupt and counter to realize signal analysis. This method will increase the hardware design cost, the calculation is more complicated, the signal's anti-interference ability is also relatively poor, and it is easy to cause calculation errors in some occasions where interrupt preemption is not allowed.
[0034] Based on this, the embodiments of the present application provide a signal processing method, system, electronic device and storage medium, which can realize signal analysis and error correction without using dedicated hardware modules by setting a timer with an input capture function in the controller, thereby reducing design costs, improving the accuracy of signal analysis and the anti-interference ability of the signal, and having a simple calculation process and wide applicability.
[0035] The signal processing method, system, electronic device and storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the system framework of the signal processing system in the present application is introduced. Exemplarily, the system framework of the signal processing system in the present application includes an input end, a controller, and an output end. The input end is used to receive an input signal, and the controller is used to parse and correct the input signal. A timer is provided in the controller, and the timer has an input capture function. The output end outputs the signal after parsing and correction.
[0036] The signal processing method in the embodiments of the present application can be illustrated by the following embodiments.
[0037] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first. For example, when obtaining user stored data and the user's cached data access request, the user's permission or consent will be obtained first. Moreover, the collection, use and processing of these data will comply with the relevant laws, regulations and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or separate consent will be obtained by means of a pop-up window or jumping to a confirmation page. After clearly obtaining the user's separate permission or separate consent, the necessary user-related data used to enable the normal operation of the embodiment of the present application will be obtained.
[0038] Figure 1 1 is a schematic diagram of the steps of the signal processing method provided in the embodiment of the present application. The signal processing method is applied to a controller, and a timer is provided in the controller, and the timer has an input capture function. In some embodiments, the signal processing method can be applied to a signal processing system, and the system can obtain real-time data of the input signal when executing the method. Optionally, the real-time data of the input signal includes the frequency, period, amplitude change, etc. of the signal.
[0039] Figure 1 The method may include but is not limited to steps S101 to S106:
[0040] Step S101, obtaining an input signal, and sequentially counting pulse signals in the input signal to obtain a plurality of count values;
[0041] Step S102, obtaining a capture result according to whether the timer captures the direction signal;
[0042] Step S103, acquiring the effective direction flag of the input signal, and determining whether to update the effective direction flag according to the acquisition result;
[0043] Step S104, calculating the pulse increment according to the capture result, the effective direction flag and the multiple count values;
[0044] Step S105, calculating the error compensation increment according to the capture result, the effective direction flag, the pulse increment and the plurality of count values;
[0045] Step S106, determining whether a capture false trigger occurs in the input signal, and calculating the number of pulses of the input signal according to the determination result and the pulse increment and the error compensation increment.
[0046] It is understandable that the controller can be the nerve center and command center of the electronic device. The controller can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0047] It is understandable that in electronic technology, a pulse signal is a signal that is continuously sent at a certain voltage amplitude and a certain time interval. The time interval between pulse signals is called the period, and the number of pulses generated per unit time (such as 1 second) is called the frequency. It can also be called the number of pulses, which is used to describe the number of pulses that appear in a periodic cyclic signal per unit time. The direction / pulse signal is a form of command input signal. The direction / pulse signal is a single pulse signal. The pulse signal sends pulses, and the direction signal is a level signal.
[0048] In some embodiments, when a timer with an input capture function detects an edge of an input signal, it captures it. At this time, the controller starts the timer to count and obtain multiple count values. It is understandable that the timer can count multiple objects according to the control of the controller, and the multiple count values can be stored in the storage middleware of the controller so that they can be directly read during subsequent calculations, saving calculation time and making the signal analysis and error correction process simpler and more efficient. At the same time, since the embodiment of the present application only requires the controller to contain a timer peripheral with an input capture function, it is not necessary to use a dedicated hardware module to implement it, saving additional design costs.
[0049] In some embodiments, a timer with an input capture function can be used to measure pulse width or signal frequency. The timer with an input capture function mainly includes three parts: a counter, a time base unit, and a capture input module. Exemplarily, first, the configuration of the counter and the capture input module is completed according to the input signal, the pulse signal is counted using the timer, the direction signal is connected to the capture input module of the timer, and the relevant variables of the controller are initialized.
[0050] In some embodiments, the pulse signal in the input signal is counted to obtain multiple count values. Counting the pulse signal can provide real-time data for calculation of subsequent pulse increments, error compensation increments, and pulse numbers.
[0051] In some embodiments, the basis for determining whether the direction signal is captured according to the timer is whether input capture occurs, that is, whether the controller detects the rising edge or the falling edge of the direction signal. Determining whether the controller detects the rising edge or the falling edge of the direction signal enables the signal processing system to perceive the change of the signal in time, and when an error occurs in the subsequent reading of the direction signal, it can also correct the error in time.
[0052] In some embodiments, if input capture occurs, the effective direction flag is updated, that is, the effective direction flag is reversed. In some embodiments, the updating of the effective direction flag is completed by reversing the effective direction flag to 1 when the effective direction flag is 0, and reversing the effective direction flag to 0 when the effective direction flag is 1. It can be understood that if input capture does not occur, the effective direction flag remains unchanged.
[0053] In some embodiments, the pulse increment is calculated based on whether the input signal is captured, the different effective direction flags, and multiple count values. If the timer captures the rising edge or falling edge of the direction signal, the input signal is captured. At this time, the current effective direction flag is reversed, and the pulse increment is calculated based on the count value of the timer during the current operation, the previous count value of the timer during the current operation, and the count value when the direction signal is captured most recently.
[0054] In some embodiments, the error compensation increment is calculated based on the capture result, the effective direction flag, the pulse increment, and multiple count values. It is understandable that if the timer captures the rising edge or falling edge of the direction signal, the input signal is captured. At this time, the current effective direction flag is reversed, and the error compensation increment is calculated based on the count value of the timer during the current operation and the count value when the direction signal is captured the most recently.
[0055] In some embodiments, it is determined whether a capture false trigger occurs in an input signal, that is, it is determined whether a capture false trigger occurs in an input signal by determining whether the current effective direction flag is inconsistent with the current input direction flag for multiple times. If the current effective direction flag is inconsistent with the current input direction flag for multiple times, it is determined that a capture false trigger occurs in the input signal. Exemplarily, if the current effective direction flag is inconsistent with the current input direction flag for 3 times, it is determined that a capture false trigger occurs in the input signal. It is understandable that the number of times the current effective direction flag is inconsistent with the current input direction flag can be 4 times, 5 times, etc. to determine that the input signal has been falsely triggered, and this embodiment does not make specific limitations here. If a capture false trigger occurs in the signal, the effective direction flag of the input signal is corrected, and the number of pulses of the input signal is calculated with the pulse increment and the error compensation increment.
[0056] It is understandable that the signal processing system executes steps S101 to S106 once every preset time, and the preset time is a time adjusted according to the signal cycle, such as 500 milliseconds. In this way, the signal can be captured timely and accurately and analyzed or error-corrected.
[0057] In some embodiments, by setting a timer with an input capture function in the controller, the signal analysis and error correction can be realized without using a dedicated hardware module, which reduces the design cost, improves the accuracy of signal analysis, and has a simple calculation process and wide applicability. In addition, since when the direction signal is interfered, if the effective direction flag is not corrected, the count value of the timer when counting the pulse signal does not match the actual count value, the effective direction flag is corrected, and when the direction signal is interfered, the number of pulses that matches the actual number can be obtained, thereby improving the anti-interference ability of the signal.
[0058] Reference Figure 2 In some embodiments, the count value includes a first count value, a second count value, and a third count value; the pulse signals in the input signal are counted in sequence to obtain a plurality of count values, including steps S201 to S203:
[0059] Step S201, taking the count value of the timer during the current operation as the first count value;
[0060] Step S202, taking the previous count value of the timer during the current operation as the second count value;
[0061] Step S203: taking the count value when the direction signal is captured most recently as the third count value.
[0062] It can be understood that the first count value, the second count value, and the third count value are all values obtained by the timer. The timer can count multiple objects according to the control of the controller. Multiple count values can be stored in the storage middleware of the controller so that they can be directly read in subsequent calculations, saving calculation time and making the signal analysis and error correction process simpler and more efficient. Exemplarily, the first count value, the second count value, and the third count value are used to participate in the calculation of the pulse increment, error compensation increment, and number of pulses of the input signal. Using the timer for counting can make the calculation simpler and faster, and because the effective direction flag is also corrected during the counting process, the accuracy of the timer counting is guaranteed, thereby improving the calculation accuracy of each parameter of the input signal.
[0063] Reference Figure 3 In some embodiments, judging whether to update the effective direction flag according to the capture result includes steps S301 to S302:
[0064] Step S301, if input capture occurs in the input signal, the effective direction flag is updated;
[0065] Step S302: If the input signal does not capture the input, the effective direction flag remains unchanged.
[0066] Reference Figure 4 , Figure 4 A flowchart for obtaining an effective direction flag. In some embodiments, the controller captures the input signal by controlling the timer. If the rising edge and the falling edge of the direction signal are detected, it indicates that the input signal has been captured. At this time, the effective direction flag is updated, that is, the effective direction flag is reversed from 0 to 1 and from 1 to 0. If the rising edge and the falling edge of the direction signal are not detected, it indicates that the input signal has not been captured. At this time, the current effective direction flag remains unchanged.
[0067] Reference Figure 5 In some embodiments, the pulse increment is calculated according to the capture result, the effective direction flag and the multiple count values, including steps S401 to S404:
[0068] Step S401: if the input signal is captured and the effective direction flag is positive, the pulse increment is calculated based on the sum of the first count value and the second count value minus the multiple of the third count value;
[0069] Step S402, if the input signal is captured and the effective direction flag is negative, the pulse increment is calculated by subtracting the first count value and the second count value according to the multiple of the third count value;
[0070] Step S403, if the input signal does not capture input, and the effective direction flag is positive, the pulse increment is calculated by subtracting the second count value from the first count value;
[0071] Step S404: if the input signal does not capture input, and the effective direction flag is negative, the pulse increment is calculated by subtracting the first count value from the second count value.
[0072] In some embodiments, the calculation formula of step S401 is as follows:
[0073] D(i)=N(i-1)+N(i)-2*L
[0074] In some embodiments, the calculation formula of step S402 is as follows:
[0075] D(i)=2*LN(i-1)-N(i)
[0076] In some embodiments, the calculation formula of step S403 is as follows:
[0077] D(i)=N(i)-N(i-1)
[0078] In some embodiments, the calculation formula of step S404 is as follows:
[0079] D(i)=N(i-1)-N(i)
[0080] It can be understood that in the formulas involved in the above steps S401 to S404, D(i) represents the pulse increment, L represents the count value when the direction signal is captured most recently, N(i-1) represents the previous count value of the timer during the current operation, and N(i) represents the count value of the timer during the current operation.
[0081] Reference Figure 6 , Figure 6 This is a flow chart of a method for calculating pulse increments in an embodiment of the present application. In some embodiments, it is first determined whether input signal capture has occurred in the input signal. The controller captures the input signal by controlling the timer. If the rising edge and falling edge of the direction signal are detected, it indicates that the input signal has been captured.
[0082] In some embodiments, if the input signal is captured, the direction of the effective direction flag is determined. If the effective direction flag is positive, the pulse increment is calculated based on the sum of the count value of the timer during the current operation and the previous count value of the timer during the current operation, minus the multiple of the count value when the direction signal was captured most recently; if the effective direction flag is negative, the pulse increment is calculated based on the multiple of the count value when the direction signal was captured most recently, minus the count value of the timer during the current operation and the previous count value of the timer during the current operation. It can be understood that the multiple of the third count value can be 2 or other multiple values obtained through simulation, and the embodiments of the present application are not specifically limited here.
[0083] In some embodiments, if the input signal does not capture the input, the direction of the effective direction flag is determined. If the effective direction flag is positive, the pulse increment is calculated based on the count value of the timer during the current operation minus the previous count value of the timer during the current operation; if the effective direction flag is negative, the pulse increment is calculated based on the previous count value of the timer during the current operation minus the count value of the timer during the current operation. It can be understood that the multiple of the third count value can be 2 or other multiple values obtained through simulation, and the embodiments of the present application are not specifically limited here.
[0084] Reference Figure 7 , Figure 7 The example diagram for calculating pulse increments is as follows: in electronic technology, a pulse signal is a signal that is continuously sent at a certain voltage amplitude and a certain time interval. The time interval between pulse signals is called the period, and the number of pulses generated per unit time (such as 1 second) is called the frequency. It can also be called the number of pulses, which is used to describe the number of pulses that appear in a periodic cyclic signal per unit time. The direction / pulse signal is a form of command input signal. The direction / pulse signal is a single pulse signal. The pulse signal sends pulses, and the direction signal is a level signal.
[0085] In some embodiments, when the timer performs the first count, the count value is N(1). At this time, the signal processing system has not captured the input signal, and the effective direction flag is positive. The pulse increment when the timer performs the second count is calculated by subtracting the previous count value of the timer during the current operation from the count value of the timer during the current operation, that is, 2*L(2)-N(2)-N(1).
[0086] When the timer counts for the second time, the count value is N(2). At this time, the signal processing system detects the rising edge of the direction signal and the input signal is captured. At this time, the effective direction flag is negative. Based on the multiple of the count value when the direction signal was captured most recently, the count value of the timer during the current operation and the previous count value of the timer during the current operation are subtracted to calculate the pulse increment when the timer counts for the second time.
[0087] When the timer counts for the third time, the count value is N(3). At this time, the signal processing system has not captured the input signal, and the effective direction flag is negative. The pulse increment is calculated based on the previous count value of the timer during the current operation minus the count value of the timer during the current operation, that is, N(2)-N(3). The pulse increment when the timer counts for the third time is calculated.
[0088] When the timer counts for the fourth time, the count value is N(4). At this time, the signal processing system detects the falling edge of the direction signal and the input signal is captured. At this time, the effective direction flag is positive. The count value of the timer during the current operation and the previous count value of the timer during the current operation are summed up, minus the multiple of the count value when the direction signal was captured most recently, that is, N(3)+N(4)-2*L(2), and the pulse increment when the timer counts for the fourth time is calculated.
[0089] The pulse increment is calculated based on whether the input direction signal is captured and the direction of the effective direction mark is judged, so that the accuracy of signal analysis can be improved.
[0090] Reference Figure 8 In some embodiments, the error compensation increment is calculated according to the capture result, the effective direction flag, the pulse increment and the plurality of count values, including steps S501 to S503:
[0091] Step S501, if input capture occurs in the input signal and the effective direction flag is positive, the error compensation increment is calculated by subtracting the third count value from the first count value;
[0092] Step S502, if input capture occurs in the input signal and the effective direction flag is negative, the error compensation increment is calculated by subtracting the first count value from the third count value;
[0093] Step S503: If the input signal does not capture the input, the error compensation increment is calculated by adding the error compensation increment at the previous moment to the pulse increment.
[0094] In some embodiments, the calculation formula of step S501 is as follows:
[0095] C(i)=N(i)-L
[0096] In some embodiments, the calculation formula of step S502 is as follows:
[0097] C(i)=LN(i)
[0098] In some embodiments, the calculation formula of step S503 is as follows:
[0099] C(i)=C(i-1)+D(i)
[0100] In some embodiments, in the formulas involved in the above steps S501 to S503, C(i) represents the error compensation increment. It can be understood that the error compensation increment is the sum of the count increments before the effective direction flag is corrected after the effective direction flag changes. C(i-1) represents the previous error compensation increment calculated by the current error compensation increment, D(i) represents the pulse increment, L represents the count value when the direction signal is captured most recently, N(i-1) represents the previous count value of the timer during the current operation, and N(i) represents the count value of the timer during the current operation.
[0101] Reference Fig. 9 , Fig. 9 In order to calculate the error compensation increment, a flowchart is provided. In some embodiments, it is first determined whether the input signal has been captured. The controller captures the input signal by controlling the timer. If the rising and falling edges of the direction signal are detected, it indicates that the input signal has been captured.
[0102] In some embodiments, when the input signal is captured, if the effective direction flag is positive, the error compensation increment is calculated according to the count value of the timer during the current operation minus the count value when the direction signal is captured most recently; if the effective direction flag is negative, the error compensation increment is calculated according to the count value when the direction signal is captured most recently minus the count value of the timer during the current operation;
[0103] In some embodiments, if the input signal does not capture the input, the error compensation increment is calculated by adding the error compensation increment at the previous moment to the pulse increment.
[0104] Reference Fig.10 , Fig.10The step diagram of calculating the number of pulses of the input signal is shown. In some embodiments, it is determined whether the input signal has a capture false trigger, and the number of pulses of the input signal is calculated based on the determination result and the pulse increment and the error compensation increment, including steps S601 to S602:
[0105] Step S601, if the input signal is captured and falsely triggered, the effective direction flag is corrected, and the number of pulses of the input signal is calculated by adding the pulse increment to the previous pulse number and subtracting the multiple of the error compensation increment;
[0106] Step S602: If the input signal does not have a capture false trigger, the effective direction flag is kept unchanged, and the number of pulses of the input signal is calculated by adding the previous pulse number to the pulse increment.
[0107] In some embodiments, the calculation formula involved in step S601 is as follows:
[0108] S=! S
[0109] O(i)=O(i-1)+D(i)-2*C(i)
[0110] In some embodiments, the calculation formula involved in step S602 is as follows:
[0111] O(i)=O(i-1)+D(i)
[0112] It can be understood that, in the formulas involved in the above steps S601 to S602, S represents the effective direction flag, !S represents the inversion of the effective direction flag, O(i) represents the number of pulses, O(i-1) represents the number of pulses calculated before the current number of pulses, C(i) represents the error compensation increment, and D(i) represents the pulse increment.
[0113] It is understandable that in electronic technology, a pulse signal is a signal that is continuously emitted at a certain voltage amplitude and a certain time interval. The time interval between pulse signals is called the period, and the number of pulses generated per unit time (such as 1 second) is called the frequency. It can also be called the pulse number. The pulse number is used to describe the number of pulses that appear in a periodic cyclic signal per unit time.
[0114] Reference Fig.11 , Fig.11 It is a flowchart for correcting the effective direction flag and calculating the number of pulses provided in an embodiment of the present application.
[0115] In some embodiments, it is first determined whether a capture mis-trigger occurs in the input signal, that is, it is determined whether the current effective direction flag is inconsistent with the current input direction signal flag for multiple consecutive times. If the current effective direction flag is inconsistent with the current input direction signal flag for multiple consecutive times, it is determined that the input signal is a capture mis-trigger. Optionally, the number of consecutive inconsistencies between the current effective direction flag and the current input direction signal flag may be 3 times, 4 times, or 5 times, and the embodiments of the present application do not impose specific restrictions on this.
[0116] In some embodiments, if the input signal is captured and falsely triggered, the effective direction flag is corrected, that is, the effective direction flag is reversed from 0 to 1, and from 1 to 0. Afterwards, the number of pulses of the input signal is calculated based on the previous number of pulses plus the pulse increment, minus the multiple of the error compensation increment;
[0117] Alternatively, if the input signal does not have a false capture trigger, that is, the number of times the current effective direction flag is consistent or inconsistent with the current input direction signal flag does not exceed the preset number of false capture triggers, the effective direction flag remains unchanged; at this time, the number of pulses of the input signal is calculated based on the previous number of pulses plus the pulse increment.
[0118] Reference Fig.12 , Fig.12 This is an example diagram of the calculation of the number of pulses in the embodiment of the present application. It can be understood that in electronic technology, a pulse signal is a signal that is continuously emitted at a certain voltage amplitude and a certain time interval. The time interval between pulse signals is called a period, and the number of pulses generated per unit time (such as 1 second) is called a frequency. It can also be called the number of pulses, which is used to describe the number of pulses that appear in a periodic cyclic signal per unit time. The direction / pulse signal is a form of command input signal. The direction / pulse signal is a single pulse signal. The pulse signal emits pulses, and the direction signal is a level signal.
[0119] In some embodiments, when the effective direction flag is incorrectly flipped due to interference in the direction signal, the signal processing system detects that the current effective direction flag is inconsistent with the current input direction flag for multiple times in a row, resulting in an abnormal calculation result. During the period from the first operation to the third operation, the pulse number output is incorrect, and the signal processing system automatically starts to correct the effective direction flag. Specifically, after the third operation, the corrected pulse number output is a correct value.
[0120] It is understandable that when the direction signal is interfered with, if the correction algorithm is not used, the number of pulses received will not match the actual number; the signal processing system of the embodiment of the present application can automatically correct the effective direction flag of the interfered direction signal, thereby outputting the correct number of pulses. In this way, the anti-interference ability of the signal can be improved, and the accuracy of the input signal analysis can be improved by correcting the interference signal.
[0121] Reference Fig.13 In some embodiments, determining whether a capture false trigger occurs in an input signal includes steps S701 to S704:
[0122] Step S701, obtaining an input direction flag of a direction signal in an input signal;
[0123] Step S702, comparing the consistency between the input direction flag and the effective direction flag;
[0124] Step S703, if the current effective direction flag is consistent with the current input direction flag, it is determined that the input signal has not been captured by a false trigger;
[0125] Step S704: if the number of times that the current effective direction flag and the current input direction flag are inconsistent continuously exceeds a preset number, it is determined that a capture error trigger occurs in the input signal.
[0126] In some embodiments, it is first determined whether a capture mis-trigger occurs in the input signal, that is, it is determined whether the current effective direction flag is inconsistent with the current input direction signal flag for multiple consecutive times. If the current effective direction flag is inconsistent with the current input direction signal flag for multiple consecutive times, it is determined that the input signal is a capture mis-trigger. Optionally, the number of consecutive inconsistencies between the current effective direction flag and the current input direction signal flag may be 3 times, 4 times, or 5 times, and the embodiments of the present application do not impose specific restrictions on this.
[0127] In some embodiments, if the number of times that the current effective direction flag is consistent or inconsistent with the current input direction signal flag does not exceed the preset number of times that capture false triggering occurs, it is determined that the input signal has not captured false triggering, and the effective direction flag is kept unchanged.
[0128] In some embodiments, whether to correct the effective direction flag is determined by judging whether the input signal is falsely captured, so that when the direction signal is interfered with, the number of pulses consistent with the actual situation can be obtained, thereby improving the anti-interference ability of the input signal.
[0129] Reference Fig.14 The following is a general description of the overall scheme of the signal processing method implementation process in the embodiment of the present application:
[0130] It is understandable that in electronic technology, a pulse signal is a signal that is continuously sent at a certain voltage amplitude and a certain time interval. The time interval between pulse signals is called the period, and the number of pulses generated per unit time (such as 1 second) is called the frequency. It can also be called the number of pulses, which is used to describe the number of pulses that appear in a periodic cyclic signal per unit time. The direction / pulse signal is a form of command input signal. The direction / pulse signal is a single pulse signal. The pulse signal sends pulses, and the direction signal is a level signal.
[0131] In some embodiments, when the signal processing system is powered on, the counter in the timer and the capture module in the timer are configured according to the signal access. For example, the configuration of the timer can be completed through a programming language. After that, the relevant variables in each module are initialized. Specifically, the data in the timer, the capture input module, the effective direction flag acquisition module, the pulse increment calculation module, the error compensation increment calculation module, the capture mis-trigger judgment module, and the pulse number calculation module can be initialized.
[0132] In some embodiments, whether the capture of the input signal occurs is determined based on whether the controller detects the rising edge or the falling edge of the direction signal. If the rising edge or the falling edge of the direction signal is detected, the capture of the input signal occurs. If the rising edge or the falling edge of the direction signal is not detected, the capture of the input signal does not occur. It is understandable that if the capture of the input signal occurs, the effective direction flag is reversed. If the capture of the input signal does not occur, the effective direction flag remains unchanged. Specifically, the effective direction flag is updated, that is, the effective direction flag is reversed from 0 to 1, and from 1 to 0.
[0133] In some embodiments, the pulse increment is calculated based on the capture result, the effective direction flag, and multiple count values. Specifically, if the input signal is input captured and the effective direction flag is positive, the pulse increment is calculated based on the sum of the first count value and the second count value minus the multiple of the third count value; if the input signal is input captured and the effective direction flag is negative, the pulse increment is calculated based on the multiple of the third count value minus the first count value and the second count value; if the input signal is not input captured and the effective direction flag is positive, the pulse increment is calculated based on the first count value minus the second count value; if the input signal is not input captured and the effective direction flag is negative, the pulse increment is calculated based on the second count value minus the first count value. By calculating the pulse increment based on the count values at different times, accurate analysis of the input signal can be achieved for subsequent calculations, while ensuring the real-time calculation of the input signal.
[0134] In some embodiments, the error compensation increment is calculated based on the capture result, the effective direction flag, the pulse increment, and multiple count values. Exemplarily, if the input signal is input captured and the effective direction flag is positive, the error compensation increment is calculated by subtracting the third count value from the first count value; if the input signal is input captured and the effective direction flag is negative, the error compensation increment is calculated by subtracting the first count value from the third count value; if the input signal is not input captured, the error compensation increment is calculated by adding the error compensation increment at the previous moment to the pulse increment. By calculating the error compensation increment based on the count values at different moments, accurate analysis of the input signal can be achieved for subsequent calculations, while ensuring the real-time nature of the input signal calculation.
[0135] In some embodiments, it is determined whether the input signal has a capture false trigger, and the number of pulses of the input signal is calculated based on the determination result and the pulse increment and error compensation increment. It is understandable that the number of pulses is used to describe the number of pulses that appear in a periodic cyclic signal per unit time.
[0136] It is understandable that when the system is running continuously, except for the need to repeatedly initialize the system configuration, the remaining steps are executed cyclically within the preset time according to the steps shown in the figure to ensure real-time detection of the input signal for subsequent analysis and error correction.
[0137] Through the above description of an embodiment of the overall solution, at least the following beneficial effects are achieved: by setting a timer with an input capture function in the controller, the signal analysis and error correction can be realized without using a dedicated hardware module, thereby reducing the design cost, improving the accuracy of signal analysis, and making the calculation process simple and widely applicable. In addition, since when the direction signal is interfered, if the effective direction flag is not corrected, the count value when the timer counts the pulse signal does not match the actual count value, the effective direction flag is corrected, and when the direction signal is interfered, the number of pulses that matches the actual number can be obtained, thereby improving the anti-interference ability of the signal.
[0138] See also Fig.15 The embodiment of the present application further provides a signal processing system, which can implement the above signal processing method, and the signal processing system includes:
[0139] An input signal acquisition module 1501 is used to acquire an input signal and count pulse signals in the input signal in sequence to obtain a plurality of count values;
[0140] The capture result acquisition module 1502 is used to obtain the capture result according to whether the timer captures the direction signal;
[0141] The effective direction flag acquisition module 1503 is used to acquire the effective direction flag of the input signal and determine whether to update the effective direction flag according to the acquisition result;
[0142] A pulse increment calculation module 1504, used to calculate the pulse increment according to the capture result, the effective direction flag and the multiple count values;
[0143] The error compensation increment calculation module 1505 is used to calculate the error compensation increment according to the capture result, the effective direction flag, the pulse increment and the multiple count values;
[0144] The pulse number calculation module 1506 is used to determine whether the input signal has a capture false trigger, and calculate the pulse number of the input signal according to the determination result and the pulse increment and the error compensation increment.
[0145] It is understandable that in electronic technology, a pulse signal is a signal that is continuously sent at a certain voltage amplitude and a certain time interval. The time interval between pulse signals is called the period, and the number of pulses generated per unit time (such as 1 second) is called the frequency. It can also be called the number of pulses, which is used to describe the number of pulses that appear in a periodic cyclic signal per unit time. The direction / pulse signal is a form of command input signal. The direction / pulse signal is a single pulse signal. The pulse signal sends pulses, and the direction signal is a level signal.
[0146] In some embodiments, when a timer with an input capture function detects an edge of an input signal, it captures it, and at this time, the controller starts the timer to count and obtain multiple count values. It is understandable that the timer can count multiple objects according to the control of the controller, and the multiple count values can be stored in the storage middleware of the controller so that they can be directly read in subsequent calculations, saving calculation time and making the signal analysis and error correction process simpler and more efficient.
[0147] In some embodiments, a timer with an input capture function can be used to measure pulse width or signal frequency. The timer with an input capture function mainly includes three parts: a counter, a time base unit, and a capture input module. Exemplarily, first, the configuration of the counter and the capture input module is completed according to the input signal, the pulse signal is counted using the counter, the direction signal is connected to the capture input module of the timer, and the relevant variables of the controller are initialized.
[0148] In some embodiments, the pulse signal in the input signal is counted to obtain multiple count values. Counting the pulse signal can provide real-time data for calculation of subsequent pulse increments, error compensation increments, and pulse numbers.
[0149] In some embodiments, the basis for determining whether the direction signal is captured according to the timer is whether input capture occurs, that is, whether the controller detects the rising edge or the falling edge of the direction signal. Determining whether the controller detects the rising edge or the falling edge of the direction signal enables the signal processing system to perceive the change of the signal in time, and when an error occurs in the subsequent reading of the direction signal, it can also correct the error in time.
[0150] In some embodiments, if input capture occurs, the effective direction flag is updated, that is, the effective direction flag is reversed. In some embodiments, the updating of the effective direction flag is completed by reversing the effective direction flag to 1 when the effective direction flag is 0, and reversing the effective direction flag to 0 when the effective direction flag is 1. It can be understood that if input capture does not occur, the effective direction flag remains unchanged.
[0151] In some embodiments, the pulse increment is calculated based on whether the input signal is captured, the different effective direction flags, and multiple count values. If the timer captures the rising edge or falling edge of the direction signal, the input signal is captured. At this time, the current effective direction flag is reversed, and the pulse increment is calculated based on the count value of the timer during the current operation, the previous count value of the timer during the current operation, and the count value when the direction signal is captured most recently.
[0152] In some embodiments, the error compensation increment is calculated based on the capture result, the effective direction flag, the pulse increment, and multiple count values. It is understandable that if the timer captures the rising edge or falling edge of the direction signal, the input signal is captured. At this time, the current effective direction flag is reversed, and the error compensation increment is calculated based on the count value of the timer during the current operation and the count value when the direction signal is captured the most recently.
[0153] In some embodiments, it is determined whether a capture false trigger occurs in an input signal, that is, it is determined whether a capture false trigger occurs in an input signal by determining whether the current effective direction flag is inconsistent with the current input direction flag for multiple times. If the current effective direction flag is inconsistent with the current input direction flag for multiple times, it is determined that a capture false trigger occurs in the input signal. Exemplarily, if the current effective direction flag is inconsistent with the current input direction flag for 3 times, it is determined that a capture false trigger occurs in the input signal. It is understandable that the number of times the current effective direction flag is inconsistent with the current input direction flag can be 4 times, 5 times, etc. to determine that the input signal has been falsely triggered, and this embodiment does not make specific limitations here. If a capture false trigger occurs in the signal, the effective direction flag of the input signal is corrected, and the number of pulses of the input signal is calculated with the pulse increment and the error compensation increment.
[0154] In some embodiments, by setting a timer with an input capture function in the controller, the signal analysis and error correction can be realized without using a dedicated hardware module, which reduces the design cost, improves the accuracy of signal analysis, and has a simple calculation process and wide applicability. In addition, since when the direction signal is interfered, if the effective direction flag is not corrected, the count value of the timer when counting the pulse signal does not match the actual count value, the effective direction flag is corrected, and when the direction signal is interfered, the number of pulses that matches the actual number can be obtained, thereby improving the anti-interference ability of the signal.
[0155] The specific implementation of the signal processing system is basically the same as the specific implementation of the above-mentioned signal processing method, and will not be repeated here. On the premise of meeting the requirements of the embodiment of the present application, the signal processing system can also be provided with other functional modules to implement the signal processing method in the above-mentioned embodiment.
[0156] An embodiment of the present application further provides an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned signal processing method when executing the computer program.
[0157] See also Fig.16 , Fig.16 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0158] The processor 1601 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0159] The memory 1602 may be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1602 may store an operating system and other application programs. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1602, and the processor 1601 calls and executes the signal processing method of the embodiments of this application;
[0160] Input / output interface 1603, used to implement information input and output;
[0161] The communication interface 1604 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WI FI, Bluetooth, etc.);
[0162] A bus 1605 that transmits information between various components of the device (e.g., the processor 1601, the memory 1602, the input / output interface 1603, and the communication interface 1604);
[0163] The processor 1601 , the memory 1602 , the input / output interface 1603 and the communication interface 1604 are connected to each other in communication within the device via the bus 1605 .
[0164] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned signal processing method is implemented.
[0165] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0166] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0167] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0168] The system embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0169] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0170] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0171] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0172] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.
[0173] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0174] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0175] If the integrated unit 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 application is essentially 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, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0176] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A signal processing method, characterized in that: Applied in a controller, the controller is provided with a timer, the timer has an input capture function, and the method comprises: Acquire an input signal, and count pulse signals in the input signal in sequence to obtain a plurality of count values; wherein the plurality of count values include a first count value, a second count value, and a third count value; Obtaining a capture result according to whether the timer captures the direction signal; Acquire the effective direction flag of the input signal, and determine whether to update the effective direction flag according to the capture result; Calculate a pulse increment according to the capture result, the effective direction flag and the multiple count values; Calculating an error compensation increment according to the capture result, the effective direction flag, the pulse increment and the multiple count values; It is determined whether the input signal has a capture false trigger, and the number of pulses of the input signal is calculated based on the determination result, the pulse increment, and the error compensation increment.
2. The signal processing method according to claim 1, characterized in that: The sequentially counting the pulse signals in the input signal to obtain a plurality of count values comprises: Using the count value of the timer during the current operation as the first count value; Using the previous count value of the timer during the current operation as the second count value; The count value when the direction signal is captured most recently is used as the third count value.
3. The signal processing method according to claim 1, characterized in that: The determining whether to update the effective direction flag according to the capture result includes: If input capture occurs to the input signal, an update operation is performed on the effective direction flag; If the input signal does not capture the input, the effective direction flag remains unchanged.
4. The signal processing method according to claim 2 or 3, characterized in that: The step of calculating the pulse increment according to the capture result, the effective direction flag and the multiple count values includes: If input capture occurs on the input signal and the effective direction flag is positive, the pulse increment is calculated based on the sum of the first count value and the second count value minus the multiple of the third count value; If input capture occurs on the input signal and the effective direction flag is negative, the pulse increment is calculated by subtracting the first count value and the second count value from the multiple of the third count value; If the input signal does not capture an input, and the effective direction flag is positive, the pulse increment is calculated by subtracting the second count value from the first count value; If the input signal does not capture an input, and the effective direction flag is negative, the pulse increment is calculated by subtracting the first count value from the second count value.
5. The signal processing method according to claim 2 or 3, characterized in that: The calculating the error compensation increment according to the capture result, the effective direction flag, the pulse increment and the multiple count values includes: If input capture occurs on the input signal and the effective direction flag is positive, the error compensation increment is calculated based on the first count value minus the third count value; If input capture occurs on the input signal and the effective direction flag is negative, the error compensation increment is calculated by subtracting the first count value from the third count value; If the input signal does not capture the input, the error compensation increment is calculated by adding the error compensation increment at the previous moment to the pulse increment.
6. The signal processing method according to claim 2 or 3, characterized in that: The step of judging whether a capture false trigger occurs in the input signal, and calculating the number of pulses of the input signal according to the judgment result, the pulse increment, and the error compensation increment, comprises: If the input signal is captured and falsely triggered, the effective direction flag is corrected, and the number of pulses of the input signal is calculated by adding the pulse increment to the previous pulse number and subtracting the multiple of the error compensation increment; If the input signal does not have a capture false trigger, the effective direction flag is kept unchanged, and the number of pulses of the input signal is calculated based on the previous number of pulses plus the pulse increment.
7. The signal processing method according to claim 6, characterized in that: The determining whether a capture false trigger occurs in the input signal comprises: Obtaining an input direction flag of a direction signal in the input signal; comparing the consistency between the input direction flag and the effective direction flag; If the current effective direction flag is consistent with the current input direction flag, it is determined that no capture false triggering occurs on the input signal; If the number of times that the current effective direction flag and the current input direction flag are inconsistent continuously exceeds a preset number, it is determined that the input signal is captured and mistriggered.
8. A signal processing system, characterized in that: The system comprises: An input signal acquisition module, used to acquire an input signal, and sequentially count pulse signals in the input signal to obtain a plurality of count values; wherein the plurality of count values include a first count value, a second count value, and a third count value; A capture result acquisition module is used to obtain a capture result according to whether the timer captures the direction signal; An effective direction flag acquisition module, used to acquire the effective direction flag of the input signal, and determine whether to update the effective direction flag according to the capture result; A pulse increment calculation module, used for calculating the pulse increment according to the capture result, the effective direction flag and the multiple count values; An error compensation increment calculation module, used for calculating an error compensation increment according to the capture result, the effective direction flag, the pulse increment and the multiple count values; The pulse number calculation module is used to determine whether the input signal has a capture false trigger, and calculate the pulse number of the input signal according to the determination result and the pulse increment and the error compensation increment.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the signal processing method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the signal processing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Speed detection method and device of permanent magnet synchronous motor
CN106645786A
Pulse signal generator and generating method thereof
CN1206959A