Speed ​​measurement method, device and electronic equipment based on incremental encoder

Through dynamic switching speed algorithm and sampling strategy, the problem of motor speed measurement deviation of incremental encoder under different working conditions is solved, achieving higher accuracy and versatility.

CN114778884BActive Publication Date: 2024-10-29TIAN XIAN SHU ZHI TECH (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210362381.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-07
Publication Date
2024-10-29
Estimated Expiration
2042-04-07

AI Technical Summary

Technical Problem

Existing incremental encoders are difficult to accurately measure motor speed under different working conditions, and there is a speed calculation deviation.

Method used

By judging the speed threshold of the target incremental encoder, dynamically switching between low-speed and high-speed speed algorithms, and combining the number of timer samples and encoder resolution, the absolute speed and speed direction of the motor are calculated to ensure accurate measurement under different working conditions.

Benefits of technology

It improves the accuracy of motor speed calculation under different working conditions and enhances the versatility and adaptability of the incremental encoder.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114778884B_ABST
    Figure CN114778884B_ABST
Patent Text Reader

Abstract

The present invention discloses a speed measurement method, device and electronic equipment based on an incremental encoder. The method comprises the following steps: determining whether a target device speed calculation method adopted by a target incremental encoder at a previous sampling moment is a low-speed algorithm; if so, determining whether an absolute speed obtained by the target incremental encoder at a previous sampling moment is greater than a first switching speed threshold, and if so, adopting a high-speed algorithm to calculate the absolute speed of the target device at the current moment; if not, determining whether the absolute speed obtained by the target incremental encoder at a previous sampling moment is less than a second switching speed threshold, and if so, adopting a low-speed algorithm to calculate the absolute speed of the target device at the current moment; determining a speed direction of the target device at the current moment; and obtaining the speed of the target device at the current moment based on the absolute speed and the speed direction; and the method effectively improves the calculation accuracy of the motor speed under different working conditions by matching different speed calculation methods with different motor operation speed thresholds.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of sensor technology, and in particular to a speed measurement method, device and electronic equipment based on an incremental encoder. Background Art

[0002] The encoder converts angular displacement or linear displacement into electrical signals. The former is called a code disk and the latter is called a yardstick. According to different working principles, encoders are divided into incremental encoders and absolute encoders.

[0003] Among them, the incremental encoder: converts the displacement into a periodic electrical signal, and then converts the electrical signal into a counting pulse, and uses the number of pulses to represent the size of the displacement. Usually, the output is A phase, B phase, and Z phase. The A phase and the B phase are pulse outputs that are delayed by 1 / 4 cycle from each other. The positive and reverse rotations can be distinguished according to the delay relationship, and the rising and falling edges of the A phase and the B phase can be doubled or quadrupled; the Z phase is a single-turn pulse, that is, one pulse is emitted per turn.

[0004] Incremental encoders are mainly used in motors, CNC machine tools and their mechanical accessories, robots, automatic assembly machines, automatic production lines, elevators, etc. to obtain the speed of the corresponding motor. The motor speed obtained by the encoder will have a slight deviation at different motor speeds, so it is necessary to find a method that can accurately obtain the motor speed under different working conditions. Summary of the invention

[0005] The object of the present invention is to provide a speed measurement method, device, electronic device and computer-readable storage medium based on an incremental encoder, which can obtain accurate speed measurement results under different working conditions of the motor.

[0006] In order to achieve the above-mentioned object of the invention, the present invention proposes the following technical solutions:

[0007] In one aspect, a speed measurement method based on an incremental encoder is provided, the method comprising:

[0008] Determine whether the target device speed calculation method used by the target incremental encoder at the last sampling moment is a low-speed algorithm, and the absolute speed corresponding to the low-speed algorithm is not greater than a first switching speed threshold;

[0009] If so, determine whether the absolute speed obtained by the target incremental encoder at the last sampling moment is greater than the first switching speed threshold; if so, use a high-speed speed algorithm to calculate the absolute speed of the target device at the current moment; the absolute speed corresponding to the high-speed speed algorithm is not less than the second switching speed threshold;

[0010] If not, determining whether the absolute speed obtained by the target incremental encoder at the last sampling moment is less than the second switching speed threshold, and if so, using a low-speed algorithm to calculate the absolute speed of the target device at the current moment;

[0011] Determine the speed direction of the target device at the current moment;

[0012] The current speed of the target device is obtained based on the absolute speed and the speed direction.

[0013] In a preferred embodiment, before determining whether the absolute speed obtained by the target incremental encoder at the last sampling moment is greater than the first switching speed threshold, the method further includes: pre-acquiring the first switching speed threshold and the second switching speed threshold, including:

[0014] Obtaining the number of low-speed samples corresponding to the low-speed resolution and the number of high-speed samples corresponding to the high-speed resolution when the low-speed resolution is equal to the high-speed resolution;

[0015] Obtaining the first switching speed threshold based on the number of low-speed samples;

[0016] The second switching speed threshold is obtained based on the number of high-speed samples.

[0017] In a preferred embodiment, the use of a high-speed algorithm to calculate the absolute speed of the target device at the current moment includes:

[0018] Get the number of high-speed timer samples at the current moment;

[0019] The absolute speed of the target device at the current moment is obtained based on the number of samples of the high-speed timing sampler, the sampling task cycle and the encoder resolution of the target incremental encoder.

[0020] In a preferred embodiment, the use of a low-speed algorithm to calculate the absolute speed of the target device at the current moment includes:

[0021] Determine whether the falling edge of signal B is acquired;

[0022] If yes, get the number of low-speed timer samples at the current moment;

[0023] The absolute speed of the target device at the current moment is obtained based on the number of samples of the low-speed timer, the magnetic encoder timer frequency of the target incremental encoder, and the encoder resolution.

[0024] In a preferred implementation, if not, the number of low-speed timer samplings is cumulatively increased to a maximum number of samplings, and the speed of the target device is set to 0.

[0025] In a preferred embodiment, before determining whether the falling edge of the B signal is acquired, the using of a low-speed algorithm to calculate the absolute speed of the target device at the current moment also includes pre-acquiring a maximum number of samples, including:

[0026] Get the system minimum speed;

[0027] The maximum number of samples is obtained based on the system minimum speed, the sampling task period, and the encoder resolution of the target incremental encoder.

[0028] In a preferred implementation, determining the speed direction of the target device at the current moment includes:

[0029] Taking the remainder of the number of samples of the high-speed timer at the current moment based on the encoder resolution to obtain a remainder result;

[0030] When the remainder result is less than half of the encoder resolution, the remainder result is enlarged to a data limit length range;

[0031] Obtain the angle at the current sampling time based on the absolute speed and angle at the previous sampling time;

[0032] The angle at the current sampling moment is limited and contracted to [-180°, 180°] to obtain the speed direction of the target device.

[0033] In a second aspect, a speed measurement device based on an incremental encoder is characterized in that the device comprises:

[0034] A first judgment module is used to judge whether the target device speed calculation method adopted by the target incremental encoder at the last sampling moment is a low-speed algorithm, and the absolute speed corresponding to the low-speed algorithm is not greater than a first switching speed threshold;

[0035] a second judgment module, configured to further judge whether the absolute speed obtained by the target incremental encoder at the last sampling moment is greater than the first switching speed threshold when the judgment result of the first judgment module is yes, and if so, to calculate the absolute speed of the target device at the current moment by using a high-speed speed algorithm; the absolute speed corresponding to the high-speed speed algorithm is not less than the second switching speed threshold;

[0036] a third judgment module, configured to further judge whether the absolute speed obtained by the target incremental encoder at the last sampling moment is less than a second switching speed threshold value when the judgment result of the first judgment module is no, and if so, to calculate the absolute speed of the target device at the current moment by using a low-speed algorithm;

[0037] A first processing module, used to determine the speed direction of the target device at a current moment;

[0038] The second processing module is used to obtain the current speed of the target device based on the absolute speed and the speed direction.

[0039] According to a third aspect, an electronic device is provided, including:

[0040] one or more processors; and

[0041] A memory associated with the one or more processors, the memory being used to store program instructions, wherein the program instructions, when read and executed by the one or more processors, execute the method as described in any one of the first aspects.

[0042] According to a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by one or more processors, the steps of the method described in any one of the first aspects are implemented.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] The present invention provides a speed measurement method, device, electronic device and computer-readable storage medium based on an incremental encoder, wherein the method comprises: judging whether a target device speed calculation method adopted by a target incremental encoder at a previous sampling moment is a low-speed algorithm, and the absolute speed corresponding to the low-speed algorithm is not greater than a first switching speed threshold; if so, judging whether the absolute speed obtained by the target incremental encoder at the previous sampling moment is greater than the first switching speed threshold, and if so, using a high-speed algorithm to calculate the absolute speed of the target device at the current moment; the absolute speed corresponding to the high-speed algorithm is not less than a second switching speed threshold; if not, judging whether the absolute speed obtained by the target incremental encoder at the previous sampling moment is less than the second switching speed threshold, and if so, using a low-speed algorithm to calculate the absolute speed of the target device at the current moment; determining the speed direction of the target device at the current moment; and obtaining the speed of the target device at the current moment based on the absolute speed and the speed direction; the method effectively improves the calculation accuracy of the motor speed under different working conditions by matching different speed calculation methods with different operating speed thresholds of the same motor, and improves the versatility and adaptability of the incremental encoder. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 is a flow chart of a speed measurement method based on an incremental encoder in this embodiment;

