Encoder direction identification method and device, computer equipment and storage medium

By identifying the interruption action of the encoder and saving signal data, data update and comparison are performed, the accuracy problem of the encoder rotation direction judgment in the prior art is solved, and efficient and accurate rotation direction judgment is achieved.

CN120216862APending Publication Date: 2025-06-27SHENZHEN 3NOD DIGITAL TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311833353.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-27
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

The prior art is difficult to accurately and effectively judge the rotational inversion of the encoder, and the pulse signal is easily disturbed by noise, resulting in a decrease in the accuracy of the determination of the rotation direction.

Method used

By identifying the interrupt action of the encoder, the signal data is obtained and saved to the signal database, the current and historical signal data are extracted from the database for data update, and finally the valid signal data is compared with the standard signal data to determine the rotation direction of the encoder.

Benefits of technology

It realizes effective and accurate judgment of the encoder rotation direction, reduces the influence of noise interference, and improves the accuracy of judgment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216862A_ABST
    Figure CN120216862A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of encoders, and relates to an encoder direction identification method and device, computer equipment and a storage medium, and the method comprises the steps: obtaining signal data of an encoder according to an interruption action, and storing the signal data in a signal database; extracting signal data corresponding to the current interruption action as first coding information, and acquiring historically stored signal data as second coding information; performing data updating on the second coding information according to the first coding information, and storing the updated second coding information as effective signal data; and comparing the effective signal data with the standard signal data, and judging the rotation direction of the encoder according to a comparison result. According to the invention, the rotation direction of the encoder can be accurately and effectively judged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of encoders, and particularly to a method and device for identifying the direction of an encoder, a computer device, and a storage medium. Background Art

[0002] A rotary encoder is a device that can be used to measure the rotational speed and direction of an object. The pulse signals generated by the rotary encoder can effectively obtain the state information during rotation, and then the encoded data of the object measured by the rotary encoder can be calculated based on the state information.

[0003] The rotary encoder includes two pulse input pins A and B. When the rotary encoder rotates, corresponding pulse signals will be generated on the pulse input pins A and B respectively. The level change states of the pulse input pins A and B are obtained based on the pulse signals, and then the rotation direction of the rotary encoder is judged based on the level change states.

[0004] The pulse signal has two level states, high level and low level. The high level of the signal is represented as 1, and the low level of the signal is represented as 0. Since there is a phase difference between the pulse signals output by the pulse input pins, the level changes of the two pulse input pins A and B are not simultaneous. When the pulse signal of the pulse input pin A changes from low level to high level, if the pulse signal of the pulse input pin B is low level at this time, it is judged that the rotation direction of the rotary encoder is clockwise; if the pulse signal of the pulse input pin B is high level, it is judged that the rotation direction of the rotary encoder is counterclockwise. However, when using the above method for judgment, it is necessary to accurately obtain the level change moment of the pulse signal to ensure that there is no error in the judgment. At the same time, the obtained pulse signal is easily interfered by noise, resulting in an error in the phase of the pulse signal and reducing the accuracy of the rotation direction judgment. Summary of the Invention

[0005] The purpose of the present application is to propose a method and device for identifying the direction of an encoder, a computer device, and a storage medium to solve the problem that the rotation direction of the encoder cannot be accurately and effectively judged.

[0006] To solve the above technical problem, an embodiment of the present application provides a method for identifying the direction of an encoder, which adopts the following technical solutions:

[0007] Identify the interrupt action of the encoder, obtain the signal data of the encoder according to the interrupt action, and save the signal data to the signal database;

[0008] Extract the signal data corresponding to the current interrupt action from the signal database as the first coding information, and obtain the historically saved signal data as the second coding information;

[0009] Update the second coding information according to the first coding information, and save the updated second coding information as valid signal data;

[0010] Compare the valid signal data with the standard signal data, and judge the rotation direction of the encoder according to the comparison result.

[0011] Further, the steps of identifying the interruption action of the encoder, obtaining the signal data of the encoder according to the interruption action, and saving the signal data to the signal database specifically include:

[0012] Obtain the identification information of the encoder, and call the corresponding interruption service program according to the identification information to monitor the encoder in real time;

[0013] Detect whether the encoder has an interruption action according to the interruption service program;

[0014] If the encoder has the interruption action, obtain the first pin signal and the second pin signal of the encoder, and save the first pin signal and the second pin signal as the signal data to the signal database;

