Z signal updating method and device of incremental square wave encoder, equipment and medium

By reading the count value and calculating the change value in the incremental square wave encoder, and selecting the capture value of the Z signal in the rotation direction, the problem that the Z signal update method in the prior art cannot automatically switch the trigger condition, and the stability of the Z signal usage value and the reliability of the angle control are achieved.

CN119756440AActive Publication Date: 2025-04-04SHENZHEN V&T TECH
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202411904784.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-04
Estimated Expiration
2044-12-23

AI Technical Summary

Technical Problem

The existing Z signal update method of incremental square wave encoder cannot automatically switch trigger conditions according to the rotation direction, resulting in the use value of the Z signal being indifferent and there are deviations, which affects the stability and accuracy of the angular control of the system.

Method used

By accessing the register, read the current and previous count values ​​of the incremental square wave encoder, calculate the change value, and select the rising or falling edge of the Z signal as the capture value according to the rotation direction. When the change value is greater than the preset value, the usage value of the Z signal is updated, and the updated value is sent to the servo system to control the rotation of the rotation axis to the target angle.

Benefits of technology

A single and identical stable value of the Z signal usage value is achieved, and it is not affected by the rotation direction and the pulse width of the Z signal, improving the consistency and reliability of angle control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119756440A_ABST
    Figure CN119756440A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of square wave encoders, and discloses a Z signal updating method, device and equipment of an incremental square wave encoder and a medium, and the method comprises the steps: selecting a difference value between a current count value and a previous count value as a change value of the incremental square wave encoder; selecting a count value corresponding to the rising edge or the falling edge of the Z signal as a capture value of the Z signal in the current period; when the change value is greater than a preset value, selecting a capture value of the Z signal in the current period as a current capture value; selecting a capture value of the Z signal in a previous period of the current period as a previous capture value; and when the difference between the current capture value and the previous capture value meets a first condition or a second condition, updating the use value of the Z signal to the current capture value, sending the current capture value to a servo system, and controlling the servo system to control the rotating shaft to rotate to a target angle according to the current capture value. According to the invention, a single and same Z signal use value can be automatically screened out, and the stability and the control precision of system control can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of square wave encoders, and in particular to a Z signal updating method, device, equipment and medium of an incremental square wave encoder. Background Art

[0002] The advantages of the incremental square wave encoder are simple principle and structure, average mechanical life of tens of thousands of hours, strong anti-interference ability and high reliability. The Z phase signal of the incremental encoder is referred to as the Z signal. The use value of the Z signal provides a clear reference point, allowing the system to determine the initial position.

[0003] However, the existing incremental square wave encoder Z signal update method uses the capture input function of the timer. The capture condition cannot automatically switch the trigger edge according to the counting direction (incrementing or decrementing) of the encoder. This results in two different values ​​for the Z signal used when the encoder is in forward and reverse rotation when the Z pulse width is relatively large. The larger the width of the Z signal pulse, the greater the deviation between the two used values. When the angle offset movement is performed with the Z position value sampled as the reference point, there will be the same position in forward and reverse rotation, and there will be deviation in the actual mechanical position, which is not conducive to the stability and accuracy of the system's angle control. Summary of the invention

[0004] The present invention provides a Z signal updating method, device, computer equipment and storage medium of an incremental square wave encoder, so as to solve the problem that the existing Z signal updating method of the incremental square wave encoder cannot automatically update the usage value of the Z signal according to the rotation direction switching trigger condition, resulting in the usage value of the Z signal being non-unique and having deviations, which is not conducive to the high stability and high precision of the system's execution of angle control.

[0005] In a first aspect, a method for updating a Z signal of an incremental square wave encoder is provided, comprising: Accessing a first register, and reading from the first register a current count value and a previous count value of an incremental square wave encoder mounted on the shaft; Subtracting the previous count value from the current count value to obtain a difference between the current count value and the previous count value, and selecting the difference between the current count value and the previous count value as a change value of the incremental square wave encoder; Select the count value corresponding to the rising edge or falling edge of the Z signal as the capture value of the Z signal in the current cycle; When the change value is greater than the preset value, the capture value of the Z signal in the current cycle is selected as the current capture value; Obtain the capture value of the Z signal in the previous cycle of the current cycle, and select the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value; When the difference between the current capture value and the previous capture value meets the first condition or the second condition, the usage value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to the target angle according to the current capture value.

