Incremental square wave encoder z signal updating method, device, equipment and medium

By calculating the difference between the current and previous count values ​​in the incremental square wave encoder, selecting the rising edge or falling edge as the capture value according to the rotation direction, and updating the Z signal usage value, the problem of non-unique Z signal is solved, and the system's angle control stability and accuracy are improved.

CN119756440BActive Publication Date: 2025-10-17SHENZHEN V&T TECH
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing Z signal update method of the incremental square wave encoder cannot automatically switch the trigger condition according to the rotation direction, resulting in non-unique Z signal values, affecting the stability and accuracy of the system angle control.

Method used

By accessing the register to obtain the current and previous count values, calculating the difference, selecting the count value corresponding to the rising or falling edge as the capture value, and updating the Z signal usage value when the difference meets the conditions, the current capture value is sent to the servo system to control the shaft to rotate to the target angle.

Benefits of technology

The singleness and stability of the Z signal usage value are achieved, the consistency and reliability of the shaft rotating to the target angle are improved, the cumulative error caused by mechanical wear is reduced, and the positioning accuracy and reliability are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119756440B_ABST
    Figure CN119756440B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of square wave encoder, and discloses a Z signal updating method, device and equipment of an incremental square wave encoder and a medium, the method comprising: selecting the difference 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 a rising edge or a falling edge of the Z signal as a capture value of the Z signal in a current period; when the change value is greater than a preset value, selecting the 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; when the difference between the current capture value and the previous capture value satisfies a first condition or a second condition, updating a 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 rotate a rotating shaft to a target angle according to the current capture value. The present application can automatically screen out a single and same Z signal use value, which is conducive to improving the stability and control precision of system control.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of square wave encoder, and particularly relates to a Z signal updating method, device and equipment of an incremental square wave encoder and a medium. BACKGROUND

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

[0003] However, the Z signal updating method of the existing incremental square wave encoder adopts the capture input function of the timer, and the capture condition cannot be automatically switched according to the counting direction (increment or decrement) of the encoder. When the Z pulse width is relatively large, the use values of the Z signal in the forward rotation and the reverse rotation of the encoder are different. The larger the width of the Z signal pulse is, the greater the deviation of the two use values is. When the Z position value is used as a reference point for angular offset motion, the same position is determined in the forward rotation and the reverse rotation, and the actual mechanical position deviates, which is not conducive to the stability and precision of the system in performing angular control. SUMMARY

[0004] The present application provides a Z signal updating method, device, computer equipment and storage medium of an incremental square wave encoder, to solve the problem that the Z signal updating method of the existing incremental square wave encoder cannot automatically switch the trigger condition to update the use value of the Z signal according to the rotation direction, resulting in that the use value of the Z signal is not unique and deviates, which is not conducive to the high stability and high precision of the system in performing angular control.

[0005] In a first aspect, a Z signal updating method of an incremental square wave encoder is provided, comprising:

[0006] Accessing a first register, and reading a current counting value and a previous counting value of an incremental square wave encoder installed on a rotating shaft from the first register;

[0007] Subtracting the previous counting value from the current counting value to obtain a difference value of the current counting value and the previous counting value, and selecting the difference value of the current counting value and the previous counting value as a change value of the incremental square wave encoder;

[0008] Selecting a counting value corresponding to a rising edge or a falling edge of a Z signal as a capture value of the Z signal in a current period;

[0009] When the change value is greater than a preset value, selecting the capture value of the Z signal in the current period as a current capture value;

[0010] acquire a capture value of the Z signal in a previous cycle of a current cycle, and select the capture value of the Z signal in the previous cycle of the current cycle as a previous capture value;

[0011] when a difference between the current capture value and the previous capture value satisfies a first condition or a second condition, update a use value of the Z signal as the current capture value, send the current capture value to a preset servo system, and control the servo system to rotate the rotating shaft to a target angle according to the current capture value.

[0012] Further, the current count value is subtracted from the previous count value to obtain a difference between the current count value and the previous count value, and the difference between the current count value and the previous count value is selected as the change value of the incremental square wave encoder, including:

[0013] the current count value is subtracted from the previous count value to obtain a difference between the current count value and the previous count value;