[0015] If the encoder does not have the interruption action, generate a continuous detection signal, and detect the interruption action according to the continuous detection signal until the encoder has the interruption action or the interruption service program stops monitoring.

[0016] Further, the steps of updating the second coding information according to the first coding information and saving the updated second coding information as valid signal data specifically include:

[0017] Obtain the historical signal data corresponding to the previous interruption action in the second coding information;

[0018] Detect whether the signal data corresponding to the first coding information is the same as the historical signal data;

[0019] If the signal data corresponding to the first coding information is the same as the historical signal data, delete the first coding information from the coding database;

[0020] If the signal data corresponding to the first coding information is different from the historical signal data, add the signal data corresponding to the first coding information to the historical signal data according to the preset data update rule for data update;

[0021] Confirm the historical signal data after data update as valid signal data, and save the valid signal data.

[0022] Further, before the step of detecting whether the signal data corresponding to the first encoded information is the same as the historical signal data, the following steps are further included:

[0023] Obtain the storage time information corresponding to the storage of the signal data in the signal database;

[0024] Obtain the current time information corresponding to the current interruption action;

[0025] Compare the storage time information with the current time information, determine the current storage time information corresponding to the current time information in the storage time information, and use the signal data corresponding to the current storage time information as the signal data corresponding to the first encoded information;

[0026] Compare the storage time information with the current time information, determine the historical storage time information that does not correspond to the current time information in the storage time information, and use the signal data corresponding to the historical storage information as the historical signal data.

[0027] Further, the step of adding the signal data corresponding to the first encoded information to the historical signal data for data update according to the preset data update rule specifically includes:

[0028] Obtain the data update rule, parse the data update rule, and obtain the data update steps;

[0029] Shift the historical signal data two bits to the left according to the data update steps, and generate a data update bit at the initial position before the historical signal data is shifted to the left;

[0030] Add the signal data corresponding to the first encoded information to the data update bit for data update.

[0031] Further, the standard signal data includes first standard signal data and second standard signal data. The step of comparing the valid signal data with the standard signal data and judging the rotation direction of the encoder according to the comparison result specifically includes:

[0032] Identify the number of data bits of the valid signal data. When the number of data bits of the valid signal data reaches six, extract the corresponding first standard signal data from the valid signal data in the standard database;

[0033] Detect whether the valid signal data corresponds to the first standard signal data;

[0034] If the valid signal data corresponds to the first standard signal data, further determine the rotation direction corresponding to the first standard signal data, and use the rotation direction corresponding to the first standard signal data as the rotation direction of the encoder;

[0035] If the valid signal data does not correspond to the first standard signal data, when the number of digits of the valid signal data reaches eight, extract the corresponding second standard signal data from the standard database, and determine the rotation direction of the encoder according to the valid signal data and the second standard signal data.

[0036] Further, the step of determining the rotation direction of the encoder according to the valid signal data and the second standard signal data specifically includes:

[0037] Detect whether the valid signal data corresponds to the second standard signal data;

[0038] If the valid signal data corresponds to the second standard signal data, further determine the rotation direction corresponding to the second standard signal data, and use the rotation direction corresponding to the second standard signal data as the rotation direction of the encoder;

[0039] If the valid signal data does not correspond to the second standard signal data, throw the valid signal data as an error result and generate an error message for reminder.

[0040] To solve the above technical problems, an encoder direction recognition device is further provided in an embodiment of the present application, including:

[0041] A data storage module, configured to identify the interrupt action of the encoder, obtain the signal data of the encoder according to the interrupt action, and store the signal data in the signal database;

[0042] A data determination module, configured to extract the signal data corresponding to the current interrupt action from the signal database as the first coding information, and obtain the historically stored signal data as the second coding information;

[0043] A data update module, configured to update the second coding information according to the first coding information, and store the updated second coding information as valid signal data;

[0044] A result judgment module, configured to compare the valid signal data with the standard signal data, and judge the rotation direction of the encoder according to the comparison result.

[0045] To solve the above technical problems, an embodiment of the present application further provides a computer device, which adopts the following technical solutions:

[0046] A computer device includes a memory and a processor. Computer-readable instructions are stored in the memory. When the processor executes the computer-readable instructions, the steps of the encoder direction recognition method described in any one of the above are implemented.