[0006] Further, the subtracting the previous count value from the current count value to obtain a difference between the current count value and the previous count value, and selecting the difference between the current count value and the previous count value as the change value of the incremental square wave encoder includes: Subtracting the previous count value from the current count value to obtain a difference between the current count value and the previous count value; A first selection instruction is obtained, and through the first selection instruction, a difference between the current count value and the previous count value is selected as a change value of the incremental square wave encoder.

[0007] Further, the selecting the count value corresponding to the rising edge or the falling edge of the Z signal as the captured value of the Z signal in the current cycle includes: In each cycle, the rotation direction of the incremental square wave encoder is obtained; When the rotation direction is positive, the count value corresponding to the falling edge of the Z signal is selected as the capture value of the Z signal in the current cycle. When the rotation direction is negative, the count value corresponding to the rising edge of the Z signal is selected as the capture value of the Z signal in the current cycle.

[0008] Further, when the change value is greater than a preset value, selecting the capture value of the Z signal in the current cycle as the current capture value includes: Read the second selection instruction in the preset file; Through the second selection instruction, when the change value is greater than the preset value, the capture value of the Z signal in the current cycle is selected as the current capture value.

[0009] Further, the acquiring of the capture value of the Z signal in the previous cycle of the current cycle, and selecting the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value, includes: Accessing the second register, and reading from the second register the captured value of the Z signal in the previous cycle of the current cycle; Select the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value.

[0010] Further, when the difference between the current capture value and the previous capture value satisfies the first condition or the second condition, the use value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to a target angle according to the current capture value, including: Subtracting the previous capture value from the current capture value to obtain a difference between the current capture value and the previous capture value; When the difference between the current capture value and the previous capture value meets the first condition or the second condition, the usage value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to the target angle according to the current capture value.

[0011] Further, when the difference between the current capture value and the previous capture value satisfies the first condition or the second condition, the use value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to a target angle according to the current capture value. Then, the Z signal updating method includes: A storage area is created, and the storage area is used to store the current captured value.

[0012] In a second aspect, a Z signal updating device for an incremental square wave encoder is provided, comprising: A reading module, used for accessing a first register, and reading a current count value and a previous count value of an incremental square wave encoder mounted on the rotating shaft from the first register; A first selection module is used to subtract the previous count value from the current count value to obtain a difference between the current count value and the previous count value, and select the difference between the current count value and the previous count value as a change value of the incremental square wave encoder; The second selection module is used to select the count value corresponding to the rising edge or falling edge of the Z signal as the capture value of the Z signal in the current cycle; A third selection module is used to select the capture value of the Z signal in the current cycle as the current capture value when the change value is greater than the preset value; An acquisition module is used to acquire a capture value of the Z signal in the previous cycle of the current cycle, and select the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value; An updating module is used to update the usage value of the Z signal to the current capture value when the difference between the current capture value and the previous capture value meets the first condition or the second condition, send the current capture value to a preset servo system, and control the servo system to control the shaft to rotate to a target angle according to the current capture value.

[0013] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned Z signal updating method when executing the computer program.

[0014] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned Z signal updating method are implemented.

[0015] The present application provides a Z signal updating method, device, computer equipment and storage medium of an incremental square wave encoder, accessing a first register, reading the current count value and the previous count value of the incremental square wave encoder installed on a rotating shaft from the first register; subtracting the previous count value from the current count value to obtain the difference between the current count value and the previous count value, and selecting the difference between the current count value and the previous count value as the change value of the incremental square wave encoder; selecting the count value corresponding to the rising edge or falling edge of the Z signal as the capture value of the Z signal in the current cycle; when the change value is greater than a preset value, selecting the capture value of the Z signal in the current cycle as the current capture value; obtaining the capture value of the Z signal in the previous cycle of the current cycle, and selecting the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value; when the difference between the current capture value and the previous capture value meets the first condition or the second condition, updating the use value of the Z signal to the current capture value , sending the current captured value to a preset servo system, controlling the servo system to control the shaft to rotate to a target angle according to the current captured value, the beneficial effects are in two aspects, on the one hand, when the difference between the current captured value and the previous captured value meets the first condition or the second condition, updating the usage value of the Z signal to the current captured value, sending the current captured value to the preset servo system, controlling the servo system to control the shaft to rotate to a target angle according to the current captured value, since the Z signal usage value selected according to the first condition or the second condition is a single and identical Z signal usage value, it is not affected by the rotation direction and the Z signal pulse width; on the other hand, sending the current captured value to the preset servo system, controlling the servo system to control the shaft to rotate to a target angle according to the current captured value, since the Z signal usage value is a single and identical stable value, it is beneficial to improve the consistency and reliability of controlling the shaft to rotate to a target angle. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0017] Figure 1 is a schematic diagram of an application environment of a Z signal updating method in one embodiment of the present invention; Figure 2 A schematic flow chart of a Z signal updating method provided by an embodiment of the present invention; Figure 3 is a schematic diagram of a Z signal provided by an embodiment of the present invention; Figure 4 is a data flow diagram provided by an embodiment of the present invention; Figure 5 yes Figure 2 A schematic flow chart of a specific implementation of step S26; Figure 6 is a structural schematic diagram of a Z signal updating device in one embodiment of the present invention; Figure 7 It is a structural diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION

[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0019] See also Figure 1 , Figure 1 FIG. 1 is a schematic diagram of an application environment of a Z signal updating method according to an embodiment of the present invention. The Z signal updating method provided by the embodiment of the present invention can be applied in the following embodiments: Figure 1 In an application environment, a client communicates with a server through a network.

[0020] The server accesses the first register through the client, and reads the current count value and the previous count value of the incremental square wave encoder installed on the shaft from the first register; Subtracting the previous count value from the current count value to obtain a difference between the current count value and the previous count value, and selecting the difference between the current count value and the previous count value as a change value of the incremental square wave encoder; Select the count value corresponding to the rising edge or falling edge of the Z signal as the capture value of the Z signal in the current cycle; When the change value is greater than the preset value, the capture value of the Z signal in the current cycle is selected as the current capture value; Obtain the capture value of the Z signal in the previous cycle of the current cycle, and select the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value; When the difference between the current capture value and the previous capture value meets the first condition or the second condition, the usage value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to the target angle according to the current capture value.

[0021] In the scheme implemented by the above-mentioned Z signal updating method, device, equipment and medium, the beneficial effects are in two aspects. On the one hand, when the difference between the current captured value and the previous captured value meets the first condition or the second condition, the usage value of the Z signal is updated to the current captured value, and the current captured value is sent to the preset servo system, and the servo system is controlled to control the rotation of the shaft to the target angle according to the current captured value. Since the Z signal usage value screened out according to the first condition or the second condition is a single and identical Z signal usage value, it is not affected by the rotation direction and the Z signal pulse width; on the other hand, the current captured value is sent to the preset servo system, and the servo system is controlled to control the rotation of the shaft to the target angle according to the current captured value. Since the Z signal usage value is a single and identical stable value, it is beneficial to improve the consistency and reliability of controlling the rotation of the shaft to the target angle.

[0022] The device running the client is referred to as a client device.

[0023] The device running the server is referred to as the server device.

[0024] Among them, client devices include but are not limited to smartphones, personal computers, Internet of Vehicles terminals, tablets and portable wearable devices.

[0025] The server device may be implemented by an independent server or a server cluster composed of multiple servers. The present invention is described in detail below through specific embodiments. Figure 2 , Figure 2 A flow chart of a Z signal updating method provided by an embodiment of the present invention includes the following steps: S21, accessing a first register, and reading a current count value and a previous count value of an incremental square wave encoder mounted on a rotating shaft from the first register; The current count value is the current count value.

[0026] The previous count value is the count value recorded last time.

[0027] Among them, the incremental square wave encoder refers to an incremental encoder whose output signal is a square wave.

[0028] Among them, the working principle of the incremental square wave encoder is based on the principle of photoelectric conversion. When the encoder shaft rotates, it will drive the internal grating or code disk to rotate, and then the rotational displacement will be converted into electrical signal output through the photoelectric conversion device. These electrical signals are usually square wave pulses, and the phase difference between the A and B groups of pulses is 90 degrees, so the direction of rotation can be easily determined.

[0029] S22, subtracting the previous count value from the current count value to obtain a difference between the current count value and the previous count value, and selecting the difference between the current count value and the previous count value as a change value of the incremental square wave encoder; Wherein, the subtracting the previous count value from the current count value to obtain the difference between the current count value and the previous count value, and selecting the difference between the current count value and the previous count value as the change value of the incremental square wave encoder includes: Subtracting the previous count value from the current count value to obtain a difference between the current count value and the previous count value; A first selection instruction is obtained, and through the first selection instruction, a difference between the current count value and the previous count value is selected as a change value of the incremental square wave encoder.

