A grating signal processing method, device and storage medium based on FPGA
Through the FPGA-based grating signal processing method, debounce filtering, signal sampling and trigger signal generation, the problems of fixed accuracy and inflexible trigger signal adjustment in the traditional method are solved, and variable resolution trigger signal generation is realized to meet the needs of industrial printing. High precision resolution requirements of the system.
Patent Information
- Application Number
- CN202410356537.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-03-26
AI Technical Summary
Traditional raster signal processing methods cannot meet the high-precision resolution requirements of industrial printing systems, and cannot flexibly adjust trigger signals, resulting in limited printing accuracy.
Using FPGA-based raster signal processing method, through debounce filtering, signal sampling, direction judgment and trigger signal generation, combined with FPGA configuration parameters, variable resolution trigger signal generation is achieved to meet the high-precision resolution requirements of different printing needs.
It improves the quality of the raster signal, ensures stable signal input, achieves accurate movement direction and position information acquisition, and flexibly adjusts the frequency and position of the trigger signal to meet high-precision and resolution printing requirements.
Smart Images

Figure CN118233569B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of printers, and in particular to a grating signal processing method, device and storage medium based on FPGA. Background Art
[0002] The traditional method directly inputs the grating signal, and then fixes a certain precision or divides the frequency by four to process the grating signal to obtain the direction, position information and speed.
[0003] Because in the printing system, after the grating signal is processed, not only the motion feedback such as direction, position information and speed is obtained, but also the printing trigger signal. The signal processing method of the grating directly determines the printing accuracy. Therefore, the fixed grating signal processing accuracy has a serious impact on the printing resolution, which cannot meet the high-precision resolution requirements of printing, and the trigger signal cannot be flexibly adjusted. Summary of the invention
[0004] The object of the present invention is to provide a grating signal processing method, device and storage medium based on FPGA to meet the multi-resolution triggering requirements of industrial printing systems.
[0005] The purpose of the present invention can be achieved through the following technical solutions:
[0006] The present application provides a grating signal processing method based on FPGA, comprising the following steps:
[0007] S1: grating signal input, inputs grating signals CHA and CHB into FPGA;
[0008] S2: De-jitter filtering, which performs de-jitter filtering on CHA and CHB signals to remove noise and interference and ensure stable signal input;
[0009] S3: Signal sampling: sampling CHA and CHB signals at the rising and falling edges, and obtaining the movement direction and position information by measuring the time difference between the two signals;
[0010] S4: Direction judgment: According to the sampled rising edge and falling edge information, the direction of movement is judged by comparing the phase difference of the two signals;
[0011] S5: trigger signal generation, combining the parameters configured by FPGA, select any one or more edges as the printing trigger signal, and select one edge as the standard for position information change, and set the frequency and position of the trigger signal according to the resolution requirements of the configuration;
[0012] S6: Output a trigger signal, and output the generated trigger signal to the printing system to control the triggering and position synchronization of printing.
[0013] Preferably, the grating signal CHA of the grating signal input provides a configuration interface to the MCU, sets the frequency division coefficient, obtains the resolution requirement and calculates the frequency division coefficient in the grating signal processing, and compares the calculated frequency division coefficient with the set threshold value;
[0014] When the frequency division coefficient is greater than or equal to 1, it means that the resolution requirement has been met and no further frequency division operation is required; when the frequency division coefficient is less than 1, it means that the resolution requirement cannot be met directly and a frequency division operation is required to determine the size of the frequency division coefficient.
[0015] According to the judgment result, make corresponding settings. If the division coefficient is greater than or equal to 1, the four edges are used as the trigger mode by default, and the trigger signal is output according to the original process; if the division coefficient is less than 1, the edge after division is used as the reference configuration trigger mode, and the trigger signal after division is output.
[0016] Preferably, the de-jitter filtering includes setting filter parameters, removing outliers and impulse noise by sorting the signals in a window and selecting the middle value, and setting the filter window size.
[0017] In each sampling period, the values of CHA and CHB signals are obtained, the sampled CHA and CHB signals are input into the selected filter for processing, the signals are de-jittered and filtered according to the median filtering algorithm, and the filtered CHA and CHB signals are obtained as output.
[0018] Preferably, according to the motion direction and position information in step S3, a phase difference measurement method is used for calculation, including:
[0019] Sampling signals, sampling CHA and CHB signals at the rising edge and falling edge to obtain corresponding sampling points;
[0020] Phase difference calculation, by comparing the time difference between the sampling points of the two signals, calculate the phase difference (in degrees). The specific calculation formula is as follows:
[0021] Phase difference = (Δt / T)*360°;
[0022] Where Δt is the time difference between the sampling points of CHA and CHB signals, and T is a complete signal cycle;
[0023] The direction and position of movement are calculated based on the calculated phase difference, combined with the parameters and settings of the incremental encoder. The direction of movement is determined based on the positive or negative phase difference, and the position change is calculated using the magnitude of the phase difference.
[0024] Based on signal sampling, more accurate movement direction and position information can be obtained by calculating the phase difference.
[0025] Preferably, according to the direction judgment described in step S4, the judgment is made according to the phase difference obtained in step S3. If the phase difference is positive, it indicates that the movement direction is forward; if the phase difference is negative, it indicates that the movement direction is reverse; and then according to the resolution of the incremental encoder, the position change corresponding to each complete signal cycle is determined, and 360° is set to correspond to a complete position change.
[0026] To convert the phase difference to position change, use the following formula:
[0027] Position change = (phase difference / 360°)*resolution;
[0028] Where resolution is the resolution of the incremental encoder, which means the number of encoder counts or pulses corresponding to each complete position change;
[0029] The positive or negative position change is determined based on the result of the judgment of the movement direction. If the movement direction is positive, the position change is positive; if the movement direction is reverse, the position change is negative.
[0030] Preferably, the trigger signal generation includes:
[0031] FPGA configuration parameters, set the configuration parameters in FPGA and set the FPGA clock frequency to 100MHz;
[0032] Set the trigger edge, select the rising edge of the CHA signal as the printing trigger signal, and generate a trigger signal when the rising edge of the CHA signal is detected by setting the trigger edge detection logic circuit;
[0033] Set the standard for position information change, select the falling edge of the CHB signal as the standard for position information change. When the falling edge of the CHB signal is detected, it means that the position has changed;
[0034] The frequency setting of the trigger signal uses a timer to generate the frequency of the trigger signal. The count value of the timer is set to 1000 and the clock frequency is 100MHz. Then the frequency of the trigger signal is 100MHz / 1000=100kHz.
[0035] The position setting of the trigger signal uses a counter to track the position information and generate the position of the trigger signal. The initial value of the counter is set to 0 and the step value is 10. Whenever the counter reaches a multiple of 10, a trigger signal is generated.
[0036] Output trigger signal. Generate a trigger signal and output it to the printing system based on the set trigger edge and position information. When the rising edge of the CHA signal is detected, the trigger signal is output, and when the falling edge of the CHB signal is detected, the standard for position information change is triggered.
[0037] Preferably, a control loop or feedback mechanism is introduced according to steps S1-S6, including:
[0038] Position feedback, obtaining position information in real time according to step S3;
[0039] Position comparison and correction: compare the actual position feedback with the generated trigger signal. If there is a difference, it means that the generated trigger signal needs to be corrected. According to the comparison result, the timing or position of the trigger signal is adjusted to keep it synchronized with the actual position.
[0040] The control algorithm corrects the trigger signal through an adaptive control algorithm based on the comparison result and the error size. The control algorithm dynamically adjusts the trigger signal based on the real-time feedback position information to maintain position synchronization and accuracy.
[0041] Correction strategy: If there is a slight deviation between the trigger signal and the position feedback, the trigger signal generation position is fine-tuned to make it closer to the actual position. When the position deviation is large, the trigger signal generation timing or position is adjusted according to the size and direction of the position deviation to quickly align the trigger signal with the actual position.
[0042] A grating signal processing device based on FPGA comprises: at least one processor, at least one memory and computer program instructions stored in the memory. When the computer program instructions are executed by the processor, the above method is implemented.
[0043] A storage medium stores computer program instructions, which implement the above method when the computer program instructions are executed by a processor.
[0044] The beneficial effects of the present invention are:
[0045] The grating signal is processed by de-jitter filtering to remove noise and interference to ensure stable signal input, which can improve the quality of the grating signal and reduce the impact on subsequent processing. Secondly, in the signal sampling stage, by measuring the time difference between the rising edge and the falling edge of the grating signal, accurate movement direction and position information can be obtained. Through the calculation of phase difference and direction judgment, it can be flexibly adjusted according to the actual situation to meet the resolution requirements of different printing needs;
[0046] In the trigger signal generation stage, through the configuration parameter setting of FPGA, any one or more edges can be selected as the printing trigger signal, and the frequency and position of the trigger signal can be set. The accuracy and position of the trigger signal can be flexibly adjusted according to specific needs to meet the high-precision resolution requirements of printing;
[0047] Through the comprehensive application of de-jitter filtering, signal sampling, direction judgment, trigger signal generation and control loop or feedback mechanism, the problems of fixed accuracy and inflexible trigger signal adjustment in traditional methods can be solved, and variable resolution trigger signal generation can be achieved to meet the high-precision resolution requirements of different printing needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] For better understanding and implementation, the technical solution of the present application is described in detail below with reference to the accompanying drawings.
[0049] Figure 1 A flow chart of a grating signal processing method based on FPGA provided in Example 1 of the present application;
[0050] Figure 2 A flowchart of grating signal input of a grating signal processing method based on FPGA provided in Example 1 of the present application. DETAILED DESCRIPTION
[0051] In order to further explain the technical means and effects taken by the present invention to achieve the predetermined invention purpose, exemplary embodiments will be described in detail here, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of methods and systems consistent with some aspects of the present application as detailed in the attached claims.
[0052] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0053] The specific implementation methods, features and effects of the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments.
[0054] Example 1
[0055] See also Figure 1-Figure 2, this embodiment provides a grating signal processing method, device and storage medium based on FPGA, which meets the multi-resolution triggering requirements of industrial printing systems.
[0056] The present invention provides a grating signal processing method based on FPGA, comprising the following steps:
[0057] S1: grating signal input, inputs grating signals CHA and CHB into FPGA;
[0058] S2: De-jitter filtering, which performs de-jitter filtering on CHA and CHB signals to remove noise and interference to ensure stable signal input;
[0059] S3: signal sampling, sampling the CHA and CHB signals at the rising and falling edges, and by measuring the time difference between the two signals, the movement direction and position information can be obtained;
[0060] S4: Direction judgment: judging the direction of movement (forward or reverse) based on the sampled rising and falling edge information, which can be achieved by comparing the phase difference of the two signals;
[0061] S5: trigger signal generation. Combined with the parameters configured by FPGA, any one or more edges are selected as the printing trigger signal, and an edge is selected as the standard for position information change. The frequency and position of the trigger signal can be set according to the resolution requirements of the configuration.
[0062] S6: Output a trigger signal, and output the generated trigger signal to the printing system to control the triggering and position synchronization of printing.
[0063] By de-jittering, filtering, sampling and direction judgment of the grating signal, combined with the configuration parameters of the FPGA, a trigger signal that meets the requirements can be generated to control the triggering and position synchronization of the printing system. This method can achieve variable resolution trigger signal generation to meet the resolution requirements of different printing needs.
[0064] Wherein, the CHA refers to a signal in the encoder output signal, which is used to measure rotational motion or linear displacement, and represents the position or motion by generating a pulse signal. CHA represents channel A of the encoder, which is an independent signal channel in the encoder output, and is used to determine the position and direction; the CHB refers to another signal in the encoder output signal, and CHB represents channel B of the encoder, which is also an independent signal channel in the encoder output. The CHA and CHB signals are usually separated by a certain phase to determine the direction and speed of motion;
[0065] The FPGA is a programmable gate array, which is a programmable logic device. Its logic functions can be reconfigured as needed. The FPGA can implement various complex digital logic functions, such as signal processing, control logic, etc. The FPGA described in the present invention is used to receive and process the signals output by the encoders CHA and CHB to achieve measurement and control of position or motion.
[0066] In this embodiment, the grating signal CHA of the grating signal input provides a configuration interface to the MCU, sets the frequency division coefficient, obtains the resolution requirement and calculates the frequency division coefficient in the grating signal processing, and compares the calculated frequency division coefficient with the set threshold value;
[0067] When the frequency division coefficient is greater than or equal to 1, it means that the resolution requirement has been met and no further frequency division operation is required; when the frequency division coefficient is less than 1, it means that the resolution requirement cannot be met directly and a frequency division operation is required to determine the size of the frequency division coefficient.
[0068] According to the judgment result, make corresponding settings. If the division coefficient is greater than or equal to 1, the four edges are used as the trigger mode by default, and the trigger signal is output according to the original process; if the division coefficient is less than 1, the edge after division is used as the reference configuration trigger mode, and the trigger signal after division is output.
[0069] By frequency division operation and selecting the trigger mode according to the frequency division coefficient, the accuracy and position of the trigger signal can be flexibly adjusted to meet the high-precision resolution requirements of different printing needs.
[0070] In this embodiment, the de-jitter filtering includes setting filter parameters, sorting the signal in a window and selecting the middle value to remove the outliers and impulse noise, wherein the median filter has a good suppression effect on the excitation noise or impulse noise, and setting the filter window size.
[0071] In each sampling period, the values of CHA and CHB signals are obtained, and the sampled CHA and CHB signals are input into the selected filter for processing. The signals are de-jittered and filtered according to the median filter algorithm to obtain the filtered CHA and CHB signals as output. These filtered signals will remove noise and interference to ensure stable signal input.
[0072] The median filter has a good suppression effect on excitation noise or impulse noise. Impulse noise often exists in the form of extremely short pulses. By sorting and selecting the middle value within the filter window, the impact of this type of noise on the signal can be reduced, thereby improving the signal quality.
[0073] In this embodiment, according to the motion direction and position information in step S3, a phase difference measurement method is used for calculation, including:
[0074] Sampling signals, sampling CHA and CHB signals at the rising edge and falling edge to obtain corresponding sampling points;
[0075] Phase difference calculation, by comparing the time difference between the sampling points of the two signals, calculate the phase difference (in degrees). The specific calculation formula is as follows:
[0076] Phase difference = (Δt / T)*360°;
[0077] Where Δt is the time difference between the sampling points of CHA and CHB signals, and T is a complete signal cycle;
[0078] The direction and position of movement are calculated based on the calculated phase difference, combined with the parameters and settings of the incremental encoder. The direction of movement is determined based on the positive or negative phase difference, and the position change is calculated using the magnitude of the phase difference.
[0079] Through the phase difference measurement method, the phase difference is calculated based on signal sampling, and combined with the encoder parameters and settings, high-precision movement direction judgment and accurate position change calculation can be achieved, thereby obtaining more accurate movement direction and position information.
[0080] In this embodiment, according to the direction judgment described in step S4, the phase difference obtained in step S3 is used for judgment. If the phase difference is positive, it indicates that the movement direction is forward; if the phase difference is negative, it indicates that the movement direction is reverse. Then, according to the resolution of the incremental encoder, the position change corresponding to each complete signal cycle is determined, and 360° is set to correspond to a complete position change.
[0081] To convert the phase difference to position change, use the following formula:
[0082] Position change = (phase difference / 360°)*resolution;
[0083] Where resolution is the resolution of the incremental encoder, which means the number of encoder counts or pulses corresponding to each complete position change;
[0084] The positive or negative position change is determined based on the result of the judgment of the movement direction. If the movement direction is positive, the position change is positive; if the movement direction is reverse, the position change is negative.
[0085] The direction of movement is determined according to the positive or negative phase difference, and the resolution of the incremental encoder is used to convert the phase difference into the corresponding position change. Finally, the positive or negative position change is determined according to the judgment result of the direction of movement, and the accurate direction of movement and position change can be obtained.
[0086] In this embodiment, the trigger signal generation includes:
[0087] FPGA configuration parameters, set the configuration parameters in FPGA and set the FPGA clock frequency to 100MHz;
[0088] Set the trigger edge, select the rising edge of the CHA signal as the printing trigger signal, and generate a trigger signal when the rising edge of the CHA signal is detected by setting the trigger edge detection logic circuit;
[0089] Set the standard for position information change, select the falling edge of the CHB signal as the standard for position information change. When the falling edge of the CHB signal is detected, it means that the position has changed;
[0090] The frequency setting of the trigger signal uses a timer to generate the frequency of the trigger signal. The count value of the timer is set to 1000 and the clock frequency is 100MHz. Then the frequency of the trigger signal is 100MHz / 1000=100kHz.
[0091] The position setting of the trigger signal uses a counter to track the position information and generate the position of the trigger signal. The initial value of the counter is set to 0 and the step value is 10. Whenever the counter reaches a multiple of 10, a trigger signal is generated.
[0092] Output trigger signal, generate trigger signal and output it to the printing system according to the set trigger edge and position information, for example, when the rising edge of CHA signal is detected, the trigger signal is output, and when the falling edge of CHB signal is detected, the standard of position information change is triggered.
[0093] By setting specific configuration parameters, a trigger signal that meets the requirements can be generated in the FPGA, which can realize the functions of controlling the triggering and position synchronization of printing.
[0094] In this embodiment, a control loop or feedback mechanism is introduced according to steps S1-S6, including:
[0095] Position feedback, obtaining position information in real time according to step S3;
[0096] Position comparison and correction: compare the actual position feedback with the generated trigger signal. If there is a difference, it means that the generated trigger signal needs to be corrected. According to the comparison result, the timing or position of the trigger signal is adjusted to keep it synchronized with the actual position.
[0097] The control algorithm uses an adaptive control algorithm to correct the trigger signal based on the comparison result and the error size. The control algorithm can dynamically adjust the trigger signal based on the real-time feedback position information to maintain position synchronization and accuracy.
[0098] Correction strategy: If there is a slight deviation between the trigger signal and the position feedback, the trigger signal generation timing or position can be fine-tuned to make it closer to the actual position. When the position deviation is large, the trigger signal generation timing or position can be adjusted according to the size and direction of the position deviation to quickly align the trigger signal with the actual position.
[0099] By introducing a control loop or feedback mechanism, combined with real-time position feedback and control algorithms, the output trigger signal can be monitored and corrected in real time to achieve position synchronization and accuracy control of the printing system.
[0100] A grating signal processing device based on FPGA comprises: at least one processor, at least one memory and computer program instructions stored in the memory. When the computer program instructions are executed by the processor, the above method is implemented.
[0101] A storage medium stores computer program instructions, which implement the above method when the computer program instructions are executed by a processor.
[0102] Example 2
[0103] In step S5, this embodiment converts the grating ruler with a precision of 180 dpi into a printing trigger signal with a precision of 360 dpi. An appropriate method can be selected according to specific needs to obtain a uniform or non-uniform 360 dpi trigger signal to meet the resolution requirements of the printing system.
[0104] The trigger signal generation is combined with the parameters configured by the FPGA and specific settings are made based on the signal sampling process. For the print trigger of converting 180dpi to 360dpi, the following two methods can be selected:
[0105] a. Set the rising and falling edges of the A / B phases as trigger signals, and keep the original signal sampling process. This will generate a uniform 360dpi trigger signal.
[0106] b. Select the rising edge of phase A and the rising edge of phase B as the trigger signal and ignore the falling edge. This will get an uneven 360dpi trigger signal.
[0107] Example 3
[0108] In step S5, the grating ruler with a precision of 25400 dpi is converted into a 360 dpi printing trigger signal. In the trigger signal generation of the S5 stage, the MCU sets the frequency division coefficient to realize the resolution conversion and generates the trigger signal according to the original signal sampling process. This will generate a uniform 360 dpi trigger signal to meet the resolution requirements of the printing system.
[0109] Combined with the parameters configured by FPGA, specific settings are made on the basis of the signal sampling process. For the print trigger of converting 25400dpi to 360dpi, frequency division operation is required. The frequency division coefficient is set to (25400 / 360) / 4=17.72 in MCU; then the rising and falling edges of the A / B phases of the trigger are set as trigger signals, the original signal sampling process is maintained, and in the trigger signal generation stage, the edge after frequency division is used as the reference to configure the trigger mode, and the trigger signal is output.
[0110] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technical personnel in this field can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any brief modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.
Claims
1. A grating signal processing method based on FPGA, It is characterized in that The steps include: S1: grating signal input, inputs grating signals CHA and CHB into FPGA; S2: De-jitter filtering, which performs de-jitter filtering on CHA and CHB signals to remove noise and interference and ensure stable signal input; S3: Signal sampling, sampling the CHA and CHB signals at the rising edge and the falling edge, and obtaining the movement direction and position information by measuring the time difference between the two signals; S4: Direction determination: according to the sampled rising edge information and falling edge information, the direction of movement is determined by comparing the phase difference of the two signals; S5: trigger signal generation, combining the parameters configured by FPGA, select any one or more edges as the printing trigger signal, and select one edge as the standard for position information change, and set the frequency and position of the trigger signal according to the resolution requirements of the configuration; S6: Output trigger signal, output the generated trigger signal to the printing system, and control the trigger and position synchronization of printing; The trigger signal generation comprises: FPGA configuration parameters, set the configuration parameters in FPGA and set the FPGA clock frequency to 100 MHz; Set the trigger edge, select the rising edge of the CHA signal as the printing trigger signal, and generate a trigger signal when the rising edge of the CHA signal is detected by setting the trigger edge detection logic circuit; Set the standard for position information change, select the falling edge of the CHB signal as the standard for position information change. When the falling edge of the CHB signal is detected, it means that the position has changed; The frequency setting of the trigger signal uses a timer to generate the frequency of the trigger signal. Set the count value of the timer to 1000 and the clock frequency to 100 MHz. Then the frequency of the trigger signal is 100 MHz / 1000 = 100 kHz. The position setting of the trigger signal uses a counter to track the position information and generate the position of the trigger signal. The initial value of the counter is set to 0 and the step value is 10. Whenever the counter reaches a multiple of 10, a trigger signal is generated. Output trigger signal, according to the set trigger edge and position information, generate trigger signal and output it to the printing system, when the rising edge of CHA signal is detected, the trigger signal is output, and when the falling edge of CHB signal is detected, the standard of position information change is triggered; A control loop or feedback mechanism is introduced in steps S1-S6, including: Position feedback, obtaining position information in real time according to step S3; Position comparison and correction: compare the real-time feedback position information with the generated trigger signal. If there is a difference, it means that the generated trigger signal needs to be corrected. According to the comparison result, the timing or position of the trigger signal is adjusted to keep it synchronized with the actual position. The control algorithm uses an adaptive control algorithm to correct the trigger signal based on the comparison results and the difference size. The adaptive control algorithm dynamically adjusts the trigger signal based on the real-time feedback position information to maintain position synchronization and accuracy. Correction strategy: If there is a slight deviation between the trigger signal and the real-time feedback position information, the trigger signal generation position is fine-tuned to make it closer to the actual position. When the position deviation is large, the trigger signal generation timing or position is adjusted according to the size and direction of the position deviation to quickly align the trigger signal with the actual position.
2. The grating signal processing method based on FPGA according to claim 1, It is characterized in that The grating signal CHA of the grating signal input provides a configuration interface to the MCU, sets the frequency division coefficient, obtains the resolution requirement and calculates the frequency division coefficient in the grating signal processing, and compares the calculated frequency division coefficient with the set threshold value; When the frequency division coefficient is greater than or equal to 1, it means that the resolution requirement has been met and no further frequency division operation is required; when the frequency division coefficient is less than 1, it means that the resolution requirement cannot be met directly and a frequency division operation is required to determine the size of the frequency division coefficient. According to the judgment result, make corresponding settings. If the frequency division coefficient is greater than or equal to 1, four edges are used as the trigger mode by default, and the trigger signal is output according to the original process; If the frequency division coefficient is less than 1, the divided edge is used as the reference configuration trigger mode, and the divided trigger signal is output.
3. The grating signal processing method based on FPGA according to claim 1, It is characterized in that The de-jitter filtering includes setting filter parameters, removing outliers and impulse noise by sorting the signal within a window and selecting the middle value, and setting the filter window size. In each sampling period, the values of CHA and CHB signals are obtained, the sampled CHA and CHB signals are input into the selected filter for processing, the signals are de-jittered and filtered according to the median filtering algorithm, and the filtered CHA and CHB signals are obtained as output.
4. The grating signal processing method based on FPGA according to claim 1, It is characterized in that According to the movement direction and position information in step S3, a phase difference measurement method is used to perform calculation, including: Sampling signals, sampling CHA and CHB signals at the rising edge and falling edge to obtain corresponding sampling points; Phase difference calculation, by comparing the time difference between the sampling points of the two signals, calculate the phase difference in degrees. The specific calculation formula is as follows: Phase difference = (Δt / T) * 360°; Where Δt is the time difference between the sampling points of CHA and CHB signals, and T is a complete signal cycle; The motion direction and position calculation is based on the calculated phase difference, combined with the parameters and settings of the incremental encoder, and the motion direction is determined based on the positive or negative phase difference, and the position change is calculated based on the magnitude of the phase difference; Based on the sampling signal, more accurate movement direction and position information can be obtained by calculating the phase difference.
5. The grating signal processing method based on FPGA according to claim 4, It is characterized in that According to the direction judgment described in step S4, the phase difference obtained in step S3 is used to judge that if the phase difference is positive, it means that the movement direction is forward; if the phase difference is negative, it means that the movement direction is reverse; then according to the resolution of the incremental encoder, the position change corresponding to each complete signal cycle is determined, and 360° is set to correspond to a complete position change. To convert the phase difference to position change, use the following formula: Position change = (phase difference / 360°) * resolution; Where resolution is the resolution of the incremental encoder, which means the number of encoder counts or pulses corresponding to each complete position change; The positive or negative position change is determined based on the result of the judgment of the movement direction. If the movement direction is positive, the position change is positive; if the movement direction is reverse, the position change is negative.
6. A grating signal processing device based on FPGA, It is characterized in that include: At least one processor, at least one memory and computer program instructions stored in the memory, when the computer program instructions are executed by the processor, a grating signal processing method based on FPGA as claimed in any one of claims 1 to 5 is implemented.
7. A storage medium having computer program instructions stored thereon, It is characterized in that When the computer program instructions are executed by a processor, a grating signal processing method based on FPGA as claimed in any one of claims 1 to 5 is implemented.