[0047] To solve the above technical problems, an embodiment of the present application further provides a computer-readable storage medium, adopting the following technical solutions:

[0048] A computer-readable storage medium has computer-readable instructions stored thereon. When the computer-readable instructions are executed by a processor, the steps of the encoder direction recognition method described in any one of the above are implemented.

[0049] Compared with the prior art, the embodiments of the present application mainly have the following beneficial effects:

[0050] In the present application, by recognizing the interruption action of the encoder, signal data of the encoder is obtained according to the interruption action, and thus the obtained signal data is saved to the signal database; by extracting the signal data corresponding to the current interruption action from the signal database as the first coding information and obtaining the historically saved signal data as the second coding information, data objects for comparison are obtained in the signal database; by updating the second coding information according to the first coding information and saving the updated second coding information as valid signal data, valid signal data composed of multiple signal data is effectively obtained; by comparing the valid signal data with the standard signal data and then judging the rotation direction of the encoder according to the comparison result, the rotation direction of the encoder can be judged effectively and accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] To more clearly illustrate the solutions in the present application, the following will briefly introduce the drawings required for the description of the embodiments of the present application. Obviously, the following described drawings are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0052] Figure 1 Flowchart of an embodiment of the encoder direction recognition method according to the present application;

[0053] Figure 2 is Figure 1 Flowchart of a specific implementation manner of step S10 in;

[0054] Figure 3 is Figure 1 Flowchart of a specific implementation manner of step S30 in;

[0055] Figure 4 is Figure 3 a flowchart of a specific implementation manner of step S304 in

[0056] Figure 5 is Figure 1 a flowchart of a specific implementation manner of step S40 in

[0057] Figure 6 is Figure 1 a flowchart of a specific implementation manner of step S404 in

[0058] Figure 7 a schematic structural diagram of an embodiment of an encoder direction recognition device according to the present application;

[0059] Figure 8 a schematic structural diagram of an embodiment of a computer device according to the present application. Specific implementation manner

[0060] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs; the terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above drawings are intended to cover non-exclusive inclusion. The terms "first", "second", etc. in the specification and claims of this application or the above drawings are used to distinguish different objects and not to describe a specific order.

[0061] Referring to

[0062] reference Figure 1 , a flowchart of an embodiment of an encoder direction recognition method according to the present application is shown. The encoder direction recognition method includes the following steps:

[0063] Step S10, identifying the interruption action of the encoder, obtaining the signal data of the encoder according to the interruption action, and saving the signal data to the signal database;

[0064] In this embodiment, the interrupt action of the encoder refers to the action performed by the rotary encoder during rotation according to the interrupt service subroutine. By adopting this action, it is convenient to obtain the signals on the two signal pins of the rotary encoder during the rotation of the rotary encoder, and it will not interfere with the rotation process of the rotary encoder.

[0065] Step S20: Extract the signal data corresponding to the current interrupt action from the signal database as the first coding information, and obtain the historically saved signal data as the second coding information.

[0066] In this embodiment, the first coding information refers to the signal data saved in the first variable at the current moment, and the second coding information refers to the signal data saved in the second variable at the previous moment. Among them, the signal data saved in the first variable and the second variable are both variable values composed of two pulse signal values of the encoder. Since the encoder will output at most four signal data during rotation, the second coding information has at most eight variable values, while the first coding information has two variable values. When the signal data of the next moment is saved to the first variable, the new signal data will overwrite the old signal data.

[0067] In specific implementation, the method of this embodiment can be implemented in the form of a programmed program. The first coding information of the signal database can be set as a local variable, and the second coding information of the signal database can be set as a global variable. By saving the signal data to the local variable and the global variable respectively, it is convenient for comparison and update.

[0068] Step S30: Update the data of the second coding information according to the first coding information, and save the updated second coding information as the valid signal data.

[0069] In this embodiment, the data content of the valid signal data is multiple binary values converted from the signal data, such as 101101. Among them, the valid signal data updated each time is two-bit binary values, such as 01. After each data update is completed, the action of saving the updated second coding information as the valid signal data will be executed to ensure that the valid signal data can be updated in real time. At the same time, in order to avoid the failure of the first coding information to update the second coding information, the previously saved valid signal data can also be cached, and the currently saved valid signal data and the cached valid signal data are compared. If the comparison results are different, it means that the update of the second coding information by the first coding information is successful. If the comparison results are the same, it means that the update of the second coding information by the first coding information fails, and the system will update again to ensure the validity of the valid signal data.