[0014] a first selection instruction is acquired, and the difference between the current count value and the previous count value is selected as the change value of the incremental square wave encoder through the first selection instruction.

[0015] Further, the count value corresponding to the rising edge or the falling edge of the Z signal is selected as the capture value of the Z signal in the current cycle, including:

[0016] the rotating direction of the incremental square wave encoder is acquired every cycle;

[0017] when the rotating direction is a 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, and when the rotating direction is a negative 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.

[0018] Further, when the change value is greater than a preset value, the capture value of the Z signal in the current cycle is selected as a current capture value, including:

[0019] a second selection instruction in a preset file is read;

[0020] when the change value is greater than a preset value, the capture value of the Z signal in the current cycle is selected as a current capture value through the second selection instruction.

[0021] Further, the capture value of the Z signal in a previous cycle of a current cycle is acquired, and the capture value of the Z signal in the previous cycle of the current cycle is selected as a previous capture value, including:

[0022] a second register is accessed, and the capture value of the Z signal in the previous cycle of the current cycle is read from the second register.

[0023] The capture value of the Z signal in the current cycle is selected as the previous capture value in the last cycle.

[0024] Further, when the difference between the current capture value and the previous capture value meets 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 rotate the rotating shaft to a target angle according to the current capture value.

[0025] The difference between the current capture value and the previous capture value is obtained by subtracting the previous capture value from the current capture value.

[0026] When the difference between the current capture value and the previous capture value meets 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 rotate the rotating shaft to a target angle according to the current capture value.

[0027] Further, after the Z signal updating method, when the difference between the current capture value and the previous capture value meets 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 rotate the rotating shaft to a target angle according to the current capture value.

[0028] A storage area is created, and the current capture value is stored in the storage area.

[0029] In a second aspect, a Z signal updating device of an incremental square wave encoder is provided, which includes:

[0030] A reading module is configured 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.

[0031] A first selection module is configured 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.

[0032] A second selection module is configured to select a count value corresponding to a rising edge or a falling edge of a Z signal as a capture value of the Z signal in a current cycle.

[0033] A third selection module is configured to select a capture value of the Z signal in a current cycle as a current capture value when the change value is greater than a preset value.

[0034] 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;

[0035] An update 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 rotation of the shaft to the target angle according to the current capture value.

[0036] In a third aspect, a computer device is provided, comprising 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.

[0037] 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.

[0038] The present application provides a Z signal updating method, device, computer equipment and storage medium of an incremental square wave encoder, which accesses a first register, and reads the current count value and the previous count value of the incremental square wave encoder installed on the rotating shaft from the first register; subtracts the previous count value from the current count value to obtain the difference between the current count value and the previous count value, and selects the difference between the current count value and the previous count value as the change value of the incremental square wave encoder; selects 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, selects the capture value of the Z signal in the current cycle as the current capture value; obtains the capture value of the Z signal in the previous cycle of the current cycle, and selects 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, updates the usage 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 the 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 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, sending the current captured value to the preset servo system, controlling the servo system to control the shaft to rotate 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 shaft to rotate to the target angle. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0040] Figure 1 This is a schematic diagram of an application environment of a Z signal updating method according to an embodiment of the present invention;

[0041] Figure 2 A schematic flow chart of a Z signal updating method provided by one embodiment of the present invention;

[0042] Figure 3is a schematic diagram of a Z signal provided by an embodiment of the present application;

[0043] Figure 4 is a data flow diagram provided by an embodiment of the present application;

[0044] Figure 5 is Figure 2 is a specific implementation flowchart of step S26 in the method;

[0045] Figure 6 is a structural diagram of a Z signal updating device in an embodiment of the present application;

[0046] Figure 7 is a structural diagram of a computer device in an embodiment of the present application. DETAILED DESCRIPTION

[0047] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0048] Please refer to Figure 1 , Figure 1 is an application environment schematic diagram of a Z signal updating method in an embodiment of the present application. The Z signal updating method provided by the embodiments of the present application can be applied in an application environment as shown in Figure 1 , wherein a client communicates with a server through a network.

[0049] The server accesses a first register through the client, and reads a current count value and a previous count value of an incremental square wave encoder installed on a rotating shaft from the first register.

