Encoder, encoding method and chip
Patent Information
- Application Number
- CN202311834224.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-27
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-12-27
AI Technical Summary
[0004]本发明实施例提供一种编码器、编码方法及芯片,以解决相关技术中采用软件工具和算法实现增量式编码器的方案使用门槛较高的技术问题
[0029]In the encoder, encoding method, and chip implementation scheme provided above, the encoder obtains the incremental modulation position by modulating the input position with the number of lines through the line modulation module. The target position update module maintains the current target position unchanged or updates the incremental modulation position to the current target position. The direction determination module determines the step difference based on the current target position and the self-position. The position adjustment direction is determined based on the step difference and the preset difference commutation value. The self-position update module updates the self-position according to the position adjustment direction or the current target position to obtain the updated position. The encoder output control module determines the output signal based on the first bit and the zero bit of the updated position, and at least one of the following: all bits of the updated position and the counting output parameters. The counting output parameters include the B-phase output value of the previous cycle and the position adjustment direction. This encoder provides a novel encoder implementation method. The implementation process is simple, easy to operate, and has a low threshold for use.
Smart Images

Figure CN117906647B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of incremental encoder technology, and more particularly to an encoder, encoding method, and chip. Background Technology
[0002] An incremental encoder is a sensor that converts rotational displacement into periodic electrical signals, and then converts these periodic electrical signals into digital pulse outputs. The number of pulses represents the magnitude of the displacement, and the output is a set of pulse signals corresponding to angular displacement. It can provide accurate displacement measurement, speed monitoring, and angle control information, playing an important role in improving production efficiency and quality.
[0003] Due to its advantages such as durability, shock resistance, vibration resistance, resistance to interference, high precision, and ease of use, incremental encoders have a wide range of applications, such as in the position control of motors. Common incremental encoders output A / B phase quadrature signals and the Z-phase zero-point signal. The position control field also has a need for encoding high-speed counters. However, the implementation of incremental encoders in related technologies often relies on software tools and algorithms, requiring a certain level of hardware design and programming skills, making them relatively difficult to use. Summary of the Invention
[0004] This invention provides an encoder, encoding method, and chip to address the technical problem that the use of software tools and algorithms to implement incremental encoders in related technologies has a high barrier to entry.
[0005] This invention provides an encoder comprising: a line number modulation module for acquiring an input position and multiplying the input position by a preset line number modulation multiple to obtain an incremental modulation position; a target position update module for maintaining the current target position unchanged or updating the current target position to the incremental modulation position; a direction determination module for determining a step difference based on the current target step number of the current target position and the existing step number of the existing position, and determining a position adjustment direction based on the step difference and a preset difference reversal value; an existing position update module for updating the existing position according to the position adjustment direction or the current target position to obtain an updated position; and an encoder output control module for determining an output signal based on output reference data, wherein the output reference data includes the first bit of the updated position, the zero bit of the updated position, and at least one of the following: all bits of the updated position and a counting output parameter, wherein the counting output parameter includes the B-phase output value of the previous cycle and the position adjustment direction.
[0006] In one embodiment of the present invention, the encoder further includes a synchronization position management module, which includes at least one of an immediate update module and a delayed update module, wherein: the immediate update module is used to generate a synchronization valid signal after receiving an update instruction when the immediate update module is in an active state, so as to trigger the self-position update module to update the self-position to the current target position; the delayed update module is used to generate a synchronization valid signal after receiving an update instruction when the delayed update module is in an active state, if the line number modulation module obtains a new incremental modulation position and the target position update module determines the new incremental modulation position as the new current target position, so as to trigger the self-position update module to update the self-position to the new current target position; if the synchronization position management module includes an immediate update module and a delayed update module, at the same time, the immediate update module is in an active state or the delayed update module is in an active state.
[0007] In one embodiment of the present invention, the synchronous position management module further includes an enable control module, which is used to receive a status command to configure the immediate update module to be in an active state or the delayed update module to be in an active state.
[0008] In one embodiment of the present invention, the direction determination module includes a step difference determination module and a position adjustment direction determination module, wherein:
[0009] The step difference determination module is used to determine the step difference as the difference between the current target step number and the available step number if the current target step number is greater than or equal to the available step number, and to determine the step difference as the sum of the preset maximum step number and the current target step number as the temporary step number if the current target step number is less than the available step number. The preset maximum step number is determined based on the product of the preset line number modulation multiple and the maximum line number of the input position.
[0010] The position adjustment direction determination module is used to determine the position adjustment direction as forward rotation if the current target step count is greater than the available step count and the step count difference is less than or equal to the preset difference reversal value, or if the current target step count is less than the available step count and the step count difference is greater than the preset difference reversal value; the position adjustment direction determination module is also used to determine the position adjustment direction as unchanged if the current target step count is equal to the available step count; the position adjustment direction determination module is also used to determine the position adjustment direction as reverse rotation if a preset reversal condition is met, wherein the preset reversal condition includes any one of the following: the current target step count is greater than the available step count and the step count difference is greater than the preset difference reversal value; the current target step count is less than the available step count and the step count difference is less than or equal to the preset difference reversal value; the position adjustment direction is neither forward rotation nor unchanged.
[0011] In one embodiment of the present invention, the direction determination module further includes a preset difference commutation value determination module, which is used to determine the preset difference commutation value based on the preset maximum number of steps and the preset difference commutation ratio, wherein the preset difference commutation ratio is greater than zero and the preset difference commutation ratio is less than 1.
[0012] In one embodiment of the present invention, the encoder output control module includes at least one of an ABZ-type output signal module, a high-speed counting single-pulse type signal output module, and a high-speed counting double-pulse type output signal module. The ABZ-type output signal module is used to invert the first bit of the updated position to obtain the A-phase output result, and to perform an XOR operation on the first bit and the zero bit of the updated position to obtain the B-phase output result. The ABZ-type output signal module is also used to control the Z-phase output result to be high when the number of available steps is greater than or equal to a preset Z-phase start step number and less than or equal to a preset Z-phase end step number, and to control the Z-phase output result to be low when the number of available steps is less than the preset Z-phase start step number or greater than the preset Z-phase end step number. The high-speed counting single-pulse type signal output module is used to determine the A-phase output result based on the first bit of the updated position if the position adjustment direction is forward, and to determine the A-phase output result based on the first bit of the updated position if the position adjustment direction is reverse or unchanged. The high-speed counting single-pulse type signal output module is further configured to perform an XOR operation on the first bit of the updated position and the zeroth bit of the updated position to obtain the A-phase output result. If the position adjustment direction is forward, the B-phase output is updated to the latest B-phase value only when the first bit of the self-position and the zeroth bit of the self-position are equal to a preset forward switching point. If the position adjustment direction is reversed or unchanged, the B-phase output is updated to the latest B-phase value only when the first bit of the self-position and the zeroth bit of the self-position are equal to a preset reverse switching point. The high-speed counting double-pulse type output signal module is configured to determine the A-phase output result based on the first bit of the updated position if the position adjustment direction is forward; if the position adjustment direction is reversed or unchanged, the A-phase output is low. The high-speed counting double-pulse type output signal module is also configured to perform an XOR operation on the first bit of the updated position and the zeroth bit of the updated position if the position adjustment direction is forward; if the position adjustment direction is reversed or unchanged, the B-phase output is low.
[0013] In one embodiment of the present invention, the encoder further includes a minimum cycle counter, the minimum cycle counter including a first counter and a state controller, the first counter being loaded with a loading value, and the state controller being used to trigger the loading value to change a preset loading value according to each cycle when the current target position is different from the own position, until the changed loading value is equal to a preset loading threshold, thereby generating a valid state indication signal to trigger the target position update module to determine the incremental modulation position as the current target position.
[0014] In one embodiment of the present invention, the minimum period counter is further used to trigger the target position update module to maintain the current target position unchanged when the changed loading value is greater than or less than a preset loading threshold.
[0015] In one embodiment of the present invention, the minimum cycle counter is further used to generate a valid status indication signal when the changed loading value is equal to the preset loading threshold, so as to trigger the self-position update module to update the self-position according to the position adjustment direction to obtain the updated position.
[0016] In one embodiment of the present invention, the minimum cycle counter triggers a change in the preset loading value according to each cycle, including: the minimum cycle counter triggers a decrease in the preset loading value according to each cycle, at which time the preset loading threshold is less than the loading value; or, the minimum cycle counter triggers a increase in the preset loading value according to each cycle, at which time the preset loading threshold is greater than the loading value.
[0017] In one embodiment of the present invention, the method for determining the loading value includes: obtaining the working clock cycle and the highest resolution pulse period interval corresponding to the output signal of the encoder; and determining the loading value based on the working clock cycle and the pulse period interval.
[0018] In one embodiment of the present invention, the state controller is further configured to load the load value into the first counter in the next cycle when the changed load value is equal to the preset load threshold, so that the state controller repeatedly executes the step of triggering the load value to change the preset load value according to each cycle when the current target position is different from the own position, until the changed load value is equal to the preset load threshold, and triggering the target position update module to determine the incremental modulation position as the current target position.
[0019] In one embodiment of the present invention, the self-owned position update module includes a forward update module, a reverse update module, and a holding module, wherein: the forward update module is used to adjust the self-owned position to the value of the self-owned position minus 1 when the changed load value is equal to the preset load threshold, if the position adjustment direction is forward and the self-owned position's self-owned step count is less than the current self-owned position's end step position; the forward update module is also used to adjust the self-owned position to the current self-owned position's initial step position when the changed load value is equal to the preset load threshold, if the position adjustment direction is forward and the self-owned position's self-owned step count is equal to the current self-owned position's end step position; the reverse update module... The new module is used to adjust the free position to the value of the free position plus 1 when the changed load value equals the preset load threshold, if the position adjustment direction is reversed and the free step number of the free position is greater than the initial step position of the current free position; the reverse update module is also used to adjust the free position to the end step position of the current free position when the changed load value equals the preset load threshold, if the position adjustment direction is reversed and the free step number of the free position equals the initial step position of the current free position; the holding module is used to control the free position to remain unchanged when the changed load value equals the preset load threshold and the position adjustment direction is unchanged.
[0020] In one embodiment of the present invention, the encoder further includes a watchdog monitoring module. The watchdog monitoring module is used to acquire the position adjustment direction determined by the direction determination module. If the position adjustment direction remains unchanged, it monitors the continuous effective duration of the unchanged position adjustment direction. When the continuous effective duration is greater than a preset duration threshold, it generates a watchdog monitoring valid signal and sends it to the self-position update module. The watchdog monitoring valid signal is used to trigger the self-position update module to adjust the self-position to the value of the self-position plus 1 when the self-position is less than the end step position of the self-position; and to trigger the self-position update module to adjust the self-position to the initial step position of the current self-position when the self-position is equal to the end step position of the current self-position.
[0021] In one embodiment of the present invention, the watchdog monitoring module includes a second counter and a signal generation module. The second counter is used to monitor the position adjustment direction. If the position adjustment direction remains unchanged, the second counter is triggered to reset to zero and start counting until the count value of the second counter reaches the watchdog threshold, triggering the signal generation module to generate the watchdog monitoring valid signal.
[0022] In one embodiment of the present invention, if the encoder includes at least two of a synchronization position management module, a minimum cycle counter, and a watchdog monitoring module, the self-owned position update module is used to determine one of the synchronization valid signal, status indication valid signal, and watchdog monitoring valid signal as a trigger signal according to a preset priority rule if it receives at least one of the synchronization valid signal, status indication valid signal, and watchdog monitoring valid signal, so as to trigger the self-owned position update module to update the self-owned position according to the position adjustment direction or the current target position, and obtain the updated position.
[0023] In one embodiment of the present invention, the encoder further includes a watchdog monitoring module. The watchdog monitoring module is used to acquire the position adjustment direction determined by the direction determination module. If the position adjustment direction remains unchanged, it monitors the continuous effective duration of the unchanged position adjustment direction. When the continuous effective duration is greater than a preset duration threshold, it generates a watchdog monitoring valid signal and sends it to the self-position update module. The watchdog monitoring valid signal is used to trigger the self-position update module to adjust the self-position to the value of the self-position plus 1 when the self-position is less than the end step position of the self-position; and to trigger the self-position update module to adjust the self-position to the initial step position of the current self-position when the self-position is equal to the end step position of the current self-position.
[0024] This invention also provides an encoding method, the method comprising: acquiring an input position, a current target position, and an existing position of an encoder; multiplying the input position by a preset line number modulation multiple and a maximum line number of the input position to obtain an incremental modulation position; maintaining the current target position unchanged, or updating the incremental modulation position to the current target position; determining a step difference based on the current target step number of the current target position and the existing step number of the existing position, and determining a position adjustment direction based on the step difference and a preset difference reversal value; updating the existing position according to the position adjustment direction or the current target position to obtain an updated position; and determining an output signal based on output reference data, wherein the output reference data includes the first bit of the updated position, the zero bit of the updated position, and at least one of the following: all bits of the updated position and a counting output parameter, wherein the counting output parameter includes the B-phase output value of the previous cycle and the position adjustment direction.
[0025] In one embodiment of the present invention, before maintaining the current target position unchanged or updating the incremental modulation position to the current target position, the method includes: taking the first period of an event in which the current target position is different from the own position as an initial period, triggering the updating of the incremental modulation position to the current target position after a preset period interval from the initial period; if the current target position is the same as the own position, and / or the current target position is different from the own position, maintaining the current target position unchanged within the preset period interval from the initial period.
[0026] In one embodiment of the present invention, before updating the owned position according to the position adjustment direction or the current target position to obtain the updated position, the method includes: if at least one of a valid synchronization signal, a valid status indication signal, and a valid watchdog monitoring signal is received, determining one of the valid synchronization signal, the valid status indication signal, and the valid watchdog monitoring signal as a trigger signal according to a preset priority rule to trigger the updating of the owned position according to the position adjustment direction or the current target position to obtain the updated position; wherein, determining the valid synchronization signal as the trigger signal to trigger the updating of the owned position according to the current target position to obtain the updated position includes any one of the following: after receiving an update instruction, generating a valid synchronization signal to trigger updating the owned position to the current target position; after receiving an update instruction, if a new incremental modulation position is obtained and the new incremental modulation position is updated to the new current target position, generating a valid synchronization signal to trigger updating the owned position to the new current target position; determining the valid status indication signal as the trigger signal. The trigger signal, which initiates the process of updating the self-owned position based on the position adjustment direction and the current target position to obtain the updated position, includes: when the current target position is different from the self-owned position, triggering the load value to change a preset load value every cycle until the changed load value equals a preset load threshold, generating a valid status indication signal, and updating the self-owned position based on the position adjustment direction to obtain the updated position; and determining the valid watchdog monitoring signal as the trigger signal, triggering the process of updating the self-owned position based on the position adjustment direction and the current target position to obtain the updated position, includes: if the position adjustment direction is unchanged, monitoring the continuous valid duration of the unchanged position adjustment direction; when the continuous valid duration is greater than a preset duration threshold, generating a valid watchdog monitoring signal, triggering the process of adjusting the self-owned position to the number of the self-owned position plus 1 when the self-owned position is less than the end step position of the self-owned position; and triggering the process of adjusting the self-owned position to the initial step position of the current self-owned position when the self-owned position is equal to the end step position of the current self-owned position.
[0027] In one embodiment of the present invention, determining the output signal based on the output reference data includes at least one of the following: if the output signal includes an ABZ type output signal, inverting the first bit of the updated position to obtain the A-phase output result, and performing an XOR operation on the first bit and the zeroth bit of the updated position to obtain the B-phase output result; when the number of available steps is greater than or equal to a preset Z-phase start step number and the number of available steps is less than or equal to a preset Z-phase end step number, controlling the Z-phase output result to be high; and when the number of available steps is less than the preset Z-phase start step number or the number of available steps is greater than the preset Z-phase end step number, controlling the Z-phase output result to be low; if the output signal includes a high-speed counting single-pulse type signal, if the position adjustment direction is forward, determining the A-phase output result based on the first bit of the updated position; if the position adjustment direction is reverse or unchanged, performing an XOR operation on the first bit and the zeroth bit of the updated position to obtain the B-phase output result. The zeroth bit is XORed to obtain the A-phase output result. If the position adjustment direction is forward, the B-phase output will only update the latest position adjustment direction to the latest B-phase value when the first bit of the self-position and the zeroth bit of the self-position are equal to a preset forward switching point. If the position adjustment direction is reverse or unchanged, the B-phase output will only update the latest position adjustment direction to the latest B-phase value when the first bit of the self-position and the zeroth bit of the self-position are equal to a preset reverse switching point. If the output signal includes a high-speed counting dual-pulse type output signal, if the position adjustment direction is forward, the A-phase output result is determined according to the first bit of the updated position. If the position adjustment direction is reverse or unchanged, the A-phase output is low. If the position adjustment direction is forward, the B-phase output is low. If the position adjustment direction is reverse or unchanged, the first bit of the updated position and the zeroth bit of the updated position are XORed to obtain the B-phase output result.
[0028] This invention also provides a chip that includes an encoder as described in any of the foregoing embodiments.
[0029] In the encoder, encoding method, and chip implementation scheme provided above, the encoder obtains the incremental modulation position by modulating the input position with the number of lines through the line modulation module. The target position update module maintains the current target position unchanged or updates the incremental modulation position to the current target position. The direction determination module determines the step difference based on the current target position and the self-position. The position adjustment direction is determined based on the step difference and the preset difference commutation value. The self-position update module updates the self-position according to the position adjustment direction or the current target position to obtain the updated position. The encoder output control module determines the output signal based on the first bit and the zero bit of the updated position, and at least one of the following: all bits of the updated position and the counting output parameters. The counting output parameters include the B-phase output value of the previous cycle and the position adjustment direction. This encoder provides a novel encoder implementation method. The implementation process is simple, easy to operate, and has a low threshold for use. Attached Figure Description
[0030] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 A schematic diagram of the encoder provided in an embodiment of the present invention;
[0032] Figure 2 A schematic diagram of the signals of phase A, phase B, and phase Z provided in an embodiment of the present invention;
[0033] Figure 3 A schematic diagram showing that the output of this invention is a high-speed counting single-pulse signal;
[0034] Figure 4 A schematic diagram showing that the output of this invention is a high-speed counting double-pulse signal;
[0035] Figure 5 Another structural schematic diagram of the encoder provided in an embodiment of the present invention;
[0036] Figure 6 A flowchart illustrating the encoding method provided in an embodiment of the present invention;
[0037] Figure 7 A schematic diagram of the structure of an electronic device according to an embodiment of the present invention;
[0038] Figure 8 Another schematic diagram of the electronic device in one embodiment of the present invention. Detailed Implementation
[0039] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0040] To address the aforementioned problems, embodiments of the present invention propose an encoder, an encoding method, and a chip. The solutions provided by the present invention will be described in detail below through specific embodiments.
[0041] Please see Figure 1 As shown, Figure 1 A schematic diagram of the encoder provided in an embodiment of the present invention is shown below. Figure 1 As shown, the encoder includes a line number modulation module 110, a target position update module 120, a direction determination module 130, a free position update module 140, and an encoder output control module 150. Specifically: the line number modulation module 110 is used to acquire the input position and multiply it by a preset line number modulation factor to obtain the incremental modulation position; the target position update module 120 is used to maintain the current target position unchanged or update the current target position to the incremental modulation position; the direction determination module 130 is used to determine the direction based on the current target step number and the free position. The step count determines the step difference, and the position adjustment direction is determined based on the step difference and the preset difference reversal value; the self-position update module 140 is used to update the self-position according to the position adjustment direction or the current target position to obtain the updated position; the encoder output control module 150 is used to determine the output signal according to the output reference data, the output reference data includes the first bit of the updated position, the zero bit of the updated position, and at least one of the following: all bits of the updated position and the counting output parameters, the counting output parameters include the B phase output value of the previous cycle and the position adjustment direction.
[0042] Please see Figure 2 , Figure 2 A schematic diagram of the signals of phase A, phase B, and phase Z provided in an embodiment of the present invention is shown below. Figure 2 As shown, 1 / 4 of the pulse width of the A or B signal period is defined as one step, and one period of the A or B signal is defined as one line step. In this embodiment, the number of lines refers to the number of periods of orthogonal A or B signals in the encoder within one Z-phase period. Figure 2 The signals of phase A, phase B, and phase Z in this example are merely one example, and those skilled in the art can set the signals of phase A, phase B, and phase Z as needed.
[0043] In one embodiment, the line number modulation module includes a multiplier. By inputting the input position and a preset line number modulation multiple into the multiplier, an incremental modulation position is obtained. The input position includes m-bit initial target position data target_in[m-1:0] and k-bit maximum line number input position line_in_max[k-1:0]. The preset line number modulation multiple includes n-bit line number modulation multiple line[n-1:0]. The incremental modulation position includes k+n+2-bit line number modulated target position data target_out[k+n+1:0].
[0044] For example, the input position is defined as a binary value with a width of m bits, and its field value is 0 to 2. m -1 represents the position corresponding to the number of steps in a complete line (a complete line contains 4 steps). If the input position is understood as an angle, then the full scale of the input position corresponds to a full circle of 360°, and each 90° corresponds to one step. For example: m=4, target_in[3:0]=3,3 / 2 4 *360° = 48°, the position from 0 to 90° corresponds to step 1.
[0045] Assuming the full scale of the input position is 1 line (4 steps), line adjustment involves changing 1 line to line[n-1:0]. The formulas provided in the following examples are constructed with the input position's full scale of 1 line as an example. Those skilled in the art can also adjust the input position's full scale based on this principle, thereby adjusting the formulas. The number of bits m in the input position needs to be greater than or equal to 2. If it is less than 2, for example, when the bit width is 1, the input position only has two states, and the input position cannot distinguish between 1 line and 4 steps.
[0046] To avoid the limitation of 1 line (4 steps) corresponding to the full scale of the input position, an additional number of lines corresponding to the full scale of the input position is added, defined as line_in_max (maximum number of lines for k-bit input positions). This parameter is an input configuration parameter.
[0047] For example, the line number modulation module is used to re-modulate (multiply) the line number in the original position to support higher resolution position information output. The line number modulation module can be implemented using an unsigned m*n*k multiplier. Taking an initial target position data with an input position of m bits and a line number modulation factor of n as an example, the three input multipliers are:
[0048] (1) Initial target position data target_in[m-1:0] for position m;
[0049] (2) n-bit line modulation multiple line[n-1:0];
[0050] (3) The maximum number of lines at the k-bit input position is line_in_max[k-1:0]. When the full scale of the input position is 1 line (4 steps), the input can be ignored.
[0051] The output of the line number modulation module is k+n+2 bits of incremental modulation position data target_out[k+n+1:0].
[0052] An exemplary calculation formula for the line number modulation module is shown in formulas (1) and (2):
[0053] multiply[k+n+m-1:0]=target_in[m-1:0]×line[n-1:0]×
[0054] line_in_max[k-1:0] Formula (1),
[0055] target_out[k+n+1:0]=multiply[k+n+m-1:m-2] Formula (2),
[0056] Where, target_in[m-1:0] is the input position, line[n-1:0] is the line modulation multiple, line_in_max[k-1:0] is the maximum number of lines at the k-bit input position, multiply[k+n+m-1:0] is the output data of the three-input multiplier, and target_out[k+n+1:0] is the incremental modulation position. In formula (2), multiply[k+n+m-1:m-2] means that the values from k+n+m-1 to m-2 (a total of k+n+2 bits) of multiply are assigned to target_out, that is, the k+n+m-1th bit of multiply is assigned to the k+n+1th bit of target_out, the k+n+m-2th bit of multiply is assigned to the k+nth bit of target_out, and so on... the m-2th bit of multiply is assigned to the 0th bit of target_out. The output value of target_out[k+n+1:0] reflects the number of steps corresponding to the incremental modulation position, where n is the binary bit width of the line modulation multiple value, and line[n-1:0] and line_in_max[k-1:0] can be configured by those skilled in the art as needed.
[0057] It should be noted that, for example, when n is instantiated as 16 in this invention, it means that the maximum line modulation multiple supported by the encoder at this time is 2. 16-1, or 65535 times. In this instantiated structure, the line-number modulation multiple range can be supported from 1 to 65535. That is, the larger the multiplier bit width of the three-input multiplier in the line-number modulation module, the wider the range of outputs supported. Of course, the hardware circuit overhead of the multiplier will also be greater. The same applies to m and k, which will not be elaborated further.
[0058] In one embodiment, the direction determination module includes a step difference determination module and a position adjustment direction determination module, wherein: the step difference determination module is used to determine the step difference as the difference between the current target step number and the available step number if the current target step number is greater than or equal to the available step number; and if the current target step number is less than the available step number, the sum of the preset maximum step number and the current target step number is used as the temporary step number, and the difference between the temporary step number and the available step number is determined as the step difference, wherein the preset maximum step number is determined based on the product of the preset line modulation multiple line[n-1:0] and the maximum line number of the input position line_in_max[k-1:0]; the position adjustment direction determination module is used to determine the step difference as follows: if the current target step number is greater than or equal to the available step number, the difference between the current target step number and the available step number is greater than or equal to the available step number. If the number of available steps is less than or equal to a preset difference reversal value, or if the current target number of steps is less than the number of available steps and the step difference is greater than the preset difference reversal value, the position adjustment direction is determined to be forward. The position adjustment direction determination module is also used to determine the position adjustment direction to remain unchanged if the current target number of steps is equal to the number of available steps. The position adjustment direction determination module is also used to determine the position adjustment direction to be reversed if a preset reversal condition is met. The preset reversal condition includes any one of the following: the current target number of steps is greater than the number of available steps and the step difference is greater than the preset difference reversal value; the current target number of steps is less than the number of available steps and the step difference is less than or equal to the preset difference reversal value; the position adjustment direction is neither forward nor unchanged.
[0059] In this embodiment, the direction determination module further includes a preset difference commutation value determination module. The preset difference commutation value determination module is used to determine the direction based on the product of the preset line number adjustment multiple line[n-1:0] and the maximum number of lines at the input position line_in_max[k-1:0] (preset maximum step number) and the preset difference commutation ratio. The preset difference commutation ratio is greater than zero and less than 1.
[0060] The direction determination module is used to determine the position direction, that is, to determine the relationship between the current target step count of the current target position and the current step count of the own position, so as to generate the latest position adjustment direction for the own position update module. The position adjustment direction can include three types: (1) forward rotation; (2) reverse rotation; (3) unchanged, that is, stop.
[0061] One example of how the step difference is determined is as follows:
[0062]
[0063] Where delta[k+n+1:0] is the step difference, target[k+n+1:0] is the current target step number at the current target position, owned[k+n+1:0] is the own step number at the own position, n is the binary bit width of the line modulation multiplier value, line[n-1:0] is the line number configured by the line conversion module, and line_in_max[k-1:0] is the maximum line number at the k-bit input position, which is the line number of the line modulation multiplier mentioned above. line[n-1:0] and line_in_max[k-1:0] can be configured by those skilled in the art as needed.
[0064] As shown in formula (3) above, when the current target step number is greater than or equal to the available step number, the difference between the current target step number and the available step number is directly used as the step difference. Otherwise, when the current target step number is less than the available step number, the preset maximum step number (line[n-1:0]*4*line_in_max[k-1:0]) is determined based on the product of the preset line number adjustment multiple line[n-1:0] and the maximum line number at the input position line_in_max[k-1:0], which is also the bit width of the preset line number modulation multiple. Then, the step difference is determined by subtracting the available step number from the sum of the preset maximum step number and the current target step number.
[0065] One example of how the preset difference commutation value is determined is as follows:
[0066] change_point=line[n-1:0]*1ine_in_max[K-1:0]*4*k_ratio Formula (4),
[0067] Wherein, change_point is the preset differential commutation value, and k_ratio is the preset differential commutation ratio, where 1 > k_ratio > 0, and the preset differential commutation value is an integer. The preset differential commutation ratio can be pre-configured by those skilled in the art as needed.
[0068] In one embodiment, the method for determining whether the position adjustment direction is a forward rotation is as follows:
[0069]
[0070] Where posedge_round is the forward rotation indicator signal.
[0071] F is given by delta[k+n+1:0]≤change_point and target[k+1+1:0]>owned[k+n+1:0];
[0072] Alternatively, delta[k+n+1:0] > change_point and target[k+1+1:0] < owned[k+n+1:0], where delta[k+n+1:0] is the step difference, change_point is the preset difference reversal value, target[k+1+1:0] is the current target step number at the current target position, and owned[k+n+1:0] is the own step number at the own position. If the current target step number is greater than the own step number, and the step difference is less than or equal to the preset difference reversal value; or if the current target step number is less than the own step number, and the step difference is greater than the preset difference reversal value, then posedge_round is 1; otherwise, posedge_round is 0. When posedge_round is 1, it indicates forward rotation.
[0073] In one embodiment, the method for determining whether the position adjustment direction is reversed is as follows:
[0074] negedge_round=(target[k+n+1:0]!=owned[k+n+1:0])&&(!posedge_round)
[0075] Formula (6),
[0076] Where `target[k+n+1:0]` represents the current target step count at the current target position, `owned[k+n+1:0]` represents the own step count at the current position, `posedge_round` is the forward rotation indicator signal, and `negedge_round` is the reverse rotation indicator signal; `negedge_round` is 1 when it indicates a reverse. If the position adjustment direction is not determined to be forward, and the current target step count is not equal to the own step count, then `negedge_round` is 1; otherwise, if the position adjustment direction is not determined to be forward, and the current target step count is equal to the own step count, then `negedge_round` is 0. In other words, a reverse occurs when any of the following preset reverse conditions exist: the current target step count is greater than the own step count, and the step count difference is greater than a preset difference reversal value; the current target step count is less than the own step count, and the step count difference is less than or equal to a preset difference reversal value; the position adjustment direction is neither forward nor unchanged.
[0077] In one embodiment, the method for determining whether the position adjustment direction remains unchanged is as follows:
[0078] stop_round=(target[k+n+1:0]==owned[k+n+1:0]) Formula (7),
[0079] In this system, `stop_round` is the stop indicator signal, which remains unchanged. `target[k+n+1:0]` represents the current target step count from the current target position, and `owned[k+n+1:0]` represents the own step count from the current position. When `owned[k+n+1:0]` is 1, it indicates that the own position has caught up with the current target position. In other words, by checking if the current target step count equals the own step count, `stop_round` is 1 if it does, and 0 otherwise.
[0080] In one embodiment, the encoder output control module includes at least one of an ABZ-type output signal module, a high-speed counting single-pulse signal output module, and a high-speed counting double-pulse output signal module, wherein...
[0081] The ABZ type output signal module is used to invert the first bit of the updated position to obtain the A-phase output result, and to perform an XOR operation on the first bit and the zero bit of the updated position to obtain the B-phase output result. The ABZ type output signal module is also used to control the Z-phase output result to be high when the number of available steps is greater than or equal to the preset Z-phase start step number and less than or equal to the preset Z-phase end step number, and to control the Z-phase output result to be low when the number of available steps is less than the preset Z-phase start step number or greater than the preset Z-phase end step number.
[0082] The high-speed counting single-pulse signal output module is used to determine the A-phase output result based on the first bit of the updated position if the position adjustment direction is forward. If the position adjustment direction is reverse or unchanged, an XOR operation is performed on the first bit and the zero bit of the updated position to obtain the A-phase output result. The high-speed counting single-pulse signal output module is also used to update the latest position adjustment direction to the latest B-phase value only when the first bit and the zero bit of the own position are equal to a preset forward switching point if the position adjustment direction is forward. If the position adjustment direction is reverse or unchanged, the latest position adjustment direction to the latest B-phase value only when the first bit and the zero bit of the own position are equal to a preset reverse switching point.
[0083] The high-speed counting dual-pulse output signal module is used to determine the A-phase output result based on the first bit of the updated position if the position adjustment direction is forward. If the position adjustment direction is reverse or unchanged, the A-phase output is low. The high-speed counting dual-pulse output signal module is also used to output the B-phase low if the position adjustment direction is forward, and to perform an XOR operation on the first bit and the zero bit of the updated position if the position adjustment direction is reverse or unchanged to obtain the B-phase output result.
[0084] In this embodiment, when the encoder output control module includes at least two of the following: an ABZ type output signal module, a high-speed counting single-pulse type signal output module, and a high-speed counting double-pulse type output signal module, at least one of the modules can be configured by those skilled in the art to be in a working state.
[0085] When the ABZ type output signal module is configured to be active, that is, when the encoder is configured to have ABZ type output, i.e., AB quadrature output, A leads B by one step for forward rotation (e.g., ...). Figure 2 As shown in the figure, when B leads A by one step, it is a reversal, and the Z phase is a zero-phase pulse.
[0086] An example of how the output of phase A is determined is as follows:
[0087] A=! owned[1] formula (8),
[0088] Where A is the output result of phase A, ! represents inversion, owned[1] represents the 1st bit of the current own position, owned[k+n+1:0] has a bit width of k+n+2, the least significant bit is the 0th bit, and the most significant bit is the k+n+1th bit. If owned[1] is 1, then A = 0; if owned[1] is 0, then A = 1. When A = 0, the output is low level; when A = 1, the output is high level.
[0089] An example of how the output of phase B is determined is as follows:
[0090] B=owned[0]⊕owned[1] formula (9),
[0091] Where B is the output result of phase B, and ⊕ represents the XOR operation, that is, the output of phase B is owned[0] XOR owned[1], where owned[1] represents the 1st bit of the current free position, and owned[0] represents the 0th bit of the current free position. When owned[0] and owned[1] are the same, B = 0; when owned[0] and owned[1] are different, B = 1. When B = 0, the output is low level; when B = 1, the output is high level.
[0092] An example of how the output of the Z phase is determined is as follows:
[0093] Z=(z_start[k+n+1:0]<=owned[k+n+1:0])&&(z_end[k+n+1:0]>=owned[k+n+1:0]) Formula (10),
[0094] Where Z represents the Z-phase output, z_start[k+n+1:0] and z_end[k+n+1:0] are both pre-configured parameters. z_start[k+n+1:0] is the preset Z-phase start step number, z_end[k+n+1:0] is the preset Z-phase end step number, and owned[k+n+1:0] is the number of steps at the user's own position. Specifically, when owned[k+n+1:0] is greater than or equal to z_start[k+n+1:0] and owned[k+n+1:0] is less than or equal to z_end[k+n+1:0], Z = 1, and the output is high. Otherwise, the output is low. That is, when the number of steps is less than the preset Z-phase start step number, or greater than the preset Z-phase end step number, Z = 0, and the Z-phase output is low.
[0095] When the high-speed counting single-pulse signal output module is configured to be active, that is, when the output is high-speed counting single-pulse type, please refer to [link to relevant documentation]. Figure 3 , Figure 3 This is a schematic diagram illustrating a high-speed counting single-pulse signal output provided by an embodiment of the present invention. Phase A outputs the counting pulse, and phase B outputs the counting direction. Figure 3 The sequence 1, 2, 3, 2, 1, 0 is an example count value for a high-speed pulse.
[0096] An example of how the output of phase A is determined is as follows:
[0097] A=posedge_round? owned[1]:owned[1]⊕owned[0] formula (11),
[0098] Where A is the output result of phase A, posedge_round is the forward rotation indicator signal, owned[1] represents the 1st position of the current free position, and owned[0] represents the 0th position of the current free position. ⊕ represents the XOR operation, that is, when the forward rotation indicator signal is 1 and the position adjustment direction is forward, owned[1] is used as the value of A. Otherwise, when the position adjustment direction is not forward, the output of phase A is owned[0] XOR owned[1]. When owned[0] and owned[1] are the same, A = 0. When owned[0] and owned[1] are different, A = 1. When A = 0, the output is low level, and when A = 1, the output is high level.
[0099] Phase B is the counting direction of the high-speed pulses. When phase B is 1, it corresponds to forward incrementing; when it is 0, it corresponds to reverse decrementing. The phase of phase B reversal (switching from forward to reverse or from reverse to forward) is determined by configurable parameters. An example of how the output of phase B is determined is as follows:
[0100] round_change_point=B(n-1)? owned[1:0]==posedge_point:
[0101] owned[1:0]==negedge_point formula (12),
[0102] B(n)=round_change_point&posedge_round formula (13),
[0103] Wherein, round_change_point is the B-phase commutation point control signal, posedge_point and negedge_point are the pre-configured forward and reverse commutation point parameters, respectively, B(n) represents the current B-phase output value, and B(n-1) represents the B-phase output value of the previous cycle. posedge_round is the forward rotation indicator signal. owned[1:0] is the binary value composed of the first and zeroth bits of the owned position.
[0104] That is, when the position adjustment direction is forward, the B-phase output will update the latest position adjustment direction to the latest B-phase value only when the first position and the zero position of the self-position are equal to the preset forward switching point. If the position adjustment direction is reverse or unchanged, the B-phase output will update the latest position adjustment direction to the latest B-phase value only when the first position and the zero position of the self-position are equal to the preset reverse switching point.
[0105] When the high-speed counting dual-pulse output signal module is configured to be active, the output will be high-speed counting dual-pulse type, such as... Figure 4 As shown, Figure 4 Please refer to the schematic diagram of the output being a high-speed counting double-pulse signal provided in the embodiment of the present invention. Figure 4 Phase A outputs a forward counting pulse, and phase B outputs a reverse counting pulse. The sequence 1, 2, 3, 2, 1, 0 in the figure is an example of the counting value of a high-speed pulse.
[0106] An example of how the output of phase A is determined is as follows:
[0107] A=posedge_round? owned[1]:0 formula (14),
[0108] Where A is the output result of phase A, posedge_round is the forward rotation indicator signal, and owned[1] represents the first position of the current free position. That is, when the position adjustment direction is forward rotation, posedge_round = 1, A takes the value of owned[1]. Otherwise, when the position adjustment direction is not forward rotation, A = 0, and the output is low level.
[0109] An example of how the output of phase B is determined is as follows:
[0110] B=posedge_round? 0: (owned[1]⊕owned[0]) Formula (15),
[0111] Where B is the output result of phase B, posedge_round is the forward rotation indicator signal, owned[1] represents the 1st bit of the current free position, owned[0] represents the 0th bit of the current free position, and ⊕ represents the XOR operation. That is, when the position adjustment direction is forward rotation, posedge_round=1, B=0, and the output is low level. When the position adjustment direction is reverse rotation or unchanged, if the 1st bit and the 0th bit are the same, B=0, and the output is low level. If the 1st bit and the 0th bit are different, B=1, and the output is high level.
[0112] In one embodiment, the encoder further includes a minimum cycle counter, which includes a first counter and a state controller. The first counter is loaded with a load value. The state controller is used to trigger the load value to change a preset load value every cycle when the current target position is different from the own position, until the changed load value is equal to a preset load threshold, and generate a valid state indication signal to trigger the target position update module to determine the incremental modulation position as the current target position.
[0113] In this embodiment, the minimum cycle counter is also used to trigger the target position update module to maintain the current target position unchanged when the changed load value is greater than or less than the preset load threshold.
[0114] In one embodiment, the minimum cycle counter is also used to trigger the self-position update module to update the self-position according to the position adjustment direction when the changed loading value is equal to the preset loading threshold, so as to obtain the updated position.
[0115] In this embodiment, when the changed load value in the minimum cycle counter equals a preset load threshold, the self-position update module may include a forward update module, a reverse update module, and a holding module. Specifically: the forward update module is used to adjust the self-position to the value of the self-position minus 1 when the changed load value equals the preset load threshold, if the position adjustment direction is forward and the self-position's self-step count is less than the current self-position's end step position; the forward update module is also used to adjust the self-position to the value of the self-position minus 1 when the changed load value equals the preset load threshold, if the position adjustment direction is forward and the self-position's self-step count is equal to the current self-position's end step position. The initial step position of the previous self-owned position; the reverse update module is used to adjust the self-owned position to the value of the self-owned position plus 1 when the changed load value is equal to the preset load threshold, if the position adjustment direction is reversed and the number of self-owned steps of the self-owned position is greater than the initial step position of the current self-owned position; the reverse update module is also used to adjust the self-owned position to the end step position of the current self-owned position when the changed load value is equal to the preset load threshold, if the position adjustment direction is reversed and the number of self-owned steps of the self-owned position is equal to the initial step position of the current self-owned position; the hold module is used to keep the self-owned position unchanged when the changed load value is equal to the preset load threshold and the position adjustment direction is unchanged.
[0116] In one embodiment, the minimum cycle counter triggers a change in the preset loading value for each cycle, including: the minimum cycle counter triggers a decrease in the preset loading value for each cycle, where the preset loading threshold is less than the loading value; or, the minimum cycle counter triggers a increase in the preset loading value for each cycle, where the preset loading threshold is greater than the loading value. In other words, the counting direction of the minimum cycle counter can be either increasing or decreasing, and this can be selected by those skilled in the art as needed.
[0117] In one embodiment, the loading value is determined by: obtaining the highest resolution pulse period interval corresponding to the operating clock cycle and the encoder output signal; and determining the loading value based on the operating clock cycle and the pulse period interval.
[0118] In one embodiment, the state controller is further configured to load the load value into the first counter in the next cycle when the changed load value is equal to the preset load threshold, so that the state controller repeatedly executes the step of triggering the load value to change the preset load value according to each cycle when the current target position is different from the own position, until the changed load value is equal to the preset load threshold, generating a valid state indication signal to trigger the target position update module to determine the incremental modulation position as the current target position.
[0119] For example, the minimum cycle counter includes a w-bit first counter and a state controller. The state controller is responsible for loading and running the target value (load value) of the first counter, and generates a status indication signal to the target position update module and the self-position update module. The control method is as follows: during the pre-configuration stage, based on the highest resolution pulse period interval p corresponding to the encoder output signal and the operating clock period q of this circuit, the load value r of the target value of the first counter can be calculated according to Formula 16.
[0120] r = p / q Formula (16)
[0121] Where r is the load value, p is the pulse period interval, and q is the working clock period.
[0122] Taking the logic of the first counter being decremented and the preset loading threshold being zero as an example, an exemplary state control step of the state controller is as follows: (1) Initially, the first counter loads r into the first counter; (2) When the direction determination module determines that the current home position and the current target position are inconsistent, the minimum cycle counter starts from the loading value r and keeps counting down by one in each cycle. During this stage, a running status indication signal is generated and sent to the target position update unit; (3) When the value of the first counter is reduced to 0, a line_update indication signal is generated and sent to the target position update unit and the home position update unit; (4) In the cycle when the value of the first counter is reduced to 0, the state controller will load r into the first counter in the next cycle and then repeat steps 2), 3), and 4).
[0123] It's understandable that the target position update unit can only check for new target position updates when `line_update` is valid. Otherwise, even if the line number modulation module is updating the incremental position, the target position update unit remains unchanged. In other words, once the counter starts counting, it will only stop when it reaches the threshold; the counting will not be interrupted, and the target position update unit will not update.
[0124] If the encoder output control module includes a high-speed counting single-pulse signal output module, then the determination of phase B is as follows: phase B is the counting direction of the high-speed pulse. When phase B is 1, it corresponds to forward incrementing; when it is 0, it corresponds to reverse decrementing. The phase of phase B reversal (switching from forward to reverse or from reverse to forward) is determined by configurable parameters. An example of how phase B is determined is as follows:
[0125] round_change_point=B(n-1)? owned[1:0]==posedge_point:
[0126] owned[1:0]==negedge_point formula (12),
[0127] B(n)=(line_update&round_c ange_point)? posedge_round:B(n-1) formula (17),
[0128] Wherein, round_change_point is the B-phase commutation point control signal, posedge_point and negedge_point are the pre-configured forward and reverse commutation point parameters, respectively, B(n) represents the current B-phase output value, and B(n-1) represents the B-phase output value of the previous working clock cycle. posedge_round is the forward rotation indicator signal, and line_update is the status indicator valid signal. owned[1:0] is the binary value composed of the first and zeroth bits of the owned position.
[0129] When B(n-1) is 1, that is, the value of phase B in the previous working clock cycle is 1, if owned[1:0] is equal to the forward commutation point parameter, then the commutation point control signal round_change_point of phase B is 1; if owned[1:0] is not equal to the forward commutation point parameter, then the commutation point control signal round_change_point of phase B is 0. When B(n-1) is 0, that is, the value of phase B in the previous working clock cycle is 0, if owned[1:0] is equal to the reverse commutation point parameter, then the commutation point control signal round_change_point of phase B is 1; if owned[1:0] is not equal to the reverse commutation point parameter, then the commutation point control signal round_change_point of phase B is 0.
[0130] When the commutation point control signal round_change_point of phase B is 1 and the line_update signal is 1, the output value of phase B in the current working clock cycle is equal to the value of posedge_round; otherwise, the output value of phase B remains unchanged.
[0131] In one embodiment, the encoder further includes a synchronization position management module, which includes at least one of an immediate update module and a delayed update module. The immediate update module, when active, generates a synchronization signal upon receiving an update command to trigger the own position update module to update its own position to the current target position. The delayed update module, when active, generates a synchronization signal upon receiving an update command if the line-number modulation module obtains a new incremental modulation position and the target position update module determines the new incremental modulation position as the new current target position, to trigger the own position update module to update its own position to the new current target position. If the synchronization position management module includes both an immediate update module and a delayed update module, either the immediate update module or the delayed update module is active at any given time.
[0132] In this embodiment, the synchronization location management module further includes an enable control module, which is used to receive status instructions to configure the immediate update module to be in an active state or the delayed update module to be in an active state.
[0133] For example, the synchronization location management module can be configured to have two working modes;
[0134] 1) Immediate Effect Mode: When synchronization is enabled (configured via the system bus), a `sync_update` valid signal is immediately sent to the owner's location update unit; the owner's location will immediately synchronize the current target location to the latest location. This immediate effect mode can be executed through the aforementioned immediate update module. In this mode, as soon as the switch to this mode is received, it is considered that an update command has been received, and the owner's location must be updated to the current target location, regardless of whether it has been updated before. This method has a fast update speed and rapid response, but due to the strong external borrowing force, it is prone to other system risks.
[0135] 2) Delayed Mode: When synchronization of the position is enabled (configured via the system bus), a valid `sync_update` signal is not immediately issued. It is only issued after the next target position update unit updates the target position. In other words, in delayed mode, the owner's position will synchronize the next target position with the latest owner's position. This delayed mode can be executed through the aforementioned delayed update module. Instead of directly updating the owner's position to the current target position, the target position update module obtains the new current target position before triggering the adoption of the new current target position as the owner's position, thus achieving the update of the owner's position. Therefore, the advantage of delayed mode is that it is more suitable for pre-configuring the initial position before startup. Immediate mode is more suitable for emergency stop responses during fault situations.
[0136] The synchronization location management module can operate in any mode based on different flags, commands, etc., and this is not limited here. However, it should be noted that the two modes cannot coexist; that is, it must either be an immediate mode or a delayed mode.
[0137] In one embodiment, the encoder further includes a watchdog monitoring module. The watchdog monitoring module is used to obtain the position adjustment direction determined by the direction determination module. If the position adjustment direction remains unchanged, it monitors the continuous effective duration of the unchanged position adjustment direction. When the continuous effective duration is greater than a preset duration threshold, it generates a watchdog monitoring valid signal and sends it to the self-position update module. The watchdog monitoring valid signal is used to trigger the self-position update module to adjust the self-position to the value of the self-position minus 1 when the self-position is less than the end step position of the self-position; and to trigger the self-position update module to adjust the self-position to the initial step position of the current self-position when the self-position is equal to the end step position of the current self-position.
[0138] In this embodiment, the watchdog monitoring module includes a second counter and a signal generation module. The second counter is used to monitor the position adjustment direction. If the position adjustment direction remains unchanged, the second counter is triggered to reset to zero and start counting until the count value of the second counter reaches the watchdog threshold, triggering the signal generation module to generate a valid watchdog monitoring signal.
[0139] For example, the watchdog monitoring module checks the continuous effective time of the stop_round signal of the direction determination module. This function can be enabled or disabled via register parameters. Before enabling this function, the watchdog threshold cycle number (watchdog threshold) needs to be pre-configured, and the second counter in the watchdog monitoring module will load this threshold. When stop_round is invalid, the value of this second counter is zero. When stop_round is valid, the second counter starts counting. When it reaches the threshold (the count value of the second counter reaches the watchdog threshold), the second counter will be zeroed, and a wdog_update valid pulse signal (watchdog monitoring valid signal) will be sent to the position update module. That is to say, a wdog_update valid signal will only be generated if the continuous effective time of stop_round exceeds the threshold time. This function can be used to monitor whether the position update mechanism is in a long-term "frozen state".
[0140] In one embodiment, if the encoder includes at least two of a synchronization position management module, a minimum cycle counter, and a watchdog monitoring module, the self-position update module is used to, upon receiving at least one of a valid synchronization signal, a valid status indication signal, and a valid watchdog monitoring signal, determine one of these signals as a trigger signal according to a preset priority rule. This triggers the self-position update module to update its self-position based on the position adjustment direction or the current target position, thus obtaining the updated position. The preset priority rule is a priority ranking rule for the valid synchronization signal, the valid status indication signal, and the valid watchdog monitoring signal. This rule can be set by those skilled in the art as needed. It characterizes the event corresponding to the signal with the highest priority level when the self-position update module simultaneously receives at least two of these signals; that is, the signal with the highest priority level is used as the trigger signal. If none of the three signals are received, but at least one of the position adjustment direction and the current target position is received, the updated position can be determined according to other preset rules by those skilled in the art. When only one of the three signals is received, the rule corresponding to that signal is followed.
[0141] Please see Figure 5 , Figure 5 Another structural schematic diagram of the encoder provided in an embodiment of the present invention is shown below. Figure 5 As shown, with Figure 1 Unlike the encoder in the previous embodiment, the encoder in this embodiment can be equipped with at least one of the following, according to the needs of those skilled in the art: a minimum cycle counter 160, a watchdog monitoring module 180, and a synchronization management module 170. The encoder output control module 150 can realize ABZ encoding control and / or high-speed counter control, and the output signal can be A-phase, B-phase, and Z-phase signals, or A-phase and B-phase signals. Wherein:
[0142] If the encoder is configured with a minimum cycle counter 160, the target position update module 120 can determine whether to set the current target position as target[k+n+1:0] or the incremental modulation position target_out[k+n+1:0] as the current target position based on whether the changed load value in the minimum cycle counter 160 equals the preset load threshold. If the count value of the first counter in the minimum cycle counter reaches the preset load threshold, the incremental modulation position target_out[k+n+1:0] is set as the current target position target[k+n+1:0]. Otherwise, the current target position is maintained. If the encoder is in its initial state and has no current target position (first execution flow), an initial value can be preset by those skilled in the art as the current target position.
[0143] After the line bundle modulation module 110 generates the incremental modulation position target_out[k+n+1:0] based on the input position target_in[m-1:0], the line modulation multiple line[n-1:0], and the maximum number of lines at the input position line_in_max[k-1:0], it sends the result to the target position update module 120. This target position update module 120 determines whether to update and latch the incremental modulation position target_out to the current target position target[k+n+1:0] based on the validity of the minimum period counter 160's state line_update. That is, when the minimum period counter 160's state is line_update, the current incremental modulation position target_out[k+n+1:0] is latched to the latest target position target[k+n+1:0] (the current target position); if the minimum period counter's state is running, the current target position remains unchanged (i.e., the current target position is maintained). The output of the target position update module 120 is then sent to the direction determination module 130.
[0144] If the encoder does not have a minimum cycle counter 160, the current target position can be determined according to the needs of those skilled in the art. For example, after obtaining the incremental modulation position, the incremental modulation position can be latched as the current target position, or the difference between the incremental modulation position and the current target position can be calculated. If the difference is greater than a certain preset difference, the incremental modulation position can be latched as the current target position; otherwise, the current target position can be maintained as the current target position.
[0145] When the encoder is not configured with a minimum cycle counter 160, a watchdog monitoring module 180, and a synchronization management module 170, the owned position update module 140 can, according to the configuration of those skilled in the art, update the owned position owned[k+n+1:0] based on the position adjustment direction (posedge_round forward, negedge_round reverse, stop_round unchanged) to obtain the updated position when direction priority is applied. When target priority is applied, the owned position is updated based on the current target position to obtain the updated position. Alternatively, other rules set by those skilled in the art can be used to update the owned position.
[0146] When the encoder is configured with a minimum cycle counter 160 but not with a watchdog monitoring module 180 and a synchronization management module 170, the own position update module 140 will activate the minimum cycle counter status indicator signal line_update when the modified load value of the minimum cycle counter 160 equals the preset load threshold. The own position owned[k+n+1:0] will be updated according to the position adjustment direction to obtain the updated position.
[0147] When the encoder is configured with a watchdog monitoring module 180 but not with a minimum cycle counter 160 and a synchronization management module 170, the self-owned position update module 140 obtains the position adjustment direction determined by the direction determination module 130. If the position adjustment direction remains unchanged, it monitors the continuous effective duration of the unchanged position adjustment direction. When the continuous effective duration exceeds a preset duration threshold, it generates a watchdog monitoring valid signal wdog_update. This triggers the self-owned position update module to adjust its own position to the value of its own position minus 1 if its own position is less than the end step position of its own position; and to adjust its own position to the initial step position of its own position if its own position is equal to the end step position of its current own position. That is, if the current own position is not equal to line[n-1:0]*line_in_max[k-1:0]*4-1, the updated own position is owned[k+n+1:0]+1; otherwise, the updated own position is 0.
[0148] When the encoder is configured with a synchronization management module 170 but not with a minimum cycle counter 160 and a watchdog monitoring module 180, the owned position update module 140 selects whether to update immediately based on the mode of the synchronization management module 170. After the synchronization management module receives the update command, it sends a synchronization valid signal sync_update output by the synchronization position control unit. After the owned position update module receives the synchronization signal sync_update, it updates the owned position owned[k+n+1:0] to the current target position target[k+n+1:0].
[0149] When the encoder is configured with at least two of the following: a minimum cycle counter 160, a watchdog monitoring module 180, and a synchronization management module 170, the self-positioning update module 140 can use the priority of the three modules as defined by those skilled in the art, selecting the rule corresponding to the signal of one module according to priority to update the target position. The self-positioning update unit receives input signals from the synchronization position control module, the direction determination module, the minimum cycle counter, and the watchdog monitoring module. Self-positioning update is triggered when the minimum cycle counter's status indication signal `line_update` (status indication valid signal), the watchdog monitoring module's `wdog_update` (watchdog monitoring valid signal), or the synchronization signal `sync_update` output by the synchronization position control module is valid (synchronization valid signal). An example control step is as follows:
[0150] 1. First check if sync_update is valid. If it is valid, then update the owned position [k+n+1:0] to target [k+n+1:0].
[0151] 2. If condition 1 is invalid, i.e., sync_update is invalid, check if the line_update signal of the minimum period counter is valid. If valid, the own position update module adjusts the direction according to the position input by the direction determination module to update the own position owned[k+n+1:0], that is:
[0152] 1) When forward rotation is valid, if the current owned position is not equal to line[n-1:0]*line_in_max[k-1:0]*4-1 (the end step position of the owned position, which is also the maximum threshold of the preset modulation steps), the updated owned position is owned[k+n+1:0]+1 (the value of the owned position is increased by 1); otherwise, the updated owned position is 0 (the initial step position of the owned position).
[0153] 2) When the reversal is valid, if the current owned position is not equal to 0 (the initial step position of the owned position, which is also the minimum threshold of the preset modulation steps), the updated owned position is owned[k+n+1:0]-1 (the value of the owned position is reduced by 1); otherwise, the updated owned position is line[n-1:0]*line_in_max[k-1:0]*4-1 (the end step position of the owned position).
[0154] 3) When the stop rotation is effective, the updated free position remains unchanged.
[0155] 3. If neither condition 1 nor 2 is met, i.e., sync_update is invalid and line_update is invalid, check if the watchdog monitoring module's wdog_update is valid. If valid, the default location update mechanism is as follows:
[0156] If the current owned position is not equal to line[n-1:0]*line_in_max[k-1:0]*4-1, the updated owned position is owned[k+n+1:0]+1; otherwise, the updated owned position is 0.
[0157] Please continue reading Figure 5 The encoder supports two output modes: ABZ encoding control and high-speed counter control. Specifically, it can support three output modes: ABZ type output, high-speed counting single pulse type, and high-speed counting double pulse type. Those skilled in the art can select at least one of them as the output result as needed.
[0158] Incremental encoders are widely used in position control applications such as motors. Common incremental encoder outputs are A / B phase quadrature signals and a Z-phase zero-point signal. Position control also requires encoding for high-speed counters. The above embodiment provides a multi-functional encoder design that can simultaneously generate A / B / Z encoding and high-speed counter encoding outputs, and significantly saves hardware resources by using a shared hardware unit.
[0159] The multifunctional encoder implementation provided in the above embodiments supports configurable line count and uses a self-owned position update method to support both ABZ encoding output and high-speed pulse counting encoding output. Furthermore, the minimum period of the AB phase is configurable, the zero point of the Z phase is adjustable, and a watchdog timer mechanism is designed to monitor the position and stop the encoder. Multiple encoding methods share a self-owned position update unit, thus saving significant hardware resources.
[0160] In one embodiment, a chip is also provided that includes the encoder provided in any of the foregoing embodiments.
[0161] For specific limitations regarding the chip, please refer to the limitations for the encoder mentioned above, which will not be repeated here.
[0162] In one embodiment, an encoding method is provided, which is an implementation method of the encoder provided in any of the above embodiments. Please refer to [link to relevant documentation]. Figure 6 , Figure 6 A flowchart illustrating the encoding method provided in an embodiment of the present invention is shown below. Figure 6 As shown, the method includes the following steps:
[0163] Step S610: Obtain the encoder's input position, current target position, available position, and maximum number of lines at the input position;
[0164] Step S620: Multiply the input position by the preset line number modulation multiple and the maximum line number of the input position to obtain the incremental modulation position;
[0165] Step S630: Maintain the current target position unchanged, or update the incremental modulation position to the current target position;
[0166] Step S640: Determine the step difference based on the current target step number at the current target position and the existing step number at the existing position, and determine the position adjustment direction based on the step difference and the preset difference reversal value;
[0167] Step S650: Update the current position by adjusting the direction based on the current position or the target position to obtain the updated position;
[0168] Step S660: Determine the output signal based on the output reference data.
[0169] The output reference data includes the first bit of the updated position, the zero bit of the updated position, and at least one of the following: all bits of the updated position and the counting output parameters, which include the B-phase output value and the position adjustment direction of the previous cycle.
[0170] As mentioned in the above embodiments, the preset line number modulation multiple and the maximum line number at the input position can be set by those skilled in the art as needed.
[0171] In this embodiment, before maintaining the current target position unchanged or updating the incremental modulation position to the current target position, the method includes: taking the first period of the event that the current target position is different from the own position as the initial period, and triggering the update of the incremental modulation position to the current target position after a preset period interval of the initial period; if the current target position is the same as the own position, and / or the current target position is different from the own position, maintaining the current target position unchanged within the preset period interval of the initial period.
[0172] In this embodiment, before updating the existing position based on the position adjustment direction or the current target position to obtain the updated position, the method includes: if at least one of a valid synchronization signal, a valid status indication signal, or a valid watchdog monitoring signal is received, determining one of the valid synchronization signal, the valid status indication signal, or the valid watchdog monitoring signal as a trigger signal according to a preset priority rule, so as to trigger the update of the existing position based on the position adjustment direction or the current target position to obtain the updated position; wherein,
[0173] The valid synchronization signal is determined as the trigger signal, which triggers the updating of the own position according to the current target position to obtain the updated position, including any one of the following: After receiving the update command, a valid synchronization signal is generated to trigger the updating of the own position to the current target position; After receiving the update command, if a new incremental modulation position is obtained and the new incremental modulation position is updated to the new current target position, a valid synchronization signal is generated to trigger the updating of the own position to the new current target position.
[0174] A valid status indication signal is identified as a trigger signal. This triggers an update of the user's position based on the position adjustment direction and the current target position, resulting in the updated position. This includes: when the current target position differs from the user's position, triggering a change in the load value according to a preset load value each cycle until the changed load value equals a preset load threshold, generating a valid status indication signal, and updating the user's position based on the position adjustment direction to obtain the updated position.
[0175] The watchdog monitoring valid signal is determined as the trigger signal. The trigger updates the own position according to the position adjustment direction and the current target position to obtain the updated position, including: if the position adjustment direction is unchanged, the monitoring position adjustment direction is unchanged for a continuous valid duration. When the continuous valid duration is greater than the preset duration threshold, a watchdog monitoring valid signal is generated. If the own position is less than the end step position of the own position, the own position is adjusted to the number of the own position plus 1; and if the own position is equal to the end step position of the current own position, the own position is adjusted to the initial step position of the current own position.
[0176] It is evident that in some scenarios, the solution of updating one's own position based on the current target position or adjusting the direction based on the current position only requires the current target position to update the own position. In other scenarios, both the current target position and the direction of the position adjustment are required to update the own position. It can be understood that, depending on the scenario, updating one's own position based on the current target position or adjusting the direction based on the current position includes two solutions: updating one's own position based on the current target position and updating one's own position based on both the current target position and the direction of the position adjustment.
[0177] In this embodiment, the output signal determined based on the output reference data includes at least one of the following:
[0178] If the output signal includes an ABZ type output signal, the first bit of the updated position is inverted to obtain the A-phase output result, and the first bit of the updated position and the zero bit of the updated position are XORed to obtain the B-phase output result. When the number of available steps is greater than or equal to the preset Z-phase start step number and the number of available steps is less than or equal to the preset Z-phase end step number, the Z-phase output result is controlled to be high level. When the number of available steps is less than the preset Z-phase start step number or the number of available steps is greater than the preset Z-phase end step number, the Z-phase output result is controlled to be low level.
[0179] If the output signal includes a high-speed counting single-pulse signal, if the position adjustment direction is forward, the output result of phase A is determined based on the first bit of the updated position. If the position adjustment direction is reverse or unchanged, an XOR operation is performed on the first bit and the zero bit of the updated position to obtain the output result of phase A. If the position adjustment direction is forward, the output of phase B will only update the latest position adjustment direction to the latest value of phase B when the first bit and the zero bit of the own position are equal to the preset forward switching point. If the position adjustment direction is reverse or unchanged, the output of phase B will only update the latest position adjustment direction to the latest value of phase B when the first bit and the zero bit of the own position are equal to the preset reverse switching point.
[0180] If the output signal includes a high-speed counting double-pulse output signal, if the position adjustment direction is forward, the output result of phase A is determined based on the first bit of the updated position. If the position adjustment direction is reverse or unchanged, phase A outputs a low level. If the position adjustment direction is forward, phase B outputs a low level. If the position adjustment direction is reverse or unchanged, an XOR operation is performed on the first bit of the updated position and the zeroth bit of the updated position to obtain the output result of phase B.
[0181] For specific limitations on the encoding method, please refer to the limitations on the encoder above, which will not be repeated here. In this embodiment, the encoder is essentially configured with multiple modules to execute the encoding method in any of the above embodiments. The specific functions and technical effects are the same as those in the above embodiments, and will not be repeated here.
[0182] In one embodiment, an electronic device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7As shown, the electronic device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements a coding method or server-side function or step.
[0183] In one embodiment, an electronic device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 8 As shown, the electronic device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements a client-side function or step of an encoding method.
[0184] In one embodiment, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:
[0185] Obtain the encoder's input position, current target position, and home position;
[0186] The incremental modulation position is obtained by multiplying the input position by the preset line number modulation multiple and the maximum line number of the input position;
[0187] Maintain the current target position unchanged, or update the incremental modulation position to the current target position;
[0188] The step difference is determined by comparing the current target step count at the current target position with the current step count at the current position, and the position adjustment direction is determined based on the step difference and the preset difference reversal value.
[0189] The user's position is updated based on the direction adjustment or the current target position to obtain the updated position;
[0190] The output signal is determined based on the output reference data, which includes the first bit of the updated position, the zero bit of the updated position, and at least one of the following: all bits of the updated position and the counting output parameters, which include the B-phase output value and the position adjustment direction of the previous cycle.
[0191] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0192] Obtain the encoder's input position, current target position, and home position;
[0193] The incremental modulation position is obtained by multiplying the input position by the preset line number modulation multiple and the maximum line number of the input position;
[0194] Maintain the current target position unchanged, or update the incremental modulation position to the current target position;
[0195] The step difference is determined by comparing the current target step count at the current target position with the current step count at the current position, and the position adjustment direction is determined based on the step difference and the preset difference reversal value.
[0196] The user's position is updated based on the direction adjustment or the current target position to obtain the updated position;
[0197] The output signal is determined based on the output reference data, which includes the first bit of the updated position, the zero bit of the updated position, and at least one of the following: all bits of the updated position and the counting output parameters, which include the B-phase output value and the position adjustment direction of the previous cycle.
[0198] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or electronic device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0199] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0200] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the above-described device, system, and controller can be divided into different functional units or modules to complete all or part of the functions described above.
[0201] The embodiments provided above are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. An encoder, characterized in that, The encoder includes: The line number modulation module is used to obtain the input position and multiply the input position by a preset line number modulation multiple to obtain the incremental modulation position; The target position update module is used to maintain the current target position unchanged, or update the current target position to the incremental modulation position; The direction determination module is used to determine the step difference based on the current target step number at the current target position and the free step number at the free position, and to determine the position adjustment direction based on the step difference and a preset difference reversal value. The self-owned position update module is used to update the self-owned position according to the position adjustment direction or the current target position to obtain the updated position; The encoder output control module is used to determine the output signal based on the output reference data. The output reference data includes the first bit of the updated position, the zero bit of the updated position, and at least one of the following: all bits of the updated position and counting output parameters. The counting output parameters include the B-phase output value of the previous cycle and the position adjustment direction.
2. The encoder as described in claim 1, characterized in that, The encoder further includes a synchronization position management module, which includes at least one of an immediate update module and a delayed update module, wherein: The immediate update module is used to generate a synchronization valid signal after receiving an update instruction when the immediate update module is in an active state, so as to trigger the self-located update module to update the self-located position to the current target position; The delayed update module is used to generate a synchronization valid signal when the delayed update module is in an active state and after receiving an update instruction, if the line number modulation module obtains a new incremental modulation position and the target position update module determines the new incremental modulation position as the new current target position, so as to trigger the self-position update module to update the self-position to the new current target position. If the synchronization location management module includes an immediate update module and a delayed update module, at the same time, either the immediate update module or the delayed update module is in an active state.
3. The encoder as described in claim 2, characterized in that, The synchronization location management module further includes an enable control module, which is used to receive status instructions to configure the immediate update module to be in an active state or the delayed update module to be in an active state.
4. The encoder as described in claim 1, characterized in that, The direction determination module includes a step difference determination module and a position adjustment direction determination module, wherein: The step difference determination module is used to determine the step difference as the difference between the current target step number and the available step number if the current target step number is greater than or equal to the available step number, and to determine the step difference as the difference between the current target step number and the available step number if the current target step number is less than the available step number. The preset maximum step number is determined based on the product of the preset line number modulation multiple and the maximum line number of the input position. The position adjustment direction determination module is used to determine the position adjustment direction as forward rotation if the current target number of steps is greater than the available number of steps, and the step difference is less than or equal to the preset difference reversal value; or if the current target number of steps is less than the available number of steps, and the step difference is greater than the preset difference reversal value. The position adjustment direction determination module is further configured to determine the position adjustment direction as unchanged if the current target step number is equal to the available step number; The position adjustment direction determination module is further configured to determine the position adjustment direction as reversed if a preset reversal condition is met. The preset reversal condition includes any one of the following. The current target number of steps is greater than the number of available steps, and the step difference is greater than the preset difference reversal value; The current target number of steps is less than the number of available steps, and the step difference is less than or equal to the preset difference reversal value; The direction of the position adjustment is neither clockwise nor constant.
5. The encoder as described in claim 4, characterized in that, The direction determination module further includes a preset difference commutation value determination module, which is used to determine the preset difference commutation value based on the preset maximum number of steps and the preset difference commutation ratio, wherein the preset difference commutation ratio is greater than zero and the preset difference commutation ratio is less than 1.
6. The encoder as claimed in claim 1, characterized in that, The encoder output control module includes at least one of the following: an ABZ-type output signal module, a high-speed counting single-pulse signal output module, and a high-speed counting double-pulse output signal module. The ABZ-type output signal module is used to invert the first bit of the updated position to obtain the A-phase output result, and to perform an XOR operation on the first bit and the zero bit of the updated position to obtain the B-phase output result. The ABZ-type output signal module is also used to control the Z-phase output result to be high when the number of available steps is greater than or equal to the preset Z-phase start step number and the number of available steps is less than or equal to the preset Z-phase end step number, and to control the Z-phase output result to be low when the number of available steps is less than the preset Z-phase start step number or the number of available steps is greater than the preset Z-phase end step number. The high-speed counting single-pulse signal output module is used to determine the A-phase output result based on the first bit of the updated position if the position adjustment direction is forward; and to perform an XOR operation on the first bit and the zero bit of the updated position if the position adjustment direction is reverse or unchanged, to obtain the A-phase output result. The high-speed counting single-pulse signal output module is also used to update the latest position adjustment direction to the latest B-phase value only when the first bit and the zero bit of the self-position are equal to a preset forward switching point if the position adjustment direction is forward; and to update the latest position adjustment direction to the latest B-phase value only when the first bit and the zero bit of the self-position are equal to a preset reverse switching point if the position adjustment direction is reverse or unchanged. The high-speed counting dual-pulse output signal module is used to determine the A-phase output result based on the first bit of the updated position if the position adjustment direction is forward; and to output a low level for the A-phase if the position adjustment direction is reversed or unchanged. The high-speed counting dual-pulse output signal module is also used to output a low level for the B-phase if the position adjustment direction is forward; and to perform an XOR operation on the first bit and the zero bit of the updated position to obtain the B-phase output result if the position adjustment direction is reversed or unchanged.
7. The encoder as described in any one of claims 1-6, characterized in that, The encoder further includes a minimum cycle counter, which includes a first counter and a state controller. The first counter is loaded with a load value. The state controller is used to trigger the load value to change a preset load value every cycle when the current target position is different from the own position, until the changed load value is equal to a preset load threshold, and generate a valid state indication signal to trigger the target position update module to determine the incremental modulation position as the current target position.
8. The encoder as claimed in claim 7, characterized in that, The minimum cycle counter is also used to trigger the target position update module to maintain the current target position unchanged when the changed load value is greater than or less than the preset load threshold.
9. The encoder as described in claim 7, characterized in that, The minimum cycle counter is also used to generate a valid status indication signal when the changed loading value is equal to the preset loading threshold, so as to trigger the self-position update module to update the self-position according to the position adjustment direction to obtain the updated position.
10. The encoder as claimed in claim 7, characterized in that, The minimum cycle counter triggers a change in the preset load value for each cycle, including: The minimum cycle counter triggers the loading value to decrease by a preset loading value in each cycle, at which time the preset loading threshold is less than the loading value. or, The minimum cycle counter triggers the loading value to increase by a preset loading value in each cycle, at which point the preset loading threshold is greater than the loading value.
11. The encoder as claimed in claim 7, characterized in that, The methods for determining the load value include: Obtain the working clock cycle and the highest resolution pulse cycle interval corresponding to the encoder's output signal; The load value is determined based on the working clock cycle and the pulse cycle interval.
12. The encoder as claimed in claim 11, characterized in that, The state controller is further configured to load the load value into the first counter in the next cycle when the changed load value equals the preset load threshold, so that the state controller repeatedly executes the step of triggering the load value to change the preset load value according to each cycle when the current target position is different from the own position, until the changed load value equals the preset load threshold, and triggering the target position update module to determine the incremental modulation position as the current target position.
13. The encoder as claimed in claim 9, characterized in that, The self-located update module includes a forward update module, a reverse update module, and a hold module, wherein: The forward update module is used to adjust the free position to the value of the free position minus 1 when the changed loading value is equal to the preset loading threshold, if the position adjustment direction is forward and the number of free steps of the free position is less than the end step position of the current free position. The forward update module is also used to adjust the free position to the initial step position of the current free position when the changed load value is equal to the preset load threshold, if the position adjustment direction is forward and the number of free steps of the free position is equal to the end step position of the current free position. The reverse update module is used to adjust the free position to the value of the free position plus 1 when the changed load value is equal to the preset load threshold, if the position adjustment direction is reversed and the free step number of the free position is greater than the initial step position of the current free position. The reverse update module is also used to adjust the free position to the end position of the current free position when the changed load value is equal to the preset load threshold, if the position adjustment direction is reversed and the free step number of the free position is equal to the initial step position of the current free position. The holding module is used to control the own position to remain unchanged when the changed loading value is equal to the preset loading threshold and the position adjustment direction remains unchanged.
14. The encoder as claimed in claim 7, characterized in that, The encoder also includes a watchdog monitoring module, which is used to obtain the position adjustment direction determined by the direction determination module. If the position adjustment direction is unchanged, it monitors the continuous effective duration of the unchanged position adjustment direction. When the continuous effective duration is greater than a preset duration threshold, it generates a watchdog monitoring valid signal and sends it to the self-position update module. The watchdog monitoring valid signal is used to trigger the self-position update module to adjust the self-position to the value of the self-position plus 1 when the self-position is less than the end step position of the self-position. And when the self-owned position update module is triggered, if the self-owned position is equal to the end step position of the current self-owned position, the self-owned position is adjusted to the initial step position of the current self-owned position.
15. The encoder as claimed in claim 14, characterized in that, The watchdog monitoring module includes a second counter and a signal generation module. The second counter is used to monitor the position adjustment direction. If the position adjustment direction remains unchanged, the second counter is triggered to reset to zero and start counting until the count value of the second counter reaches the watchdog threshold, triggering the signal generation module to generate the watchdog monitoring valid signal.
16. The encoder as claimed in claim 14, characterized in that, If the encoder includes at least two of the following: a synchronization position management module, a minimum cycle counter, and a watchdog monitoring module, the self-owned position update module is used to determine one of the following as a trigger signal according to a preset priority rule if it receives at least one of the following: a valid synchronization signal, a valid status indication signal, and a valid watchdog monitoring signal. This triggers the self-owned position update module to update the self-owned position based on the position adjustment direction or the current target position, thereby obtaining the updated position.
17. The encoder as claimed in any one of claims 1-6, characterized in that, The encoder also includes a watchdog monitoring module, which is used to obtain the position adjustment direction determined by the direction determination module. If the position adjustment direction is unchanged, it monitors the continuous effective duration of the unchanged position adjustment direction. When the continuous effective duration is greater than a preset duration threshold, it generates a watchdog monitoring valid signal and sends it to the self-position update module. The watchdog monitoring valid signal is used to trigger the self-position update module to adjust the self-position to the value of the self-position plus 1 when the self-position is less than the end step position of the self-position. And when the self-owned position update module is triggered, if the self-owned position is equal to the end step position of the current self-owned position, the self-owned position is adjusted to the initial step position of the current self-owned position.
18. An encoding method, characterized in that, The method includes: Obtain the encoder's input position, current target position, and home position; The incremental modulation position is obtained by multiplying the input position by the preset line number modulation factor and the maximum line number of the input position; Maintain the current target position unchanged, or update the incremental modulation position to the current target position; The step difference is determined based on the current target step number at the current target position and the free step number at the free position, and the position adjustment direction is determined based on the step difference and a preset difference reversal value. The position is updated by adjusting the direction based on the position or the current target position to obtain the updated position; The output signal is determined based on the output reference data, which includes the first bit of the updated position, the zero bit of the updated position, and at least one of the following: all bits of the updated position and the counting output parameters, which include the B-phase output value and the position adjustment direction of the previous cycle.
19. The encoding method as described in claim 18, characterized in that, Before maintaining the current target position unchanged, or updating the incremental modulation position to the current target position, the method includes: The first period of the event in which the current target position is different from the own position is taken as the initial period, and the incremental modulation position is updated to the current target position after a preset period interval from the initial period. If the current target position is the same as the existing position, and / or the current target position is different from the existing position, the current target position remains unchanged within the initial period interval preset period.
20. The encoding method as described in claim 18, characterized in that, Before updating the existing position based on the stated position or the current target position, and obtaining the updated position, the method includes: If at least one of the following is received: a valid synchronization signal, a valid status indication signal, or a valid watchdog monitoring signal, one of the following is determined as a trigger signal according to a preset priority rule: to trigger the updating of the own position based on the position adjustment direction or the current target position, so as to obtain the updated position. in, The effective synchronization signal is determined as the trigger signal to trigger the updating of the own position according to the current target position to obtain the updated position, including any one of the following: after receiving an update instruction, a effective synchronization signal is generated to trigger the updating of the own position to the current target position; after receiving an update instruction, if a new incremental modulation position is obtained and the new incremental modulation position is updated to the new current target position, a effective synchronization signal is generated to trigger the updating of the own position to the new current target position. The valid status indication signal is determined as the trigger signal, triggering the updating of the self-owned position based on the position adjustment direction and the current target position to obtain the updated position. This includes: when the current target position is different from the self-owned position, triggering the loading value to change a preset loading value every cycle until the changed loading value equals a preset loading threshold, generating a valid status indication signal, and updating the self-owned position based on the position adjustment direction to obtain the updated position. Determining the watchdog monitoring valid signal as the trigger signal, triggering the updating of the self-owned position based on the position adjustment direction and the current target position to obtain the updated position includes: if the position adjustment direction remains unchanged, monitoring the continuous valid duration of the unchanged position adjustment direction; when the continuous valid duration is greater than a preset duration threshold, generating a watchdog monitoring valid signal, triggering the adjustment of the self-owned position to the number of the self-owned position plus 1 when the self-owned position is less than the end step position of the self-owned position; and triggering the adjustment of the self-owned position to the initial step position of the current self-owned position when the self-owned position is equal to the end step position of the current self-owned position.
21. The encoding method according to any one of claims 18-20, characterized in that, The output signal is determined to include at least one of the following based on the output reference data: If the output signal includes an ABZ type output signal, the first bit of the updated position is inverted to obtain the A-phase output result, and an XOR operation is performed on the first bit and the zero bit of the updated position to obtain the B-phase output result. When the number of available steps is greater than or equal to the preset Z-phase start step number and the number of available steps is less than or equal to the preset Z-phase end step number, the Z-phase output result is controlled to be high level. When the number of available steps is less than the preset Z-phase start step number or the number of available steps is greater than the preset Z-phase end step number, the Z-phase output result is controlled to be low level. If the output signal includes a high-speed counting single-pulse type signal, if the position adjustment direction is forward, the A-phase output result is determined based on the first bit of the updated position. If the position adjustment direction is reverse or unchanged, an XOR operation is performed on the first bit and the zero bit of the updated position to obtain the A-phase output result. If the position adjustment direction is forward, the B-phase output will update the latest position adjustment direction to the latest B-phase value only when the first bit and the zero bit of the self-position are equal to a preset forward switching point. If the position adjustment direction is reverse or unchanged, the B-phase output will update the latest position adjustment direction to the latest B-phase value only when the first bit and the zero bit of the self-position are equal to a preset reverse switching point. If the output signal includes a high-speed counting double-pulse output signal, if the position adjustment direction is forward, the A-phase output result is determined based on the first bit of the updated position; if the position adjustment direction is reverse or unchanged, the A-phase output is low; if the position adjustment direction is forward, the B-phase output is low; if the position adjustment direction is reverse or unchanged, an XOR operation is performed on the first bit of the updated position and the zeroth bit of the updated position to obtain the B-phase output result.
22. A chip, characterized in that, The chip includes an encoder as described in any one of claims 1-17.
Citation Information
Patent Citations
Rotating electrical machine control apparatus and rotating electrical machine system
CN104348384A
Incremental encoder based on rotary transformer
CN202648676U