[0070] Step S40: Compare the valid signal data with the standard signal data, and determine the rotation direction of the encoder according to the comparison result.

[0071] In this embodiment, the standard signal data includes first standard signal data and second standard signal data. The data bit number corresponding to the first standard signal data is six bits. The data bit number refers to the data length of the binary value in the signal data. The data bit number corresponding to the second standard signal data is eight bits. After comparing the valid signal data with the first standard signal data, if the valid signal data does not correspond to the first standard signal data, then compare the valid signal data with the second standard signal data to determine the rotation direction of different encoders.

[0072] This application identifies the interruption action of the encoder, obtains the signal data of the encoder according to the interruption action, and saves the obtained signal data to the signal database; extracts the signal data corresponding to the current interruption action from the signal database as the first coding information, and obtains the historically saved signal data as the second coding information, so as to obtain the data objects for comparison in the signal database; updates the second coding information according to the first coding information, and saves the updated second coding information as the valid signal data, so as to effectively obtain the valid signal data composed of multiple signal data; compares the valid signal data with the standard signal data, and then determines the rotation direction of the encoder according to the comparison result, so as to effectively and accurately judge the rotation direction of the encoder.

[0073] Continue to refer to Figure 2 , which shows a flowchart of a specific embodiment of step S10, including the following steps:

[0074] Step S101: Obtain the identification information of the encoder, and call the corresponding interrupt service program according to the identification information to monitor the encoder in real time;

[0075] In this embodiment, the identification information of the encoder is the device id of the encoder. The interrupt service program is a program set to monitor the action state of the encoder in real time. When an interrupt action occurs in the encoder, the interrupt service program will send an interrupt signal, and the encoder will obtain the signal data of the first pin signal and the second pin signal at this time according to the interrupt signal.

[0076] Step S102: Detect whether the encoder has an interrupt action according to the interrupt service program;

[0077] Step S103: If the encoder has the interrupt action, obtain the first pin signal and the second pin signal of the encoder, and save the first pin signal and the second pin signal as the signal data to the signal database;

[0078] In this embodiment, the first pin signal and the second pin signal of the encoder respectively correspond to pins A and B of the encoder. When the first pin signal and the second pin signal at pins A and B at the current moment are acquired, the first pin signal and the second pin signal will be numerically recorded in the signal level state. The signal data is composed of the sorting of the first pin signal and the second pin signal. For example, when the first pin signal at pin A is in the high level state when acquired, the first pin signal is recorded as 1. When the second pin signal at pin B is in the low level state when acquired, the second pin signal is recorded as 0, and the signal data is 10, and so on.

[0079] Step S104, if the encoder does not have the interruption action, a continuous detection signal is generated, and the interruption action is detected according to the continuous detection signal until the encoder has the interruption action or the interruption service program stops monitoring.

[0080] In this embodiment, if it is necessary to control the encoder to stop monitoring the interruption action, a monitoring pause signal needs to be sent to the encoder for control.

[0081] Continue to refer to Figure 3 , which shows a flowchart of a specific embodiment of step S30, including the following steps:

[0082] Step S301, acquire the historical signal data corresponding to the previous interruption action in the second coding information;

[0083] In this embodiment, when the signal database records the signal data each time, it will record the time information of the corresponding interruption action, and sort according to the time information of the interruption action to determine the previous terminal action.

[0084] Step S302, detect whether the signal data corresponding to the first coding information is the same as the historical signal data;

[0085] Step S303, if the signal data corresponding to the first coding information is the same as the historical signal data, delete the first coding information from the coding database;

[0086] In this embodiment, when the signal data corresponding to the first coding information is the same as the historical signal data, it means that the currently saved signal data and the historically saved signal data are repeated. Since the signal data of the encoder will not be repeated, it means that the currently saved signal data is incorrect, and the first coding information needs to be deleted.

[0087] Step S304, if the signal data corresponding to the first encoded information is different from the historical signal data, update the data by adding the signal data corresponding to the first encoded information to the historical signal data according to a preset data update rule;

[0088] Step S305, confirm the historical signal data after data update as valid signal data and save the valid signal data.

