Disclosure of Invention
Based on this, it is necessary to provide a method, an apparatus and a system for configuring a device address in a communication system, which can realize efficient configuration of a slave device in the communication system.
A method of device address configuration in a communication system, comprising:
the current equipment detects whether equipment is accessed according to the in-place signal;
when detecting that the equipment is accessed, allocating an address for the accessed equipment;
and sending the allocated address information to the accessed equipment, and reporting the access information and the address information of the accessed equipment to the monitoring main equipment.
In one embodiment, if the current device is a monitoring master device, the step of allocating an address to the accessed device when it is detected that the device is accessed includes:
when detecting that a device is accessed, the address allocated to the accessed device is all zero.
In one embodiment, if the current device is a non-monitoring master device, the step of allocating an address to the accessed device when detecting that a device is accessed includes:
and when detecting that the equipment is accessed, allocating an address for the accessed equipment according to the address of the current equipment.
In one embodiment, the address allocated to the accessed device is the self address +1 of the current device.
In one embodiment, the method further comprises the following steps:
detecting whether the accessed equipment is removed or not according to the in-place signal;
when the removal of the accessed equipment is detected, reporting the removal information to the monitoring main equipment; the removal information includes address information of the removed device.
An apparatus for configuring a device address in a communication system, comprising:
the detection module is used for detecting whether equipment is accessed according to the in-place signal;
the distribution module is used for distributing an address for the accessed equipment when the detection module detects that the equipment is accessed;
and the communication module is used for sending the allocated address information to the accessed equipment and reporting the access information and the address information of the accessed equipment to the monitoring main equipment.
In one embodiment, the system further comprises a monitoring module,
the monitoring module is used for monitoring each level of accessed equipment;
and the distribution module is used for distributing all zero addresses for the accessed equipment when the detection module detects that the equipment is accessed.
In one embodiment, the allocating module allocates an address to the accessed device according to the address of the current device when the detecting module detects that the device is accessed.
In one embodiment, the detection module is further configured to detect whether an accessed device is removed according to the presence signal;
the communication module is further configured to report removal information to the monitoring master device when the detection module detects that the accessed device is removed; the removal information includes address information of the removed device.
A device address configuration system in a communication system, comprising: the monitoring system comprises monitoring main equipment, slave equipment and bridging cables, wherein the monitoring main equipment and each level of slave equipment are connected in a star or daisy chain manner through the bridging cables;
the monitoring master device is used for allocating addresses to the accessed slave devices when detecting that the slave devices are accessed, and sending the allocated address information to the accessed slave devices;
and the slave equipment is used for allocating an address for the next-level slave equipment according to the address of the slave equipment when detecting that the next-level slave equipment is accessed, sending the allocated address information to the next-level slave equipment, and reporting the access state and the address information of the next-level slave equipment to the monitoring master equipment.
According to the device address configuration method in the communication system, the address of the slave device is allocated to the accessed device by the current device after the current device is accessed, so that the address can be automatically allocated to the slave device in the communication system without manual pre-configuration, and the efficiency is high.
Detailed Description
In one embodiment, a device address configuration system in a communication system is provided, as shown in fig. 1, including a monitoring master device 102, a slave device 104, and a bridge cable, where the monitoring master device and each level of slave devices are connected by the bridge cable in a star or daisy chain manner. The data bus in one embodiment may be an RS485 bus.
The monitoring master device 102 is configured to, when it is detected that a slave device accesses, assign an address to the accessed slave device, and send address information assigned to the accessed slave device.
The slave device 104 is configured to, when detecting that a next-stage slave device is accessed, allocate an address to the next-stage slave device according to the address of the slave device, send the allocated address information to the next-stage slave device, and report an access state and address information of the next-stage slave device to the monitoring master device 102.
As shown in fig. 1, the monitoring master has a cascade interface (Next), and the slave has a cascade interface (Next) and a resource interface (Source). The cascade interface of the monitoring master device is connected with the resource interface of the first-level slave device through a bus, and the cascade interface of the Nth-level slave device is connected with the resource interface of the (N + 1) th-level slave device through the bus. It should be understood that, in a communication system, the cascade interfaces and the resource interfaces of the monitoring master device and the slave devices at different levels are the same, that is, the interfaces of the monitoring master device and the slave devices in the communication system are uniform, and the slave devices can be alternatively used, thereby facilitating the device development and engineering maintenance.
Meanwhile, in view of the requirement of cable universality, in a specific implementation mode, a data bus can be realized by selecting the most common direct connection network cable, the engineering practicability is strong, and Ethernet interfaces are correspondingly selected as communication interfaces for all levels of connection interfaces and resource interfaces, so that the Ethernet interface without an isolation transformer is recommended to be selected because the communication speed of the monitoring bus is low and the communication distance between systems is not too far. The access mode of the monitoring master device and the monitoring slave device can be star-shaped or daisy-chained.
In one embodiment, the interfaces of the monitoring master and slave are unified, including address line pins ADDR1 and ADDR2, and bit detect pin DI. In a specific embodiment, the definition of the sequence of the buses for connecting the interfaces is shown in table 1.
TABLE 1 line order definition of the bus
Line sequence
|
Definition of
|
Description of the invention
|
1
|
RM_A
| Slave 485A |
|
2
|
RM_B
|
Slave device 485B
|
3
|
N/A
| Reservation |
|
4
|
GND
|
Common ground
|
5
|
SLAVE_ADDR2
| Slave address | 2
|
6
|
N/A
| Reservation |
|
7
|
SLAVE_DI
|
Slave device presence detection
|
8
|
SLAVE_ADDR1
|
Slave device address 1 |
The lines with the serial numbers of the bus correspond to the pins of the interface, and the line 1 and the line 2 can form a double-stranded wire to be used as an independent RS485 bus and be used as a master-slave device communication bus. Lines 3 and 6 are used as reservations, may be used for device telecommunication buses, or to extend slave address bits, etc. The connectors of the bridge cables corresponding to the bus line sequence are also required to be uniform. In one particular embodiment, the cable connector is an RJ-45 connector, i.e., a "crystal head". The cable can carry out length adjustment according to the actual engineering application of equipment, and engineering application convenient and fast, stability are high.
In one embodiment, a schematic structural diagram of a cascade interface of a monitoring master device is shown in fig. 2. And an address line pin of the cascade interface of the monitoring master device is connected with a pull-down resistor, and the default level is a low level. Specifically, this is achieved by a strong pull-down of the 56 ohm resistor. The on-line detection pin is defaulted to a high level through a pull-up resistor, and specifically is realized through weak pull-up of a 10K ohm resistor.
In one embodiment, a schematic structural diagram of a cascade interface of a slave device is shown in fig. 3. And an address line pin and an on-position detection pin of the cascade interface of the slave device are pulled up through resistors, and the default level is high level. In particular, the pull-up is realized by a weak pull-up of 10K ohm resistance.
In one embodiment, a schematic structural diagram of the resource interface of the slave device is shown in fig. 4, an address line pin and a bit detection pin of the resource interface of the slave device are pulled down through a resistor, and a default level is a low level. The address line pin is realized by weak pull-down of 10K ohm resistance, and the on-site detection pin is realized by strong pull-down of 56 ohm resistance.
When the slave device is connected to the monitoring master device, the low level 0 is given through the on-position detection pin of the resource interface, the level signal of the on-position detection pin of the cascade interface of the monitoring master device is converted from the default high level to the low level, and the monitoring master device judges whether the slave device is connected according to the change of the level signal of the on-position detection pin of the cascade interface of the monitoring master device. When the next-stage slave device is connected to the previous-stage slave device, the low level is given out through the on-position detection pin of the resource interface, the level signal of the on-position detection pin of the cascade interface of the previous-stage slave device is converted from the default high level to the low level, and the previous-stage slave device judges whether the slave device is connected according to the change of the level signal of the on-position detection pin of the cascade interface.
When the monitoring master detects that a slave device is accessed, the address assigned to the accessed slave device through the address line pin of the cascade interface is all zero, for example, the monitoring master directly controls the address line pins ADDR1 and ADDR2 of the cascade interface to be low level through a hardware circuit. And the slave equipment receives the corresponding level signal through the address line of the resource interface of the slave equipment and acquires the allocated address information.
It should be understood that when a slave device detects that the bit detection pin of its cascade interface is high, it is said to be the last stage of the link, and no next-stage slave device is connected behind it. When the slave device detects that the in-place detection pin of the cascade interface of the slave device is changed from low level to high level, the next-stage slave device is removed, the removal information is reported to the monitoring master device, the removal information comprises address information of the next-stage slave device, and the monitoring master device removes control over the slave device, so that the integrity of the system is guaranteed.
When the slave device detects that the next-stage slave device is accessed, the address allocated to the accessed next-stage slave device through the address line pin of the cascade interface is the self address + 1. For example, when the first-level slave device detects that the next-level slave device is accessed, the two address line pins ADDR1 and ADDR2 of the cascade interface are set to 0 and 1, respectively. When the second-level slave device detects that the next-level slave device is accessed, the two address line pins ADDR1 and ADDR2 of the cascade interface are respectively set to 1 and 0. And so on for the address line pins of the other interfaces.
In the device address configuration system in the communication system, since the address of the slave device is allocated by the monitoring master device after being accessed to the monitoring master device or the upper-level slave device, or is allocated according to the address of the upper-level slave device, the address can be automatically allocated to the slave device in the communication system without manual pre-configuration, and the efficiency is high. Meanwhile, the communication mode between the monitoring master device and the slave device and between the slave device and the next-level slave device is simple, the monitoring master device is only responsible for detecting the configuration condition of the first-level slave device, each level of slave device is also only responsible for detecting the configuration condition of the next-level slave device, the detection result is interacted with the monitoring master device through the communication of the master device and the slave device, the influence of environmental factors in the networking configuration process is small, and the stability is high.
In one embodiment, a device address configuration method in a communication system is provided, which is applied to the monitoring master device 102 or the slave device in fig. 5. As shown in fig. 6, the method comprises the steps of:
s502: and the current equipment detects whether equipment is accessed according to the on-site signal.
Specifically, the monitoring master device or the slave device judges whether a device is accessed according to a level signal of an in-place detection pin of the cascade interface. When the slave device is connected to the upper-level device, the low-level signal is sent to the on-position detection pin of the cascade interface of the monitoring main device through the on-position detection pin of the resource interface of the slave device, and the on-position detection pin of the upper-level device is converted from high level to low level. The upper level device may be a monitoring master device or a slave device.
S504: when the device is detected to be accessed, an address is allocated to the accessed device.
If the current device is the monitoring master device, when detecting that the device is accessed, the address allocated to the accessed device is all zero. Specifically, when a device access is detected, the address line pins ADDR1 and ADDR2 of the cascade interface are set to the initial level 0, 0, and the level signal is sent to the address line pin of the resource interface of the slave device 1 through the data bus. The specific address is associated with an address line pin of the interface. For example, when two address line pins are used, the address of the first-stage slave device is 0.0, and when four address line pins are used, the address of the first-stage slave device is 0.0.0.0.
If the current device is a slave device, when the access of the device is detected, an address is allocated to the accessed device according to the address of the current device, and specifically, when the access of the device is detected, an address line pin of the cascade interface is set to a corresponding level to allocate an address to the accessed slave device. Specifically, the address allocated to the accessed device is the address +1 of the current device. For example, if the address of the first level slave device is 0.0, the address allocated to the second level slave device is 0.1. For another example, if the address of the first level slave device is 0.0.0.0, then the address assigned to the second level slave device is 0.0.0.1, and so on for the other levels of slave devices.
S506: and sending the allocated address information to the accessed equipment, and reporting the access state and the address information of the accessed equipment to the monitoring main equipment. In this embodiment, when the slave device detects that the accessed next-stage slave device is removed, the removal information is reported to the monitoring master device, and the monitoring master device removes the control on the removed slave device, thereby ensuring the integrity of the system.
According to the device address configuration method in the communication system, the address of the slave device is allocated to the accessed device by the current device after the current device is accessed, so that the address can be automatically allocated to the slave device in the communication system without manual pre-configuration, and the efficiency is high. Meanwhile, the communication mode of the monitoring master device and the monitoring slave device is simple, the monitoring master device is only responsible for detecting the configuration condition of the first-stage slave device, each stage of slave device is also only responsible for detecting the configuration condition of the next-stage slave device, the detection result is interacted with the monitoring master device through the communication of the master device and the slave device, the influence of environmental factors on the networking configuration process is small, and the stability is high.
In one embodiment, an apparatus for configuring a device address in a communication system is provided, as shown in fig. 6, including:
a detecting module 602, configured to detect whether a device is accessed according to the presence signal.
An allocating module 604, configured to allocate an address to an accessed device when the detecting module detects that a device is accessed.
The communication module 606 is configured to send the allocated address information to the accessed device, and report the access state and the address information of the accessed device to the monitoring master device.
In another embodiment, the system further comprises a monitoring module for monitoring the accessed devices of each stage.
The allocating module 604 allocates all zero addresses to the accessed devices when the detecting module detects that the devices are accessed.
The device address configuration apparatus in the communication system in this embodiment is provided in the monitoring master device.
In another embodiment, the allocating module 604 allocates an address for the accessed device according to the address of the current device when the detecting module detects that the device is accessed. Specifically, the address allocated to the accessed device is the address +1 of the current device. The device address configuration apparatus in the communication system in this embodiment is a device in a slave device.
In another embodiment, the detecting module 602 is further configured to detect whether an accessed device is removed according to the presence signal. The communication module 606 is further configured to report removal information to the monitoring master device when the detection module detects that the accessed device is removed; the removal information includes address information of the removed device.
According to the device address configuration device in the communication system, the address of the slave device is allocated to the accessed device by the current device after the current device is accessed, so that the address can be automatically allocated to the slave device in the communication system without manual pre-configuration, and the efficiency is high. Meanwhile, the communication mode of the monitoring master device and the monitoring slave device is simple, the monitoring master device is only responsible for detecting the configuration condition of the first-stage slave device, each stage of slave device is also only responsible for detecting the configuration condition of the next-stage slave device, the detection result is interacted with the monitoring master device through the communication of the master device and the slave device, the influence of environmental factors on the networking configuration process is small, and the stability is high.
In one embodiment, a communication system for monitoring master and slave devices is provided, as shown in fig. 7, which includes monitoring master, slave 1 to slave 4 by employing star or daisy chain connections. The working process is as follows:
step 1: and the high level of an in-place detection pin of the cascade interface of the monitoring master device is converted into the low level, the address line pins ADDR1 and ADDR2 of the cascade interface are set to initial levels 0 and 0 when the access of the slave device 1 is detected.
Specifically, when the slave device 1 accesses the monitoring master device, the in-place detection pin of the resource interface thereof sends a low level signal to the in-place detection pin of the cascade interface of the monitoring master device, and the in-place detection pin of the monitoring master device is changed from a high level to a low level. At the same time, the monitoring master device sets the address line pins ADDR1 and ADDR2 of its cascade interface to initial level 0, 0, and sends the level signal to the address line pin of the resource interface of the slave device 1 through the bridge cable.
Step 2: the slave device 1 receives the assigned address information via the address line pins of its resource interface. The on-bit detection pin of the cascade interface of the slave 1 switches from high level to low level, detects that the slave 2 is accessed, and sets the address line pins ADDR1 and ADDR2 of the cascade interface to 0, 1.
And step 3: the slave device 2 receives the assigned address information via the address line pins of its resource interface. The on-bit detection pin of the cascade interface of the slave device 2 switches from high level to low level, detects that the slave device 3 is accessed, and sets the address line pins ADDR1 and ADDR2 of the cascade interface to 1 and 0.
And 4, step 4: the slave device 3 receives the allocated address information via address line pins of its resource interface. The on-bit detection pin of the cascade interface of the slave device 3 switches from high to low, detects that the slave device 4 is accessed, and sets the address line pins ADDR1 and ADDR2 of the cascade interface to 1, 1.
And 5, receiving the allocated address information from the equipment 4 through an address line pin of the resource interface. The bit detection pin of the cascade interface of the slave device 4 is high, which means that it is the last stage of the link and no other slave device is connected later.
In one embodiment, a communication system for monitoring master and slave devices is provided, as shown in fig. 8, which includes monitoring master, slave 1 to slave 16 in a star or daisy chain connection. The difference between this embodiment and the previous embodiment is that, in this embodiment, the address line pins of each interface include 4 address lines, which are ADDR1 to ADDR4, 4 address lines in the corresponding data bus, and 4 address line pins of the interface. In this embodiment, the monitoring master device assigns an address to the slave device 1 as 0, 0, 0, 0, the slave device 1 assigns an address to the slave device 2 as 0, 0, 0, 1, the slave device 2 assigns an address to the slave device 3 as 0, 0, 1, 0, and so on, and the address assignments of the other slave devices are not described herein one by one. In this embodiment, each interface has 4 address line pins, and the cascade node of the slave device reaches 16 levels at most.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.