[0030] S23, selecting the count value corresponding to the rising edge or falling edge of the Z signal as the captured value of the Z signal in the current cycle; Among them, the count value corresponding to the rising edge or falling edge of the Z signal is selected as the capture value of the Z signal in the current cycle, including: In each cycle, the rotation direction of the incremental square wave encoder is obtained; When the rotation direction is positive, the count value corresponding to the falling edge of the Z signal is selected as the capture value of the Z signal in the current cycle. When the rotation direction is negative, the count value corresponding to the rising edge of the Z signal is selected as the capture value of the Z signal in the current cycle.

[0031] Wherein, in each cycle, the rotation direction of the incremental square wave encoder is obtained.

[0032] Among them, the rising edge is the instantaneous state of the digital signal changing from a low level to a high level, which marks a clear and important change point of the signal. In a digital circuit, a rising edge is formed when the voltage value of the signal increases rapidly from a logic low level to a logic high level in a short period of time, and this change is significant enough to be recognized by the circuit.

[0033] Among them, the falling edge is the instantaneous state of the digital signal changing from a high level to a low level, which also marks a key change point of the signal. In a digital circuit, when the voltage value of the signal drops rapidly from a logic high level to a logic low level in a short period of time, and this change is obvious enough to be detected by the circuit, a falling edge is formed.

[0034] Exemplarily, when the rotation direction is the positive direction, the count value corresponding to the falling edge of the Z signal is selected as the captured value of the Z signal in the current cycle, and when the rotation direction is the reverse direction, the count value corresponding to the rising edge of the Z signal is selected as the captured value of the Z signal in the current cycle, including: When the rotation direction is positive, the trigger edge of the Z signal sampling is configured to be the falling edge. When the falling edge of the Z signal appears, the count value corresponding to the falling edge of the Z signal is recorded by the timer, and the count value corresponding to the falling edge of the Z signal is selected as the capture value of the Z signal in the current cycle; When the rotation direction is in the reverse direction, the trigger edge of the Z signal sampling is configured to be the rising edge. When the rising edge of the Z signal occurs, the count value corresponding to the rising edge of the Z signal is recorded by the timer, and the count value corresponding to the rising edge of the Z signal is selected as the capture value of the Z signal in the current cycle.

[0035] Among them, during reversal, when the rising edge of the Z signal appears, the count value corresponding to the rising edge of the Z signal is recorded by the timer, and the count value corresponding to the rising edge of the Z signal is selected as the capture value of the Z signal in the current cycle; during forward rotation, when the falling edge of the Z signal appears, the count value corresponding to the falling edge of the Z signal is recorded by the timer, and the count value corresponding to the falling edge of the Z signal is selected as the capture value of the Z signal in the current cycle. In this way, there is no need to indiscriminately sample the entire pulse cycle of the Z signal, which not only ensures that the target required Z signal usage value is sampled, but also significantly improves the accuracy of the capture value of the Z signal in the current cycle.

[0036] See also Figure 3 , Figure 3 is a schematic diagram of a Z signal provided by an embodiment of the present invention, which is described in detail as follows: Figure 3 Includes forward and reverse rotation.

[0037] Among them, forward rotation means rotation in the positive direction, and reverse rotation means rotation in the reverse direction.

[0038] Among them, 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,... , represents the change of the count value of the incremental square wave encoder during forward rotation.

[0039] Among them, 0,9,8,7,6,5,4,3,2,1,0,9,8,7,6,5,4,3,2,1,0,..., represents the change of the count value when the incremental square wave encoder is reversed.

[0040] Among them, when the rotation direction is positive, that is, when rotating in the positive direction, the count value corresponding to the falling edge of the Z signal is selected as the capture value of the Z signal in the current cycle. At this time, the count value corresponding to the falling edge of the Z signal is 5, and the count value corresponding to the rising edge is 3.

[0041] Among them, when the rotation direction is the reverse direction, that is, when rotating in the reverse direction, the count value corresponding to the rising edge of the Z signal is selected as the capture value of the Z signal in the current cycle. At this time, the count value corresponding to the rising edge of the Z signal is 5, and the count value corresponding to the falling edge is 3.