[0050] The current count value is subtracted from the previous count value to obtain a difference value of the current count value and the previous count value, and the difference value of the current count value and the previous count value is selected as a change value of the incremental square wave encoder.

[0051] A count value corresponding to a rising edge or a falling edge of the Z signal is selected as a capture value of the Z signal in a current period.

[0052] When the change value is greater than a preset value, the capture value of the Z signal in the current period is selected as a current capture value.

[0053] A capture value of the Z signal in a previous period of the current period is obtained, and the capture value of the Z signal in the previous period of the current period is selected as a previous capture value.

[0054] When the difference between the current capture value and the previous capture value meets 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 rotate the rotating shaft to a target angle according to the current capture value.

[0055] In the scheme implemented by the above 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 capture value and the previous capture value meets 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 rotate the rotating shaft to a target angle according to the current capture value. Since the Z signal use value screened according to the first condition or the second condition is a single and same Z signal use value, it is not affected by the rotation direction and the Z signal pulse width. On the other hand, the current capture value is sent to a preset servo system, and the servo system is controlled to rotate the rotating shaft to a target angle according to the current capture value. Since the Z signal use value is a single and same stable value, it is beneficial to improve the consistency and reliability of controlling the rotating shaft to rotate to the target angle.

[0056] Among them, the device running the client is referred to as: client device.

[0057] Among them, the device running the server is referred to as: server device.

[0058] Among them, the client device includes but is not limited to a smart phone, a personal computer, a vehicle Internet of Things terminal, a tablet computer and a portable wearable device.

[0059] Among them, the server device can be realized by an independent server or a server cluster composed of multiple servers. The application will be described in detail through specific embodiments. Please refer to Figure 2 , Figure 2 A flowchart of a Z signal updating method provided by an embodiment of the application includes the following steps:

[0060] S21, accessing a first register, reading a current count value and a previous count value of an incremental square wave encoder installed on a rotating shaft from the first register;

[0061] Among them, the current count value is the current count value.

[0062] Among them, the previous count value is the count value recorded last time.

[0063] Among them, the incremental square wave encoder refers to an incremental encoder with a square wave output signal.

[0064] The working principle of the incremental square wave encoder is based on photoelectric conversion principle. When the encoder rotating shaft rotates, the internal grating or code disc rotates, and then the rotating displacement is converted into electrical signal output through the photoelectric conversion device. These electrical signals are usually square wave pulses, and the phase difference between A and B two groups of pulses is 90 degrees, so that the rotating direction can be easily judged.

[0065] S22, subtracting the previous count value from the current count value to obtain a difference value of the current count value and the previous count value, and selecting the difference value of the current count value and the previous count value as the change value of the incremental square wave encoder;

[0066] The method further includes:

[0067] Subtracting the previous count value from the current count value to obtain a difference value of the current count value and the previous count value;

[0068] Obtaining a first selection instruction, and selecting the difference value of the current count value and the previous count value as the change value of the incremental square wave encoder through the first selection instruction.

[0069] S23, selecting the count value corresponding to the rising edge or the falling edge of the Z signal as the capture value of the Z signal in the current period;

[0070] The method further includes:

[0071] In each cycle, the rotating direction of the incremental square wave encoder is obtained.

[0072] When the rotating direction is a 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 period, and when the rotating direction is a negative 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 period.

[0073] In each cycle, the rotating direction of the incremental square wave encoder is obtained.

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

[0075] Wherein, the falling edge is the instantaneous state of the digital signal from high level to low level transition, which also marks a key change point of the signal. In digital circuit, when the voltage value of the signal rapidly decreases from logic high level to logic low level in a short time, and the change is obvious enough to be detected by the circuit, a falling edge is formed.

[0076] 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 capture value of the Z signal in the current period, and when the rotation direction is the negative 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 period, comprising:

[0077] 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 falling edge of the Z signal occurs, 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 period.

[0078] When the rotation direction is the negative direction, the trigger edge of the Z signal sampling is configured as the rising edge, and 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 period.

[0079] Wherein, when the rotation direction is 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 period, and when the rotation direction is the negative 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 period, comprising:

[0080] Please refer to Figure 3 , Figure 3 is the schematic diagram of the Z signal provided by an embodiment of the application, which is described in detail as follows:

[0081] Figure 3 Including positive rotation and negative rotation.

[0082] Wherein, the positive rotation is the positive direction rotation. Wherein, the negative rotation is the negative direction rotation.

[0083] Wherein, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,..., indicates the change of the count value of the incremental square wave encoder when rotating in the positive direction.

[0084] Wherein, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, …, indicates the change of the count value when the incremental square wave encoder is reversed.

[0085] Wherein, when the rotation direction is the positive direction, i.e. positive direction rotation, the falling edge of the Z signal is selected as the capture value of the Z signal in the current period, at this time, the falling edge of the Z signal corresponds to the count value 5, and the rising edge corresponds to the count value 3.

[0086] Wherein, when the rotation direction is the reverse direction, i.e. reverse direction rotation, the rising edge of the Z signal is selected as the capture value of the Z signal in the current period, at this time, the rising edge of the Z signal corresponds to the count value 5, and the falling edge corresponds to the count value 3.

[0087] S24, when the change value is greater than the preset value, the capture value of the Z signal in the current period is selected as the current capture value;

[0088] Wherein, when the change value is greater than the preset value, the capture value of the Z signal in the current period is selected as the current capture value, comprising:

[0089] Reading the second selection instruction in the preset file;

[0090] 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 period is selected as the current capture value.

[0091] S25, obtaining the capture value of the Z signal in the previous period of the current period, and selecting the capture value of the Z signal in the previous period of the current period as the previous capture value;

[0092] Wherein, obtaining the capture value of the Z signal in the previous period of the current period, and selecting the capture value of the Z signal in the previous period of the current period as the previous capture value, comprising:

[0093] Accessing the second register, and reading the capture value of the Z signal in the previous period of the current period from the second register;

[0094] Selecting the capture value of the Z signal in the previous period of the current period as the previous capture value.

[0095] Wherein, the first register and the second register are different registers.

[0096] S26, 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 capture value to the preset servo system, and controlling the servo system to rotate the shaft to the target angle according to the current capture value.

[0097] when the difference between the current capture value and the previous capture value satisfies the first condition or the second condition, updating a use value of the Z signal to the current capture value, sending the current capture value to a preset servo system, and controlling the servo system to rotate the rotating shaft to a target angle according to the current capture value.

[0098] when the difference between the current capture value and the previous capture value satisfies the first condition and is a first time, updating a use value of the Z signal to the current capture value, sending the current capture value to a preset servo system, and controlling the servo system to rotate the rotating shaft to a target angle according to the current capture value.

[0099] when the difference between the current capture value and the previous capture value satisfies the first condition and is not a first time, determining whether the difference between the current capture value and the previous capture value is less than T / 2, when the difference between the current capture value and the previous capture value is less than T / 2, updating a use value of the Z signal to the current capture value, sending the current capture value to a preset servo system, and controlling the servo system to rotate the rotating shaft to a target angle according to the current capture value.

[0100] when the difference between the current capture value and the previous capture value satisfies the second condition, updating a use value of the Z signal to the current capture value, sending the current capture value to a preset servo system, and controlling the servo system to rotate the rotating shaft to a target angle according to the current capture value.

[0101] when the difference between the current capture value and the previous capture value satisfies the first condition, indicating that the difference between the current capture value and the previous capture value is greater than 0,

[0102] wherein, when the difference between the current capture value and the previous capture value satisfies the first condition and is a first time, the use value of the Z signal needs to be directly updated to the current capture value, the current capture value needs to be sent to a preset servo system, and the servo system needs to be controlled to rotate the rotating shaft to a target angle according to the current capture value, in order to prevent the Z signal capture value from being a stable value if the encoder is always rotated in the same direction after power-on, and in order to prevent the value from being missed if the value is exactly greater than T / 2.

[0103] When the difference between the current capture value and the previous capture value meets the first condition and is not the first time, it is determined whether the difference between the current capture value and the previous capture value is less than T / 2, and when the difference between the current capture value and the previous capture value is less than T / 2, the use value of the Z signal is updated to the current capture value, and the width of the Z signal pulse itself is a pulse less than T / 2, and for the case that the difference is greater than T / 2, the first condition is not screened, and the second condition is screened.

