A bus encoder detection method, system, electronic device and storage medium
By acquiring the communication data protocol packets between the bus encoder and the servo driver and displaying them as curves, the problem of difficulty in quantifying the real-time relative position jitter range of the bus encoder was solved, thus improving the equipment's operating accuracy and production consistency.
Patent Information
- Application Number
- CN202511251907.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-03
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2045-09-03
AI Technical Summary
Existing technologies make it difficult to quantify the jitter range of the real-time relative position of the bus encoder, which affects the equipment's operational accuracy and production consistency.
By acquiring the communication data protocol packets between the bus encoder and the servo driver, adding them to the listening protocol packet array, and sending them in batches to the parsing array when a preset number is met, position parsing and curve drawing are performed to display the position and relative position changes of the bus encoder.
It enables the quantification of the real-time relative position jitter range of the bus encoder, improving the accuracy of equipment operation and the production consistency of the bus encoder, and making it easier for operators to quickly grasp the equipment status.
Smart Images

Figure CN120740659B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data detection and analysis, and particularly relates to a bus encoder detection method and system, an electronic device and a storage medium. BACKGROUND
[0002] In the field of industrial automation, the precision requirement of motion control is increasingly improved. As a core feedback element, the accuracy of the position data of the bus encoder directly affects the performance of the equipment. At present, the servo system generally uses incremental or absolute encoders to transmit the position signal through the bus. With the development of high speed and high precision of equipment, the traditional detection method is difficult to quantify the relative position jitter range, which leads to the fact that the control algorithm cannot accurately compensate for dynamic errors, and restricts the performance improvement of the equipment. In recent years, the demand for micron-level positioning in intelligent manufacturing has increased rapidly, but the random jitter of the encoder signal caused by factors such as electromagnetic interference and mechanical vibration has not formed a standardized evaluation system, which affects the production consistency of the bus encoder.
[0003] Therefore, how to quantify the jitter range of the real-time relative position of the bus encoder is an important problem to be solved, which is crucial for the operator to further improve the accuracy of the equipment operation. SUMMARY
[0004] The purpose of the present application is to overcome the above technical problems, and provide a bus encoder detection method and system, an electronic device and a storage medium, which can quantify the jitter range of the real-time relative position of the bus encoder, so as to ensure the production consistency of the bus encoder and further improve the accuracy of the equipment operation.
[0005] In a first aspect, an embodiment of the present application discloses a bus encoder detection method, which adopts the following scheme:
[0006] A bus encoder detection method comprises the following steps: obtaining a target communication data protocol packet between a bus encoder and a servo driver, and adding the target communication data protocol packet to a listening protocol packet array; when the number of protocol packets in the listening protocol packet array meets a preset number, sending the protocol packets in the listening protocol packet array to a to-be-analyzed protocol packet array; performing position analysis on the protocol packets in the to-be-analyzed protocol packet array to obtain target position information corresponding to each protocol packet; calculating a relative position change amount of adjacent positions according to a plurality of continuous target position information; and displaying a first curve drawn based on the plurality of target position information, and displaying a second curve drawn according to the relative position change amount.
[0007] By adopting the technical scheme, the target communication data protocol packet between the bus encoder and the servo driver is acquired and added to the monitoring protocol packet array, real-time monitoring of the position protocol packet is realized, and preparation is made for subsequent analysis; when the number of protocol packets in the monitoring protocol packet array meets the preset receiving number, the protocol packets are sent to the to-be-analyzed protocol packet array, real-time and parallel batch processing of data is realized, the number of thread program interruptions is reduced, and the program processing efficiency is improved; the position of the protocol packet is analyzed, the target position information is acquired, the position information in the communication content between the bus encoder and the servo driver can be accurately acquired, the first curve is drawn based on the target position information, and the second curve is drawn based on the relative position change amount for display, the position state of the bus encoder and the relative position change trend can be intuitively presented, the jitter range of the real-time relative position of the bus encoder is quantified, the operator can quickly master the working condition and performance characteristics of the bus encoder, and the production consistency of the bus encoder is ensured.
[0008] Optionally, the adding of the target communication data protocol packet to the monitoring protocol packet array comprises: judging whether the number of the target communication data protocol packets received by the serial port exceeds the preset receiving number; if yes, the monitoring protocol packet array is emptied first, and then the current target communication data protocol packet is added to the monitoring protocol packet array; if not, the current target communication data protocol packet is directly added to the monitoring protocol packet array, and the number of received serial ports is correspondingly increased.
[0009] By adopting the technical scheme, whether the number of received protocol packets of the serial port exceeds the preset receiving number is judged, the frequency of signal transmission between threads is reduced, and the number of thread interruptions is reduced; when the preset receiving number is exceeded, the monitoring protocol packet array is emptied first, and then the current target communication data protocol packet is added to the monitoring protocol packet array, so that the occupation of too much system memory is avoided, the subsequent continuous processing is not affected, and the timeliness of data is ensured; when the preset receiving number is not exceeded, the current target communication data protocol packet is directly added to the monitoring data protocol packet array, and the number of received serial ports is correspondingly increased, which is helpful for orderly and continuous accumulation of position protocol packet data for subsequent analysis and processing.
[0010] Optionally, the displaying the first curve based on the plurality of target position information and the displaying the second curve based on the relative position change amount comprises: obtaining current position information and a total number of times of resolving the position information, and adding the current position information and the total number of times of resolving the position information to a first display source array together, wherein the total number of times of resolving the position information is represented by an x-axis of the curve; obtaining a target relative position change amount of the current position information and previous time position information, and adding the target relative position change amount and the total number of times of resolving the position information to a second display source array together; determining whether a data amount in the first display source array reaches a preset value; if yes, performing down-sampling processing on data in the first display source array to obtain target structure display data; updating position information in the target structure display data to the first curve for display; and updating position information in the second display source array to the second curve for display.
[0011] By using the above technical solution, the current position information and the total number of times of resolving the position information are obtained and added to the first display source array together, the total number of times of resolving the position information is stored in association with the position information, which facilitates subsequent processing and display of the change of the position information with the number of times of resolving; the target relative position change amount of the current position information and the previous time position information is obtained and added to the second display source array together, which can clearly record the position change under different numbers of times of resolving; the determination of whether the data amount in the first display source array reaches the preset value helps to control the data amount and avoid the influence of excessive data on processing efficiency; the down-sampling processing on the data in the first display source array when the data amount reaches the preset value to obtain the target structure display data can reduce data redundancy, extract key information, and improve the response speed of interface display; the updating of the position information in the target structure display data to the first curve for display can update the first curve in real time to show the latest position information; and the updating of the position information in the second display source array to the second curve for display can update the second curve in real time to show the latest relative position change amount.
[0012] Optionally, the method further comprises: continuously updating a maximum value, a minimum value, and an average value of the plurality of relative position change amounts based on relative position change amounts of adjacent positions, and displaying the maximum value, the minimum value, and the average value together with the second curve.
[0013] By using the above technical solution, the maximum value, the minimum value, and the average value of the relative position change amounts of adjacent time points can be continuously updated and displayed together with the second curve, which can intuitively present the position change, and enable the user to more comprehensively and clearly know the characteristics of the relative position change amount in the running process of the bus encoder, thereby providing more abundant data support for subsequent analysis of the working state of the bus encoder.
[0014] Optionally, the amount of data in the first curve and the second curve adopts a new-in-old-out display principle, wherein the position information of the latest time is entered into the first display source array or the second display source array, when the position information of the latest time is entered into the first display source array or the second display source array, and when the position information contained in the first display source array or the second display source array reaches a preset threshold, the earliest position information is removed, and the position information of the latest time or the relative position change amount is added.
[0015] By adopting the above technical solution, it is ensured that the first curve and the second curve always display the latest data, so that the display screen can dynamically present the real-time state of the bus encoder, the display lag problem caused by data accumulation is avoided, and the working change trend of the bus encoder is more clearly and intuitively reflected.
[0016] In a second aspect, another embodiment of the present application discloses a bus encoder detection system, which adopts the following scheme:
[0017] A bus encoder detection system comprises: a receiving module configured to obtain a target communication data protocol packet between a bus encoder and a servo driver, and add the target communication data protocol packet to a listening protocol packet array; a sending module configured to send the protocol packets in the listening protocol packet array to a to-be-analyzed protocol packet array when the number of protocol packets in the listening protocol packet array meets a preset number; an analyzing module configured to analyze the position of the protocol packets in the to-be-analyzed protocol packet array to obtain target position information corresponding to each protocol packet; a calculating module configured to calculate a relative position change amount of adjacent positions according to a plurality of target position information; and a display module configured to draw a first curve based on the plurality of target position information for display, and draw a second curve based on the relative position change amount for display.
[0018] By adopting the above technical solution, the target communication data protocol packet between the bus encoder and the servo driver can be obtained, and the communication data protocol packets meeting the preset number can be sent to the to-be-analyzed protocol packet array, the communication data protocol packets can be analyzed to obtain target position information, the first curve can be drawn based on the target position information for display, and the second curve can be drawn based on the relative position change amount of adjacent positions for display, so that the position of the bus encoder and the relative position change amount can be intuitively viewed.
[0019] Optionally, the receiving module comprises: a listening unit, configured to receive target communication data protocol packets between the bus encoder and the servo driver; a first judging unit, configured to judge whether the number of the target communication data protocol packets received by the serial port exceeds a preset receiving number; if yes, the listening protocol packet array is emptied first, and then the current target communication data protocol packet is added to the listening protocol packet array; if no, the current target communication data protocol packet is directly added to the listening protocol packet array, and the number of the serial port received is correspondingly increased.
[0020] By using the above technical solution, the listening protocol packet array can be effectively managed, data loss and confusion caused by receiving too many protocol packets can be avoided, the effectiveness, accuracy and real-time performance of subsequent data analysis can be ensured, the data receiving process can be reasonably controlled, and subsequent unified and continuous processing of the protocol packets can be facilitated.
[0021] Optionally, the display module comprises: a first adding unit, configured to add current position information and a total analysis number of recorded position information to a first display source array, wherein the total analysis number is represented by a curve x axis; a second adding unit, configured to obtain a target relative position change amount of the current position information and previous position information, and add the target relative position change amount and the total analysis number to a second display source array; a second judging unit, configured to judge whether the data amount in the first display source array reaches a preset value; if yes, the data in the first display source array is down-sampled to obtain target structure display data; a first curve updating unit, configured to update the position information in the target structure display data to the first curve for display; and a second curve updating unit, configured to update the position information in the second display source array to the second curve for display.
[0022] By adopting the technical scheme, the total analysis times and the position information are associatedly stored by adding the current position information and the total analysis times of the recorded position information to the first display source array, so that the change of the position information with the analysis times can be conveniently processed and displayed; the target relative position change amount of the current position information and the last time position information is obtained by the second adding unit and is added to the second display source array together with the total analysis times, so that the relative position change under different analysis times can be clearly recorded; the data amount in the first display source array is judged by the second judging unit to reach the preset value, which is helpful to control the data amount and avoid the influence of excessive data on the processing efficiency; the data in the first display source array is subjected to downsampling processing to obtain the target structure display data when the data amount reaches the preset value, so that the data redundancy can be reduced, the key information can be extracted, and the interface refresh display efficiency can be improved; the position information in the target structure display data is updated to the first curve by the first curve updating unit to be displayed, so that the first curve can be updated in real time to show the latest position information; the position information in the second display source array is updated to the second curve by the second curve updating unit to be displayed, so that the second curve can be updated in real time to show the latest relative position change amount.
[0023] In a third aspect, another embodiment of the present application discloses an electronic device, which adopts the following scheme:
[0024] An electronic device, comprising: a memory and a processor, the memory is used to store a computer program; the processor is used to implement the steps of the method according to any one of the above when executing the computer program.
[0025] In a fourth aspect, another embodiment of the present application discloses a computer readable storage medium, which adopts the following scheme:
[0026] A computer readable storage medium, the computer readable storage medium has a computer program stored thereon, and the computer program is executed by a processor to implement the steps of the method according to any one of the above.
[0027] In summary, the present application includes at least one of the following beneficial technical effects:
[0028] 1. By obtaining the communication data protocol package between the bus encoder and the servo driver, adding it to the monitoring protocol package array, and sending it to the to-be-analyzed protocol package array when the number of protocol packages in the monitoring protocol package array meets the preset receiving number, the data can be processed in batches in real time and in parallel, the number of thread program interruptions is reduced, and the program processing efficiency is improved;
[0029] 2. The first curve is drawn based on the position information and the second curve is drawn according to the relative position change amount, which facilitates intuitive observation of the position and speed change of the encoder, so as to realize the jitter range of the quantized bus encoder real-time relative position change amount, facilitate the operator to quickly master the working condition and performance characteristics of the bus encoder, and further ensure the production consistency of the bus encoder.
[0030] 3. By judging whether the number of received protocol packets exceeds the preset receiving number, the frequency of signal sending between threads can be reduced, and the number of thread interruptions can be reduced; when the preset receiving number is exceeded, the monitoring protocol packet array is emptied first, and then the current target communication data protocol packet is added to the monitoring protocol packet array, which can avoid occupying too much system memory and affecting subsequent continuous processing, and ensure the timeliness of data; when it is not exceeded, it is directly added to the monitoring data protocol packet array and the corresponding receiving number is increased, which is helpful for orderly and continuously accumulating position protocol packet data for subsequent analysis and processing. BRIEF DESCRIPTION OF DRAWINGS
[0031] Figure 1 It is a block diagram schematic diagram of a dynamic test system;
[0032] Figure 2 It is a flowchart of a bus encoder detection method disclosed in an embodiment of the present application;
[0033] Figure 3 It is a specific flowchart of step S50 in the bus encoder detection method disclosed in the embodiment; Figure 2
[0034] Figure 4 It is a schematic diagram of curve display according to the data in the display source array;
[0035] Figure 5 It is a specific flowchart of step S12 in the bus encoder detection method disclosed in an embodiment of the present application;
[0036] Figure 6 It is a flowchart of a bus encoder detection system disclosed in another embodiment of the present application;
[0037] Figure 7 It is a structural schematic diagram of an electronic device disclosed in still another embodiment of the present application. DETAILED DESCRIPTION
[0038] The present application will be further described in detail below with reference to the accompanying drawings.
[0039] Embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While embodiments of the present application are shown in the drawings, it is understood that the present application can be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and fully convey the scope of the present application to those skilled in the art.
[0040] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in this application and the appended claims, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0041] It should be understood that although the terms "first," "second," etc. can be used herein to describe various information, these terms are not intended to denote a particular order or hierarchy. These terms are used only to distinguish one from another. For example, a first information can also be termed a second information, and, similarly, a second information can also be termed a first information, without departing from the scope of the present application. Therefore, the features defined with "first," "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "a plurality of" is two or more, unless otherwise specifically defined.
[0042] The technical solutions of the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0043]
First embodiment
[0044] Please refer to Figure 1 A bus encoder detection method disclosed in the embodiments of the present application is applied to a dynamic test system composed of a PC host computer test program, a bus encoder A and a motor A, a servo driver A, a USB to RS485, a high-precision encoder B and a motor B, a servo driver B, a coupling, a drag support, and various connection lines.
[0045] The PC host computer test program receives through the USB to serial RS485, monitors the communication data protocol package between the bus encoder A and the servo driver A in real time, includes the protocol package sent by the servo driver A and the protocol package returned by the bus encoder A, analyzes the protocol package and obtains the position information in the data package, calculates the relative change position between the two adjacent position protocol packages, and statistically displays the maximum value, the minimum value and the average value of the relative change position, and displays the position curve 1 (corresponding to the first curve described below) and the relative change position curve 2 (corresponding to the second curve described below) on the interface.
[0046] Bus encoder A: bus encoder to be tested;
[0047] Motor A: install bus encoder A to be tested, do not rotate actively during the whole test process;
[0048] Servo driver A: provide power supply for bus encoder A to be tested, and generate fixed period output position protocol package, the design period is, for example, 50us, and the actual period needs to be measured by an oscilloscope between two output reading protocol packages;
[0049] USB to RS485: the host computer half-duplex listens to RS485 bus data, the PC host computer test program and the device for listening to the protocol package between bus encoder A and servo driver A, and the listening mode only receives;
[0050] High-precision encoder B and motor B and servo driver B: the host computer software controls servo driver B through USB to serial (servo driver internally provided), drives motor B to output a set speed to drive motor A to rotate, in this embodiment, it can be understood that servo driver A does not drive motor A to rotate, and motor B rotates at a set speed to drive motor A to operate);
[0051] Coupling and counter support: coupling and fixing bus encoder A and motor A, and high-precision encoder B and motor B.
[0052] Referring to Figure 2 A bus encoder detection method disclosed in the embodiment of the application comprises a data receiving and adding step, a protocol package sending step, a position analyzing step and a curve calculating and displaying step. First, the target communication data protocol package is collected through the data receiving and adding step, when the number meets the preset value, the protocol package is transferred to the array to be analyzed by using the protocol package sending step, the target position information is obtained through the position analyzing step, and finally the position change amount is obtained and the curve is displayed through the curve calculating and displaying step. In this way, the jitter of the bus encoder feedback position can be intuitively presented, and the accuracy of the device operation can be easily mastered by the operator. The reason lies in that this process operation can systematically process the communication data between the bus encoder and the servo driver, and the position jitter condition can be visualized through curve comparison.
[0053] Specifically, the following steps are included:
[0054] S10, obtaining target communication data protocol package between bus encoder and servo driver, and adding the target communication data protocol package to the listening protocol package array;
[0055] Referring to Figure 1In the embodiment, the fixed period is generated by the servo driver, the reading encoder position information protocol packet request is requested, and the receiving of the PC through the USB to serial RS485 is realized, so as to realize the real-time monitoring of the communication data protocol packet between the bus encoder A and the servo driver A. The relevant communication data protocol packet can be effectively collected, and the subsequent analysis is prepared. In addition, the plurality of communication data protocol packets received successively are added to the monitoring protocol packet array, so that the data transmission frequency during the subsequent data processing is reduced, and the efficiency of the data processing is improved.
[0056] Specifically, the step S10 comprises:
[0057] S11, obtaining a target communication data protocol packet between the bus encoder and the servo driver;
[0058] The target communication data protocol packet between the bus encoder and the servo driver is obtained, and the data required for analysis can be collected.
[0059] S12, judging whether the number of the target communication data protocol packets received by the serial port exceeds a preset receiving number;
[0060] If yes, the monitoring protocol packet array is emptied, and the current target communication data protocol packet is added to the monitoring protocol packet array;
[0061] If no, the current target communication data protocol packet is directly added to the monitoring protocol packet array, and the number of the serial port receiving is correspondingly increased.
[0062] The number of the serial port receiving protocol packets is judged whether it exceeds the preset receiving number, so that the data amount of the monitoring protocol packet array can be controlled, and the processing burden caused by too much data and data loss can be avoided. When the preset receiving number is exceeded, the array is emptied and the current protocol packet is added, so that the influence of the array data on the PC memory on the subsequent processing can be avoided, and the timeliness and effectiveness of the monitoring protocol packet array data are ensured. When the preset receiving number is not exceeded, the current protocol packet is directly added and the receiving number is increased, which is helpful for orderly accumulating data for subsequent analysis and processing.
[0063] For example, referring to Figure 4 The flowchart corresponding to the step S12 is specifically shown in the following.
[0064] First, the serial port is opened and initialized;
[0065] The serial port protocol packet data is received, and whether the set serial port receiving number is exceeded is judged;
[0066] If yes, a signal of adding the received protocol packet is sent, and the receiving protocol packet array is emptied to prepare to receive a new data packet;
[0067] If no, the serial port protocol packet data is continuously received.
[0068] S20, when the number of protocol packets in the monitoring protocol packet array meets the preset number, sending the protocol packets in the monitoring protocol packet array to the to-be-parsed protocol packet array;
[0069] In this embodiment, when the number of protocol packets in the monitoring protocol packet array meets the preset number, the protocol packets are sent to the to-be-parsed protocol packet array, and data can be processed in batches to improve efficiency. Meanwhile, this judgment mechanism can ensure that the data in the monitoring protocol packet array is always within a reasonable range, avoiding subsequent processing difficulties due to excessive data.
[0070] S30, performing position analysis on the protocol packets in the to-be-parsed protocol packet array to obtain target position information corresponding to each protocol packet;
[0071] It is explained that in this embodiment, each protocol packet received has CRC correction, which is used to ensure the correctness of the position data, so as to facilitate accurate calculation and analysis of subsequent data.
[0072] S40, calculating a relative position change amount of adjacent positions according to the plurality of target position information.
[0073] The relative position change amount of adjacent positions is calculated according to the plurality of target position information, which can facilitate obtaining the dynamic position change of the bus encoder at different times, help to quickly find possible abnormalities of the bus encoder, and improve the accuracy and convenience of bus encoder detection.
[0074] S50, drawing a first curve based on the plurality of target position information for display, and drawing a second curve according to the relative position change amount for display;
[0075] The first curve displays the real-time position information of the bus encoder A based on the monitoring and analysis, and the second curve displays the relative change position, i.e., the speed, which is obtained from the adjacent positions of the first curve. The setting of this step S50 can intuitively present the position state and relative position change trend of the bus encoder, facilitating the operator to quickly master the working condition and performance characteristics of the bus encoder.
[0076] Specifically, referring to Figure 3 This step S50 includes:
[0077] S51, obtaining current position information and recording the total analysis times of position information, and adding them to the first display source array;
[0078] Wherein, the total analysis times are accumulated with the analysis times, and the current position information and the total analysis times of the recorded position information are added to the first display source array, so that the first display source array can store the basic data for generating the first curve, and the real-time position information of the bus encoder A can be displayed by drawing the curve according to the data. Referring to Figure 4 In the embodiment, the x-axis is the coordinate horizontal axis corresponding to the total analysis times, the left y-axis is the bus encoder position value, and the right y-axis is the bus encoder relative position change value.
[0079] S52, obtaining the target relative position change amount of the current position information and the last time position information, and adding the total analysis times to the second display source array;
[0080] Wherein, the step S52 adds the x-axis value and the position change amount to the second display source array, which can record the relationship between the relative position change amount and the bus encoder reading times, that is, the data receiving time, so as to generate the second curve to intuitively reflect the actual adjacent position change amount.
[0081] S53, judging whether the data amount in the first display source array reaches the preset value; if yes, performing downsampling processing on the data in the first display source array to obtain the target structure display data;
[0082] Wherein, the step S53 helps to control the timing of data processing, and the data in the first display source array is subjected to downsampling processing when the data amount reaches the preset value, so as to further optimize the data structure to clearly display the data. Here, the downsampling processing can use the LTTB algorithm, for example, 5000 data points are downsampled to 888 data points to draw the curve / line graph. In this way, the data amount can be reduced, and the display efficiency can be improved.
[0083] S54, updating the position information in the target structure display data to the first curve for display;
[0084] Wherein, the position information in the target structure display data is updated to the first curve for display, which can intuitively present the change of the standard position with time. Here, the display curve can use professional drawing software such as MATLAB, Origin, etc., or a simple drawing module can be integrated in the industrial control system, which is not limited.
[0085] S55, updating the position information in the second display source array to the second curve for display.
[0086] The step S55 updates the position information in the second display source array to the second curve for display, so that the operator can intuitively see the running abnormity and correct in time to improve the accuracy of the equipment operation.
[0087] Further, the method further comprises: continuously updating the maximum value, the minimum value and the average value of the plurality of relative position change amounts based on the relative position change amount of the adjacent position, and displaying the maximum value, the minimum value and the average value together with the second curve.
[0088] The maximum value, the minimum value and the average value of the plurality of relative position change amounts are continuously updated based on the relative position change amount of the adjacent position, and the maximum value, the minimum value and the average value are displayed together with the second curve, so that the dynamic range and the concentration trend of the relative position change amount can be reflected in real time, and the fluctuation of the relative position change amount can be observed intuitively.
[0089] Further, in the embodiment, the data amount in the first curve and the second curve adopts the display principle of new-in-old-out.
[0090] The position information of the latest time is entered into the first display source array or the second display source array, and when the position information contained in the first display source array or the second display source array reaches a preset threshold before the position information of the latest time is entered into the first display source array or the second display source array, the initial position information is removed, and the position information of the latest time or the relative position change amount is added. In this way, the first curve and the second curve can always display the latest data, so that the real-time state of the bus encoder can be dynamically presented on the display screen, the display lag problem caused by data accumulation can be avoided, and the working change trend of the bus encoder can be more clearly and intuitively reflected.
[0091] In summary, the bus encoder detection method disclosed in the first embodiment of the application can effectively collect relevant communication data protocol packets by obtaining the target communication data protocol packets between the bus encoder and the servo driver and adding the target communication data protocol packets to the listening protocol packet array, so as to prepare for subsequent analysis; when the number of protocol packets in the listening protocol packet array meets the preset receiving number, the listening protocol packet array is sent together to the to-be-analyzed protocol packet array, so that the data can be processed in real time and in parallel, and the processing efficiency is improved; the position information in the communication content between the bus encoder and the servo driver is accurately obtained by performing position analysis on the protocol packet and obtaining the target position information; the first curve is drawn based on the target position information, and the second curve is drawn based on the relative position change amount for display, so that the position state of the bus encoder and the trend of the relative position change amount can be intuitively presented, and the operator can quickly master the working condition and performance characteristics of the bus encoder.
[0092]
Second Embodiment
[0093] Please refer to Figure 6In the second embodiment of the present application, a bus encoder detection system is disclosed, which comprises a receiving module 210, a sending module 220, an analyzing module 230, a calculating module 240 and a display module 250.
[0094] The receiving module 210 is configured to acquire a target communication data protocol packet between the bus encoder and the servo driver, and add the target communication data protocol packet to an array of monitored protocol packets; the sending module 220 is configured to send the protocol packets in the array of monitored protocol packets to an array of protocol packets to be analyzed when the number of protocol packets in the array of monitored protocol packets meets a preset number; the analyzing module 230 is configured to analyze the position of the protocol packets in the array of protocol packets to be analyzed, and acquire target position information corresponding to each protocol packet; the calculating module 240 is configured to calculate a relative position change of adjacent positions according to a plurality of target position information; and the display module 250 is configured to display a first curve based on the plurality of target position information, and display a second curve based on the relative position change.
[0095] Further, the receiving module 210 comprises:
[0096] A monitoring unit is configured to acquire a target communication data protocol packet between the bus encoder and the servo driver; a first judging unit is configured to judge whether the number of target communication data protocol packets received by the serial port exceeds a preset receiving number; if yes, the array of monitored protocol packets is emptied first, and then the current target communication data protocol packet is added to the array of monitored protocol packets; if no, the current target communication data protocol packet is directly added to the array of monitored protocol packets, and the number of protocol packets received by the serial port is correspondingly increased.
[0097] Further, the display module 250 comprises:
[0098] The display module comprises:
[0099] A first adding unit is configured to acquire current position information and a total analysis number of position information, and add them to a first display source array; the total analysis number of position information is represented by a curve x axis;
[0100] A second adding unit is configured to acquire a target relative position change between the current position information and previous position information, and add the target relative position change and the total analysis number of position information to a second display source array;
[0101] A second judging unit is configured to judge whether the data amount in the first display source array reaches a preset value;
[0102] If yes, the data in the first display source array is down-sampled to obtain target structure display data;
[0103] a first curve updating unit configured to update position information in the target structure display data into the first curve for display;
[0104] a second curve updating unit configured to update position information in the second display source array into the second curve for display.
[0105] It should be noted that the bus encoder detection method realized by the bus encoder detection system disclosed in the second embodiment of the present application is the same as the first embodiment, and thus will not be described in detail here. Alternatively, each module in the present embodiment and the above-mentioned other operations or functions are respectively used to implement the method in the foregoing embodiments.
[0106]
Third Embodiment
[0107] Please refer to Figure 7 In the third embodiment of the present application, an electronic device is disclosed, which comprises a memory 310 and a processor 320. The memory 310 is configured to store a computer program. The processor 320 is configured to implement the steps of the bus encoder detection method disclosed in the first embodiment of the present application when executing the computer program. Details can be found in the foregoing description, and thus will not be described in detail here.
[0108] The electronic device provided in the present embodiment has the same technical effects as the bus encoder detection method in the first embodiment when applied in practice.
[0109]
Fourth Embodiment
[0110] In the fourth embodiment of the present application, a computer readable storage medium is disclosed. The computer readable storage medium is, for example, a non-volatile memory, such as a magnetic medium (e.g., a hard disk, a floppy disk, and a magnetic tape), an optical medium (e.g., a CDROM disk and a DVD), a magneto-optical medium (e.g., an optical disk), and a hardware device specially constructed for storing and executing computer executable instructions (e.g., a read-only memory (ROM), a random access memory (RAM), a flash memory, etc.). The computer readable storage medium stores a computer program. The computer readable storage medium can execute the computer program by one or more processors or processing devices to implement the bus encoder detection method in the foregoing embodiments.
[0111] In addition, it can be understood that the foregoing embodiments are only exemplary descriptions of the present application, and the technical solutions of the embodiments can be arbitrarily combined and used without conflict in technical features, contradiction in structure, and violation of the purpose of the present application.
[0112] In several embodiments provided by the present application, it should be understood that the disclosed methods, systems and devices can be implemented in other manners. For example, the modules included in the above-described system are merely illustrative; the division of the modules is merely a logical function division; there can be another division manner for the actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different parts can be indirect couplings or communication connections through some interfaces, devices or units, and can be electric, mechanical or in other forms.
[0113] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they can be located in one place or distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0114] In addition, the functional units / modules in each embodiment of the present application can be integrated into a processing unit / module, or each unit / module can be physically present alone, or two or more units / modules can be integrated into one unit / module. The integrated unit / module can be realized in the form of hardware or in the form of hardware plus software functional unit / module.
[0115] The integrated unit / module realized in the form of software functional unit / module can be stored in a computer-readable storage medium. The software functional unit stored in a storage medium includes a plurality of instructions for causing one or more processors of a computer device (which can be a personal computer, a server, or a network device, etc.) to execute some steps of the method described in each embodiment of the present application. The foregoing storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0116] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for some technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for detecting a bus encoder, characterized in that, include: Obtain the target communication data protocol packet between the bus encoder and the servo driver, and add the target communication data protocol packet to the listening protocol packet array; When the number of protocol packets in the listening protocol packet array meets the preset number, the protocol packets in the listening protocol packet array are sent together to the protocol packet array to be parsed; The location of the protocol packets in the array of protocol packets to be parsed is parsed to obtain the target location information corresponding to each protocol packet; Based on multiple consecutive target location information, the relative position change between adjacent locations is calculated; A first curve is plotted based on multiple target location information and displayed, and a second curve is plotted based on the relative position change and displayed. The step of plotting and displaying a first curve based on multiple target location information, and plotting and displaying a second curve based on the relative position change, includes: The current location information and the total number of times the location information is recorded are obtained and added together to the first display source array, wherein the total number of times the information is recorded is represented by the x-axis curve; Obtain the target relative position change between the current position information and the previous position information, and add the target relative position change and the total number of parsing times to the second display source array; Determine whether the amount of data in the first display source array has reached a preset value; If so, downsample the data in the first display source array to obtain the target structure display data; The position information in the target structure display data is updated to be displayed on the first curve; The position information in the second display source array is updated to the second curve for display.
2. The method according to claim 1, characterized in that, Adding the target communication data protocol packet to the listening protocol packet array includes: Determine whether the number of target communication data protocol packets received via serial port exceeds the preset number of packets to be received; If so, first clear the listening protocol packet array, and then add the current target communication data protocol packet to the listening protocol packet array; If not, the target communication data protocol packet is directly added to the listening protocol packet array, and the number of serial port receptions increases accordingly.
3. The method according to claim 1, characterized in that, Also includes: Based on the relative position changes of adjacent positions, the maximum, minimum, and average values of multiple relative position changes are continuously statistically updated and displayed together with the second curve.
4. The method according to claim 1, characterized in that, The data in the first curve and the second curve adopt the display principle of new in and old out. The position information of the latest moment enters the first display source array or the second display source array. Before the position information of the latest moment enters the first display source array or the second display source array, if the position information contained in the first display source array or the second display source array reaches a preset threshold, the initial position information is removed and the position information of the latest moment or the relative position change amount is added.
5. A bus encoder detection system, characterized in that, The method for performing any one of claims 1 to 4 includes: The receiving module is used to acquire the target communication data protocol packet between the bus encoder and the servo driver, and add the target communication data protocol packet to the listening protocol packet array; The sending module is used to send all the protocol packets in the listening protocol packet array to the protocol packet array to be parsed when the number of protocol packets in the listening protocol packet array meets the preset number; The parsing module is used to parse the protocol packets in the array of protocol packets to be parsed, and obtain the target location information corresponding to each protocol packet; The calculation module is used to calculate the relative position change between adjacent positions based on multiple consecutive target position information. The display module is used to draw a first curve based on multiple target position information for display, and to draw a second curve based on the relative position change for display.
6. The system according to claim 5, characterized in that, The receiving module includes: The monitoring unit is used to acquire the target communication data protocol packets between the bus encoder and the servo driver. The first judgment unit is used to determine whether the number of target communication data protocol packets received by the serial port exceeds the preset number of packets to be received. If so, first clear the listening protocol packet array, and then add the current target communication data protocol packet to the listening protocol packet array; If not, the target communication data protocol packet is directly added to the listening protocol packet array, and the number of serial port receptions increases accordingly.
7. The system according to claim 5, characterized in that, The display module includes: The first adding unit is used to obtain the current location information and the total number of times the location information is recorded, and add them together to the first display source array, wherein the total number of times the information is recorded is represented by the x-axis of the curve. The second adding unit is used to obtain the target relative position change between the current position information and the previous position information, and add the target relative position change and the total number of parsing times to the second display source array; The second judgment unit is used to determine whether the amount of data in the first display source array has reached a preset value; If so, downsample the data in the first display source array to obtain the target structure display data; The first curve update unit is used to update the position information in the target structure display data to the first curve for display. The second curve update unit is used to update the position information in the second display source array to the second curve for display.
8. An electronic device, characterized in that, include: Memory and processor, wherein the memory is used to store computer programs; The processor is configured to implement the steps of the method as described in any one of claims 1 to 4 when executing the computer program.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
WiFi signal data acquisition and processing method and WiFi signal data acquisition and processing system
CN110536324A
Absolute value encoder transmission delay compensation method
CN114499335A