[0042] S24, when the change value is greater than the preset value, selecting the capture value of the Z signal in the current cycle as the current capture value; Wherein, when the change value is greater than a preset value, selecting the capture value of the Z signal in the current cycle as the current capture value includes: Read the second selection instruction in the preset file; Through the second selection instruction, when the change value is greater than the preset value, the capture value of the Z signal in the current cycle is selected as the current capture value.

[0043] S25, obtaining the capture value of the Z signal in the previous cycle of the current cycle, and selecting the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value; The acquisition of the capture value of the Z signal in the previous cycle of the current cycle and the selection of the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value include: Accessing the second register, and reading from the second register the captured value of the Z signal in the previous cycle of the current cycle; Select the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value.

[0044] The first register and the second register are different registers.

[0045] S26, when the difference between the current capture value and the previous capture value meets the first condition or the second condition, the usage value of the Z signal is updated to the current capture value, the current capture value is sent to the preset servo system, and the servo system is controlled to control the shaft to rotate to the target angle according to the current capture value.

[0046] When the difference between the current capture value and the previous capture value satisfies the first condition or the second condition, the use value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to a target angle according to the current capture value, including: When the difference between the current captured value and the previous captured value meets the first condition and is taken for the first time, the use value of the Z signal is updated to the current captured value, the current captured value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to a target angle according to the current captured value; When the difference between the current captured value and the previous captured value meets the first condition and is not the first time the value is taken, determine whether the difference between the current captured value and the previous captured value is less than T / 2, and when the difference between the current captured value and the previous captured value is less than T / 2, update the use value of the Z signal to the current captured value, send the current captured value to a preset servo system, and control the servo system to control the shaft to rotate to a target angle according to the current captured value; When the difference between the current capture value and the previous capture value meets the second condition, the usage value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to the target angle according to the current capture value.

[0047] When the difference between the current captured value and the previous captured value meets the first condition, it means that the difference between the current captured value and the previous captured value is greater than 0. Among them, when the difference between the current captured value and the previous captured value meets the first condition and is the first time the value is taken, the usage value of the Z signal needs to be directly updated to the current captured value, and the current captured value is sent to the preset servo system. The servo system is controlled to control the shaft to rotate to the target angle according to the current captured value. This is to prevent the encoder from rotating in the same direction all the time after power-on, then the Z signal capture value will be a stable and unchanged value. If this value happens to be greater than T / 2, in order to prevent this value from being missed, when the difference meets the first condition and is the first time the value is taken, the current captured value needs to be taken once as the usage value of the Z signal.

[0048] When the difference between the current captured value and the previous captured value meets the first condition and is not the first time the value is taken, determine whether the difference between the current captured value and the previous captured value is less than T / 2. When the difference between the current captured value and the previous captured value is less than T / 2, update the usage value of the Z signal to the current captured value. The width of the Z signal pulse itself is a pulse less than T / 2. For the case where the difference is greater than T / 2, it is not screened under the first condition, but screened by the second condition.

[0049] Exemplarily, the first condition is Pdel>0, and the second condition is Pdel<-T / 2; The Pdel is the difference between the current captured value and the previous captured value, and T is the counting period.

[0050] When the difference between the current captured value and the previous captured value satisfies the first condition or the second condition, the process of updating the used value of the Z signal to the current captured value is described below by taking the incremental square wave encoder in forward rotation as an example for ease of explanation: For example, if the counting period of the incremental square wave encoder is T=10, the count value 0 to 9 changes periodically, such as Figure 3 shown.

[0051] Among them, 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,... , represents the change of the count value of the incremental square wave encoder during forward rotation.

[0052] Among them, when the current capture value is 5 and the previous capture value is the power-on initialization value 0, when the difference between 5 and 0 is greater than 0, it means that the difference between 5 and 0 meets the first condition, but does not meet the difference less than T / 2. At this time, if it is the first time to obtain the value, the use value of the Z signal is updated to 5. In this way, after power-on, even if the rotation direction remains unchanged and the capture value is always 5, we can get the correct, unique, and same use value 5. Among them, when the current capture value is 5 and the previous capture value is 3, when the difference between 5 and 3 is greater than 0, it means that the difference between 5 and 3 meets the first condition, and when the value is taken for the first time, the use value of the Z signal is updated to 5. When it is not the first time to take the value, the condition that the difference is less than T / 2 is also met, and the use value of the Z signal is also updated to 5.