[0046] Figure 2 is a flow chart of a speed measurement method based on an incremental encoder in a specific implementation in this embodiment;

[0047] Figure 3Schematic diagram of the structure of the computer-readable storage medium in this embodiment. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiment of the present invention, not all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0049] In the description of the present invention, it is to be understood that the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "plurality" means two or more.

[0050] With the development of sensor technology, when using incremental encoders to obtain the motor speed, it is necessary to set different incremental encoders for motors with different operating conditions to achieve accurate measurement of the running speed. When using the same incremental encoder to obtain the running speed of a motor with complex working conditions, it is inevitable that there will be a certain deviation. In response to the above problems, the present application provides a speed measurement method, device, electronic device and computer-readable storage medium based on an incremental encoder, which can achieve accurate measurement of the motor speed under different working conditions.

[0051] The following will be combined with the attached Figures 1 to 3 The data processing method, device and electronic device of this embodiment are further described in detail.

[0052] Example

[0053] like Figure 1 , 2 As shown, this embodiment provides a speed measurement method based on an incremental encoder. The incremental encoder in this embodiment is an incremental magnetic encoder, and the signal output form of the incremental magnetic encoder is ABZ. AB are square waves with a duty cycle of 50%, and the AB signals differ by 90°. When rotating forward, A leads B, and when rotating reverse, B leads A. When the motor rotates one circle, A and B respectively output N square waves. When the motor rotates one circle, Z will output a pulse signal at a fixed position of each circle.