[0104] Exemplarily, the first condition is Pdel>0, and the second condition is Pdel<-T / 2.

[0105] The Pdel is the difference between the current capture value and the previous capture value, and the T is a counting period.

[0106] When the difference between the current capture value and the previous capture value meets the first condition or the second condition, the use value of the Z signal is updated to the current capture value, and for the convenience of description, the positive rotation of the incremental square wave encoder is taken as an example, and the following is taken as an example:

[0107] For example, the counting period T of the incremental square wave encoder is 10, and the counting value periodically changes from 0 to 9, as shown in the following table: Figure 3

[0108] In the table, 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 counting value when the incremental square wave encoder rotates in the positive direction.

[0109] In the table, 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 indicates that the difference between 5 and 0 meets the first condition, but does not meet the condition that the difference is less than T / 2, and at this time, if it is the first time, the use value of the Z signal is updated to 5. In this way, after power-on, even if the rotation direction does not change, the capture value is always 5, and we can obtain the correct, unique and same use value 5.

[0110] In the table, 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 indicates that the difference between 5 and 3 meets the first condition, and when it is the first time, the use value of the Z signal is updated to 5. When it is not the first time, it also meets the condition that the difference is less than T / 2, and the use value of the Z signal will also be updated to 5.

[0111] In the table, 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, it does not meet the first condition, and at the same time, the difference is greater than -T / 2, and it also does not meet the second condition, and the use value of the Z signal will not be updated.

[0112] ​Wherein, since T=10, -T / 2 is -5, when the current capture value is 0 and the previous capture value is 6, if the difference between 0 and 6 is less than -5, it means that the difference between 0 and 6 satisfies the second condition, and the use value of the Z signal is updated to 0.

[0113] Wherein, since T=10, -T / 2 is -5, when the current capture value is 1 and the previous capture value is 8, if the difference between 1 and 8 is less than -5, it means that the difference between 1 and 8 satisfies the second condition, and the use value of the Z signal is updated to 1.

[0114] Wherein, since T=10, -T / 2 is -5, when the current capture value is 2 and the previous capture value is 9, if the difference between 2 and 9 is less than -5, it means that the difference between 2 and 9 satisfies the second condition, and the use value of the Z signal is updated to 2.

[0115] Wherein, the control of the servo system according to the use value to control the rotation of the shaft to the target angle is to control the servo system to rotate the shaft to the target angle according to the use value screened out.

[0116] Wherein, by continuously screening and updating the use value of the Z signal, real-time correction of the current position can be realized, which can effectively reduce the cumulative error caused by mechanical wear, improve the positioning accuracy, and enhance the positioning reliability.

[0117] Wherein, after the Z signal updating method, 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 the preset servo system, and the servo system is controlled to rotate the shaft to the target angle according to the current capture value.

[0118] Creating a storage area, and storing the current capture value in the storage area.

[0119] Wherein, the use value of the Z signal is referred to as the use value of the Z signal.

[0120] In the embodiment of the present application, the beneficial effects are in two aspects. On the one hand, when the difference between the current capture value and the previous capture value meets 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 the preset servo system, and the servo system is controlled to rotate the rotating shaft to the target angle according to the current capture value. Since the use value of the Z signal screened according to the first condition or the second condition is a single and same use value of the Z signal, it is not affected by the rotation direction and the pulse width of the Z signal. On the other hand, the current capture value is sent to the preset servo system, and the servo system is controlled to rotate the rotating shaft to the target angle according to the current capture value. Since the use value of the Z signal is a single and same stable value, it is beneficial to improve the consistency and reliability of controlling the rotating shaft to rotate to the target angle.

[0121] Please refer to Figure 4 , Figure 4 is a data flowchart provided by an embodiment of the present application, which is described in detail as follows:

[0122] S401, subtracting the previous count value from the current count value to obtain the change value of the incremental square wave encoder;

[0123] S402, determining whether the change value has exceeded 3. If yes, performing S403, otherwise, performing S406;