[0053] Among them, when the current capture value is 3 and the previous capture value is 5, when the difference between 3 and 5 is less than 0, the first condition is not met. At the same time, the difference > -T / 2, the second condition is not met, and the usage value of the Z signal will be kept unchanged.

[0054] Among them, since T=10, -T / 2 is -5. When the current capture value is 0 and the previous capture value is 6, when the difference between 0 and 6 is less than -5, it means that the difference between 0 and 6 meets the second condition, and the usage value of the Z signal is updated to 0.

[0055] Among them, since T=10, -T / 2 is -5. When the current capture value is 1 and the previous capture value is 8, when the difference between 1 and 8 is less than -5, it means that the difference between 1 and 8 meets the second condition, and the usage value of the Z signal is updated to 1.

[0056] Among them, since T=10, -T / 2 is -5. When the current capture value is 2 and the previous capture value is 9, when the difference between 2 and 9 is less than -5, it means that the difference between 2 and 9 meets the second condition, and the usage value of the Z signal is updated to 2.

[0057] Among them, controlling the servo system to control the rotating shaft to rotate to the target angle according to the usage value means controlling the servo system to rotate the rotating shaft to the target angle according to the filtered usage value.

[0058] Among them, by continuously screening and updating the usage value of the Z signal, real-time correction of the current position can be achieved, which can effectively reduce the cumulative error caused by mechanical wear, improve the positioning accuracy, and enhance the reliability of positioning.

[0059] Wherein, when the difference between the current capture value and the previous capture value satisfies the first condition or the second condition, the use value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to a target angle according to the current capture value. Then, the Z signal updating method includes: A storage area is created, and the storage area is used to store the current captured value.

[0060] The usage value of the Z signal is referred to as the Z signal usage value for short.

[0061] In an embodiment of the present invention, the beneficial effects lie in two aspects. On the one hand, when the difference between the current captured value and the previous captured value meets the first condition or the second condition, the usage value of the Z signal is updated to the current captured value, and the current captured value is sent to a preset servo system, and the servo system is controlled to control the rotation of the shaft to the target angle according to the current captured value. Since the Z signal usage value screened out according to the first condition or the second condition is a single and identical Z signal usage value, it is not affected by the rotation direction and the Z signal pulse width. On the other hand, the current captured value is sent to a preset servo system, and the servo system is controlled to control the rotation of the shaft to the target angle according to the current captured value. Since the Z signal usage value is a single and identical stable value, it is beneficial to improve the consistency and reliability of controlling the rotation of the shaft to the target angle.

[0062] See also Figure 4 , Figure 4 It is a data flow diagram provided by an embodiment of the present invention, which is described in detail as follows: S401, subtract the previous count value from the current count value to obtain the change value of the incremental square wave encoder; S402, determine whether the change value has exceeded 3; if yes, execute S403, otherwise, execute S406; S403, obtaining the current capture value and the previous capture value, and determining whether the difference between the current capture value and the previous capture value satisfies the first condition or the second condition; if yes, executing S404, otherwise executing S405; S404, updating the usage value of the Z signal to the current captured value; S405, record the current capture value; S406, configuring the trigger edge for sampling the Z signal.

[0063] The usage value of the Z signal is referred to as the Z signal usage value for short.

[0064] Among them, configuring the trigger edge of Z signal sampling includes: When the rotation direction is the positive direction, the trigger edge of the Z signal sampling is configured to be the falling edge, and when the rotation direction is the reverse direction, the trigger edge of the Z signal sampling is configured to be the rising edge.

[0065] In the embodiment of the present invention, when the rotation direction is the positive direction, the trigger edge of the Z signal sampling is configured as the falling edge, and when the rotation direction is the reverse direction, the trigger edge of the Z signal sampling is configured as the rising edge. By switching the trigger edge according to the rotation direction, it is ensured that the count value corresponding to the required positive falling edge can be captured regardless of whether it is forward or reverse. In contrast, if the trigger edge is not switched according to the rotation direction, and the forward and reverse rotations are triggered by the same falling edge, then the forward and reverse triggers capture two different values, and it cannot be guaranteed that the Z signal usage value is a single, identical value, and the target angle that the system takes the Z trigger value as a reference point cannot guarantee consistency and reliability.