[0054] Specifically, the speed measurement method based on the incremental encoder includes the following steps:

[0055] S1. Determine whether a target device speed calculation method used by a target incremental encoder at a previous sampling moment is a low-speed algorithm, wherein an absolute speed corresponding to the low-speed algorithm is not greater than a first switching speed threshold.

[0056] Specifically, the target device in this embodiment is a motor. A part of the target incremental encoder is arranged on the rotating shaft of the motor, and a part of the target incremental encoder is arranged on the microcontroller unit MCU, for measuring the rotation speed of the motor.

[0057] Since the speed calculation method is determined before the corresponding speed value in the speed measurement process of the previous sampling moment, this step S1 can shorten the data processing interval between the current sampling moment and the previous sampling moment by judging the speed calculation type, thereby further shortening the speed measurement cycle.

[0058] This embodiment is divided into different working conditions according to different thresholds of motor speed, and the working conditions include but are not limited to a speed range not greater than a first switching speed threshold and a speed range not less than a second switching speed threshold. Usually, the first switching speed threshold is not greater than the second switching speed threshold.

[0059] More specifically, the low speed algorithm shown in the following formula (1) is used to calculate the speed (Speed) under the corresponding working condition. low ):

[0060]

[0061] Among them, C L o w is the number of samples of the low-speed timer, specifically the number of samples within the high-level width between a group of adjacent rising edges and falling edges of the counting B signal;

[0062] F t is the magnetic encoder timer frequency (MHz);

[0063] R is the encoder resolution.

[0064] It should be noted that the above Speed low is the absolute speed (motor speed rpm), without speed direction. Further, according to the above formula (1), Speed low Follow C Low Increase and decrease.

[0065] When the judgment result of the above step S1 is yes, then step S2a is executed, and if the judgment result is no, then step S2b is executed, that is, either S2a or S2b is executed. Specifically:

[0066] S2a. If yes, determine whether the absolute speed obtained by the target incremental encoder at the previous sampling moment is greater than the first switching speed threshold. If yes, use a high-speed algorithm to calculate the absolute speed of the target device at the current moment, wherein the absolute speed corresponding to the high-speed algorithm is not less than the second switching speed threshold; if no, use a low-speed algorithm to calculate and obtain the absolute speed.

[0067] Specifically, in step S2a, the high-speed algorithm is used to calculate the absolute speed of the target device at the current moment, including:

[0068] S2a1, get the number of samples of the high-speed timer at the current moment C Hight ;

[0069] S2a2, based on the number of samples C of high-speed timing sampler Hight , sampling task period T and the encoder resolution R of the target incremental encoder to obtain the absolute speed of the target device at the current moment.

[0070] For example, the following formula (2) is used to calculate the speed (Speed) under the corresponding working condition: High ):

[0071]

[0072] Among them, C High The number of samples of the high-speed timer;

[0073] T is the task period (μs);

[0074] R is the encoder resolution.

[0075] According to the above formula (2), the speed Speed High With the high-speed timer sampling number C High

[0076] This embodiment does not limit the length of the task cycle T, which is usually about 80 μs.

[0077] S2b, if not, determine whether the absolute speed obtained by the target incremental encoder at the last sampling moment is less than the second switching speed threshold; if so, use the low-speed algorithm as shown in formula (1) to calculate the absolute speed of the target device at the current moment.

[0078] It should be noted that during the sampling process, there must be a difference between the number of low-speed timer sampling and the number of high-speed timer sampling. When the low-speed resolution is equal to the high-speed resolution, the number of low-speed sampling corresponding to the low-speed resolution is C. L The number of high-speed samples corresponding to the high-speed resolution C HTherefore, before steps S2a and S2b, the method further includes step S01, pre-acquiring a first switching speed threshold and a second switching speed threshold, and step S01 includes:

[0079] S01a, obtain the number of low-speed samples C corresponding to the low-speed resolution when the low-speed resolution is equal to the high-speed resolution L , and the number of high-speed samples corresponding to the high-speed resolution C H ;

[0080] S01b, based on the number of low-speed samples C L The first switching speed threshold Speed ​​is calculated by the low speed algorithm shown in formula (1): low (C L ),Right now Figure 2 The threshold for switching from medium to low speed.

[0081] S01c, based on high-speed sampling number C H The second switching speed threshold Speed ​​is calculated by the high speed algorithm shown in formula (2): High (C H ),Right now Figure 2 Medium and high speed switching low speed threshold.

[0082] Further, in step S2b, the absolute speed of the target device at the current moment is calculated using a low-speed algorithm, including:

[0083] S2b1, determine whether the falling edge of signal B is acquired;

[0084] S2b2, if yes, then obtain the number of low-speed timer samples at the current moment;

[0085] S2b3, obtaining the absolute speed of the target device at the current moment based on the number of samples of the low-speed timer, the magnetic encoder timer frequency of the target incremental encoder and the encoder resolution;

[0086] S2b4, if not, the number of low-speed timer samplings is cumulatively increased to the maximum number of samplings, and the speed of the target device is set to 0.

[0087] It should be noted that the above steps S2b2 to S2b3 and S2b4 can be performed selectively.

[0088] In a preferred embodiment, before step S2b1, step S2b further includes:

[0089] Get the system minimum speed Speed min (rpm); In a preferred embodiment, Speed min (rpm) is an empirical value. Based on the system's minimum speed Speedmin (rpm), sampling task period T and the encoder resolution R of the target incremental encoder to obtain the maximum sampling number Counter maxInt .

[0090] Exemplarily, the maximum sampling number Counter is calculated by the following formula (3): maxInt :

[0091]

[0092] Where, T is the task period (μs);

[0093] R is the encoder resolution.

[0094] As a preferred embodiment, in order to improve the speed measurement accuracy, after S2b3, step S2b also includes S2b5, abnormal speed check, specifically determining whether the absolute speed is abnormal by verifying whether the absolute speed obtained by calculation falls within the current speed threshold.

[0095] S3. Determine the speed direction of the target device at the current moment.

[0096] The aforementioned steps S1 to S2 are used to calculate the absolute speed (rpm) of the motor at the current sampling moment, and the step S3 is used to calculate the speed direction of the motor at the current sampling moment, ie, forward or reverse.

[0097] Specifically, step S3 includes:

[0098] S31. Taking the modulus of the number of samples of the high-speed timer at the current moment based on the encoder resolution to obtain a modulo result.

[0099] S32, when the remainder result is less than half of the encoder resolution, the remainder result is enlarged to the data limit length range. When the remainder result is not less than half of the encoder resolution, the remainder result is corrected by subtracting the encoder resolution.

[0100] Exemplarily, the data limit length range is -32768 to 32767. It should be noted that the data is enlarged to -32768 to 32767 in order to utilize the technique of returning the data to 0 when the length of int type data overflows, and this process corresponds to the angle modulus operation in step S31.

[0101] S33. Obtain the angle at the current sampling moment based on the absolute speed and angle at the previous sampling moment.

[0102] Further, step S33 specifically includes:

[0103] Get the angles of the n consecutive sampling moments before the current sampling moment, where n is an integer not less than 2;

[0104] The direction change at the current sampling moment is determined based on the angle change directions in n consecutive sampling moments before the current sampling moment.

[0105] Exemplarily, it is determined whether the direction of the previous n-1 sampling moment has changed compared to the previous n sampling moment. If so, the current judgment result is abandoned and the previous judgment result is retained. If not, it is determined again. If the judgment result is consistent with the previous judgment result, the count is increased by 1. If the judgment result is inconsistent with the previous judgment result, the count is reduced by 1. The same method is used to make corresponding judgments for the previous n-2, previous n-3, etc. sampling moments. When the count reaches the preset threshold, it is determined that the speed of the current sampling moment has changed compared to the previous sampling moment. If the count does not reach the threshold, it is determined that the speed of the current sampling moment is consistent with the previous sampling moment.

[0106] Therefore, when this step is making angle judgments, when angle changes occur, a delayed judgment is required to mitigate the impact of abnormal data, thereby further improving the speed measurement accuracy.

[0107] S34, limiting the angle at the current sampling moment and shrinking it to [-180°, 180°] to obtain the speed direction of the target device.

[0108] Furthermore, this embodiment limits and filters the angle change rate by using the velocity at the previous moment, that is, uses acceleration to limit and filter.

[0109] S4. Obtain the current speed of the target device based on the absolute speed obtained in step S2 and the speed direction obtained in step S3.

[0110] In this embodiment, the speed at the current sampling moment is the product of the absolute speed and the speed direction. After the absolute speed and the speed direction at the current sampling moment are obtained, the speed of the target device at the current moment can be known.

[0111] In summary, this embodiment provides a speed measurement method based on an incremental encoder by matching different speed calculation methods with different motor operating speed thresholds of the same motor, thereby effectively improving the calculation accuracy of the motor speed under different working conditions and improving the versatility of the incremental encoder.

[0112] This embodiment also provides a speed measurement device based on an incremental encoder, the device comprising:

[0113] A first judgment module is used to judge whether the target device speed calculation method adopted by the target incremental encoder at the last sampling moment is a low-speed algorithm, wherein the absolute speed corresponding to the low-speed algorithm is not greater than a first switching speed threshold;

[0114] a second judgment module, configured to further judge whether the absolute speed obtained by the target incremental encoder at the last sampling moment is greater than a first switching speed threshold when the judgment result of the first judgment module is yes, and if so, to calculate the absolute speed of the target device at the current moment by using a high-speed speed algorithm; the absolute speed corresponding to the high-speed speed algorithm is not less than a second switching speed threshold, and the second switching speed threshold is greater than the first switching speed threshold;

[0115] a third judgment module, configured to further judge whether the absolute speed obtained by the target incremental encoder at the last sampling moment is less than a second switching speed threshold value when the judgment result of the first judgment module is no, and if so, to calculate the absolute speed of the target device at the current moment by using a low-speed algorithm;

[0116] A first processing module, used to determine the speed direction of the target device at a current moment;

[0117] The second processing module is used to obtain the current speed of the target device based on the absolute speed and the speed direction.

[0118] Furthermore, the second judgment module includes:

[0119] The first acquisition unit is used to obtain the number of samples of the high-speed timer at the current moment;

[0120] The first processing unit is used to obtain the absolute speed of the target device at a current moment based on the number of samples of the high-speed timing sampler, the sampling task cycle and the encoder resolution of the target incremental encoder.

[0121] Furthermore, the third judgment module includes:

[0122] A first judgment unit, used to judge whether a falling edge of the B signal is collected;

[0123] A second acquisition unit, configured to acquire the number of low-speed timer samples at the current moment when the judgment result of the first judgment unit is yes;

[0124] The second processing unit is used to obtain the absolute speed of the target device at the current moment based on the number of samples of the low-speed timer, the magnetic encoder timer frequency of the target incremental encoder, and the encoder resolution.

[0125] The third processing unit is used for, when the judgment result of the first judgment unit is no, the number of samplings of the low-speed timer is cumulatively increased to the maximum number of samplings, and the speed of the target device is set to 0.

[0126] The fourth processing unit is used to obtain the minimum speed of the system; and obtain the maximum sampling number based on the minimum speed of the system, the sampling task period and the encoder resolution of the target incremental encoder.

[0127] Furthermore, the first processing module includes:

[0128] A fifth processing unit, configured to obtain a modulo result by modulo the number of samples of the high-speed timer at the current moment based on the encoder resolution;

[0129] A sixth processing unit, configured to amplify the remainder result to a data limit length range when the remainder result is less than half of the encoder resolution;

[0130] A seventh processing unit, configured to obtain an angle at a current sampling moment based on the absolute speed and angle at a previous sampling moment;

[0131] The eighth processing unit limits the angle at the current sampling moment and shrinks it to [-180°, 180°] to obtain the speed direction of the target device.

[0132] Furthermore, the device also includes a third processing module, which is used to pre-acquire the first switching speed threshold and the second switching speed threshold, including:

[0133] Obtaining the number of low-speed samples corresponding to the low-speed resolution and the number of high-speed samples corresponding to the high-speed resolution when the low-speed resolution is equal to the high-speed resolution;

[0134] Obtaining the first switching speed threshold based on the number of low-speed samples;

[0135] The second switching speed threshold is obtained based on the number of high-speed samples.

[0136] It should be noted that: the speed measurement device based on the incremental encoder provided in the above embodiment only uses the division of the above functional modules as an example when triggering the speed measurement service based on the incremental encoder. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the system is divided into different functional modules to complete all or part of the functions described above. In addition, the speed measurement device based on the incremental encoder provided in the above embodiment and the embodiment of the speed measurement method based on the incremental encoder belong to the same concept, that is, the system is based on the method, and its specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0137] In addition, this embodiment further provides an electronic device, including:

[0138] one or more processors; and

[0139] A memory associated with the one or more processors, the memory is used to store program instructions, and when the program instructions are read and executed by the one or more processors, the aforementioned speed measurement method based on the incremental encoder is executed.

[0140] Regarding the data processing method performed by executing program instructions, the specific execution details and corresponding beneficial effects are consistent with the description of the aforementioned method and will not be repeated here.

[0141] And, if Figure 3 As shown, this embodiment further provides a computer-readable storage medium 31 on which a computer program 310 is stored. When the computer program is executed by one or more processors 32, the aforementioned speed measurement method based on the incremental encoder is implemented.

[0142] Specifically, any combination of one or more computer-readable media can be used. Computer-readable storage media can be computer-readable signal media or computer-readable storage media or any combination of the above two. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0143] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0144] The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical cable, RF, etc., or any suitable combination of the foregoing.

[0145] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0146] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0147] Computer program code for performing the operation of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0148] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0149] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.

[0150] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0151] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0152] All of the above optional technical solutions can be combined in any way to form optional embodiments of the present invention, that is, any multiple embodiments can be combined to meet the needs of different application scenarios. They are all within the protection scope of this application and will not be described one by one here.

[0153] It should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A speed measurement method based on an incremental encoder, characterized in that: The method comprises: Determine whether the target device speed calculation method used by the target incremental encoder at the last sampling moment is a low-speed algorithm, and the absolute speed corresponding to the low-speed algorithm is not greater than a first switching speed threshold; If so, determine whether the absolute speed obtained by the target incremental encoder at the last sampling moment is greater than the first switching speed threshold; if so, use a high-speed speed algorithm to calculate the absolute speed of the target device at the current moment; the absolute speed corresponding to the high-speed speed algorithm is not less than the second switching speed threshold; If not, determining whether the absolute speed obtained by the target incremental encoder at the last sampling moment is less than the second switching speed threshold, and if so, using a low-speed speed algorithm to calculate the absolute speed of the target device at the current moment; Determine the speed direction of the target device at the current moment; Obtaining the current speed of the target device based on the absolute speed and the speed direction; Before determining whether the absolute speed obtained by the target incremental encoder at the last sampling moment is greater than the first switching speed threshold, the method further includes: pre-acquiring the first switching speed threshold and the second switching speed threshold, including: Obtaining the number of low-speed samples corresponding to the low-speed resolution and the number of high-speed samples corresponding to the high-speed resolution when the low-speed resolution is equal to the high-speed resolution; Obtaining the first switching speed threshold based on the number of low-speed samples; The second switching speed threshold is obtained based on the number of high-speed samples.

