A method and system for detecting high-speed counting function of encoder input module
By using the signal generator and CAN protocol to realize the high-speed counting function detection of the encoder input module, the problem of cumbersome detection steps and low accuracy is solved, automated detection is realized, 1.5MHz frequency requirements are met, and detection flexibility and accuracy are improved. sex.
Patent Information
- Application Number
- CN202411186298.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-08-28
AI Technical Summary
The existing encoder input modules have cumbersome detection steps during the production stage, which are prone to missed, the detection process is complex, the detection accuracy is low, and the programmable logic controller cannot meet the 1.5MHz frequency requirement, resulting in inaccurate detection.
A signal generator is used instead of the programmable logic controller, the 1.5MHz frequency and fixed pulse number are set through the SCPI protocol, and the high-speed count value of the encoder input module is automatically read using the CAN protocol, and the entire detection process is completely automated.
The inspection steps are simplified, the detection accuracy and flexibility are improved, manual operation is reduced, and production efficiency and product quality are improved.
Smart Images

Figure CN118687612B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of encoder detection, and in particular to a method and system for detecting a high-speed counting function of an encoder input module. Background Art
[0002] At present, in the production stage of the encoder input module, it is necessary to detect whether the high-speed counting function of the four high-speed counting interfaces (A0, B0, A1, B1) of the encoder input module is normal. The current detection method is to use the programmable logic controller to pre-program the ladder diagram program, let the programmable logic controller connect to the human-machine interface through the Modbus_TCP protocol, and the human-machine interface edits the operation interface according to the ladder diagram program of the programmable logic controller. During production, the high-speed output port of the programmable logic controller is manually connected to the four high-speed counting ports of the encoder input module in turn, and a fixed number of pulses is set through the human-machine interface to send to the high-speed counting port of the encoder input module, and then the upper computer software of the encoder input module is opened to check whether the number of pulses received is consistent with the number sent. The above detection method has cumbersome operation steps, most of which are manually operated and detected. There may be serious quality risks caused by serious missing processes, and the high-speed output pulse frequency of the programmable logic controller cannot reach the 1.5MHz required by the encoder input module. There is a problem that the input source cannot meet the detection requirements. Therefore, how to simplify the operation steps, automatically detect and ensure the accuracy of the input source is the problem encountered by the encoder input module in the production stage. Summary of the invention
[0003] The technical problem to be solved by the present invention is that the detection steps may be missed, the detection process is complicated, the existing codable logic controller cannot meet the detection requirements, and the detection accuracy is low. The purpose is to provide a method and system for detecting the high-speed counting function of an encoder input module. By replacing the programmable logic controller with a signal generator, the detection software controls the signal generator to set a 1.5MHz frequency and a fixed number of pulses through the SCPI protocol, the frequency and number of pulses of the signal generator can be arbitrarily set through the host computer software, the high-speed counting function is read through the CAN protocol, and the whole process is fully automated, so that the whole detection method is more flexible, and the operation steps are simpler and faster than the previous detection method through the programmable logic controller, and the detection accuracy is improved at the same time.
[0004] The present invention is achieved through the following technical solutions:
[0005] A first aspect of the present invention provides a method for detecting a high-speed counting function of an encoder input module, comprising the following specific steps:
[0006] Check whether the host computer and the signal generator communicate successfully. If so, the host computer initializes the signal generator channel parameters through the SCPI protocol.
[0007] Generate a signal generator channel waveform according to the signal generator channel parameters;
[0008] Send CAN commands to the CAN card based on the signal generator channel waveform;
[0009] Get the returned CAN data and parse it, and read the high-speed count value of the encoder input module;
[0010] Generate test results for high-speed count value analysis.
[0011] Further, the host computer initializes the signal generator parameters through the SCPI protocol, and the specific steps include:
[0012] Obtain the detection instruction of whether the host computer and the signal generator have successfully communicated, and obtain the signal of the signal generator;
[0013] Send multiple instructions to the signal generator in sequence through the host computer;
[0014] The parameters of the signal generator channels are set through multiple commands.
[0015] Furthermore, the host computer sequentially sends multiple instructions to the signal generator including: CAN data frame header 0x601, read data command 0x2F, read data address 0x0A, no effect 0x00, trigger command 0x01;
[0016] The signal generator channel parameter settings include: frequency of 1.5 MHz, waveform of sine wave, voltage of 5 V, and pulse of 10,000 cycles.
[0017] Furthermore, the CAN data returned by the acquisition includes:
[0018] The data returned in real time by the CAN heartbeat message mechanism includes CAN data and other data. The CAN data returned by the encoder input module will be mixed with other data.
[0019] Furthermore, the returned CAN data includes a CAN data frame header 0x601, an upload data command 0x4F, an upload data address 0x0A, a high-speed counting data high bit 0x27, and a high-speed counting data low bit 0x10.
[0020] Furthermore, the specific steps of parsing the returned CAN data include:
[0021] Send a command to read high-speed CAN;
[0022] Loop one thousand times to check whether the frame header is 0x601;
[0023] If it is not 0x601, resend the command to read high-speed CAN;
[0024] If it is 0x601, read the byte of the 0x601 frame header to see if it is 0x4F;
[0025] If it is not 0x4F, re-circulate and match whether the frame header is 0x601;
[0026] If it is 0x4F, convert the last 2 bytes of the 0x601 frame header from hexadecimal data to decimal;
[0027] Check whether the data is within the set threshold.
[0028] Furthermore, the last two bytes of the 0x601 frame header are converted from hexadecimal data to decimal data, specifically including:
[0029] Get the data returned as hexadecimal;
[0030] Convert the last two bytes of the above data from hexadecimal data to decimal data, and obtain the first converted data and place it in the register;
[0031] The first conversion data of the extraction register is multiplied by 10 to obtain a high-speed count value;
[0032] Furthermore, the confirmation of whether the data is a set threshold includes:
[0033] Get the high-speed count value. If the high-speed count value is 100000, it means that the encoder input module is detected successfully and the encoder input module is good.
[0034] If the high-speed count value is not 100000, it means that the encoder input module detection has failed and this encoder input module is defective.
[0035] A second aspect of the present invention provides an encoder input module high-speed counting function detection system, which is applied to an encoder input module high-speed counting function detection method, comprising a signal generator, a relay, an encoder input module, a host computer and a CAN card;
[0036] The host computer controls the signal generator to connect the relay to pull in the encoder input module, and the encoder input module is powered on;
[0037] The signal generator and the CAN card are connected to a host computer via USB. The host computer controls the signal generator via USB to set a fixed frequency and pulse quantity, and controls the CAN card via USB to read the high-speed counting value of the encoder input module;
[0038] The power supply module is used for supplying power.
[0039] Furthermore, the channel CH1+ and the channel CH2+ of the signal generator are respectively connected to the encoder input module interface A0, interface A1, interface B0, and interface B1 by means of relay switching;
[0040] The power supply module is connected to the encoder input voltage through relay switching to realize the power supply control of the encoder input module;
[0041] The interface CANH and the interface CANL of the CAN card are connected to the interface CANH and the interface CANL of the encoder input module respectively.
[0042] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0043] The signal generator is used to replace the original programmable logic controller as the input source of the encoder input module, which meets the 1.5MHz frequency requirement of the high-speed counting function detection of the encoder input module. In addition, the frequency and pulse number of the signal generator can be arbitrarily modified through the host computer software, making the entire detection method more flexible, and the operation steps are simpler and faster than the previous detection method through the programmable logic controller, which is more conducive to the detection in the production stage;
[0044] Use automation to replace manual operation and testing to improve production efficiency and product quality. The entire testing process is fully automatically controlled, and the test results are displayed on the testing system software after the test is completed;
[0045] Relays are used to realize the switching of the signal generator to the four high-speed counting ports of the encoder input module, and the high-speed counting function is read through the CAN protocol. The whole process is fully automated. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without creative work. In the drawings:
[0047] Figure 1 is the detection method in the embodiment of the present invention;
[0048] Figure 2 is a schematic diagram of a detection system in an embodiment of the present invention;
[0049] Figure 3 is a waveform of a signal generator in an embodiment of the present invention;
[0050] Figure 4 The CAN data processing process in the embodiment of the present invention
[0051] Figure 5 A test report generated after the upper computer software detects the encoder input module detection method in the embodiment of the present invention;
[0052] Figure 6 Schematic diagram of hardware connection of the encoder input module detection method in an embodiment of the present invention;
[0053] Figure 7 A schematic diagram of scanning a two-dimensional barcode by an encoder input module detection method in an embodiment of the present invention;
[0054] Figure 8 It is a schematic diagram of the automatic operation of the encoder input module detection method in an embodiment of the present invention. DETAILED DESCRIPTION
[0055] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0056] As a possible implementation, Figure 1 As shown, this embodiment provides a method for detecting the high-speed counting function of an encoder input module, including the following specific steps: detecting whether the host computer and the signal generator communicate successfully, if the communication is successful, the host computer initializes the signal generator channel parameters through the SCPI protocol; generates the signal generator channel waveform according to the signal generator channel parameters; based on the signal generator channel waveform, sends a CAN instruction to the CAN card; obtains and parses the returned CAN data, and reads the encoder input module high-speed counting value; analyzes the high-speed counting value to generate a test result. By replacing the programmable logic controller with a signal generator, the detection software controls the signal generator to set a 1.5MHz frequency and a fixed number of pulses through the SCPI protocol, and the frequency and number of pulses of the signal generator can be arbitrarily set through the host computer software. The high-speed counting function is read through the CAN protocol, and the entire process is fully automated, making the entire detection method more flexible, and simpler and faster than the previous detection method through the programmable logic controller, while improving the detection accuracy.
[0057] In some possible implementations, detecting whether the host computer and the signal generator communicate successfully includes: sending a SCPI "*IDN?" command to the signal generator through the host computer software, and returning the signal generator model if the host computer and the signal generator communicate successfully, and if nothing is returned, the communication fails, and checking the USB connection between the signal generator and the computer.
[0058] In some possible implementations, the host computer initializes the signal generator parameters through the SCPI protocol, and the specific steps include:
[0059] Obtain the detection instruction of whether the host computer and the signal generator have successfully communicated, and obtain the signal of the signal generator;
[0060] Send multiple instructions to the signal generator in sequence through the host computer;
[0061] The parameters of the signal generator channels are set through multiple commands.
[0062] In some possible implementations, such as Figure 3 As shown, the signal generator channel 1 is set to a 1.5MHz, sine wave, 5V, and 10,000-cycle pulse.
[0063] In some possible implementations, the host computer sequentially sends the following SCPI commands to the signal generator:
[0064] SOUR1:APPL:SIN1.500000,5,0,0;
[0065] SOUR1:BURS:MODETRIG;
[0066] SOUR1:BURS:NCYC100000;
[0067] OUTP1 ON;
[0068] SOUR1:BURS:TRIG;
[0069] In some possible implementations, the waveform calculation formula of the signal generator is: y(t)=5sin(2π⋅1000t).
[0070] In some possible implementations, the host computer sequentially sends multiple instructions to the signal generator including: CAN data frame header 0x601, read data command 0x2F, read data address 0x0A, no effect 0x00, trigger command 0x01;
[0071] The signal generator channel parameter settings include: frequency of 1.5MHz, waveform of sine wave, voltage of 5V, and pulse of 10,000 cycles. The frequency of 1.5MHz, waveform of sine wave, voltage of 5V, and pulse of 10,000 cycles are set because the frequency required for the detection of the object in this embodiment is 1.5MHz, and the high-speed output pulse frequency of the programmable logic controller cannot reach the 1.5MHz required by the encoder input module. The input source cannot meet the detection requirements. In order to remedy this problem, this application sets the frequency to 1.5MHz.
[0072] In some possible implementations, obtaining the returned CAN data includes:
[0073] The data returned by the CAN heartbeat message mechanism in real time includes CAN data and other data. The CAN data returned by the encoder input module will be mixed with other data. Since the CAN data returned by the encoder input module will be mixed with other CAN data, it is necessary to parse the CAN data.
[0074] In some possible implementations, the returned CAN data includes a CAN data frame header 0x601, an upload data command 0x4F, an upload data address 0x0A, a high-speed counting data high bit 0x27, and a high-speed counting data low bit 0x10.
[0075] In some possible implementations, such as Figure 4 As shown, the specific steps for parsing the returned CAN data include:
[0076] Send a command to read high-speed CAN;
[0077] Loop one thousand times to check whether the frame header is 0x601;
[0078] If it is not 0x601, resend the command to read high-speed CAN;
[0079] If it is 0x601, read the byte of the 0x601 frame header to see if it is 0x4F;
[0080] If it is not 0x4F, re-circulate and match whether the frame header is 0x601;
[0081] If it is 0x4F, convert the last 2 bytes of the 0x601 frame header from hexadecimal data to decimal;
[0082] Check whether the data is within the set threshold.
[0083] Because the sent and returned data are in hexadecimal, they need to be converted to decimal. Convert the last two bytes of the above data from hexadecimal to decimal. The data obtained is 10000. Because the high-speed count value is stored in the register after dividing by 10, it is multiplied by 10, which is the high-speed count value of 100000. If the high-speed count value is 100000, it means that the encoder input module is detected successfully, and this encoder input module is a good product. If it is not a failure, this encoder input module is a defective product.
[0084] As a possible implementation, Figure 2As shown, this embodiment provides an encoder input module high-speed counting function detection system, which is applied to an encoder input module high-speed counting function detection method, including a signal generator, a relay, an encoder input module, a host computer and a CAN card;
[0085] The host computer controls the signal generator to connect the relay to the encoder input module, and the encoder input module is powered on;
[0086] Connect 220VAC (equipped with a circuit breaker to prevent short circuit) to the signal generator and the power module respectively to power the signal generator and the power module. Connect the dual channels CH1+ and CH2+ of the signal generator to the encoder input modules A0, A1, B0, and B1 respectively through relay switching to realize input source control. Connect the power module 5V to the encoder input module 5V through relay switching to realize encoder input module power supply control. Connect the CAN card CANH and CANL to the encoder input module CANH and CANL respectively to realize the encoder input module communication mode. The signal generator and CAN card are connected to the industrial computer through USB. The detection software of the industrial computer controls the signal generator through USB to set a fixed frequency and number of pulses, and controls the CAN card through USB to read the high-speed counting value of the encoder input module.
[0087] As a possible implementation method, this embodiment provides an implementation method. Specifically, first manually scan the two-dimensional barcode of the encoder input module to start, then the detection method host computer software controls the power connection relay to be energized, and the encoder input module is powered on. The detection method host computer software sets the signal generator frequency to 1.5MHz, sine wave, 5V, and 100,000 pulses through the SCPI protocol, and controls the output of the signal generator. The host computer software controls the corresponding encoder high-speed counting ports (A0, A1, B0, B1) to be connected to the signal generator in sequence by controlling the energizing relay. The detection method host computer software reads the high-speed counting value of the encoder input module by sending a CAN instruction, and after parsing the returned CAN data, determines whether it is 100,000. If so, the host computer software interface will display "success" and generate a test report. If not, the host computer interface will display "failure" and record it in the test report. Figure 5 As shown in the figure, this is the test report generated by the upper computer software after the encoder input module detection method is completed. If a customer complains about the high-speed counting function problem after the encoder input module leaves the factory, the customer can provide a two-dimensional barcode. The factory technicians can query the test report at that time based on the two-dimensional barcode to understand the detection situation at that time, so as to help the technicians determine the cause of the problem.
[0088] like Figure 6As shown, when operating in detection mode, first place the encoder input module on the work surface, manually connect the relay cable to the encoder input module, and make hardware connections.
[0089] like Figure 7 As shown, a barcode gun is used manually to scan the two-digit barcode on the encoder input module.
[0090] like Figure 8 As shown, the encoder input module detection method starts to run automatically after the host computer software detects the two-dimensional barcode of the encoder input module.
[0091] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for detecting the high-speed counting function of an encoder input module, characterized in that: The specific steps include: Detect whether the host computer and the signal generator communicate successfully. If the communication is successful, the host computer initializes the signal generator channel parameters through the SCPI protocol. The host computer initializes the signal generator parameters through the SCPI protocol, including: obtaining a detection instruction for whether the host computer and the signal generator communicate successfully, and obtaining a signal generator signal; sending multiple instructions to the signal generator in sequence through the host computer, including: CAN data frame header 0x601, read data command 0x2F, read data address 0x0A, no effect 0x00, trigger command 0x01; setting the parameters of the signal generator channel through multiple instructions, and the signal generator channel parameter settings include: frequency is 1.5MHz, waveform is a sine wave, voltage is 5V, and pulse is a pulse with 10,000 cycles; Generate a signal generator channel waveform according to the signal generator channel parameters; Send CAN commands to the CAN card based on the signal generator channel waveform; Get the returned CAN data and parse it, and read the high-speed count value of the encoder input module; The returned CAN data includes: the data returned in real time by the CAN heartbeat message mechanism includes CAN data and other data, and the CAN data returned by the encoder input module will be mixed with other data; the returned CAN data includes the CAN data frame header 0x601, the upload data command 0x4F, the upload data address 0x0A, the high-speed counting data high bit 0x27 and the high-speed counting data low bit 0x10; Parsing the returned CAN data includes: sending the command to read the high-speed CAN; looping one thousand times to match whether the frame header is 0x601; if not 0x601, resending the command to read the high-speed CAN; if it is 0x601, reading whether the byte of the 0x601 frame header is 0x4F; if not 0x4F, re-looping to match whether the frame header is 0x601; if it is 0x4F, converting the last 2 bytes of the 0x601 frame header from hexadecimal data to decimal; obtaining the returned hexadecimal data; The last two bytes of the acquired and returned CAN data and the parsed and returned CAN data are converted from hexadecimal data to decimal data, and the first converted data is obtained and placed in the register; the first converted data of the register is extracted and multiplied by 10 to obtain a high-speed count value; Confirm whether the data is within the set threshold: Get high-speed count value; If the high-speed count value is 100000, it means that the encoder input module is detected successfully and the encoder input module is good. If the high-speed count value is not 100000, it means that the encoder input module detection has failed and the encoder input module is defective.
2. A high-speed counting function detection system for an encoder input module, applied to the high-speed counting function detection method for an encoder input module according to claim 1, characterized in that: Including signal generator, relay, encoder input module, host computer, CAN card and power module; The host computer controls the signal generator to connect the relay to pull in the encoder input module, and the encoder input module is powered on; The signal generator and the CAN card are connected to a host computer via USB. The host computer controls the signal generator via USB to set a fixed frequency and pulse quantity, and controls the CAN card via USB to read the high-speed counting value of the encoder input module; The power module is used for supplying power.
3. The encoder input module high-speed counting function detection system according to claim 2 is characterized in that: The channel CH1+ and channel CH2+ of the signal generator are respectively connected to the encoder input module interface A0, interface A1, interface B0, and interface B1 through relay switching; The power supply module is connected to the encoder input voltage through relay switching to realize the power supply control of the encoder input module; The interface CANH and the interface CANL of the CAN card are connected to the interface CANH and the interface CANL of the encoder input module respectively.
