An automatic identification method, system and medium based on high-speed 485 module
By obtaining the input level status data of the controller GPIO and the slave module GPIO, the preparation status of the front module is determined, and automatic identification and linking of modules are realized through high-speed 485 communication, which solves the high cost and low efficiency of automatic identification of high-speed 485 modules in the existing technology. solve the problem and realize efficient and low-cost module automatic identification and linking.
Patent Information
- Application Number
- CN202411444175.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-10-16
AI Technical Summary
The prior art has high cost and low efficiency in automatic identification of high-speed 485 modules, making it difficult to effectively solve the problem of module location and address designation in multi-module environments, resulting in high probability of errors.
By obtaining the pull-up input level status data of the controller GPIO and the preset pull-down input level status data of the slave module GPIO1, the preparation status of the front module is determined, and automatic identification and linking of modules are realized through high-speed 485 communication to improve the accuracy of data transmission. rate and efficiency.
Automatic identification and linking of modules are realized, the probability of errors is reduced, and the cost is low and efficient, solving the problems of high cost and low efficiency of identification methods in the existing technology.
Smart Images

Figure CN118963228B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of high-speed 485 modules, and in particular to an automatic identification method, system and medium based on high-speed 485 modules. Background Art
[0002] Generally, a variety of modules are mounted on the controller, such as digital IO module, analog voltage input and output module, analog current input and output module, encoder analysis module, PWM power drive module, and the number of corresponding ports on each module is different. In actual applications, users need to specify the location and address of the module in the program according to the arrangement order of the module in order to access the module. When the number of modules is large, the probability of error is high. The existing method of automatic identification through ethercat (Ethernet control automation technology) slave station as networking has high module cost and controller cost. Therefore, a low-cost and high-efficiency identification method is needed.
[0003] In view of the above problems, effective technical solutions are urgently needed. Summary of the invention
[0004] The purpose of this application is to provide a method, system and medium for automatic identification based on high-speed 485 modules, which can realize automatic module identification link through 485 communication and improve the accuracy and efficiency of data transmission.
[0005] The present application also provides an automatic identification method based on a high-speed 485 module, comprising the following steps:
[0006] Obtain the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and obtain the corresponding front module preparation state according to the pull-up input level state data and the pull-down input level state data;
[0007] According to the front module preparation state, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state;
[0008] According to the access status, the slave module is marked as module n through high-speed 485 communication, module query information is sent, and query link status is obtained according to the sending status of the module query information;
[0009] According to the query link status, the type data of module n is obtained, the receiving data information of module n is sent according to the type data and the output end is configured as a pull-up input.
[0010] Optionally, in the automatic identification method based on the high-speed 485 module described in the present application, the obtaining of the pull-up input level status data of the controller GPIO and the preset pull-down input level status data of the slave module input terminal, and obtaining the corresponding front module preparation state according to the pull-up input level status data and the pull-down input level status data, specifically includes:
[0011] Get the pull-up input level status data of the controller GPIO, including pull-up input high level or pull-up input low level;
[0012] Obtain the pull-down input level state data of the preset slave module input terminal, including the pull-down input high level or the pull-down input low level;
[0013] Performing an AND operation on the pull-up input level state data and the pull-down input level state data to obtain the front module preparation state data;
[0014] The front module preparation state is determined according to the front module preparation state data, including ready or not ready.
[0015] Optionally, in the automatic identification method based on the high-speed 485 module described in the present application, according to the preparation state of the front module, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state, specifically including:
[0016] If the front module is in the ready state, the slave module GPIO1 is switched to the output mode, and the output level state is obtained, including output high level or output low level;
[0017] The controller GPIO determines the output level state and obtains the access state accordingly;
[0018] If the output level state is output low level, the access state is module access; if the output level state is output high level, the access state is no module access.
[0019] Optionally, in the automatic identification method based on the high-speed 485 module described in the present application, the slave module is marked as module n through the high-speed 485 communication according to the access status, the module query information is sent, and the query link status is obtained according to the sending status of the module query information, specifically including:
[0020] If the access status is module access, the controller GPIO sends module tag information and module type query information through high-speed 485 communication;
[0021] Mark the slave module as module n, and obtain the communication response time data;
[0022] Compare the communication response time data with a preset communication response time threshold to obtain a query link status, including a successful link or an unsuccessful link;
[0023] If the communication response time data is greater than the communication response time threshold, the query link status is that the link is unsuccessful;
[0024] If the communication response time data is less than or equal to the communication response time threshold, the query link status is a successful link.
[0025] Optionally, in the automatic identification method based on the high-speed 485 module described in the present application, obtaining the type data of module n according to the query link status, sending the received data information of module n according to the type data and configuring the output end as a pull-up input specifically includes:
[0026] If the query link status is successful, then receiving and obtaining the type data of module n;
[0027] According to the received data information of the type data sending module n, the received data information includes address data and received data length value;
[0028] Module n configures GPIO2 as a pull-up input.
[0029] Optionally, in the automatic identification method based on the high-speed 485 module described in the present application, after the module n configures GPIO2 as a pull-up input, it also includes:
[0030] Detect the level change state of GPIO2, including no change state or low state;
[0031] If the level change state is a pull-down state, there is a module to be connected after module n.
[0032] In a second aspect, the present application provides an automatic identification system based on a high-speed 485 module, the system comprising: a memory and a processor, wherein the memory stores a program of an automatic identification method based on a high-speed 485 module, and when the program of the automatic identification method based on a high-speed 485 module is executed by the processor, the following steps are implemented:
[0033] Obtain the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and obtain the corresponding front module preparation state according to the pull-up input level state data and the pull-down input level state data;
[0034] According to the front module preparation state, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state;
[0035] According to the access status, the slave module is marked as module n through high-speed 485 communication, module query information is sent, and query link status is obtained according to the sending status of the module query information;
[0036] According to the query link status, the type data of module n is obtained, the receiving data information of module n is sent according to the type data and the output end is configured as a pull-up input.
[0037] Optionally, in the automatic identification system based on the high-speed 485 module described in the present application, the obtaining of the pull-up input level status data of the controller GPIO and the preset pull-down input level status data of the slave module input terminal, and obtaining the corresponding front module preparation state according to the pull-up input level status data and the pull-down input level status data, specifically includes:
[0038] Get the pull-up input level status data of the controller GPIO, including pull-up input high level or pull-up input low level;
[0039] Obtain the pull-down input level state data of the preset slave module input terminal, including the pull-down input high level or the pull-down input low level;
[0040] Performing an AND operation on the pull-up input level state data and the pull-down input level state data to obtain the front module preparation state data;
[0041] The front module preparation state is determined according to the front module preparation state data, including ready or not ready.
[0042] Optionally, in the automatic identification system based on the high-speed 485 module described in the present application, according to the preparation state of the front module, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state, specifically including:
[0043] If the front module is in the ready state, the slave module GPIO1 is switched to the output mode, and the output level state is obtained, including output high level or output low level;
[0044] The controller GPIO determines the output level state and obtains the access state accordingly;
[0045] If the output level state is output low level, the access state is module access; if the output level state is output high level, the access state is no module access.
[0046] In the third aspect, the present application also provides a readable storage medium, which stores an automatic identification method program based on the high-speed 485 module. When the automatic identification method program based on the high-speed 485 module is executed by a processor, the steps of an automatic identification method based on the high-speed 485 module as described in any of the above items are implemented.
[0047] As can be seen from the above, the automatic identification method, system and medium based on the high-speed 485 module provided by the present application. The method obtains the pull-up input level status data of the controller GPIO and the preset pull-down input level status data of the slave module GPIO1, and then determines the pre-module preparation state. According to the pre-module preparation state, the controller GPIO determines the output level state, thereby obtaining the access state of the slave module, marking the module and sending module query information through high-speed 485 communication according to the access state, and then obtaining the query link state, obtaining the type data according to the query link state, sending the received data information according to the type data and configuring the output end as the pull-up input; thereby realizing the automatic module recognition link through 485 communication, and realizing the technology of improving the accuracy and efficiency of data transmission.
[0048] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures particularly pointed out in the written description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 A flowchart of an automatic identification method based on a high-speed 485 module provided in an embodiment of the present application;
[0051] Figure 2 A flowchart of obtaining a pre-module preparation state of an automatic identification method based on a high-speed 485 module provided in an embodiment of the present application;
[0052] Figure 3 A flowchart of obtaining the access status of a slave module based on an automatic identification method of a high-speed 485 module provided in an embodiment of the present application;
[0053] Figure 4A flowchart of obtaining a query link status based on an automatic identification method of a high-speed 485 module provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0055] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0056] Please refer to Figure 1 , Figure 1 485 module in some embodiments of the present application. The automatic identification method based on the high-speed 485 module is used in terminal devices, such as computers, mobile phones, etc. The automatic identification method based on the high-speed 485 module includes the following steps:
[0057] S11, obtaining the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and obtaining the corresponding front module preparation state according to the pull-up input level state data and the pull-down input level state data;
[0058] S12, according to the front module preparation state, switching the slave module GPIO1 to output and obtaining the output level state, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state;
[0059] S13, marking the slave module as module n through high-speed 485 communication according to the access status, sending module query information, and obtaining the query link status according to the sending status of the module query information;
[0060] S14. According to the query link status, the type data of module n is obtained, and the receiving data information of module n is sent according to the type data and the output end is configured as a pull-up input.
[0061] It should be noted that there will be multiple modules or multiple modules of the same type on the controller. When establishing communication, it is necessary to first detect the ready state of the module. The slave module refers to the module located behind the front module. While the communication connection is established between the front module and the slave module, the controller is also connected to the module through high-speed 485 communication; the ready state of the front module is obtained by processing the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and the access state of the slave module is obtained according to the ready state of the front module combined with the output level state. According to the access state, the module marking and sending module query information are completed through high-speed 485 communication, and the query link state is obtained according to the sending of the module query information. Finally, the type data of the module is obtained according to the query link state, and then the module receiving data information is obtained.
[0062] Please refer to Figure 2 , Figure 2 The present invention provides a flowchart of obtaining the front module preparation state of an automatic identification method based on a high-speed 485 module according to an embodiment of the present invention. According to an embodiment of the present invention, the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module input terminal are obtained, and the corresponding front module preparation state is obtained according to the pull-up input level state data and the pull-down input level state data, specifically including:
[0063] S21, obtaining the pull-up input level state data of the controller GPIO, including the pull-up input high level or the pull-up input low level;
[0064] S22, obtaining the pull-down input level state data of the preset slave module input terminal, including the pull-down input high level or the pull-down input low level;
[0065] S23, performing an AND operation on the pull-up input level state data and the pull-down input level state data to obtain front module preparation state data;
[0066] S24. Determine the front module preparation state according to the front module preparation state data, including ready or not ready.
[0067] It should be noted that the controller GPIO refers to the general-purpose input / output port of the controller. GPIO is the abbreviation of General-Purpose Input / Output. When the controller is used as a pull-up input, its level state is obtained, including a high level or a low level. At the same time, the pull-down input level state data of the preset slave module input terminal is obtained. The level of the slave module pull-down input terminal also includes a high level or a low level. The pull-up input level state data and the pull-down input level state data are ANDed to obtain the front module preparation state data. The front module preparation state data calculation formula is:
[0068] ;
[0069] in, Prepare status data for the front module, For pull-up input level status data, Input level status data for pull-down;
[0070] In this embodiment, the high level is 1 and the low level is 0. When the pull-up input level status data is the pull-up input high level and the pull-down input level status data is the pull-down input high level, the result of the AND operation, that is, the front module preparation status data is 1, and 1 corresponds to the front module preparation status of being ready; when the current module preparation status data is 0, the front module preparation status is not ready; in this embodiment, when the voltage is 1.65V, a high level will be detected.
[0071] Please refer to Figure 3 , Figure 3 The flowchart of obtaining the access status of the slave module based on the automatic identification method of the high-speed 485 module provided by the embodiment of the present application. According to the embodiment of the present invention, according to the preparation state of the front module, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access status of the slave module according to the output level state, specifically including:
[0072] S31, if the front module is in the ready state, the slave module GPIO1 is switched to the output mode, and the output level state is obtained, including output high level or output low level;
[0073] S32, the controller GPIO determines the output level state and obtains the access state accordingly;
[0074] S33. If the output level state is output low level, the access state is module access; if the output level state is output high level, the access state is no module access.
[0075] It should be noted that GPIO1 distinguishes the input / output at both ends of the module. The preparation status of the front module affects the access of the slave module. Therefore, when the current module preparation status is ready, the slave module GPIO1 switches to output mode and obtains the output level status, including output high level or output low level. The controller GPIO will judge the output level status, where the output low level corresponds to module access, and the output high level corresponds to no module access. Through this judgment, the access status can be clearly determined.
[0076] Please refer to Figure 4 , Figure 4The flowchart of obtaining the query link status of an automatic identification method based on a high-speed 485 module provided by an embodiment of the present application. According to the embodiment of the present invention, the slave module is marked as module n through high-speed 485 communication according to the access status, module query information is sent, and the query link status is obtained according to the sending status of the module query information, specifically including:
[0077] S41, if the access status is module access, the controller GPIO sends module tag information and module type query information through high-speed 485 communication;
[0078] S42, marking the slave module as module n, and obtaining the communication response time data by statistics;
[0079] S43, comparing the communication response time data with a preset communication response time threshold to obtain a query link status, including a successful link or an unsuccessful link;
[0080] S44, if the communication response time data is greater than the communication response time threshold, the query link status is that the link is unsuccessful;
[0081] S45. If the communication response duration data is less than or equal to the communication response duration threshold, the query link status is successful.
[0082] It should be noted that in order to avoid confusion between modules and ensure the accuracy of data sent by the controller and communication between modules, the data receiving address of the module and the length of the receivable data must be determined. First, only when the access status is module access, the controller GPIO can send module marking information and module type query information through high-speed 485 communication. The module marking information is to determine the module number for easy distinction; the module type query information is to obtain the module type. After marking the module as n, n can be a positive integer such as 1, 2, 3, etc., and the module is named and marked according to the module position or order. After the module type query information is sent, it must be limited It is impossible to wait indefinitely for a certain reaction time, so it is necessary to count the communication response time data. If the communication response time data is greater than the preset communication response time threshold, it means that after a long waiting time, the module type query information has not been sent successfully. If the communication response time data is less than or equal to the preset communication response time threshold, the query link status is successful. In this embodiment, the communication response time threshold is set to: (0,5], which means successful link; greater than 5 means unsuccessful link; when the communication response time data is 3, the commodity heat index category is the effective commodity heat index. The query link status is successful link.
[0083] According to an embodiment of the present invention, obtaining type data of module n according to querying the link status, sending receiving data information of module n according to the type data and configuring the output end as a pull-up input specifically includes:
[0084] If the query link status is successful, then receiving and obtaining the type data of module n;
[0085] According to the received data information of the type data sending module n, the received data information includes address data and received data length value;
[0086] Module n configures GPIO2 as a pull-up input.
[0087] It should be noted that if the query link status is successful, normal communication is established between the controller and the module. The type data of module n is obtained according to the module type query information, and the receiving data information of module n is obtained according to the type data, including the address data and the receiving data length value. The address data reflects the address of the module receiving data, and the receiving data length value indicates the length of the data that can be received. GPIO2 is named to distinguish the two ports of the module.
[0088] According to an embodiment of the present invention, after module n configures GPIO2 as a pull-up input, it further includes:
[0089] Detect the level change state of GPIO2, including no change state or low state;
[0090] If the level change state is a pull-down state, there is a module to be connected after module n.
[0091] It should be noted that, since the controller is connected to many modules, when it is uncertain whether there are other modules behind the linked module, it is necessary to detect the level change state of GPIO2, including no change state or low state. The no change state means that the level has not changed, and the low state means that the level is pulled low. When the level change state is the low state, it means that there are modules to be linked after the linked module.
[0092] It is worth mentioning that it also includes:
[0093] The controller combines the data to be sent into a data frame, which includes a data address and corresponding data content;
[0094] Send the data address and data content to the link module via high-speed 485 communication;
[0095] Each link module intercepts the data content of the module in the data frame according to the address data and the received data length value.
[0096] It should be noted that when the controller sends data, the data will be integrated into a data frame, which will contain the data address and the data content corresponding to the data address. Each module will query and intercept the data belonging to the module according to its own address data and the length value of the received data.
[0097] The present invention also discloses an automatic identification system based on a high-speed 485 module, comprising a memory and a processor, wherein the memory stores an automatic identification method program based on a high-speed 485 module, and when the automatic identification method program based on a high-speed 485 module is executed by the processor, the following steps are implemented:
[0098] Obtain the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and obtain the corresponding front module preparation state according to the pull-up input level state data and the pull-down input level state data;
[0099] According to the front module preparation state, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state;
[0100] According to the access status, the slave module is marked as module n through high-speed 485 communication, module query information is sent, and query link status is obtained according to the sending status of the module query information;
[0101] According to the query link status, the type data of module n is obtained, the receiving data information of module n is sent according to the type data and the output end is configured as a pull-up input.
[0102] It should be noted that there will be multiple modules or multiple modules of the same type on the controller. When establishing communication, it is necessary to first detect the ready state of the module. The slave module refers to the module located behind the front module. While the communication connection is established between the front module and the slave module, the controller is also connected to the module through high-speed 485 communication; the ready state of the front module is obtained by processing the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and the access state of the slave module is obtained according to the ready state of the front module combined with the output level state. According to the access state, the module marking and sending module query information are completed through high-speed 485 communication, and the query link state is obtained according to the sending of the module query information. Finally, the type data of the module is obtained according to the query link state, and then the module receiving data information is obtained.
[0103] According to an embodiment of the present invention, the step of obtaining the pull-up input level status data of the controller GPIO and the pull-down input level status data of the preset slave module input terminal, and obtaining the corresponding front module preparation state according to the pull-up input level status data and the pull-down input level status data, specifically includes:
[0104] Get the pull-up input level status data of the controller GPIO, including pull-up input high level or pull-up input low level;
[0105] Obtain the pull-down input level state data of the preset slave module input terminal, including the pull-down input high level or the pull-down input low level;
[0106] Performing an AND operation on the pull-up input level state data and the pull-down input level state data to obtain the front module preparation state data;
[0107] The front module preparation state is determined according to the front module preparation state data, including ready or not ready.
[0108] It should be noted that the controller GPIO refers to the general-purpose input / output port of the controller. GPIO is the abbreviation of General-Purpose Input / Output. When the controller is used as a pull-up input, its level state is obtained, including a high level or a low level. At the same time, the pull-down input level state data of the preset slave module input terminal is obtained. The level of the slave module pull-down input terminal also includes a high level or a low level. The pull-up input level state data and the pull-down input level state data are ANDed to obtain the front module preparation state data. The front module preparation state data calculation formula is:
[0109] ;
[0110] in, Prepare status data for the front module, For pull-up input level status data, Input level status data for pull-down;
[0111] In this embodiment, the high level is 1 and the low level is 0. When the pull-up input level status data is the pull-up input high level and the pull-down input level status data is the pull-down input high level, the result of the AND operation, that is, the front module preparation status data is 1, and 1 corresponds to the front module preparation status of being ready; when the current module preparation status data is 0, the front module preparation status is not ready; in this embodiment, when the voltage is 1.65V, a high level will be detected.
[0112] According to an embodiment of the present invention, according to the front module preparation state, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state, specifically including:
[0113] If the front module is in the ready state, the slave module GPIO1 is switched to the output mode, and the output level state is obtained, including output high level or output low level;
[0114] The controller GPIO determines the output level state and obtains the access state accordingly;
[0115] If the output level state is output low level, the access state is module access; if the output level state is output high level, the access state is no module access.
[0116] It should be noted that GPIO1 distinguishes the input / output at both ends of the module. The preparation status of the front module affects the access of the slave module. Therefore, when the current module preparation status is ready, the slave module GPIO1 switches to output mode and obtains the output level status, including output high level or output low level. The controller GPIO will judge the output level status, where the output low level corresponds to module access, and the output high level corresponds to no module access. Through this judgment, the access status can be clearly determined.
[0117] According to an embodiment of the present invention, the slave module is marked as module n through high-speed 485 communication according to the access status, module query information is sent, and the query link status is obtained according to the sending status of the module query information, specifically including:
[0118] If the access status is module access, the controller GPIO sends module tag information and module type query information through high-speed 485 communication;
[0119] Mark the slave module as module n, and obtain the communication response time data;
[0120] Compare the communication response time data with a preset communication response time threshold to obtain a query link status, including a successful link or an unsuccessful link;
[0121] If the communication response time data is greater than the communication response time threshold, the query link status is that the link is unsuccessful;
[0122] If the communication response time data is less than or equal to the communication response time threshold, the query link status is a successful link.
[0123] It should be noted that in order to avoid confusion between modules and ensure the accuracy of data sent by the controller and communication between modules, the data receiving address of the module and the length of the receivable data must be determined. First, only when the access status is module access, the controller GPIO can send module marking information and module type query information through high-speed 485 communication. The module marking information is to determine the module number for easy distinction; the module type query information is to obtain the module type. After marking the module as n, n can be a positive integer such as 1, 2, 3, etc., and the module is named and marked according to the module position or order. After the module type query information is sent, it must be limited It is impossible to wait indefinitely for a certain reaction time, so it is necessary to count the communication response time data. If the communication response time data is greater than the preset communication response time threshold, it means that after a long waiting time, the module type query information has not been sent successfully. If the communication response time data is less than or equal to the preset communication response time threshold, the query link status is successful. In this embodiment, the communication response time threshold is set to: (0,5], which means successful link; greater than 5 means unsuccessful link; when the communication response time data is 3, the commodity heat index category is the effective commodity heat index. The query link status is successful link.
[0124] According to an embodiment of the present invention, obtaining type data of module n according to querying the link status, sending receiving data information of module n according to the type data and configuring the output end as a pull-up input specifically includes:
[0125] If the query link status is successful, then receiving and obtaining the type data of module n;
[0126] According to the received data information of the type data sending module n, the received data information includes address data and received data length value;
[0127] Module n configures GPIO2 as a pull-up input.
[0128] It should be noted that if the query link status is successful, normal communication is established between the controller and the module. The type data of module n is obtained according to the module type query information, and the receiving data information of module n is obtained according to the type data, including the address data and the receiving data length value. The address data reflects the address of the module receiving data, and the receiving data length value indicates the length of the data that can be received. GPIO2 is named to distinguish the two ports of the module.
[0129] According to an embodiment of the present invention, after module n configures GPIO2 as a pull-up input, it further includes:
[0130] Detect the level change state of GPIO2, including no change state or low state;
[0131] If the level change state is a pull-down state, there is a module to be connected after module n.
[0132] It should be noted that, since the controller is connected to many modules, when it is uncertain whether there are other modules behind the linked module, it is necessary to detect the level change state of GPIO2, including no change state or low state. The no change state means that the level has not changed, and the low state means that the level is pulled low. When the level change state is the low state, it means that there are modules to be linked after the linked module.
[0133] It is worth mentioning that it also includes:
[0134] The controller combines the data to be sent into a data frame, which includes a data address and corresponding data content;
[0135] Send the data address and data content to the link module via high-speed 485 communication;
[0136] Each link module intercepts the data content of the module in the data frame according to the address data and the received data length value.
[0137] It should be noted that when the controller sends data, the data will be integrated into a data frame, which will contain the data address and the data content corresponding to the data address. Each module will query and intercept the data belonging to the module according to its own address data and the length value of the received data.
[0138] The third aspect of the present invention provides a readable storage medium, which includes an automatic identification method program based on a high-speed 485 module. When the automatic identification method program based on a high-speed 485 module is executed by a processor, the steps of an automatic identification method based on a high-speed 485 module as described in any one of the above items are implemented.
[0139] The present invention discloses an automatic identification method, system and medium based on a high-speed 485 module. The method obtains the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and then determines the pre-module preparation state. According to the pre-module preparation state, the controller GPIO determines the output level state, thereby obtaining the access state of the slave module. According to the access state, the module is marked and module query information is sent through high-speed 485 communication, and then the query link state is obtained. According to the query link state, type data is obtained, and according to the type data, received data information is sent and the output end is configured as a pull-up input; thereby, the module automatically identifies the link through 485 communication, and the technology of improving the accuracy and efficiency of data transmission is realized.
[0140] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0141] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0142] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0143] Those skilled in the art can understand that: all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, the aforementioned program can be stored in a readable storage medium, and when the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, and other media that can store program codes.
[0144] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
Claims
1. An automatic identification method based on high-speed 485 module, characterized in that: include: Obtain the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and obtain the corresponding front module preparation state according to the pull-up input level state data and the pull-down input level state data; According to the front module preparation state, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state; According to the access status, the slave module is marked as module n through high-speed 485 communication, module query information is sent, and query link status is obtained according to the sending status of the module query information; According to the query link status, the type data of module n is obtained, the receiving data information of module n is sent according to the type data and the output end is configured as a pull-up input.
2. The automatic identification method based on the high-speed 485 module according to claim 1 is characterized in that: The method of obtaining the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and obtaining the corresponding front module preparation state according to the pull-up input level state data and the pull-down input level state data, specifically includes: Get the pull-up input level status data of the controller GPIO, including pull-up input high level or pull-up input low level; Get the pull-down input level status data of the preset slave module GPIO1, including the pull-down input high level or the pull-down input low level; Performing an AND operation on the pull-up input level state data and the pull-down input level state data to obtain the front module preparation state data; The front module preparation state is determined according to the front module preparation state data, including ready or not ready.
3. The automatic identification method based on high-speed 485 module according to claim 2 is characterized in that: According to the front module preparation state, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state, specifically including: If the front module is in the ready state, the slave module GPIO1 is switched to the output mode, and the output level state is obtained, including output high level or output low level; The controller GPIO determines the output level state and obtains the access state accordingly; If the output level state is output low level, the access state is module access; if the output level state is output high level, the access state is no module access.
4. The automatic identification method based on high-speed 485 module according to claim 3 is characterized in that: The method of marking the slave module as module n through high-speed 485 communication according to the access status, sending module query information, and obtaining the query link status according to the sending status of the module query information specifically includes: If the access status is module access, the controller GPIO sends module tag information and module type query information through high-speed 485 communication; Mark the slave module as module n, and obtain the communication response time data; Compare the communication response time data with a preset communication response time threshold to obtain a query link status, including a successful link or an unsuccessful link; If the communication response time data is greater than the communication response time threshold, the query link status is that the link is unsuccessful; If the communication response time data is less than or equal to the communication response time threshold, the query link status is a successful link.
5. The automatic identification method based on high-speed 485 module according to claim 4 is characterized in that: The method of obtaining the type data of module n according to the query link status, sending the received data information of module n according to the type data and configuring the output end as a pull-up input specifically includes: If the query link status is successful, then receiving and obtaining the type data of module n; According to the received data information of the type data sending module n, the received data information includes address data and received data length value; Module n configures GPIO2 as a pull-up input; Among them, GPIO2 is another port of module n besides GPIO1.
6. The automatic identification method based on high-speed 485 module according to claim 5 is characterized in that: After module n configures GPIO2 as a pull-up input, it also includes: Detect the level change state of GPIO2, including no change state or low state; If the level change state is a pull-down state, there is a module to be connected after module n.
7. An automatic identification system based on high-speed 485 modules, characterized in that: The invention comprises a memory and a processor, wherein the memory comprises an automatic identification method program based on a high-speed 485 module, and the automatic identification method program based on a high-speed 485 module is executed by the processor to implement the following steps: Obtain the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and obtain the corresponding front module preparation state according to the pull-up input level state data and the pull-down input level state data; According to the front module preparation state, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state; According to the access status, the slave module is marked as module n through high-speed 485 communication, module query information is sent, and query link status is obtained according to the sending status of the module query information; According to the query link status, the type data of module n is obtained, the receiving data information of module n is sent according to the type data and the output end is configured as a pull-up input.
8. The automatic identification system based on high-speed 485 module according to claim 7 is characterized in that: The method of obtaining the pull-up input level state data of the controller GPIO and the pull-down input level state data of the preset slave module GPIO1, and obtaining the corresponding front module preparation state according to the pull-up input level state data and the pull-down input level state data, specifically includes: Get the pull-up input level status data of the controller GPIO, including pull-up input high level or pull-up input low level; Get the pull-down input level status data of the preset slave module GPIO1, including the pull-down input high level or the pull-down input low level; Performing an AND operation on the pull-up input level state data and the pull-down input level state data to obtain the front module preparation state data; The front module preparation state is determined according to the front module preparation state data, including ready or not ready.
9. The automatic identification system based on high-speed 485 module according to claim 8 is characterized in that: According to the front module preparation state, the slave module GPIO1 is switched to output and the output level state is obtained, the controller GPIO determines the output level state, and obtains the access state of the slave module according to the output level state, specifically including: If the front module is in the ready state, the slave module GPIO1 is switched to the output mode, and the output level state is obtained, including output high level or output low level; The controller GPIO determines the output level state and obtains the access state accordingly; If the output level state is output low level, the access state is module access; if the output level state is output high level, the access state is no module access.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes an automatic identification method program based on a high-speed 485 module. When the automatic identification method program based on a high-speed 485 module is executed by a processor, the steps of an automatic identification method based on a high-speed 485 module as described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Low-cost field bus remote input-output system
CN102314161A
RS-485 bus polarity self-adaption method based on response frame effectiveness
CN110069437A