[0066] See also Figure 5 , Figure 5 yes Figure 2 A specific implementation flow diagram of step S26 is described in detail as follows: S51, subtracting the previous capture value from the current capture value to obtain a difference between the current capture value and the previous capture value; S52, when the difference between the current capture value and the previous capture value meets the first condition or the second condition, the usage value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to the target angle according to the current capture value.

[0067] In an embodiment of the present invention, when the difference between the current capture value and the previous capture value satisfies the first condition or the second condition, the usage value of the Z signal is updated to the current capture value, and the current capture value is sent to a preset servo system, and the servo system is controlled to control the rotation of the shaft to the target angle according to the current capture value. Since the screened Z signal usage value is a single, identical and stable value, it is beneficial to improve the consistency and reliability of controlling the rotation of the shaft to the target angle.

[0068] See also Figure 6 , Figure 6 FIG. 1 is a schematic diagram of a structure of a Z signal updating device in one embodiment of the present invention. Figure 6 As shown, the Z signal updating device includes a reading module 101, a first selection module 102, a second selection module 103, a third selection module 104, an acquisition module 105, and an updating module 106. The functional modules are described in detail as follows: A reading module 101 is used to access a first register, and read a current count value and a previous count value of an incremental square wave encoder installed on a rotating shaft from the first register; A first selection module 102 is used to subtract the previous count value from the current count value to obtain a difference between the current count value and the previous count value, and select the difference between the current count value and the previous count value as a change value of the incremental square wave encoder; The second selection module 103 is used to select the count value corresponding to the rising edge or falling edge of the Z signal as the capture value of the Z signal in the current cycle; A third selection module 104 is used to select the capture value of the Z signal in the current cycle as the current capture value when the change value is greater than a preset value; The acquisition module 105 is used to acquire the capture value of the Z signal in the previous cycle of the current cycle, and select the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value; The updating module 106 is used to update the usage value of the Z signal to the current capture value when the difference between the current capture value and the previous capture value meets the first condition or the second condition, send the current capture value to a preset servo system, and control the servo system to control the shaft to rotate to a target angle according to the current capture value.

[0069] In an embodiment of the present invention, the beneficial effects lie in two aspects. On the one hand, when the difference between the current captured value and the previous captured value meets the first condition or the second condition, the usage value of the Z signal is updated to the current captured value, and the current captured value is sent to a preset servo system, and the servo system is controlled to control the rotation of the shaft to the target angle according to the current captured value. Since the Z signal usage value screened out according to the first condition or the second condition is a single and identical Z signal usage value, it is not affected by the rotation direction and the Z signal pulse width. On the other hand, the current captured value is sent to a preset servo system, and the servo system is controlled to control the rotation of the shaft to the target angle according to the current captured value. Since the Z signal usage value is a single and identical stable value, it is beneficial to improve the consistency and reliability of controlling the rotation of the shaft to the target angle.

[0070] For the specific definition of the Z signal updating device, please refer to the definition of the Z signal updating method above, which will not be repeated here.

[0071] Each module in the above-mentioned Z signal updating device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0072] See also Figure 7 , Figure 71 is another structural diagram of a computer device in one embodiment of the present invention. In one embodiment, a computer device is provided. The computer device is a server device or a client device. The internal structure diagram thereof can be as shown in FIG. Figure 7 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external database. When the computer program is executed by the processor, the functions or steps of a Z signal update method of an incremental square wave encoder can be implemented.

[0073] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor.

[0074] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant description of the aforementioned method embodiment. In order to avoid repetition, they will not be described one by one here.

[0075] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.

[0076] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure to enable those skilled in the art to practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent only possible variations. Unless explicitly required, separate components and functions are optional, and the order of operations may vary. Parts and sub-samples of some embodiments may be included in or replace parts and sub-samples of other embodiments. Moreover, the terms used in this application are only used to describe the embodiments and are not used to limit the claims.

[0077] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of units can be only a logical function division, and there can be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some sub-samples can be ignored or not executed.

[0078] In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or units, which may be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, the functional units in the embodiments disclosed herein may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0079] The flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the 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. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and the block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.

Claims

1. A method for updating the Z signal of an incremental square wave encoder, characterized in that: include: Accessing a first register, and reading from the first register a current count value and a previous count value of an incremental square wave encoder mounted on the shaft; Subtracting the previous count value from the current count value to obtain a difference between the current count value and the previous count value, and selecting the difference between the current count value and the previous count value as a change value of the incremental square wave encoder; Select the count value corresponding to the rising edge or falling edge of the Z signal as the capture value of the Z signal in the current cycle; When the change value is greater than the preset value, the capture value of the Z signal in the current cycle is selected as the current capture value; Obtain the capture value of the Z signal in the previous cycle of the current cycle, and select the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value; When the difference between the current capture value and the previous capture value meets the first condition or the second condition, the usage value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to the target angle according to the current capture value.

