Embodiment
It should be noted that the first and second grade wordings occurred in text are only used for distinguishing same technical characteristic, it is not right
Order and quantity of the technical characteristic etc. cause to limit.Diagram in text is given for example only, not to quantity of each element etc.
Cause to limit.
Further to illustrate the effect of the technological means taken of the present invention and acquirement, below first from the angle of whole system
Degree sets out, and with reference to accompanying drawing and preferred embodiment, to technical scheme, carries out clear and complete description.
The hardware configuration for the system for distributing address to the master-slave communication that daisy chain is connected first is simply introduced:
As shown in figure 1, the system that a kind of master-slave communication of daisy chain connection distributes address, including main frame and N grades of slaves (from
Machine 1 to slave N), by first in the bit line (DI/I of the main frame and DI/O of slave 1 between main frame and first order slave (slave 1)
Between line) and the first address wire (including:Line ... ... between the ADDn/O of main frame and the ADDn/I of slave 1, main frame
ADD2/O and slave 1 ADD2/I between line, the line between the ADD1/O of main frame and the ADD1/I of slave 1) connection,
Connected between n-th grade of slave and (n+1)th grade of slave by (n+1)th in bit line and the (n+1)th address wire;N is more than or equal to 1 and is less than
N integer, i.e., 0<n≤N.For example, between slave 1 and slave 2 second in DI/O of the bit line for DI/I and the slave 2 of slave 1
Between line, the second address wire between slave 1 and slave 2 includes:Between the ADDn/O of slave 1 and the ADDn/I of slave 2
Line ... ..., the line between the ADD2/O of slave 1 and the ADD2/I of slave 2, the ADD1/O of slave 1 and slave 2
Line between ADD1/I.Second between the slave of other adjacent levels is similar in bit line and the second address wire, not detailed herein
State.
Main frame and slave can be the communication equipments such as single-chip microcomputer.Daisy chain is connected as each equipment in communication system successively
Connection, for example, as shown in figure 1, main frame, slave 1, slave 2, slave 3 ... and slave N are sequentially connected, composition daisy chain is connected
Mode.In the master-slave communication system that daisy chain is connected, a main frame is communicated with multiple slaves, and main frame undertakes higher level's work(
Can, sent and ordered to slave by bus, the communication between each slave and main frame is distinguished using address, while slave and slave
Between communication cable use daisy chain connected mode.The data/address bus of slave be two-way interactive data/address bus, i.e., it is a certain from
Machine and main frame are set up after data communication, and the slave and main frame can be carried out the two-way interactive of data.
In order to realize the automatic distribution of slave mailing address, the hardware configuration of slave communication system is improved, i.e.,
Bit line and address wire are arranged between the equipment (equipment includes main frame and slave) of adjacent level.Below to line in place and address wire
Simply introduced.
It is used for upper level equipment in bit line and detects whether next stage equipment is in place, by next stage equipment output level, upper one
Level equipment is detected.It can according to actual needs be determined, alternatively, lead between the equipment of adjacent level in the quantity of bit line
One is crossed to connect in bit line.For example, as shown in figure 1, between main frame and slave 1 provided with one bit line (DI/I of main frame with
Line between the DI/O of slave 1), whether main frame was in place in bit line detection slave 1 according to being somebody's turn to do.DI represents the end connected in bit line
Mouthful, subsequently in order to express easily, directly represented with DI in bit line ,/I below represents input ,/O below represents output.Can be with
Input/output port general on relevant device is selected as DI/I ports and DI/O ports, for example, selecting one on main frame
General input port selects a general output port to be used as DI/O ports as DI/I ports on slave 1, then main
Line between the DI/I ports of machine and the DI/O ports of slave 1 is that, in bit line, that is to say detection line in place.
It is that next stage equipment transmits mailing address that address wire, which is used for upper level equipment, next by upper equipment output level
Level equipment carries out the automatic identification of mailing address according to the level of reception.The slave that the quantity of address wire is typically connected as needed
Quantity and coded system determine, for example, using binary-coded method set level when, if main frame need control
Four slaves, then can set two address wires between the equipment of adjacent level.As shown in figure 1, ADD represents the end of address wire connection
Mouthful, in order to express easily, the follow-up mode directly numbered with ADD+ represents address wire, and/I below represents input ,/O below
Represent output.
Then the operation principle for the system for distributing address to the master-slave communication that daisy chain is connected simply is introduced:
The main frame by first bit line detect the first order slave it is in place when, be first order slave distribution
First mailing address, and first mailing address is sent to the first order slave by the first address wire;Described first
Level slave obtains first mailing address, and row data communication is entered with first mailing address and the main frame;N-th grade of slave
By (n+1)th bit line detect (n+1)th grade of slave it is in place when, by (n+1)th grade of slave information in place with data communication mode
It is sent to the main frame;It is (n+1)th grade of slave distribution n-th when the main frame receives (n+1)th grade of slave information in place
+ 1 mailing address, and (n+1)th mailing address is sent to n-th grade of slave with data communication mode;Described n-th grade from
(n+1)th mailing address is sent to (n+1)th grade of slave by machine by the (n+1)th address wire;(n+1)th grade of slave is obtained
(n+1)th mailing address, row data communication is entered with (n+1)th mailing address and the main frame.
As shown in figure 1, during slave 1 (first order slave) access host, the DI/O ports output level of slave 1, the level
By the DI/I ports that main frame is delivered in bit line DI between slave 1 and main frame, after Host Detection to DI/I port levels, really
Recognize slave 1 in place.The level that slave 1 is exported can be configured according to actual needs, for example, the level that slave 1 is exported is set
For high level, Host Detection to DI/I ports confirms that slave 1 is in place when having high level, and the level that can also export slave 1 is set
Low level etc. is set to, the present invention makes restriction not to this.
Main frame can arbitrarily set several different mailing addresses, and for distributing to each slave, each of setting leads to
Letter address can be stored in main frame in forms such as lists., will be from advance in the presence of main frame in bit line by detecting slave 1
Automatically the mailing address that an address is set to slave 1 is chosen in several mailing addresses set, then by slave 1 communicatedly
Location is sent to slave 1, and slave 1 is obtained and main frame identical mailing address, and both can be carried out data communication.
In one embodiment, as shown in figure 1, main frame is chosen after the mailing address of slave 1, according to the mailing address to it
The level for the ADD1/O~ADDn/O address ports being connected with each address wire is configured, by ADD1/O~ADDn/O of setting
The level of address port is with being delivered to the ADD1/I~ADDn/I being connected with each address wire of slave 1 by corresponding address wire
Location port.Main frame can use pre-arranged code mode when setting port level, such as binary coding mode.Slave 1 is read
The low and high level state of its ADD1/I~ADDn/I address port is taken, with corresponding coded system by the low and high level state of reading
Corresponding mailing address is translated as, therefore slave 1 is obtained and main frame identical mailing address, both can enter row data communication.
Slave 1 translates the coded system used when the coded system taken during mailing address sets the address port of main frame by main frame.
N-th grade of slave is to include each slave of first order slave.Understand for convenience, subsequently led to according to slave 2
The order that letter address sets up data communication, the acquisition mailing address of slave 3 and main frame with main frame and sets up data communication ... is to main frame
And the workflow of each slave is introduced.
As shown in figure 1, when slave 2 (second level slave) accesses slave 1, the DI/O ports output level of slave 2, the level
By the DI/I ports that slave 1 is delivered in bit line DI between slave 2 and slave 1, slave 1 detects DI/I port levels
Afterwards, confirm that slave 2 is in place, the information in place of slave 2 is sent to main frame with data communication mode.Main frame is according to pre-setting
Each mailing address is that slave 2 distributes mailing address, while sending the mailing address of distribution to slave with data communication mode
1, the mailing address of the mailing address and slave 1 of slave 2 is differed.
It is the mailing address that slave 2 is distributed that slave 1, which receives main frame, and the mailing address of slave 2 is sent into slave 2, from
Machine 2 is obtained and main frame identical mailing address, and both can be carried out data communication.In one embodiment, as shown in figure 1,
When slave 1 receives the mailing address that main frame distributes for slave 2, it is connected with each address wire according to the mailing address
The level of ADD1/O~ADDn/O address ports is configured, and the level of ADD1/O~ADDn/O address ports of setting is passed through
Corresponding address wire is delivered to the ADD1/I~ADDn/I address ports being connected with each address wire of slave 2.Slave 1 is being set
Pre-arranged code mode can be used during port level, such as binary coding mode.Slave 2 reads its ADD1/I~ADDn/I
The low and high level state of address port, using corresponding coded system by the low and high level state transition of reading as it is corresponding communicatedly
The mailing address detected, is then set to the mailing address of slave 2 by location, therefore slave 2 is obtained and communicated with main frame identical
Address, both can enter row data communication.Slave 2 translates the coded system taken during mailing address and sets slave 1 for slave 1
The coded system used during address port.
With same mechanism, slave 3 (third level slave) is by reading the height of its ADD1/I~ADDn/I address port
Level state, can obtain host assignment to its address information, realize the data communication with main frame.By that analogy, can be by
Slave expands to N grades, and slave N is by reading the low and high level state of its ADD1/I~ADDn/I address port so as to obtain main frame
The mailing address allocated it, realize with the data communication of main frame, wherein main frame is the mailing address that distributes of each slave not phase
Together.
In the communication of whole slave, the address acquisition of the distribution of the address of main frame and slave artificially manual need not be set
Put, main frame and corresponding slave addresses can be allowed to be consistent, improve engineering joint efficiency and accuracy, reduce artificial mistake
By mistake.
Below from the angle of first order slave, with reference to accompanying drawing and preferred embodiment, to technical scheme, enter
The clear and complete description of row.
As shown in Fig. 2 a kind of master-slave communication distribution address approach of daisy chain connection, including step:
S110, first order slave obtain the first mailing address that main frame is sent by the first address wire, logical with described first
Row data communication is entered in letter address with the main frame;First mailing address is that the main frame detects the by first in bit line
The mailing address distributed when one-level slave is in place for the first order slave, passes through between the main frame and the first order slave
First address wire and described first is connected in bit line;
S120, first order slave by second bit line detect second level slave it is in place when, by the second level slave
Information in place is sent to the main frame with data communication mode;Pass through between the second level slave and the first order slave
Second connects in bit line and the second address wire;
The second of the second level slave that S130, the first order slave reception main frame are returned with data communication mode is led to
Believe address, second mailing address is sent to the second level slave by the second address wire so that the second level from
Machine enters row data communication with second mailing address and the main frame.
The master-slave communication distribution address approach of above-mentioned daisy chain connection can realize that program is operated in by corresponding program
In first order slave, first order slave is the slave being connected with main frame.In whole mailing address assigning process, each slave
Mailing address is by the way that after host assignment, the address wire between equipment passes to next stage slave from upper level slave and entered successively
Row automatic identification, it is not necessary to set manually, so as to improve the accuracy of project installation, it is to avoid manual operation mistake
By mistake.
In step s 110, main frame and slave can be the communication equipments such as single-chip microcomputer.In order to realize slave mailing address
Automatic distribution, bit line and address wire are arranged between the equipment of adjacent level.It is used for upper level equipment in bit line and detects next stage
Whether equipment is in place, and by next stage equipment output level, upper level equipment is detected.Can be according to reality in the quantity of bit line
Need to be determined, alternatively, connected between the equipment of adjacent level by one in bit line.Address wire is for upper level equipment
Next stage equipment transmits mailing address, and by upper equipment output level, next stage equipment is carried out communicatedly according to the level of reception
The automatic identification of location.The quantity and coded system for the slave that the quantity of address wire is typically connected as needed are determined.
As shown in figure 1, during 1 access host of slave, the DI/O ports output level of slave 1, the level passes through slave 1 and master
The DI/I ports that main frame 1 is delivered in bit line DI between machine, main frame 1 is detected after DI/I port levels, confirms that slave 1 exists
Position.The level that slave 1 is exported can be configured according to actual needs.
In the presence of main frame in bit line by detecting slave 1, it will be selected automatically from each mailing address pre-set
Take an address to be set to the mailing address of slave 1, the mailing address of slave 1 is then sent to slave 1, slave 1 is obtained and master
Machine identical mailing address, both can be carried out data communication.
In one embodiment, first order slave obtains the step for the first mailing address that main frame is sent by the first address wire
Suddenly it can include:First order slave reads the level for the address input end mouthful that first order slave is connected with the first address wire;It is described
Level is the level that the main frame is set according to the first mailing address;The level is translated as corresponding communication by first order slave
Address, obtains the first mailing address.
Main frame is chosen after the mailing address of slave 1, the ADD1/O being connected according to the mailing address to it with each address wire
The level of~ADDn/O address ports is configured, and the level of ADD1/O~ADDn/O address ports of setting is passed through corresponding
Address wire is delivered to the ADD1/I~ADDn/I address ports being connected with each address wire of slave 1.Main frame is setting port electricity
Pre-arranged code mode can be usually used, such as binary coding mode.Slave 1 reads its ADD1/I~ADDn/I addresses end
Mouthful low and high level state, using corresponding coded system by the low and high level state transition of reading as corresponding mailing address, because
This slave 1 is obtained and main frame identical mailing address, and both can enter row data communication.Slave 1 is taken when translating mailing address
Coded system coded system for the using when address port of main frame is set by main frame.
In the step s 120, slave 1 detects whether slave 2 is in place by being connected with slave 2 in bit line.In an implementation
In example, the master-slave communication distribution address approach of daisy chain connection can also include step:First order slave is by second in bit line
Detect whether second level slave is in place, including:Whether the first order receives from the input port in place of machine testing first order slave
Second level slave passes through the second level sent in bit line;The input port in place is that first order slave and second connect in bit line
The port connect;If receiving level, first order slave determines that second level slave is in place;Otherwise, first order slave determines the second level
Slave is not in place.
As shown in figure 1, when slave 2 accesses slave 1, the DI/O ports output level of slave 2, the level passes through the He of slave 2
The DI/I ports that slave 1 is delivered in bit line DI between slave 1, slave 1 is detected after DI/I port levels, confirms slave 2
In place, the information in place of slave 2 is sent to main frame with data communication mode.If slave 1 does not detect DI/I port levels,
Then confirm that slave 2 is not in place, and any operation is not performed.
In step s 130, main frame is received after the information in place of slave 2 of the transmission of slave 1, is that slave 2 is distributed communicatedly
Location, while sending the mailing address of distribution to slave 1, the mailing address of slave 2 and the communication of slave 1 with data communication mode
Address is differed.It is the mailing address that slave 2 is distributed that slave 1, which receives main frame, the mailing address of slave 2 is passed through corresponding
Location line is sent to slave 2, and slave 2 is obtained and main frame identical mailing address, and both can be carried out data communication.
In one embodiment, second mailing address is sent to described by first order slave by the second address wire
The step of two grades of slaves, can include:
First order slave sets the level of the address output end mouthful of first order slave according to second mailing address;Address
Output port is the port that first order slave is connected with the second address wire;
The level of address output end mouthful is sent to the second level slave by first order slave by the second address wire.
As shown in figure 1, slave 1 receive main frame be slave 2 distribute mailing address, according to the mailing address to its with it is each
The level of ADD1/O~ADDn/O address ports of individual address wire connection is configured, by ADD1/O~ADDn/O addresses of setting
The level of port is delivered to the ADD1/I~ADDn/I addresses end being connected with each address wire of slave 2 by corresponding address wire
Mouthful.Slave 1 can use pre-arranged code mode when setting port level, such as binary coding mode.Slave 2 reads it
The low and high level state of ADD1/I~ADDn/I address ports, with corresponding coded system by the low and high level state transition of reading
For corresponding mailing address, then the mailing address detected be set to the mailing address of slave 2, thus slave 2 obtain with
The mailing address of main frame identical slave 2, both can enter row data communication.Slave 2 translates the coding taken during mailing address
Mode is set the coded system used during the address port of slave 1 by slave 1.
In the communication of whole slave, the address acquisition of the distribution of the address of main frame and slave artificially manual need not be set
Put, main frame and corresponding slave addresses can be allowed to be consistent, improve engineering joint efficiency and accuracy, reduce artificial mistake
By mistake.
Based on same inventive concept, the present invention also provides a kind of slave, below in conjunction with the accompanying drawings to the specific of slave of the present invention
Embodiment is described in detail.
As shown in figure 3, a kind of slave, the slave is first order slave, including:
Communication building block 110, for obtaining the first mailing address that main frame is sent by the first address wire, with described
One mailing address enters row data communication with the main frame;First mailing address is that the main frame is detected by first in bit line
The mailing address distributed to the first order slave when in place for the first order slave, between the main frame and the first order slave
Connected by first address wire and described first in bit line;
Detection module 120, for by second bit line detect second level slave it is in place when, by the second level slave
Information in place is sent to the main frame with data communication mode;Pass through between the second level slave and the first order slave
Second connects in bit line and the second address wire;
Mailing address forwarding module 130, the second level returned for receiving the main frame with data communication mode from
Second mailing address of machine, is sent to the second level slave, so that institute by second mailing address by the second address wire
State second level slave and row data communication is entered with second mailing address and the main frame.
In order to realize the automatic distribution of slave mailing address, bit line and address wire are arranged between the equipment of adjacent level.
It is used for whether upper level equipment detection next stage equipment is in place in bit line, by next stage equipment output level, upper level equipment is entered
Row detection.Can be determined according to actual needs in the quantity of bit line, alternatively, between the equipment of adjacent level by one
Bit line is connected.It is that next stage equipment transmits mailing address that address wire, which is used for upper level equipment, next by upper equipment output level
Level equipment carries out the automatic identification of mailing address according to the level of reception.The slave that the quantity of address wire is typically connected as needed
Quantity and coded system be determined.
As shown in figure 1, during 1 access host of slave, the DI/O ports output level of slave 1, the level passes through slave 1 and master
The DI/I ports that main frame 1 is delivered in bit line DI between machine, main frame 1 is detected after DI/I port levels, confirms that slave 1 exists
Position.The level that slave 1 is exported can be configured according to actual needs.
In the presence of main frame in bit line by detecting slave 1, one address of automatic selection is set to slave 1 communicatedly
The mailing address of slave 1, is then sent to the communication building block 110 of slave 1 by location, and slave 1 is obtained to be led to main frame identical
Believe address, both can be carried out data communication.
In one embodiment, the address that the reading of communication building block 110 first order slave is connected with the first address wire is defeated
The level of inbound port;The level is the level that the main frame is set according to the first mailing address;The level is translated as pair
The mailing address answered, obtains the first mailing address.
The detection module 120 of slave 1 detects whether slave 2 is in place by being connected with slave 2 in bit line.In an implementation
In example, it is in place by second that detection module 120 detects whether the input port in place of first order slave receives second level slave
The level that line is sent;Input port in place is first order slave and the second port being connected in bit line;When receiving level, really
Determine second level slave in place;When not receiving level, determine that second level slave is not in place.
Main frame is received after the information in place of slave 2 of the transmission of slave 1, is the distribution mailing address of slave 2, while will distribution
Mailing address slave 1 is sent to data communication mode, the mailing address of the mailing address and slave 1 of slave 2 is differed.From
It is the mailing address that slave 2 is distributed that the mailing address forwarding module 130 of machine 1, which receives main frame, and the mailing address of slave 2 is passed through
Corresponding address wire is sent to slave 2, and slave 2 is obtained and main frame identical mailing address, and both can be carried out data communication.
In one embodiment, mailing address forwarding module 130 sets first order slave according to second mailing address
Address output end mouthful level;The port that address output end mouthful is connected for first order slave with the second address wire;Address is defeated
The level of exit port is sent to the second level slave by the second address wire.
In the communication of whole slave, the address acquisition of the distribution of the address of main frame and slave artificially manual need not be set
Put, main frame and corresponding slave addresses can be allowed to be consistent, improve engineering joint efficiency and accuracy, reduce artificial mistake
By mistake.
Below from the angle of other slaves, with reference to accompanying drawing and preferred embodiment, to technical scheme, carry out
Clear and complete description.
As shown in figure 4, a kind of master-slave communication distribution address approach of daisy chain connection, including step:
S210, n-th grade of slave obtain the mailing address that (n-1)th grade of slave is sent by nth address line, with it is described communicatedly
Row data communication is entered in location with main frame;The mailing address detects n-th grade of slave in bit line by n-th for (n-1)th grade of slave and existed
The mailing address obtained during position from main frame, is connected between n-th grade of slave and (n-1)th grade of slave by nth address line and n-th in bit line
Connect, n is the integer more than 1;
S220, n-th grade of slave by (n+1)th bit line detect (n+1)th grade of slave it is in place when, (n+1)th grade of slave is existed
The information of position is sent to the main frame with data communication mode;It is in place by (n+1)th between n-th grade of slave and (n+1)th grade of slave
Line and the connection of the (n+1)th address wire;
S230, n-th grade of slave receive the mailing address for (n+1)th grade of slave that the main frame is returned with data communication mode,
The mailing address of (n+1)th grade of slave is sent to (n+1)th grade of slave by the (n+1)th address wire, so that (n+1)th grade of slave is logical with it
Row data communication is entered in letter address with the main frame.
The master-slave communication distribution address approach of above-mentioned daisy chain connection can realize that program is operated in by corresponding program
In other slaves in addition to first order slave.In whole mailing address assigning process, the mailing address of each slave is to pass through
After host assignment, the address wire between equipment passes to next stage slave from upper level slave and carries out automatic identification successively,
It need not be set manually, so as to improve the accuracy of project installation, it is to avoid human operational error.
In step S210, main frame and slave can be the communication equipments such as single-chip microcomputer.In order to realize slave mailing address
Automatic distribution, bit line and address wire are arranged between the equipment of adjacent level.It is used for upper level equipment in bit line and detects next stage
Whether equipment is in place, and by next stage equipment output level, upper level equipment is detected.Can be according to reality in the quantity of bit line
Need to be determined, alternatively, connected between the equipment of adjacent level by one in bit line.Address wire is for upper level equipment
Next stage equipment transmits mailing address, and by upper equipment output level, next stage equipment is carried out communicatedly according to the level of reception
The automatic identification of location.The quantity and coded system for the slave that the quantity of address wire is typically connected as needed are determined.
(n-1)th grade of slave is to realize the slave of data communication in main frame.When n-th grade of slave accesses (n-1)th grade of slave, the
The DI/O ports output level of n grades of slaves, the level between n-th grade of slave and (n-1)th grade of slave in bit line DI by transmitting
To the DI/I ports of (n-1)th grade of slave, (n-1)th grade of slave is detected after DI/I port levels, confirms that n-th grade of slave is in place.N-th
The level of level slave output can be configured according to actual needs.
In the presence of (n-1)th grade of slave in bit line by detecting n-th grade of slave, by n-th grade of slave information in place with
Data communication mode is sent to main frame, when main frame receives n-th grade of slave information in place, by automatically from pre-set each
The mailing address that an address is set to n-th grade of slave is chosen in mailing address, then by the mailing address of n-th grade of slave with data
Communication mode is sent to (n-1)th grade of slave, and (n-1)th grade of slave sends out the mailing address of n-th grade of slave by corresponding address wire
N-th grade of slave is given, n-th grade of slave is obtained and main frame identical mailing address, and both can be carried out data communication.
In one embodiment, n-th grade of slave obtains the mailing address that (n-1)th grade of slave is sent by nth address line
Step can include:N-th grade of slave reads the level for the address input end mouthful that n-th grade of slave is connected with nth address line;Address is defeated
The level of inbound port is the level that (n-1)th grade of slave is set according to the mailing address of n-th grade of slave;N-th grade of slave is defeated by address
The level of inbound port is translated as corresponding mailing address, obtains the mailing address of n-th grade of slave.
(n-1)th grade of slave is received after mailing address of the main frame for the distribution of n-th grade of slave, according to the mailing address to its with
The level of ADD1/O~ADDn/O address ports of each address wire connection is configured, by ADD1/O~ADDn/O of setting
The level of location port is delivered to the ADD1/I~ADDn/I being connected with each address wire of n-th grade of slave by corresponding address wire
Address port.(n-1)th grade of slave can use pre-arranged code mode, such as binary coding mode when setting port level
Deng.N-th grade of slave reads the low and high level state of its ADD1/I~ADDn/I address port, will be read with corresponding coded system
Low and high level state transition be corresponding mailing address, therefore n-th grade of slave obtains logical with n-th grade of slave of main frame identical
Believe address, both can enter row data communication.The coded system taken during n-th grade of slave translation mailing address for (n-1)th grade from
The coded system used during the address port of machine (n-1)th grade of slave of setting.
In step S220, n-th grade of slave detects that (n+1)th grade of slave is by being connected with (n+1)th grade of slave in bit line
It is no in place.In one embodiment, the master-slave communication distribution address approach of daisy chain connection can also include step:N-th grade from
Machine detects whether (n+1)th grade of slave be in place in place by (n+1)th in bit line, including:N-th grade from machine testing its input port in place
(DI/I) whether receive (n+1)th grade of slave and pass through the (n+1)th level sent in bit line;Input port in place is n-th grade of slave
With the (n+1)th port being connected in bit line;If receiving level, determine that (n+1)th grade of slave is in place;Otherwise, it determines (n+1)th grade of slave
It is not in place.
When (n+1)th grade of slave accesses n-th grade of slave, the DI/O ports output level of (n+1)th grade of slave, the level passes through the
The DI/I ports that n-th grade of slave is delivered in bit line DI between n+1 grades of slaves and n-th grade of slave, n-th grade of slave is detected
After DI/I port levels, confirm that (n+1)th grade of slave is in place, by (n+1)th grade of slave information transmission in place to main frame.If n-th grade
Slave does not detect DI/I port levels, then confirms that (n+1)th grade of slave be not in place, any operation is not performed.
In step S230, main frame is received after (n+1)th grade of slave that n-th grade of slave send information in place, is (n+1)th
Level slave distribution mailing address, while sending the mailing address of distribution to n-th grade of slave with data communication mode.N-th grade from
Machine receives mailing address of the main frame for (n+1)th grade of slave distribution, and the mailing address of (n+1)th grade of slave is passed through into corresponding address
Line is sent to (n+1)th grade of slave, and (n+1)th grade of slave is obtained and main frame identical mailing address, and both can be carried out data and lead to
Letter.
In one embodiment, the mailing address of (n+1)th grade of slave is sent to by n-th grade of slave by the (n+1)th address wire
The step of (n+1)th grade of slave, can include:
N-th grade of slave sets the level of the address output end mouthful of n-th grade of slave according to the mailing address of (n+1)th grade of slave;
The port that address output end mouthful is connected for n-th grade of slave with the (n+1)th address wire;
The level of address output end mouthful is sent to (n+1)th grade of slave by n-th grade of slave by the (n+1)th address wire.
N-th grade of slave receives mailing address of the main frame for the distribution of (n+1)th grade of slave, according to the mailing address to its with it is each
The level of ADD1/O~ADDn/O address ports of individual address wire connection is configured, by ADD1/O~ADDn/O addresses of setting
The level of port is delivered to the ADD1/I~ADDn/I being connected with each address wire of (n+1)th grade of slave by corresponding address wire
Address port.N-th grade of slave can use pre-arranged code mode when setting port level, such as binary coding mode.
(n+1)th grade of slave reads the low and high level state of its ADD1/I~ADDn/I address port, will be read with corresponding coded system
Low and high level state transition be corresponding mailing address, the mailing address detected is then set to (n+1)th grade of slave
Mailing address, therefore (n+1)th grade of slave obtains the mailing address with (n+1)th grade of slave of main frame identical, both can enter line number
According to communication.The coded system taken during (n+1)th grade of slave translation mailing address sets the address of n-th grade of slave for n-th grade of slave
The coded system used during port.
In the communication of whole slave, the address acquisition of the distribution of the address of main frame and slave artificially manual need not be set
Put, main frame and corresponding slave addresses can be allowed to be consistent, improve engineering joint efficiency and accuracy, reduce artificial mistake
By mistake.
Based on same inventive concept, the present invention also provides another slave, below in conjunction with the accompanying drawings to the tool of another slave
Body embodiment is described in detail.
As shown in figure 5, a kind of slave, the slave is n-th grade of slave, n is the integer more than 1, including:
Communication building block 210, for obtaining the mailing address that (n-1)th grade of slave is sent by nth address line, with described
Mailing address enters row data communication with main frame;The mailing address is that (n-1)th grade of slave detects n-th grade by n-th in bit line
When slave is in place from main frame obtain mailing address, between n-th grade of slave and (n-1)th grade of slave by nth address line and n-th
Bit line is connected;
Detection module 220, for by (n+1)th bit line detect (n+1)th grade of slave it is in place when, by (n+1)th grade of slave
Information in place is sent to the main frame with data communication mode;Between n-th grade of slave and (n+1)th grade of slave by (n+1)th
Bit line and the connection of the (n+1)th address wire;
Mailing address forwarding module 230, for receiving (n+1)th grade of slave that the main frame is returned with data communication mode
Mailing address, is sent to (n+1)th grade of slave, so that (n+1)th grade by the mailing address of (n+1)th grade of slave by the (n+1)th address wire
Slave enters row data communication with its mailing address and the main frame.
Main frame and slave can be the communication equipments such as single-chip microcomputer.In order to realize the automatic distribution of slave mailing address, in phase
Bit line and address wire are arranged between the equipment of adjacent level.It is used for upper level equipment in bit line and detects whether next stage equipment is in place,
By next stage equipment output level, upper level equipment is detected.It can be determined according to actual needs in the quantity of bit line,
Alternatively, connected between the equipment of adjacent level by one in bit line.Address wire is used for upper level equipment and passed for next stage equipment
Mailing address is passed, by upper equipment output level, next stage equipment carries out the automatic identification of mailing address according to the level of reception.
The quantity and coded system for the slave that the quantity of address wire is typically connected as needed are determined.
When n-th grade of slave accesses (n-1)th grade of slave, the DI/O ports output level of n-th grade of slave, the level passes through n-th
The DI/I ports that (n-1)th grade of slave is delivered in bit line DI between level slave and (n-1)th grade of slave, (n-1)th grade from machine testing
To after DI/I port levels, confirm that n-th grade of slave is in place.The level of n-th grade of slave output can be set according to actual needs
Put.
In the presence of (n-1)th grade of slave in bit line by detecting n-th grade of slave, by n-th grade of slave information in place with
Data communication mode is sent to main frame, when main frame receives n-th grade of slave information in place, and one address of automatic selection is set to
The mailing address of n-th grade of slave, is then sent to (n-1)th grade of slave by the mailing address of n-th grade of slave with data communication mode,
The mailing address of n-th grade of slave is sent to the communication building block of n-th grade of slave by (n-1)th grade of slave by corresponding address wire
210, n-th grade of slave is obtained and main frame identical mailing address, and both can be carried out data communication.
In one embodiment, communication building block 210 reads the address input that n-th grade of slave is connected with nth address line
The level of port;The level that the level of address input end mouthful is set for (n-1)th grade of slave according to the mailing address of n-th grade of slave;
The level of address input end mouthful is translated as corresponding mailing address, the mailing address of n-th grade of slave is obtained.
The detection module 220 of n-th grade of slave detects that (n+1)th grade of slave is by being connected with (n+1)th grade of slave in bit line
It is no in place.In one embodiment, detection module 220 detects whether the input port in place (DI/I) of n-th grade of slave receives
(n+1)th grade of slave passes through the (n+1)th level sent in bit line;Input port in place is that n-th grade of slave is connected with (n+1)th in bit line
Port;When receiving level, determine that (n+1)th grade of slave is in place;When not receiving level, determine that (n+1)th grade of slave does not exist
Position.
Main frame is received after (n+1)th grade of slave that n-th grade of slave send information in place, is that (n+1)th grade of slave distribution is logical
Address is believed, while the mailing address of distribution to be sent to the mailing address forwarding module of n-th grade of slave with data communication mode
230.The mailing address forwarding module 230 of n-th grade of slave receives mailing address of the main frame for (n+1)th grade of slave distribution, by n-th
The mailing address of+1 grade of slave is sent to (n+1)th grade of slave by corresponding address wire, and (n+1)th grade of slave obtains identical with main frame
Mailing address, both can be carried out data communication.
In one embodiment, mailing address forwarding module 230 sets n-th grade according to the mailing address of (n+1)th grade of slave
The level of the address output end mouthful of slave;The port that address output end mouthful is connected for n-th grade of slave with the (n+1)th address wire;By ground
The level of location output port is sent to (n+1)th grade of slave by the (n+1)th address wire.
In the communication of whole slave, the address acquisition of the distribution of the address of main frame and slave artificially manual need not be set
Put, main frame and corresponding slave addresses can be allowed to be consistent, improve engineering joint efficiency and accuracy, reduce artificial mistake
By mistake.
Below from the angle of main frame, with reference to accompanying drawing and preferred embodiment, to technical scheme, carry out clear
With complete description.
As shown in fig. 6, a kind of master-slave communication distribution address approach of daisy chain connection, including step:
S310, main frame by first bit line detect first order slave it is in place when, be first order slave distribution the
One mailing address, and first mailing address is sent to the first order slave by the first address wire, so that described
One-level slave enters row data communication with first mailing address and main frame;Pass through between the main frame and the first order slave
First connects in bit line and the first address wire;
S320, main frame receive n-th grade of slave by (n+1)th bit line detect (n+1)th grade of slave it is in place when send
It is that (n+1)th grade of slave distributes the (n+1)th mailing address during information, and by (n+1)th mailing address with data communication mode
N-th grade of slave is sent to, so that (n+1)th mailing address is sent to by n-th grade of slave by the (n+1)th address wire
(n+1)th grade of slave;Described information is sent with data communication mode, between n-th grade of slave and (n+1)th grade of slave
Connected by (n+1)th in bit line and the (n+1)th address wire, n is the integer more than or equal to 1.
The master-slave communication distribution address approach of above-mentioned daisy chain connection can realize that program is operated in by corresponding program
In main frame.In whole mailing address assigning process, the mailing address of each slave is by after host assignment, between equipment
Address wire pass to next stage slave successively from upper level slave and carry out automatic identification, it is not necessary to set manually, from
And improve the accuracy of project installation, it is to avoid human operational error.
In step S310, main frame and slave can be the communication equipments such as single-chip microcomputer.In order to realize slave mailing address
Automatic distribution, bit line and address wire are arranged between the equipment of adjacent level.It is used for upper level equipment in bit line and detects next stage
Whether equipment is in place, and by next stage equipment output level, upper level equipment is detected.Can be according to reality in the quantity of bit line
Need to be determined, alternatively, connected between the equipment of adjacent level by one in bit line.Address wire is for upper level equipment
Next stage equipment transmits mailing address, and by upper equipment output level, next stage equipment is carried out communicatedly according to the level of reception
The automatic identification of location.The quantity and coded system for the slave that the quantity of address wire is typically connected as needed are determined.
As shown in figure 1, during 1 access host of slave, the DI/O ports output level of slave 1, the level passes through slave 1 and master
The DI/I ports that main frame 1 is delivered in bit line DI between machine, main frame 1 is detected after DI/I port levels, confirms that slave 1 exists
Position.The level that slave 1 is exported can be configured according to actual needs.
In the presence of main frame in bit line by detecting slave 1, one address of automatic selection is set to slave 1 communicatedly
Location, is then sent to slave 1 by the mailing address of slave 1, slave 1 obtain with main frame identical mailing address, both just can be with
Enter row data communication.
In one embodiment, as shown in figure 1, main frame is chosen after the mailing address of slave 1, according to the mailing address to it
The level for the ADD1/O~ADDn/O address ports being connected with each address wire is configured, by ADD1/O~ADDn/O of setting
The level of address port is with being delivered to the ADD1/I~ADDn/I being connected with each address wire of slave 1 by corresponding address wire
Location port.Main frame can use pre-arranged code mode when setting port level, such as binary coding mode.Slave 1 is read
The low and high level state of its ADD1/I~ADDn/I address port is taken, with corresponding coded system by the low and high level state of reading
Corresponding mailing address is translated as, therefore slave 1 obtains the mailing address with main frame identical slave 1, both can enter line number
According to communication.Slave 1 translates the volume used when the coded system taken during mailing address sets the address port of main frame by main frame
Code mode.
In step s 320, n-th grade of slave realizes the slave communicated with host data to have obtained mailing address, and n is big
In equal to 1.When (n+1)th grade of slave accesses n-th grade of slave, the DI/O ports output level of (n+1)th grade of slave, the level passes through the
The DI/I ports that n-th grade of slave is delivered in bit line DI between n+1 grades of slaves and n-th grade of slave, n-th grade of slave is detected
After DI/I port levels, confirm that (n+1)th grade of slave is in place, the information of (n+1)th grade of slave is sent to master with data communication mode
Machine.Main frame is (n+1)th grade of slave distribution mailing address, while sending the mailing address of distribution to n-th with data communication mode
Level slave.
N-th grade of slave receives mailing address of the main frame for (n+1)th grade of slave distribution, by (n+1)th grade of slave communicatedly
Location is sent to (n+1)th grade of slave by corresponding address wire, and (n+1)th grade of slave is obtained and main frame identical mailing address, both
It can be carried out data communication.In one embodiment, n-th grade of slave receives the mailing address that main frame is (n+1)th grade of distribution,
The level of its ADD1/O~ADDn/O address port being connected with each address wire is configured according to the mailing address, will be set
The level for the ADD1/O~ADDn/O address ports put (n+1)th grade of slave is delivered to by corresponding address wire with each address
ADD1/I~ADDn/I address ports of line connection.N-th grade of slave can use pre-arranged code mode when setting port level,
Such as binary coding mode.(n+1)th grade of slave reads the low and high level state of its ADD1/I~ADDn/I address port, with
The low and high level state transition of reading is corresponding mailing address by corresponding coded system, then by the mailing address detected
The mailing address of (n+1)th grade of slave is set to, therefore (n+1)th grade of slave obtains the communication with (n+1)th grade of slave of main frame identical
Address, both can enter row data communication.The coded system taken during (n+1)th grade of slave translation mailing address is n-th grade of slave
The coded system used during the address port of n-th grade of slave of setting.
In the communication of whole slave, the address acquisition of the distribution of the address of main frame and slave artificially manual need not be set
Put, main frame and corresponding slave addresses can be allowed to be consistent, improve engineering joint efficiency and accuracy, reduce artificial mistake
By mistake.
Based on same inventive concept, the present invention also provides a kind of main frame, below in conjunction with the accompanying drawings to the specific of main frame of the present invention
Embodiment is described in detail.
As shown in fig. 7, a kind of main frame, including:
First communication building block 310, for by first bit line detect first order slave it is in place when, be described
One-level slave distribute the first mailing address, and by first mailing address by the first address wire be sent to the first order from
Machine, so that the first order slave enters row data communication with first mailing address and main frame;The main frame and described first
Connected between level slave by first in bit line and the first address wire;
Second communication building block 320, for receive n-th grade of slave by (n+1)th bit line detect (n+1)th grade from
It is that (n+1)th grade of slave distributes the (n+1)th mailing address during the information sent when machine is in place, and by (n+1)th mailing address
N-th grade of slave is sent to data communication mode, so that (n+1)th mailing address is passed through n-th by n-th grade of slave
+ 1 address wire is sent to (n+1)th grade of slave;Described information is sent with data communication mode, n-th grade of slave with it is described
Connected between (n+1)th grade of slave by (n+1)th in bit line and the (n+1)th address wire, n is the integer more than or equal to 1.
Main frame and slave can be the communication equipments such as single-chip microcomputer.In order to realize the automatic distribution of slave mailing address, in phase
Bit line and address wire are arranged between the equipment of adjacent level.It is used for upper level equipment in bit line and detects whether next stage equipment is in place,
By next stage equipment output level, upper level equipment is detected.It can be determined according to actual needs in the quantity of bit line,
Alternatively, connected between the equipment of adjacent level by one in bit line.Address wire is used for upper level equipment and passed for next stage equipment
Mailing address is passed, by upper equipment output level, next stage equipment carries out the automatic identification of mailing address according to the level of reception.
The quantity and coded system for the slave that the quantity of address wire is typically connected as needed are determined.
As shown in figure 1, during 1 access host of slave, the DI/O ports output level of slave 1, the level passes through slave 1 and master
The DI/I ports that main frame 1 is delivered in bit line DI between machine, main frame 1 is detected after DI/I port levels, confirms that slave 1 exists
Position.The level that slave 1 is exported can be configured according to actual needs.
In the presence of the first communication building block 310 of main frame in bit line by detecting slave 1, one will be chosen automatically
Address is set to the mailing address of slave 1, and the mailing address of slave 1 then is sent into slave 1, and slave 1 obtains identical with main frame
Mailing address, both can be carried out data communication.
N-th grade of slave realizes the slave communicated with host data to have obtained mailing address.(n+1)th grade of slave access
During n-th grade of slave, the DI/O ports output level of (n+1)th grade of slave, the level by (n+1)th grade of slave and n-th grade of slave it
Between the DI/I ports that n-th grade of slave is delivered in bit line DI, n-th grade of slave detected after DI/I port levels, confirms (n+1)th
Level slave is in place, and the information of (n+1)th grade of slave is sent to the second communication building block 320 of main frame with data communication mode.
Second communication building block 320 is (n+1)th grade of slave distribution mailing address, while by the mailing address of distribution with data communication side
Formula sends n-th grade of slave to.
N-th grade of slave receives mailing address of the main frame for (n+1)th grade of slave distribution, by (n+1)th grade of slave communicatedly
Location is sent to (n+1)th grade of slave, and (n+1)th grade of slave is obtained and main frame identical mailing address, and both can be carried out data and lead to
Letter.In one embodiment, n-th grade of slave receives the mailing address that main frame is (n+1)th grade of distribution, according to the mailing address pair
The level of its ADD1/O~ADDn/O address port being connected with each address wire is configured, by the ADD1/O of setting~
The level of ADDn/O address ports is delivered to being connected with each address wire for (n+1)th grade of slave by corresponding address wire
ADD1/I~ADDn/I address ports.N-th grade of slave can use pre-arranged code mode when setting port level, and such as two enter
Coded system processed etc..(n+1)th grade of slave reads the low and high level state of its ADD1/I~ADDn/I address port, to compile accordingly
The low and high level state transition of reading is corresponding mailing address by code mode, and the mailing address detected then is set into the
The mailing address of n+1 grades of slaves, therefore (n+1)th grade of slave obtains the mailing address with (n+1)th grade of slave of main frame identical, both
Row data communication can be entered.The coded system taken during (n+1)th grade of slave translation mailing address sets n-th grade for n-th grade of slave
The coded system used during the address port of slave.
In the communication of whole slave, the address acquisition of the distribution of the address of main frame and slave artificially manual need not be set
Put, main frame and corresponding slave addresses can be allowed to be consistent, improve engineering joint efficiency and accuracy, reduce artificial mistake
By mistake.
For a better understanding of the present invention, described in detail with reference to a specific embodiment.
As shown in figure 8, being 1 monitoring host computer (i.e. main frame) and 4 monitoring slave (i.e. slave) connections, monitoring in this example
Have between main frame and monitoring slave 1 in bit line DI, two address wires ADD1 and ADD2, between monitoring slave 1 and monitoring slave 2
Have with bit line DI, two address wires ADD1 and ADD2, monitoring between slave 2 and monitoring slave 3 in bit line DI, two ground
Location line ADD1 and ADD2, have in bit line DI, two address wires ADD1 and ADD2 between monitoring slave 3 and monitoring slave 4.In place
Line DI is detected by next stage output level, upper level;Address wire is by upper level output level, next stage detection;Slave
Data/address bus is two-way interactive data/address bus.
As shown in figure 9, when monitoring 1 access host of slave, monitoring slave 1 exports DI level, DI electricity from its DI/O port
The flat DI/I ports for being transferred to monitoring host computer in bit line by DI.Monitoring host computer is detected after DI level, it is believed that have next stage from
Machine, is low level to monitor the distribution of slave 1 address (such as 00) and exporting ADD1/O and ADD2/O port level, by corresponding
Address wire passes to ADD1/O and ADD2/O low level the ADD1/I ports and ADD2/I ports of monitoring slave 1.Work as monitoring
When slave 1 detects the level of its ADD1/I port and ADD2/I ports for low level, mailing address is written as 00.Therefore main frame
Identical with the mailing address of first order slave, slave just can realize data communication by bus.
When monitoring slave 1 by detecting monitoring slave 2 in bit line DI and connecting in place, monitoring slave 1 uses data communication
The information in place for monitoring slave 2 is told monitoring host computer by mode.Monitoring host computer will distribute mailing address to monitoring slave 2, and such as 01
(ADD2/O=0, ADD1/O=1), monitoring slave 1 is transmitted in the way of data communication by the address information for monitoring slave 2.Monitoring
Slave 1 obtains after address information its ADD2/O port and ADD1/O ports being set to low level and high level respectively, passes through correspondence
Address wire by monitor slave 1 ADD1/O ports and ADD2/O ports level pass to monitoring slave 2 ADD1/I ports
With ADD2/I ports.Monitoring slave 2 detects its ADD1/I port and ADD2/I ports are respectively high level and low level, will lead to
Letter address is written as 01, identical with the mailing address of slave 2 in main frame, therefore monitoring host computer and monitoring slave 2 can pass through bus
Realize data communication.
When monitoring slave 2 by detecting monitoring slave 3 in bit line DI and connecting in place, monitoring slave 2 uses data communication
The information in place for monitoring slave 3 is told monitoring host computer by mode.Monitoring host computer will distribute mailing address to monitoring slave 3, and such as 10
(ADD2/O=1, ADD1/O=0), monitoring slave 2 is transmitted in the way of data communication by the address information for monitoring slave 3.Monitoring
Slave 2 obtains after address information its ADD2/O port and ADD1/O ports being set to high level and low level respectively, passes through correspondence
Address wire by monitor slave 2 ADD1/O ports and ADD2/O ports level pass to monitoring slave 3 ADD1/I ports
With ADD2/I ports.Monitoring slave 3 detects its ADD1/I port and ADD2/I ports are respectively low level and high level, will lead to
Letter address is written as 10, identical with the mailing address of slave 3 in main frame, therefore monitoring host computer and monitoring slave 3 can pass through bus
Realize data communication.
When monitoring slave 3 by detecting monitoring slave 4 in bit line DI and connecting in place, monitoring slave 3 uses data communication
The information in place for monitoring slave 4 is told monitoring host computer by mode.Monitoring host computer will distribute mailing address to monitoring slave 4, and such as 11
(ADD2/O=1, ADD1/O=1), monitoring slave 3 is transmitted in the way of data communication by the address information for monitoring slave 4.Monitoring
Slave 3 obtains after address information its ADD2/O port and ADD1/O ports being set to high level and high level respectively, passes through correspondence
Address wire by monitor slave 3 ADD1/O ports and ADD2/O ports level pass to monitoring slave 4 ADD1/I ports
With ADD2/I ports.Monitoring slave 4 detects its ADD1/I port and ADD2/I ports are respectively high level and high level, will lead to
Letter address is written as 11, identical with the mailing address of slave 4 in main frame, therefore monitoring host computer and monitoring slave 4 can pass through bus
Realize data communication.
The master-slave communication of above-mentioned daisy chain connection distributes address approach, system and slave, main frame, and the address of each slave is
After host assignment, the line between equipment passes to next stage slave from upper level slave and carries out automatic identification successively
, it is not necessary to set manually, the automatic distribution for the slave addresses that main frame is connected to multiple daisy chains is realized, so as to improve
Engineering efficiency and accuracy, improve the accuracy and convenience of address setting, reduce human operational error, evade artificial
The wrong communication mistake brought is set, and address distribution can arbitrarily be distributed by main frame, not by hardware controls.
One of ordinary skill in the art will appreciate that realize all or part of flow in above-described embodiment method, being can be with
The hardware of correlation is instructed to complete by computer program, described program can be stored in a computer read/write memory medium
In, the program is upon execution, it may include such as the flow of the embodiment of above-mentioned each method.Wherein, described storage medium can be magnetic
Dish, CD, read-only memory (Read-Only Memory, ROM) or random access memory (Random Access
Memory, RAM) etc..
Each technical characteristic of embodiment described above can be combined arbitrarily, to make description succinct, not to above-mentioned reality
Apply all possible combination of each technical characteristic in example to be all described, as long as however, the combination of these technical characteristics is not deposited
In contradiction, the scope of this specification record is all considered to be.
Embodiment described above only expresses the several embodiments of the present invention, and it describes more specific and detailed, but simultaneously
Can not therefore it be construed as limiting the scope of the patent.It should be pointed out that coming for one of ordinary skill in the art
Say, without departing from the inventive concept of the premise, various modifications and improvements can be made, these belong to the protection of the present invention
Scope.Therefore, the protection domain of patent of the present invention should be determined by the appended claims.