[0089] In an alternative embodiment of this embodiment, before step S302, the following steps are also included:

[0090] Obtain the save time information corresponding to when the signal database saves the signal data;

[0091] In this embodiment, the data save time is recorded whenever the signal database saves signal data. The save time information corresponding to the signal data refers to the data save time when all signal data in the signal database are saved.

[0092] Obtain the current time information corresponding to the current interrupt action;

[0093] In this embodiment, when the interrupt action of the encoder is executed, the corresponding time information is recorded. Based on the time information and the actual current moment, the current interrupt action is determined. Specifically, it is the time difference between the time value of the current moment and the time information. Since the encoder may have multiple time information within the same cycle during rotation, the interrupt action corresponding to the time information with the smallest time difference is taken as the current interrupt action, and this time information is used as the current time information.

[0094] Compare the save time information with the current time information, determine the current save time information corresponding to the current time information in the save time information, and use the signal data corresponding to the current save time information as the signal data corresponding to the first encoded information;

[0095] Compare the save time information with the current time information, determine the historical save time information that does not correspond to the current time information in the save time information, and use the signal data corresponding to the historical save information as the historical signal data.

[0096] In this embodiment, the first encoded information is the signal data saved by the current interrupt action, and the second encoded information is the signal data saved by the previous interrupt action. The signal data saved by the two interrupt actions are compared to determine whether the signal data saved by the two interrupt actions are the same, so as to eliminate the interference of duplicate signal data.

[0097] Continue to refer to Figure 4, showing a flowchart of a specific embodiment of step S304, including the following steps:

[0098] Step S3041, obtain the data update rule, parse the data update rule, and obtain data update steps;

[0099] Step S3042, shift the historical signal data two bits to the left according to the data update steps, and generate a data update bit at the initial position before the historical signal data is shifted to the left;

[0100] In this embodiment, when the historical signal data is shifted two bits to the left, a data update bit will be generated at the original position. The signal data that the data update bit can update is also two bits. For example, if the variable value of the second variable is 10 and the variable value of the first variable is 11, then the updated variable value of the second variable is 1011. If the variable value of the second variable is 1011 and the variable value of the first variable is 01, then the updated variable value of the second variable is 101101, and so on. In specific implementation, the data update rule can be set correspondingly according to the actual situation.

[0101] Step S3043, add the signal data corresponding to the first coding information to the data update bit for data update.

[0102] In this embodiment, after the first coding information is added to the data update bit, an update completion event will be generated, and the system will export and record the valid signal data according to the update completion time.

[0103] Continue to refer to Figure 5 , showing a flowchart of a specific embodiment of step S40, including the following steps:

[0104] Step S401, identify the number of data bits of the valid signal data. When the number of data bits of the valid signal data reaches six, extract the corresponding first standard signal data from the standard database according to the valid signal data;

[0105] In this embodiment, the number of data bits refers to how many bits the binary value in the valid signal data contains. For example, if the valid signal data is 10110100, then the number of data bits of the valid signal data is 8 bits. Another example is 101101, then the valid signal data is 6 bits, and so on.

[0106] In this embodiment, the number of bits of the valid signal data is determined according to the signal data output by the encoder in one revolution. By converting the signal data of one revolution of the encoder into a binary value and obtaining the number of bits of the binary value, the number of bits of the historical saved data is obtained. For example, if the valid signal data is 1101001011, then take 11010010 from the valid signal data, and group 11010010 into pairs according to the variable value, obtaining four groups: 11, 01, 00, 10. The corresponding number of valid records is 4 times, indicating that the encoder will output signal data four times during one revolution. In this embodiment, considering that due to different manufacturing processes of the encoder, the signal data output by the encoder is also different. Some encoders will output three encoded data during one revolution. For example, if the valid signal data is 01001101 and the number of valid records is 3 times, therefore, different standard signal data are set for different encoders in this application. The corresponding standard signal data is extracted from the database according to the number of bits of the valid signal data for comparison, so as to meet the judgment of the rotation direction of encoders with different manufacturing processes.

[0107] Step S402, detect whether the valid signal data corresponds to the first standard signal data;

[0108] Step S403, if the valid signal data corresponds to the first standard signal data, further determine the rotation direction corresponding to the first standard signal data, and use the rotation direction corresponding to the first standard signal data as the rotation direction of the encoder;

