Dynamic expansion structure and method suitable for 485 or CAN bus module
By designing the dynamic expansion structure of the 485 or CAN bus module, the lack of low-cost dynamic expansion bus in modular industrial controllers is solved, dynamic address configuration and data transmission between modules are realized, and master-slave mode switching and slave stations are supported. Resource scanning meets the needs of domestically produced industrial controllers.
Patent Information
- Application Number
- CN202410652512.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-08-23
AI Technical Summary
The lack of low-cost dynamic expansion bus in existing modular industrial controllers has limited the development of domestic industrial controllers, inconsistent standards, and low flexibility, making it difficult to realize low-cost modular industrial controllers.
A dynamic expansion structure suitable for 485 or CAN bus modules is designed, including master station module, slave station module and expansion bus. The communication between modules is realized through common ground line, upper level indication line, lower level indication line, serial port line and communication bus. Dynamic address configuration and data transmission, supporting master-slave mode switching and slave resource scanning.
It realizes a small number of lines, dynamic switching of master and slave stations, dynamic expansion of slave station modules and resource scanning, supports various slave station types, and meets the needs of modular industrial controllers.
Smart Images

Figure CN118534816A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial control technology, and in particular to a dynamic expansion structure and method suitable for a 485 or CAN bus module. Background Art
[0002] Modular industrial controllers are the core components of industrial automation control systems. They adopt modular design and play an increasingly important role in the field of industrial automation with their high reliability, flexibility, ease of use and maintenance. Each module has specific functions, such as input / output modules, communication modules, control modules, etc. These modules can be combined and configured as needed to achieve automatic control of the production process and improve production efficiency and product quality. However, modular industrial controllers have long been monopolized by foreign companies. Their backplane buses include EtherCAT, Profinet, Powerlink, Ethernet / IP, etc. They have complex and closed technologies, high prices, and require dedicated chips. The domestic industrial bus started late, and there are still shortcomings such as inconsistent standards, low flexibility, and low output-input ratio, which bring difficulties to the realization of domestic low-cost modular industrial controllers. Therefore, there is an urgent need for a module dynamic expansion structure and method based on a low-cost bus to promote the development of domestic industrial controllers. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a dynamic expansion structure and method suitable for 485 or CAN bus modules to solve the problem of lack of low-cost dynamic expansion bus in the prior art, thereby solving the problem of dynamic address configuration of modular controllers.
[0004] The invention discloses a dynamic expansion structure applicable to a 485 or CAN bus module, comprising a master station module, a slave station module and an expansion bus, wherein the master station module is connected to a slave station module as a subordinate thereof through the expansion bus, and each slave station module is extended and connected step by step through the expansion bus;
[0005] The expansion bus includes a common ground line, an upper level indicator line, a lower level indicator line, a serial port line and a communication bus, wherein the common ground line is used to provide a signal loop, the upper level indicator line is used to determine whether there is an upper level, the lower level indicator line is used to determine whether there is a lower level, the serial port line is used to dynamically configure the slave station address and slave station type, and the communication bus is used for high-speed data transmission between modules;
[0006] The master station module is responsible for executing the logic task of reading and writing the local port or reading and writing the slave station port via the communication bus;
[0007] The slave module is responsible for receiving communication bus data and performing corresponding actions on the slave port.
[0008] Furthermore, the types of the slave station modules include at least one of a switch quantity input module, a switch quantity output module, an analog quantity input module, an analog quantity output module and a communication module.
[0009] The present invention also discloses a dynamic expansion method of the above dynamic expansion structure, which comprises the following steps:
[0010] Step 1, after power-on, each module in the dynamic expansion structure determines whether there is a superior through the superior indication line. If so, the communication bus runs in slave mode and the module is a slave module, then continue to step 2; if not, the communication bus runs in master mode and the module is a master module, then jump to step 12;
[0011] Step 2, the slave module determines whether there is a subordinate through the subordinate indication line, if yes, continue to step 3; if not, jump to step 9;
[0012] Step 3, the slave module determines whether the serial port line connected to the lower level returns subsequent slave type data frames. If so, continue to step 4; if not, loop to determine whether the serial port line connected to the lower level returns subsequent slave type data frames;
[0013] Step 4: Set the station ID to the number of subsequent slave stations plus 1;
[0014] Step 5: Add the local station type byte code to the slave station type data frame header;
[0015] Step 6: Send the complete slave type data frame through the serial port connected to the upper level;
[0016] Step 7: Wait for communication bus data and perform corresponding actions;
[0017] Step 8: Determine whether the serial port line connected to the upper level issues a rescan slave resource instruction. If so, forward the rescan slave resource instruction to the serial port line connected to the lower level and jump to step 1; if not, jump to step 7;
[0018] Step 9, set the slave station ID to 1;
[0019] Step 10, forming a slave station type data frame according to the slave station type;
[0020] Step 11, send the slave type data frame through the serial port connected to the upper level, and then continue to step 7;
[0021] Step 12, the master station module determines whether there is a subordinate through the subordinate indication line, if yes, then continue to execute step 13; if not, then loop execution according to the logic task to read and write the local port;
[0022] Step 13, the master station module determines whether the serial port line connected to the subordinate returns subsequent slave station type data frames, if so, continue to execute step 14; if not, loop to determine whether the serial port line connected to the subordinate returns subsequent slave station type data frames;
[0023] Step 14, counting the number of slave stations according to the number of bytes of the slave station type data frame;
[0024] Step 15, determining each slave station ID according to the byte order of the slave station type data frame;
[0025] Step 16, determining the function code and the number of channels of each slave station according to the byte content of the slave station type data frame;
[0026] Step 17: Execute in a loop to read and write local port and communication bus data according to the logic task to control the slave port.
[0027] Furthermore, the slave station type data frame is a series of continuous byte codes, and each byte, namely 8 bits, is the type of a slave station module.
[0028] Beneficial effects of the present invention:
[0029] The dynamic expansion structure and method of the present invention is applicable to 485 or CAN bus modules, has the advantages of few lines, dynamic switching of master and slave stations, dynamic expansion of slave station modules, dynamic scanning of slave station resources, support for various slave station types, support for various differential buses as communication buses, etc., and meets the needs of modular industrial controllers. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a block diagram of a dynamic expansion structure applicable to a 485 or CAN bus module in an embodiment.
[0031] Figure 2 It is another block diagram of the dynamic expansion structure applicable to 485 or CAN bus module in the embodiment.
[0032] Figure 3 The flowchart is a dynamic expansion method applicable to 485 or CAN bus modules. DETAILED DESCRIPTION
[0033] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0034] like Figure 1 As shown, the dynamic expansion structure applicable to the 485 or CAN bus module in this embodiment includes a master station module 1, a slave station module 2 and an expansion bus 3. The master station module is connected to the slave station module as its subordinate through the expansion bus, and the slave station modules are connected step by step through the expansion bus.
[0035] The expansion bus 2 includes a common ground line, an upper level indicator line, a lower level indicator line, a serial port line and a communication bus. The common ground line is used to provide a signal loop, the upper level indicator line is used to determine whether there is an upper level, the lower level indicator line is used to determine whether there is a lower level, the serial port line is used to dynamically configure the slave station address and slave station type, and the communication bus is used for high-speed data transmission between modules.
[0036] like Figure 2 As shown, in the dynamic expansion structure described in this embodiment, the common ground line is connected to the GND of the module; the upper-level indicator line is connected to the power supply through a pull-up resistor in the upper-level module, and is connected to the IsUpSta signal in the lower-level module; the lower-level indicator line is connected to the power supply through a pull-up resistor in the lower-level module, and is connected to the IsDnSta signal in the upper-level module; the serial port line is two lines, Tx and Rx, the serial port line connected to the upper level is connected to a serial port of the control chip of the module, and the serial port line connected to the lower level is connected to another serial port of the control chip of the module, and the data of both are routed through the control chip; the communication bus can be 485 buses A and B that follow the Modbus protocol, can be a CAN bus, or can be other differential buses.
[0037] The master station module 1 is responsible for executing the logic task of reading and writing the local port or reading and writing the slave station port via the communication bus; each slave station module 2 is responsible for receiving the communication bus data and executing the corresponding action on the slave station port.
[0038] The types of the slave module in this embodiment may be a switch input module, a switch output module, an analog input module, an analog output module, a communication module, etc.
[0039] like Figure 3 As shown, the dynamic expansion method of the above dynamic expansion structure includes the following steps:
[0040] Step 1. After power-on, each module in the dynamic expansion structure determines whether there is a superior through the superior indication line. If so, the communication bus runs in slave mode and the module is a slave module, then continue to step 2; if not, the communication bus runs in master mode and the module is a master module, then jump to step 12.
[0041] Step 2: The slave module determines whether there is a subordinate through the subordinate indication line. If so, continue to step 3; if not, jump to step 9.
[0042] Step 3, the slave module determines whether the serial port line connected to the lower level returns subsequent slave type data frames. If so, continue to step 4; if not, loop to determine whether the serial port line connected to the lower level returns subsequent slave type data frames.
[0043] Step 4: Set the station ID to the number of subsequent slave stations plus 1.
[0044] Step 5: Add the station type byte code to the slave station type data frame header.
[0045] Step 6: Send the complete slave type data frame through the serial port connected to the upper level.
[0046] Step 7: Wait for communication bus data and perform corresponding actions.
[0047] Step 8: Determine whether the serial port line connected to the upper level issues a rescan slave resource instruction. If so, forward the rescan slave resource instruction to the serial port line connected to the lower level and jump to step 1; if not, jump to step 7.
[0048] Step 9. Set the slave ID to 1.
[0049] Step 10: Compose a slave station type data frame according to the slave station type.
[0050] Step 11: Send the slave type data frame through the serial port connected to the upper level, and then continue to step 7.
[0051] Step 12, the master station module determines whether there is a subordinate through the subordinate indication line, if yes, continue to execute step 13; if not, loop and execute reading and writing the local port according to the logic task.
[0052] Step 13, the master station module determines whether the serial port line connected to the subordinate returns subsequent slave station type data frames. If so, continue to execute step 14; if not, loop to determine whether the serial port line connected to the subordinate returns subsequent slave station type data frames.
[0053] Step 14: Count the number of slave stations according to the number of bytes of the slave station type data frame.
[0054] Step 15: Determine each slave station ID according to the byte sequence of the slave station type data frame.
[0055] Step 16: Determine the function code and channel number of each slave station according to the byte content of the slave station type data frame.
[0056] Step 17: Execute in a loop to read and write local port and communication bus data according to the logic task to control the slave port.
[0057] The slave type data frame described in this embodiment is a series of continuous byte codes, and each byte, i.e., 8 bits, is the type of a slave module. The slave module type can be customized to 256 categories, and its order represents the slave module address decreasing in sequence, such as being defined as: 0000 0001 0000 0010 0000 0001, indicating that there are 3 slave modules, the first byte indicates that the slave module with address 3 is an 8-channel switch output module, the second byte indicates that the slave module with address 2 is a 4-channel switch input module, and the third byte indicates that the slave module with address 1 is an 8-channel switch output module.
[0058] Therefore, in this embodiment, the number of slave modules hung on the bus, the relative position of each slave module, and the type of each slave module, i.e., the number of data channels, can be known through the slave module type data frame, so that dynamic expansion of slave modules and dynamic scanning of bus resources can be realized. At the same time, each module can dynamically switch the master / slave operation mode according to whether there is an upper-level module. The scheme described in this embodiment has the advantages of a small number of lines, dynamic switching of master and slave stations, dynamic expansion of slave modules, dynamic scanning of slave resources, support for various slave types, and support for various differential buses as communication buses, etc., which meets the needs of modular industrial controllers.
[0059] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.
Claims
1. A dynamic expansion structure suitable for 485 or CAN bus module, characterized by: It includes a master station module, a slave station module and an expansion bus. The master station module is connected to the slave station module as its subordinate through the expansion bus, and the slave station modules are connected step by step through the expansion bus. The expansion bus includes a common ground line, an upper level indicator line, a lower level indicator line, a serial port line and a communication bus, wherein the common ground line is used to provide a signal loop, the upper level indicator line is used to determine whether there is an upper level, the lower level indicator line is used to determine whether there is a lower level, the serial port line is used to dynamically configure the slave station address and slave station type, and the communication bus is used for high-speed data transmission between modules; The master station module is responsible for executing the logic task of reading and writing the local port or reading and writing the slave station port via the communication bus; The slave module is responsible for receiving communication bus data and performing corresponding actions on the slave port.
2. The dynamic expansion structure applicable to 485 or CAN bus module according to claim 1, characterized in that: The types of the slave station modules include at least one of a switch quantity input module, a switch quantity output module, an analog quantity input module, an analog quantity output module and a communication module.
3. A method for dynamically expanding the dynamic expansion structure according to claim 1 or 2, characterized in that: The following steps are involved: Step 1, after power-on, each module in the dynamic expansion structure determines whether there is a superior through the superior indication line. If so, the communication bus runs in slave mode and the module is a slave module, then continue to step 2; if not, the communication bus runs in master mode and the module is a master module, then jump to step 12; Step 2, the slave module determines whether there is a subordinate through the subordinate indication line, if yes, continue to step 3; if not, jump to step 9; Step 3, the slave module determines whether the serial port line connected to the lower level returns subsequent slave type data frames, if so, proceed to step 4; If not, loop to determine whether the serial line connected to the lower level returns subsequent slave type data frames; Step 4: Set the station ID to the number of subsequent slave stations plus 1; Step 5: Add the local station type byte code to the slave station type data frame header; Step 6: Send the complete slave type data frame through the serial port connected to the upper level; Step 7: Wait for communication bus data and perform corresponding actions; Step 8: Determine whether the serial port line connected to the upper level issues a rescan slave resource instruction. If so, forward the rescan slave resource instruction to the serial port line connected to the lower level and jump to step 1; if not, jump to step 7; Step 9, set the slave station ID to 1; Step 10, forming a slave station type data frame according to the slave station type; Step 11, send the slave type data frame through the serial port connected to the upper level, and then continue to step 7; Step 12, the master station module determines whether there is a subordinate through the subordinate indication line, if yes, then continue to execute step 13; if not, then loop execution according to the logic task to read and write the local port; Step 13, the master station module determines whether the serial port line connected to the lower level returns subsequent slave station type data frames, if so, proceed to step 14; If not, loop to determine whether the serial line connected to the lower level returns subsequent slave type data frames; Step 14, counting the number of slave stations according to the number of bytes of the slave station type data frame; Step 15, determining each slave station ID according to the byte order of the slave station type data frame; Step 16, determining the function code and the number of channels of each slave station according to the byte content of the slave station type data frame; Step 17: Execute in a loop to read and write local port and communication bus data according to the logic task to control the slave port.
4. The dynamic expansion method according to claim 3, characterized in that: The slave station type data frame is a series of continuous byte codes, and each byte, namely 8 bits, represents the type of a slave station module.