2. The method according to claim 1, characterized in that The using of a high-speed algorithm to calculate the absolute speed of the target device at the current moment includes: Get the number of high-speed timer samples at the current moment; The absolute speed of the target device at the current moment is obtained based on the number of samples of the high-speed timing sampler, the sampling task cycle and the encoder resolution of the target incremental encoder.

3. The method according to claim 1, characterized in that The step of using a low-speed algorithm to calculate the absolute speed of the target device at the current moment includes: Determine whether the falling edge of signal B is acquired; If yes, get the number of low-speed timer samples at the current moment; The absolute speed of the target device at the current moment is obtained based on the number of samples of the low-speed timer, the magnetic encoder timer frequency of the target incremental encoder, and the encoder resolution.

4. The method according to claim 3, characterized in that If not, the number of low-speed timer samplings is cumulatively increased to the maximum number of samplings, and the speed of the target device is set to 0.

5. The method according to claim 4, characterized in that Before determining whether the falling edge of the B signal is acquired, the step of using a low-speed algorithm to calculate the absolute speed of the target device at the current moment also includes pre-acquiring a maximum number of samples, including: Get the system minimum speed; The maximum number of samples is obtained based on the system minimum speed, the sampling task period, and the encoder resolution of the target incremental encoder.

6. The method according to claim 1, characterized in that Determining the speed direction of the target device at the current moment includes: The modulo result is obtained by taking the modulo number of the high-speed timer samples at the current moment based on the encoder resolution; When the remainder result is less than half of the encoder resolution, the remainder result is enlarged to a data limit length range; Obtain the angle at the current sampling time based on the absolute speed and angle at the previous sampling time; The angle at the current sampling moment is limited and contracted to [-180°, 180°] to obtain the speed direction of the target device.

7. A speed measuring device based on an incremental encoder, characterized in that: The device comprises: A first judgment module is used to judge whether the target device speed calculation method adopted by the target incremental encoder at the last sampling moment is a low-speed algorithm, and the absolute speed corresponding to the low-speed algorithm is not greater than a first switching speed threshold; a second judgment module, configured to further judge whether the absolute speed obtained by the target incremental encoder at the last sampling moment is greater than the first switching speed threshold when the judgment result of the first judgment module is yes, and if so, to calculate the absolute speed of the target device at the current moment by using a high-speed speed algorithm; the absolute speed corresponding to the high-speed speed algorithm is not less than the second switching speed threshold; a third judgment module, configured to further judge whether the absolute speed obtained by the target incremental encoder at the last sampling moment is less than a second switching speed threshold value when the judgment result of the first judgment module is no, and if so, to calculate the absolute speed of the target device at the current moment by using a low-speed algorithm; A first processing module, used to determine the speed direction of the target device at a current moment; A second processing module, configured to obtain a current speed of the target device based on the absolute speed and the speed direction; The method further includes a third processing module, which is used to pre-acquire the first switching speed threshold and the second switching speed threshold, including: Obtaining the number of low-speed samples corresponding to the low-speed resolution and the number of high-speed samples corresponding to the high-speed resolution when the low-speed resolution is equal to the high-speed resolution; Obtaining the first switching speed threshold based on the number of low-speed samples; The second switching speed threshold is obtained based on the number of high-speed samples.

8. An electronic device, characterized in that: include: one or more processors; as well as A memory associated with the one or more processors, the memory being used to store program instructions, wherein when the program instructions are read and executed by the one or more processors, the method according to any one of claims 1 to 6 is executed.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by one or more processors, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Self-adaptive encoder speed measuring device and method

    CN103516288A

  • Angular speed calculating method and apparatus

    CN106441375A

  • Steering wheel angle analysis method and device

    CN110962930A