2. The Z signal updating method according to claim 1, characterized in that: The step of subtracting the previous count value from the current count value to obtain a difference between the current count value and the previous count value, and selecting the difference between the current count value and the previous count value as a change value of the incremental square wave encoder includes: Subtracting the previous count value from the current count value to obtain a difference between the current count value and the previous count value; A first selection instruction is obtained, and through the first selection instruction, a difference between the current count value and the previous count value is selected as a change value of the incremental square wave encoder.

3. The Z signal updating method according to claim 1, characterized in that: The selecting the count value corresponding to the rising edge or the falling edge of the Z signal as the captured value of the Z signal in the current cycle includes: In each cycle, the rotation direction of the incremental square wave encoder is obtained; When the rotation direction is positive, the count value corresponding to the falling edge of the Z signal is selected as the capture value of the Z signal in the current cycle. When the rotation direction is negative, the count value corresponding to the rising edge of the Z signal is selected as the capture value of the Z signal in the current cycle.

4. The Z signal updating method according to claim 1, characterized in that: When the change value is greater than the preset value, selecting the capture value of the Z signal in the current cycle as the current capture value includes: Read the second selection instruction in the preset file; Through the second selection instruction, when the change value is greater than the preset value, the capture value of the Z signal in the current cycle is selected as the current capture value.

5. The Z signal updating method according to claim 1, characterized in that: The acquiring the captured value of the Z signal in the previous cycle of the current cycle, and selecting the captured value of the Z signal in the previous cycle of the current cycle as the previous captured value, includes: Accessing the second register, and reading from the second register the captured value of the Z signal in the previous cycle of the current cycle; Select the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value.

6. The Z signal updating method according to claim 1, characterized in that: When the difference between the current captured value and the previous captured value satisfies the first condition or the second condition, the use value of the Z signal is updated to the current captured value, the current captured value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to a target angle according to the current captured value, including: Subtracting the previous capture value from the current capture value to obtain a difference between the current capture value and the previous capture value; When the difference between the current capture value and the previous capture value meets the first condition or the second condition, the usage value of the Z signal is updated to the current capture value, the current capture value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to the target angle according to the current capture value.

7. The Z signal updating method according to claim 1, characterized in that: When the difference between the current captured value and the previous captured value satisfies the first condition or the second condition, the use value of the Z signal is updated to the current captured value, the current captured value is sent to a preset servo system, and the servo system is controlled to control the shaft to rotate to a target angle according to the current captured value. Then, the Z signal updating method includes: A storage area is created, and the storage area is used to store the current captured value.

8. A Z signal updating device for an incremental square wave encoder, characterized in that: include: A reading module, used for accessing a first register, and reading a current count value and a previous count value of an incremental square wave encoder mounted on the rotating shaft from the first register; A first selection module is used to subtract the previous count value from the current count value to obtain a difference between the current count value and the previous count value, and select the difference between the current count value and the previous count value as a change value of the incremental square wave encoder; The second selection module is used to select the count value corresponding to the rising edge or falling edge of the Z signal as the capture value of the Z signal in the current cycle; A third selection module is used to select the capture value of the Z signal in the current cycle as the current capture value when the change value is greater than the preset value; An acquisition module is used to acquire a capture value of the Z signal in the previous cycle of the current cycle, and select the capture value of the Z signal in the previous cycle of the current cycle as the previous capture value; An updating module is used to update the usage value of the Z signal to the current capture value when the difference between the current capture value and the previous capture value meets the first condition or the second condition, send the current capture value to a preset servo system, and control the servo system to control the shaft to rotate to a target angle according to the current capture value.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the Z signal updating method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the Z signal updating method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • System and method for monitoring output signals of an encoder

    CN103364022A

  • Permanent magnet motor rotor position calculation method

    CN104218865A

  • System method for servo motor position control

    CN104317253A

  • Micro-control unit, motor rotating speed measuring method and system, and storage medium

    CN114518782A

  • Motor position calibration method and system based on FPGA and single-chip microcomputer

    CN117748997A