[0109] In this embodiment, the rotation directions corresponding to the first standard signal data include the clockwise rotation direction and the counterclockwise rotation direction. The first standard signal data corresponding to the clockwise rotation direction includes 010011, 001101, 110100, and the first standard signal data corresponding to the counterclockwise rotation direction includes 100011, 001110, 111000. The corresponding rotation direction is judged according to the correspondence between the valid signal data and the above data, and the rotation direction is used as the rotation direction of the encoder.

[0110] Step S404, if the valid signal data does not correspond to the first standard signal data, when the number of bits of the valid signal data reaches eight, extract the corresponding second standard signal data from the standard database, and judge the rotation direction of the encoder according to the valid signal data and the second standard signal data.

[0111] In this embodiment, since the valid signal data updates two data bits at a time, when the valid signal data does not correspond to the first standard signal data, the system will identify whether the number of data bits of the valid signal data reaches eight after the next update of the valid signal data. When the number of data bits of the valid signal data reaches eight, the corresponding second standard signal data is extracted from the standard database.

[0112] Continue to refer to Figure 6 , which shows a flowchart of a specific embodiment of step S404, including the following steps:

[0113] Step S4041, detect whether the valid signal data corresponds to the second standard signal data;

[0114] Step S4042, if the valid signal data corresponds to the second standard signal data, further determine the rotation direction corresponding to the second standard signal data, and use the rotation direction corresponding to the second standard signal data as the rotation direction of the encoder;

[0115] In this embodiment, the rotation directions corresponding to the second standard signal data include the clockwise rotation direction and the counterclockwise rotation direction. The second standard signal data corresponding to clockwise rotation includes 11010010, 01001011, 00101101, 10110100. If the valid signal data corresponds to the above values, it is determined that the rotation direction of the encoder is clockwise rotation; the second standard signal data corresponding to counterclockwise rotation includes 11100001, 10000111, 00011110, 01111000. If the valid signal data corresponds to the above values, it is determined that the rotation direction of the encoder is counterclockwise rotation.

[0116] Step S4043, if the valid signal data does not correspond to the second standard signal data, throw the valid signal data as an error result and generate an error message for reminder.

[0117] In this embodiment, if the valid signal data does not correspond to the second standard signal data, it means that an error occurs when the valid signal data is acquired. The system will judge the valid signal data as an error data and throw it, and generate a corresponding error message to be sent to the display interface for display reminder.

[0118] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. This computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM), etc.

[0119] It should be understood that although the steps in the flowchart of the accompanying drawings are shown in sequence according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and they can be executed in other orders. Moreover, at least some of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same moment, but can be executed at different moments, and their execution order is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps.

[0120] Further reference Figure 7 to Figure 1 As an implementation of the method shown above, an embodiment of an encoder direction recognition device is provided in this application. This device embodiment corresponds to the method embodiment shown Figure 1 above, and this device can be specifically applied to various electronic devices.

[0121] As Figure 7 shown, the encoder direction recognition device 500 described in this embodiment includes: a data storage module 501, a data determination module 502, a data update module 503, and a result judgment module 504. Among them:

[0122] The data storage module 501 is used to identify the interrupt action of the encoder, obtain the signal data of the encoder according to the interrupt action, and store the signal data in the signal database;

[0123] The data determination module 502 is used to extract the signal data corresponding to the current interrupt action from the signal database as the first coding information, and obtain the historically stored signal data as the second coding information;

[0124] The data update module 503 is used to update the second coding information according to the first coding information, and store the updated second coding information as valid signal data;

[0125] A result judgment module 504 is configured to compare the valid signal data with the standard signal data and judge the rotation direction of the encoder according to the comparison result.

[0126] In this application, by identifying the interruption action of the encoder, the signal data of the encoder is obtained according to the interruption action, and thus the obtained signal data is saved to the signal database; by extracting the signal data corresponding to the current interruption action from the signal database as the first coding information, and obtaining the historically saved signal data as the second coding information, data objects for comparison are obtained in the signal database; by updating the second coding information according to the first coding information, and saving the updated second coding information as the valid signal data, the valid signal data composed of multiple signal data is effectively obtained; by comparing the valid signal data with the standard signal data, and then judging the rotation direction of the encoder according to the comparison result, the rotation direction of the encoder can be effectively and accurately judged.