[0124] 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 meets the first condition or the second condition. If yes, performing S404, otherwise, performing S405;

[0125] S404, updating the use value of the Z signal to the current capture value;

[0126] S405, recording the current capture value;

[0127] S406, configuring the trigger edge of the Z signal sampling.

[0128] The use value of the Z signal is referred to as the use value of the Z signal.

[0129] The configuring the trigger edge of the Z signal sampling comprises:

[0130] When the rotation direction is the positive direction, the trigger edge of the Z signal sampling is the falling edge, and when the rotation direction is the negative direction, the trigger edge of the Z signal sampling is the rising edge.

[0131] In the embodiment of the present application, when the rotation direction is the positive direction, the trigger edge of the Z signal sampling is the falling edge, and when the rotation direction is the reverse direction, the trigger edge of the Z signal sampling is the rising edge. By switching the trigger edge according to the rotation direction, it is ensured that the required count value corresponding to the positive rotation falling edge can be captured whether the rotation is positive or reverse. In contrast, if the trigger edge is not switched according to the rotation direction, the positive rotation and the reverse rotation are triggered by the same falling edge, and the positive rotation and the reverse rotation trigger capture two different values, so it cannot be ensured that the Z signal uses a single and same value, and the target angle of the system using the Z trigger value as the reference point cannot be ensured to be consistent and reliable.

[0132] Please refer to Figure 5 , Figure 5 is Figure 2 a specific implementation flowchart of step S26 in

[0133] S51, subtracting the previous capture value from the current capture value to obtain the difference between the current capture value and the previous capture value;

[0134] S52, 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 capture value to a preset servo system, and controlling the servo system to rotate the shaft to a target angle according to the current capture value.

[0135] In the embodiment of the present application, when the difference between the current capture value and the previous capture value meets 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 rotate the shaft to a target angle according to the current capture value. Since the screened Z signal use value is a single and same stable value, it is beneficial to improve the consistency and reliability of controlling the shaft to rotate to the target angle.

[0136] Please refer to Figure 6 , Figure 6 is a structural diagram of a Z signal updating device in an embodiment of the present application, as shown in Figure 6 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 functions of each module are described in detail as follows.

[0137] The reading module 101 is configured to access a first register and read the current count value and the previous count value of an incremental square wave encoder installed on a shaft from the first register.

[0138] The first selection module 102 is configured to subtract the previous count value from the current count value to obtain a difference value of the current count value and the previous count value, and select the difference value of the current count value and the previous count value as a change value of the incremental square wave encoder.

[0139] The second selection module 103 is configured to select a count value corresponding to a rising edge or a falling edge of the Z signal as a capture value of the Z signal in a current period.

[0140] The third selection module 104 is configured to select the capture value of the Z signal in the current period as a current capture value when the change value is greater than a preset value.

[0141] The acquisition module 105 is configured to acquire a capture value of the Z signal in a previous period of the current period, and select the capture value of the Z signal in the previous period of the current period as a previous capture value.

[0142] The update module 106 is configured to update a use value of the Z signal to the current capture value when a difference value of the current capture value and the previous capture value satisfies a first condition or a second condition, send the current capture value to a preset servo system, and control the servo system to rotate the rotating shaft to a target angle according to the current capture value.

[0143] In the embodiment of the present application, the beneficial effects are in two aspects. On the one hand, when the difference value of 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 the preset servo system, and the servo system is controlled to rotate the rotating shaft to the target angle according to the current capture value. Since the use value of the Z signal screened according to the first condition or the second condition is a single and same use value of the Z signal, the use value is not affected by the rotation direction and the pulse width of the Z signal. On the other hand, the current capture value is sent to the preset servo system, and the servo system is controlled to rotate the rotating shaft to the target angle according to the current capture value. Since the use value of the Z signal is a single and same stable value, the consistency and reliability of the control of the rotating shaft to the target angle are improved.

[0144] The specific limitation of the Z signal updating device can be referred to the limitation of the Z signal updating method in the above, which will not be repeated here.

[0145] The above-mentioned modules in the Z signal updating device can be all or partially realized by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to the above-mentioned modules.