[0127] To solve the above technical problems, an embodiment of this application further provides a computer device. For details, please refer to Figure 8 , Figure 8 which is the basic structural block diagram of the computer device in this embodiment.

[0128] The computer device 6 includes a memory 61, a processor 62, and a network interface 63 that are communicatively connected to each other through a system bus. It should be noted that only the computer device 6 with components 61-63 is shown in the figure, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be alternatively implemented. Among them, those skilled in the art of this technology can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0129] The computer device can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The computer device can perform human-computer interaction with the user through a keyboard, a mouse, a remote control, a touchpad, a voice control device, or the like.

[0130] The memory 61 includes at least one type of readable storage medium, which includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 61 may be an internal storage unit of the computer device 6, such as the hard disk or memory of the computer device 6. In other embodiments, the memory 61 may also be an external storage device of the computer device 6, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, FlashCard, etc. equipped on the computer device 6. Of course, the memory 61 may also include both the internal storage unit and the external storage device of the computer device 6. In this embodiment, the memory 61 is generally used to store the operating system and various application software installed on the computer device 6, such as the program code of the encoder direction recognition method. In addition, the memory 61 may also be used to temporarily store various types of data that have been output or will be output.

[0131] In some embodiments, the processor 62 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. The processor 62 is generally used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is used to run the program code stored in the memory 61 or process data, such as running the program code of the encoder direction recognition method.

[0132] The network interface 63 may include a wireless network interface or a wired network interface, and the network interface 63 is generally used to establish a communication connection between the computer device 6 and other electronic devices.

[0133] This application identifies the interruption action of the encoder, obtains the signal data of the encoder according to the interruption action, and thus saves the obtained signal data to the signal database; by extracting the signal data corresponding to the current interruption action from the signal database as the first coding information, and obtaining the historically saved signal data as the second coding information, data objects for comparison are obtained in the signal database; by updating the second coding information according to the first coding information and saving the updated second coding information as valid signal data, valid signal data composed of multiple signal data is effectively obtained; by comparing the valid signal data with the standard signal data and then judging the rotation direction of the encoder according to the comparison result, the rotation direction of the encoder is effectively and accurately judged.

[0134] This application also provides another implementation manner, that is, to provide a computer-readable storage medium storing an encoder direction recognition program, which can be executed by at least one processor, so that the at least one processor executes the steps of the encoder direction recognition method as described above.

[0135] This application identifies the interruption action of the encoder, obtains the signal data of the encoder according to the interruption action, and thus saves the obtained signal data to the signal database; by extracting the signal data corresponding to the current interruption action from the signal database as the first coding information, and obtaining the historically saved signal data as the second coding information, data objects for comparison are obtained in the signal database; by updating the second coding information according to the first coding information and saving the updated second coding information as valid signal data, valid signal data composed of multiple signal data is effectively obtained; by comparing the valid signal data with the standard signal data and then judging the rotation direction of the encoder according to the comparison result, the rotation direction of the encoder is effectively and accurately judged.

[0136] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation manner. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0137] Obviously, the embodiments described above are only a part of the embodiments of this application, rather than all of them. The preferred embodiments of this application are shown in the accompanying drawings, but they do not limit the patent scope of this application. This application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosed content of this application more thorough and comprehensive. Although this application has been described in detail with reference to the foregoing embodiments, for those skilled in the art, they can still modify the technical solutions described in the foregoing specific embodiments, or perform equivalent replacements on some of the technical features. Any equivalent structures made by using the content of this application's specification and drawings, directly or indirectly applied in other related technical fields, are equally within the scope of patent protection of this application.

Claims

1. A method for identifying the direction of an encoder, characterized in that, Including: Identifying the interrupt action of the encoder, obtaining the signal data of the encoder according to the interrupt action, and saving the signal data to the signal database; Extracting the signal data corresponding to the current interrupt action from the signal database as the first coding information, and obtaining the historically saved signal data as the second coding information; Updating the data of the second coding information according to the first coding information, and saving the updated second coding information as valid signal data; Comparing the valid signal data with the standard signal data, and judging the rotation direction of the encoder according to the comparison result.