[0146] Please refer to Figure 7 , Figure 7 is another structural schematic diagram of a computer device in an embodiment of the present application. In an embodiment, a computer device is provided, which is a server device or a client device, and an internal structure diagram of the computer device can be as shown in Figure 7 . The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. The processor of the computer device is configured 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 running the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is configured to communicate with an external database. The computer program, when executed by the processor, can implement the functions or steps of the Z signal updating method of the incremental square wave encoder.

[0147] In an embodiment, a computer device is provided, which includes a memory, a processor and a computer program stored in the memory and executable on the processor.

[0148] It should be noted that the functions or steps that can be achieved by the computer readable storage medium or the computer device described above can be referred to the related description of the method embodiments, and will not be described again here to avoid repetition.

[0149] The processor described above can be a general processor, including a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP) and the like; and can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0150] The above description and drawings suffice to fully enable one skilled in the art to practice the embodiments of the present disclosure. Other embodiments can include structural, logical, electrical, process, and other changes. The embodiments are merely representative of the possible variations. Individual components and functions are optional unless explicitly required, and the order of operations can be varied. Portions and sub-combinations of some embodiments can be included or substituted into other embodiments. Also, the terminology used in this application is for the purpose of describing the embodiments and is not intended to be limiting on the claims.

[0151] In the embodiments disclosed herein, the disclosed methods, products (including but not limited to devices, apparatuses, etc.) can be implemented in other ways. For example, the above-described device embodiments are merely illustrative, for example, the division of units can be merely a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some sub-combinations can be omitted or not executed.

[0152] In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms. The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. Some or all of the units can be selected to implement the embodiments according to actual needs. In addition, the functional units in the embodiments of the present disclosure can be integrated in one processing unit, or each unit can be a physically independent unit, or two or more units can be integrated in one unit.

[0153] The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other processing device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other processing device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.

Claims

1. A Z signal updating method for 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 captured value of the Z signal in the current cycle; When the change value is greater than the preset value, the captured value of the Z signal in the current cycle is selected as the current captured value; Obtain the captured value of the Z signal in the previous cycle of the current cycle, and select the captured value of the Z signal in the previous cycle of the current cycle as the previous captured value; When the difference between the current captured value and the previous captured value satisfies the first condition or the second condition, updating the used value of the Z signal to the current captured value, sending the current captured value to a preset servo system, and controlling the servo system to rotate the shaft to a target angle according to the current captured value; The step of selecting a count value corresponding to a rising edge or a falling edge of the Z signal as a 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.

2. The Z signal updating method according to claim 1, wherein: 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 a difference between the current count value and the previous count value is selected as a change value of the incremental square wave encoder through the first selection instruction.

3. The Z signal updating method according to claim 1, wherein: When the change value is greater than a preset value, selecting the captured value of the Z signal in the current period as the current captured 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.

4. The Z signal updating method according to claim 1, wherein: 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; The captured value of the Z signal in the previous cycle of the current cycle is selected as the previous captured value.

5. The Z signal updating method according to claim 1, wherein: When the difference between the current captured value and the previous captured value satisfies the first condition or the second condition, updating the used value of the Z signal to the current captured value, sending the current captured value to a preset servo system, and controlling the servo system to rotate the shaft 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, and the current capture value is sent to the preset servo system, which controls the servo system to control the shaft to rotate to the target angle according to the current capture value.

6. The Z signal updating method according to claim 1, wherein: When the difference between the current captured value and the previous captured value satisfies the first condition or the second condition, the used 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 rotate the shaft to a target angle according to the current captured value. The Z signal updating method includes: A storage area is created, and the storage area is used to store the current captured value.

7. A Z signal updating device for an incremental square wave encoder, characterized in that: include: A reading module, configured to access a first register and read 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, configured 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 configured to select a captured value of the Z signal in the current period as a current captured value when the change value is greater than a 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, configured to update the used value of the Z signal to the current captured value when the difference between the current captured value and the previous captured value satisfies a first condition or a second condition, send the current captured value to a preset servo system, and control the servo system to rotate the shaft to a target angle according to the current captured value; The step of selecting a count value corresponding to a rising edge or a falling edge of the Z signal as a 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.

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

9. 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 6 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