2. The encoder direction recognition method according to claim 1, wherein The step of identifying the interrupt action of the encoder, obtaining the signal data of the encoder according to the interrupt action, and saving the signal data to the signal database specifically includes: Obtaining the identification information of the encoder, and calling the corresponding interrupt service program according to the identification information to monitor the encoder in real time; Detecting whether the encoder has an interrupt action according to the interrupt service program; If the encoder has the interrupt action, obtaining the first pin signal and the second pin signal of the encoder, and saving the first pin signal and the second pin signal as the signal data to the signal database; If the encoder does not have the interrupt action, generating a continuous detection signal, and detecting the interrupt action according to the continuous detection signal until the encoder has the interrupt action or the interrupt service program stops monitoring.

3. The encoder direction recognition method according to claim 1, characterized in that The step of updating the data of the second coding information according to the first coding information, and saving the updated second coding information as valid signal data specifically includes: Obtaining the historical signal data corresponding to the previous interrupt action in the second coding information; Detecting whether the signal data corresponding to the first coding information is the same as the historical signal data; If the signal data corresponding to the first coding information is the same as the historical signal data, deleting the first coding information from the coding database; If the signal data corresponding to the first coding information is different from the historical signal data, adding the signal data corresponding to the first coding information to the historical signal data according to the preset data update rule for data update; Confirming the historically signal data after data update as valid signal data, and saving the valid signal data.

4. The encoder direction recognition method according to claim 3, characterized in that Before the step of detecting whether the signal data corresponding to the first coding information is the same as the historical signal data, the following steps are further included: Obtaining the save time information corresponding to the signal database when saving the signal data; Obtaining the current time information corresponding to the current interrupt action; Comparing the save time information with the current time information, determining the current save time information corresponding to the current time information in the save time information, and using the signal data corresponding to the current save time information as the signal data corresponding to the first coding information; Compare the saved time information with the current time information, determine the historical saved time information that does not correspond to the current time information in the saved time information, and use the signal data corresponding to the historical saved information as the historical signal data.

5. The encoder direction recognition method according to claim 3, characterized in that The step of adding the signal data corresponding to the first encoding information to the historical signal data for data update according to the preset data update rule specifically includes: Obtain the data update rule, parse the data update rule, and obtain the data update steps; Shift the historical signal data two bits to the left according to the data update steps, and generate a data update bit at the initial position before the left shift of the historical signal data; Add the signal data corresponding to the first encoding information to the data update bit for data update.

6. The encoder direction recognition method according to claim 1, wherein The standard signal data includes first standard signal data and second standard signal data. The step of comparing the valid signal data with the standard signal data and judging the rotation direction of the encoder according to the comparison result specifically includes: Identify the number of data bits of the valid signal data. When the number of data bits of the valid signal data reaches six, extract the corresponding first standard signal data from the standard database according to the valid signal data; Detect whether the valid signal data corresponds to the first standard signal data; If the valid signal data corresponds to the first standard signal data, further determine the rotation direction corresponding to the first standard signal data, and use the rotation direction corresponding to the first standard signal data as the rotation direction of the encoder; If the valid signal data does not correspond to the first standard signal data, when the number of data bits of the valid signal data reaches eight, extract the corresponding second standard signal data from the standard database, and judge the rotation direction of the encoder according to the valid signal data and the second standard signal data.

7. The encoder direction recognition method according to claim 6, characterized in that The step of judging the rotation direction of the encoder according to the valid signal data and the second standard signal data specifically includes: Detect whether the valid signal data corresponds to the second standard signal data; If the valid signal data corresponds to the second standard signal data, further determine the rotation direction corresponding to the second standard signal data, and use the rotation direction corresponding to the second standard signal data as the rotation direction of the encoder; If the valid signal data does not correspond to the second standard signal data, throw the valid signal data as an error result and generate an error message for reminder.

8. An encoder direction recognition device, characterized in that, Includes: A data saving module, configured to identify the interruption action of the encoder, obtain the signal data of the encoder according to the interruption action, and save the signal data to the signal database; A data determination module, configured to extract the signal data corresponding to the current interruption action from the signal database as the first encoding information, and obtain the historically saved signal data as the second encoding information; A data update module, configured to perform data update on the second coding information according to the first coding information, and save the updated second coding information as valid signal data; A result judgment module, configured to compare the valid signal data with the standard signal data, and judge the rotation direction of the encoder according to the comparison result.

9. A computer device, comprising a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the encoder direction recognition method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the encoder direction recognition method according to any one of claims 1 to 7 are implemented.