CN104932997B - A kind of monobus communication means and system - Google Patents
A kind of monobus communication means and system Download PDFInfo
- Publication number
- CN104932997B CN104932997B CN201510323725.9A CN201510323725A CN104932997B CN 104932997 B CN104932997 B CN 104932997B CN 201510323725 A CN201510323725 A CN 201510323725A CN 104932997 B CN104932997 B CN 104932997B
- Authority
- CN
- China
- Prior art keywords
- slave
- host
- code
- bit
- identity code
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/40—Bus structure
- G06F13/4063—Device-to-bus coupling
- G06F13/4068—Electrical coupling
- G06F13/4081—Live connection to bus, e.g. hot-plugging
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Mobile Radio Communication Systems (AREA)
- Small-Scale Networks (AREA)
Abstract
A kind of monobus communication means and system, in search step, host successively sends reset signal search command to slave;Read the present bit and its complement code of the Identity Code for the slave that slave returns;The present bit and its complement code for the Identity Code that host is returned according to slave generate specific bit, and specific bit is sent to slave;Slave continues to participate in search process when the next bit for the present bit for determining its Identity Code is matched with specific bit, otherwise, into wait state;Host sends the next bit for reading slave Identity Code and its order of complement code to slave, until only remaining only one does not enter wait state in slave, host reads and record all place values of the Identity Code of the slave for not entering wait state;It repeats the above steps, up to the Identity Code of all slaves under host record.The monobus communication means and system have the advantages that communication efficiency is high, communication is accurate.
Description
Technical field
This application involves the communications fields, and in particular to a kind of monobus communication means and system.
Background technique
Bussing technique is the important technology of a kind of chip or communication between devices, relative to point-to-point communication technology, bus
Communication can be effectively reduced the complexity of line, improve the utilization rate of line.Existing bus is in such a way that data are transmitted
Universal serial bus and parallel bus can be divided into, at present common universal serial bus have SPI, I2C, USB, IEEE1394,
RS232, CAN etc., and comparatively type will be lacked parallel bus, common such as IEEE1284, ISA, PCI.But it either goes here and there
Row bus or parallel bus, bus communication require the support of a plurality of communication line, this can be very valuable to I/O mouthfuls of resources
Circuit design brings difficulty, therefore the monobus communication technology is come into being.Existing Single Wire Bus Technology is with Maxim wholly-owned subsidiary
The 1-Wire comparative maturity of Dallas and the most commonly used.It uses single signal wire, not only transmits clock, but also transmission data and number
Be according to transmission it is two-way, have and save I/O mouth line resource, of simple structure and low cost, many convenient for bus extension and maintenance etc.
Advantage.
Existing monobus is suitable for individual host system, can control one or more slave devices.When only one
When slave is located in bus, system can be operated according to single node system;And when multiple slaves are located in bus, then system according to
Multi-node system operation.
Summary of the invention
The application provides a kind of monobus communication means and system, has the advantages that communication efficiency is high, communication is accurate.
According to a first aspect of the present application, this application provides a kind of monobus communication means, comprising:
Search step comprising sub-step below:
Host sends reset signal to slave;
Host sends search command to slave;
Host reads the present bit and its complement code of the Identity Code for the slave that slave returns;
The present bit and its complement code for the Identity Code that host is returned according to slave generate specific bit, and specific bit is sent
To slave;
Slave is continued to participate in and was searched for when the next bit for the present bit for determining its Identity Code is matched with specific bit
Journey, otherwise, into wait state;
Host sends the next bit for reading slave Identity Code and its order of complement code to slave, until only surplus in slave
Lower only one does not enter wait state, and host reads and record the institute of the Identity Code of the slave for not entering wait state
There is place value;
It repeats the above steps, up to the Identity Code of all slaves under host record;
Data transmission step: host sends communications command to slave, and slave enters preparation state according to the communications command,
Host is communicated with slave.
In one embodiment, in described search step, host is using binary search tree algorithm search to all slaves.
In one embodiment, the present bit and its complement code for the Identity Code that host is returned according to slave generate specific bit,
Specifically: when present bit and its complement code are all " 1 ", host, which is judged as in bus, does not have slave response;When present bit and its benefit
When code is all " 0 ", host is judged as that the present bit of the Identity Code of slave includes " 0 " and " 1 ";When present bit and its complement code point
Not Wei " 0 " and " 1 " when, host is judged as that the present bit of the Identity Code of slave is " 0 ";When present bit and its complement code are distinguished
When for " 1 " and " 0 ", host is judged as that the present bit of the Identity Code of slave is " 1 ";Host is true according to above-mentioned judging result
Determine the bit pointer in binary search tree algorithm, and specific bit is generated according to the bit pointer.
In one embodiment, the Identity Code includes the data of 8 bytes, and the data of the 1st byte are used for table
Show the device type of slave.
In one embodiment, host is read in the present bit and its complement code of the Identity Code for the slave that slave returns, institute
It states present bit and its complement code is the data value that host is read from bus, the data value is the data value that all slaves are sent
The result of logical AND.
In one embodiment, further include matching step between search step and data transmission step: host is sent out to slave
The Identity Code for needing matched slave is sent, slave matches the Identity Code with the Identity Code of the machine, such as
Fruit mismatches, then enters sleep state, if it does, then into wait state.
According to a second aspect of the present application, this application provides a kind of monobus communication system, including a host and more
A slave, the host are connected with slave by monobus;
When slave in the base unit search bus, host successively sends reset signal and search command to slave, and reads
Take slave return slave Identity Code present bit and its complement code, further according to slave return Identity Code it is current
Position and its complement code generate specific bit, and specific bit is sent to slave;
The slave is used for when the next bit for the present bit for determining its Identity Code is matched with specific bit, continues to join
With search process, otherwise, into wait state;
The host is also used to send next bit and its order of complement code of reading slave Identity Code to slave, until
Only remaining only one does not enter wait state in slave, and host reads and records the identity of the slave for not entering wait state
All place values of identification code, up to the Identity Code of all slaves under host record
The host is also used to after having searched for all slaves, sends communications command to slave, in slave according to described logical
After letter order enters preparation state, communicated with slave.
In one embodiment, the host is used for using the slave in binary search tree algorithm search bus.
In one embodiment, the present bit and its complement code for the Identity Code that host is used to be returned according to slave generate specified
When position: when present bit and its complement code are all " 1 ", host, which is judged as in bus, does not have slave response;When present bit and its complement code
When being all " 0 ", host is judged as that the present bit of the Identity Code of slave includes " 0 " and " 1 ";When present bit and its complement code are distinguished
When for " 0 " and " 1 ", host is judged as that the present bit of the Identity Code of slave is " 0 ";When present bit and its complement code are respectively
When " 1 " and " 0 ", host is judged as that the present bit of the Identity Code of slave is " 1 ";Host is used for according to above-mentioned judging result
It determines the bit pointer in binary search tree algorithm, and specific bit is generated according to the bit pointer.
In one embodiment, before the host is also used to after having searched for all slaves, sends communications command to slave, to
Slave sends the Identity Code for needing matched slave;Slave is also used to the Identity Code by the Identity Code and the machine
It is matched, if it does not match, into sleep state, if it does, then into wait state.
A kind of monobus communication means provided by the present application and system, in search step, host is successively sent to slave
Reset signal search command;Read the present bit and its complement code of the Identity Code for the slave that slave returns;Host is according to slave
The present bit and its complement code of the Identity Code of return generate specific bit, and specific bit is sent to slave;Slave is determining
When the next bit of the present bit of its Identity Code is matched with specific bit, search process is continued to participate in, otherwise, into waiting shape
State;Host sends the next bit for reading slave Identity Code and its order of complement code to slave, until being only left only in slave
A one by one not enter wait state, host reads and records all positions of the Identity Code of the slave for not entering wait state
Value;It repeats the above steps, up to the Identity Code of all slaves under host record.The monobus communication means and system have
The advantage that communication efficiency is high, communication is accurate.
Detailed description of the invention
Fig. 1 is the operating process schematic diagram of ROM order in a kind of embodiment of the application;
Fig. 2 is the software flow pattern of base unit search step in monobus communication means in a kind of embodiment of the application;
Fig. 3 is the software flow pattern of base unit search step in monobus communication means in a kind of embodiment of the application;
Fig. 4 is the software flow pattern of base unit search step in monobus communication means in a kind of embodiment of the application.
The division name in Fig. 2-4 is explained below:
Cmp_id_bit --- id_bit complement code, this are the id_ of all response slave devices in search process
The logical AND result of bit_number complement codes.
Id_bit --- the value read for the first time in search in place, this is all response slave devices in search process
The logical AND result of id_bit_number complement codes.
Id_bit_number --- record current search is who amount in 1 to 64 ROM codes.
LastDeviceFlag --- what is once searched before indicating has been the flag bit of the last one slave device.
LastDiscrepancy --- bit pointer indicates search next time since which value difference dystopy.
LastFamilyDiscrepancy --- bit pointer, for indicating whether LastDiscrepancy is in ROM code
In in preceding 8 families code and its position.
Last_zero --- last time is written into the position of 0 value difference dystopy.
ROM_NO --- 8 byte buffers of the ROM registration code that record is currently being searched.
Search_direction --- bit variable, value are used to indicate the direction of search.With this data bit specified value
All slave devices proceed to respond to search operation, other slave devices are transferred to wait state until reset signal next time.
Specific embodiment
Monobus communication only has a data wire, device Host or slave to connect by an open-drain or tri-state port
To the data line, therefore equipment is allowed to discharge data/address bus when not sending data, so that bus is used by other equipment.It is single
The external pull-up resistor of bus request, in this way, monobus is high level in idle state.
In monobus communication system provided in this embodiment, level difference between communicating pair is simultaneously not fixed, or even much
More than single-chip microcontroller can tolerance range.In response to this, device will directly be burnt with conducting wire connection.Therefore, device it
Between increase capacitance, only relative level is allowed to pass through.
Typical monobus command sequence includes following three steps:
Step 1: initialization
Step 2: ROM order (with the data exchanged with the need)
Step 3: command function (with the data exchanged with the need)
Access single wire bus device every time, it is necessary to strictly observe this command sequence.If there is sequence confusion, then monobus
Device will not respond host.But this criterion appoints Search ROM order and alarm search command exception in executing the two
After what one order, host cannot execute command function thereafter, it is necessary to be back to the first step.
It is all to initialize and start based on all transmission processes on monobus, initialization procedure is answered by what host issued
The transponder pulse composition of digit pulse and slave response.Transponder pulse knows host, has slave devices in bus, and prepare just
Thread.
All single wire bus devices require to use stringent communication protocol, to guarantee the integrality of data.The protocol definition
Several signal types: reset pulse, transponder pulse write 0, write 1, reading 0 and read 1.All these signals, in addition to transponder pulse with
Outside, synchronization signal is all issued by host, and sending all order and data all is the low level of byte preceding.
Each single-chip microcontroller has the ID of unique 7 bytes, in order to more easily identify that equipment (is collecting cassette or SLB
Plate or handheld device), in the present embodiment, a byte is increased before distinct device to show its identity.ID code
Be it is read-only, there are in ROM, therefore may also be referred to as ROM code.Host scans for slave according to ID code.
After Host Detection to transponder pulse, so that it may issue ROM order.These orders are unique with each slave devices
64 ROM code correlations allow host when connecting multiple slave devices on monobus, specify and operate some slave devices.This
A little orders also allow host to be able to detect that how many slave devices and its device type in bus, or either with or without equipment
In alarm condition.For part slave devices, 5 kinds of ROM orders can be supported, the length of every kind of order is 8.Host exists
Before sending command function, it is necessary to send out suitable ROM order.The operating process of ROM order is as shown in Figure 1, below will be brief
The function of each ROM order is introduced on ground, and using under what circumstances.
In step 1.1, host sends reset signal (reset pulse) to slave.In the present embodiment, using between dipulse
Length of time as 1 and 0 and the differences of signals such as reset and made entirely logical by reasonably designing the length of each period
Letter is quickly, accurately.In the present embodiment, after host sends reset pulse, slave returns to transponder pulse.In certain embodiments, from
Machine can not also return to transponder pulse, and host is directly defaulted as slave and has received reset signal, and enters preparation state.
In step 1.2, host sends ROM order, and ROM order is including a variety of, below to read ROM order, matching ROM life
Enable, Search ROM order, the search command and jumping over of alarming are illustrated for ROM order, in other embodiments, according to host
The difference of device type, ROM order can also include other.
In step 1.3, host, which is sent, reads ROM order [33h].It reads ROM order and is appropriate only for single node, be only applicable to bus
The situation of only one upper slave devices.The slave allows host directly to read its 64 ROM codes, and need not execute search
ROM process.If the order is used for multi-node system, data collision necessarily occurs, because each slave devices can respond
The order.
In step 1.31, slave first sends the product code of a byte.
In step 1.32, slave retransmits the serial codes of 6 bytes.
In step 1.33, slave sends the CRC validation code of a byte.
By in step 1.31- step 1.33 as can be seen that the Identity Code of slave has 8 bytes in total, first
A byte is product code, and the 2-7 byte is serial codes, and the 8th byte is CRC validation code.
After step 1.33, step 1.8 can be gone to, host is to slave sending function order, to carry out data transmission.
In step 1.4, host sends matching ROM order (55h) to slave.When the slave that host needs to determine with some
When communication, it is necessary to slave is matched, preparation state is at, and other slaves then ignore next communication request.Matching
When, send the ID (Identity Code) of clump machine for needing to communicate first, after all slaves receive the ID that host is sent, by its with
The ID of oneself compares, and if they are the same, then brings himself into wait state, otherwise brings himself into sleep state, ignores host and connects down
The order come.Specific step is as follows:
In step 1.41, host sends the 0th of ID to be matched to slave.
In step 1.42, slave judges whether the 0th of ID to be matched match with the 0th of self ID, if mismatched,
Then enter sleep state, if it does, then returning to the signal for indicating successful match to host.
In step 1.43, host sends the 1st of ID to be matched to slave.
In step 1.44, slave judges whether the 1st of ID to be matched match with the 1st of self ID, if mismatched,
Then enter sleep state, if it does, then returning to the signal for indicating successful match to host.
The rest may be inferred, and one, host connects one data bit that ID to be matched is sent to slave, until all 64 data
Position matching finishes, that is, proceeds to step 1.45, host sends the 63rd of ID to be matched to slave.
In step 1.46, slave judges whether the 63rd of ID to be matched match with the 63rd of self ID, if not
Match, then enter sleep state, if it does, then returning to the signal for indicating successful match to host.At this point, the slave is host
The slave for needing to communicate.Next, going to step 1.8, host is to slave sending function order, to carry out data transmission.
In step 1.5, host sends Search ROM order (F0h) to slave.When system initial power-on, host must be looked for
Out in bus all slave devices ROM code (Identity Code), such host can judge the number and class of slave
Type.Host is all in bus to find out by repeating Search ROM circulation (Search ROM order is followed by a data exchange)
Slave devices.If only one slave devices of bus Search ROM order can be substituted using ROM order is read.Each
Having executed Search ROM circulation aft engine must be returned to the first step initialization of command sequence.Specific step is as follows:
In step 1.51, the present bit that host reads the Identity Code for the slave that slave returns (is the 0th in step 1.51
Position) and its complement code;Later, the present bit and its complement code for the Identity Code that host is returned according to slave generate specific bit, and will
Specific bit is sent to slave.
All slaves first in bus send first (least significant bit) in ID code simultaneously, with all monobus
Communication is the same, and either reading data still write data to slave device, all starts each bit manipulation by single bus master.According to
As a result the characteristic of monobus is equivalent to the logical AND for all sending data bit when all slave devices response host simultaneously
(AND);After slave sends first of its ROM code, the lower bit manipulation of host-initiated, then slave sends the benefit of a data
Code.
In step 1.52, slave when the next bit for the present bit for determining its Identity Code is matched with specific bit, after
It is continuous to participate in search process, otherwise, into wait state.
In step 1.53, host reads the 1st data and its complement code of the Identity Code for the slave that slave returns;It
Afterwards, host generates the 2nd specific bit, and specific bit is sent to slave.
In step 1.54, slave when the next bit for the present bit for determining its Identity Code is matched with specific bit, after
It is continuous to participate in search process, otherwise, into wait state.
The rest may be inferred, and slave one connects one data bit that ID is sent to host, until all 64 data bit are sent
It finishes, that is, proceeds to step 1.55, host reads the 63rd data and its complement code of the Identity Code for the slave that slave returns;
Later, host generates the 63rd specific bit, and specific bit is sent to slave.
In step 1.56, slave is said when the next bit for the present bit for determining its Identity Code is matched with specific bit
The bright slave is the slave that remaining only one does not enter wait state, and host reads and records the Identity Code of the slave
All place values.Later, initialization is re-started, operation is continued searching, up to the identity of all slaves under host record
Code.
In step 1.6, host sends alarm search command (ECh) to slave.Except those are provided with the slave of warning mark
Response is outer, and the working method of the order is fully equivalent to Search ROM order.The order allows host equipment to judge that those slaves are set
It is standby that alarm has occurred (such as nearest measurement is too high or too low for temperature).It is the same with Search ROM order to be followed in completion alarm search
Ring aft engine must be returned to the first step of command sequence.Specific step is as follows:
In step 1.61, the present bit that host reads the Identity Code for the slave that slave returns (is the 0th in step 1.61
Position) and its complement code;Later, the present bit and its complement code for the Identity Code that host is returned according to slave generate specific bit, and will
Specific bit is sent to slave.
In step 1.62, judge whether the next bit of the present bit of Identity Code is provided with the matched slave of specific bit
Warning mark, if so, then host continue read slave Identity Code next bit and its complement code, i.e., with step 1.53-
Step 1.56 is identical;Otherwise, it is back to the first step of command sequence.
In step 1.7, host jumps over ROM order (CCh) to slave transmission.It jumps over ROM order and is appropriate only for single node.It is main
Machine can access simultaneously all slave devices in bus using the order, and need not issue any ROM code information.For example,
Host is by after ROM order is jumped in sending, following inversion temperature order [44h], so that it may at the same it is all on command line
Slave starts inversion temperature, and the time of host is greatly saved in this way.It is worth noting that, if being followed after jumping over ROM order
Be to read buffer order [BEh] or other read operation orders, then the order can be only applied to single node system, otherwise will be by
The order is all responded in multiple nodes and causes data collision.
The application is described in further detail below by specific embodiment combination attached drawing.
A kind of monobus communication system, including a host and multiple slaves are present embodiments provided, host and slave are logical
Monobus is crossed to be connected.The monobus communication means that monobus communication system uses successively includes three steps: search, matching sum number
According to transmission.
(1) it searches for
In the present embodiment, searching algorithm is using binary tree structure, and search process is carried out along each partial node, until looking for
To the ID code of slave device, i.e., until leaf, subsequent search operation is carried out along other paths on node, according to same
Mode is until finding all slave device codes in bus.
Searching algorithm passes through reset (reset of Reset part) first, after being successfully executed the operation, starts to scan for grasping
Make.The search command (0xF0) of 1 byte is sent with all slave devices of the aft engine in bus, search command makes monobus
On slave device it is ready, start to scan for.
After search command issues, start actual search process.All slaves first in bus send ID code simultaneously
In first (least significant bit), communicated with all monobus, either reading data still write to slave device
Data, all by each bit manipulation of host-initiated.According to the characteristic that monobus communicates, when all slave devices while response host
When, it is as a result equivalent to the logical AND (AND) for all sending data bit, after slave sends first of its ROM code, under host-initiated
One bit manipulation, then slave sends the complement code of a data, can be done from the data bit read twice to first of ROM code
Several judgements out, referring to following table 1.
Table 1:
As it can be seen from table 1 if slave device in all buses has an identical value in present bit, only one
Individual path is optional.Not having the case where response device in bus is a kind of abnormality, it may be possible to which the slave device to be searched exists
It is detached from search process with bus.If present bit existing 0 also has 1, such case is known as place value difference, it is in subsequent searches
Device is searched in the process to play a crucial role.If searching algorithm specify the first round inquiry in there is difference, i.e., data bit/complement code=
When 0/0, then 0 path is selected.Certainly, in other embodiments, when data bit/complement code=0/0,1 path can also be selected, to choosing
It is determined with the selection in path by searching algorithm.Meanwhile the different position of last time value difference is recorded, for searching for use next time.
When table 2 lists occurrence difference, the selection situation in path.
Table 2:
According to the requirement of searching algorithm, host must the slave in bus send back to a specific bit.If slave device
The value of the next bit of the present bit of middle ID code is matched with the data bit (specific bit), then continues to participate in search process;If from machine
The next bit of the present bit of part mismatches therewith, then the device is transformed into wait state, and remains waiting for state until next
Monobus reset signal arrives.The search of remaining 63 ID code still carries out weight according to the mode of this " reading two, write one "
Multiple operation, goes on according to this searching algorithm, and finally other than a slave device, all slaves, which will enter, waits shape
State detects, so that it may obtain the ROM code of the slave device for not entering wait state retained to the end by last wheel.Subsequent
In search process, different path or branch are selected to search the ID code of other devices.It should be noted that in the present embodiment,
The 1st (least significant bit) to the 64th (most significant bit) expression of the data bit of ID code, rather than the commonly used 0th
Position is to the 63rd mode.Setting allows difference place value counter initial value being set to 0 in this way, provides for the comparison of subsequent step
Convenience.Table 3 is shown in the present embodiment, the search process of host and slave.
Table 3:
It should be noted that when host reads the 64th ROM code of slave, that is, having recorded the slave in table 3
ROM code does not need the 64th complement code for reading slave ROM code, does not need to retransmit specific bit yet, and is to revert to initial
Change step, continues searching other slaves.
The slave search mechanisms in monobus communication means provided in this embodiment are exemplified below.
ROM search process is a simple three steps cyclic program: reading one, the complement code for reading this, one phase of write-in
The data bit of prestige.Bus host all repeats such three step cyclic programs in each of ROM.When some slave device of completion
Afterwards, host just understand that the ROM information of the slave device.Remaining slave devices quantity and its ROM code pass through identical
Process can be obtained.
Following ROM search process example assumes that four different slave devices are connected in same bus, they
ROM code it is as follows:
Specific search process is as follows
1, host issues reset pulse, starts initialization sequence.Slave devices issue the transponder pulse of response.
2, then host issues ROM search command in bus.
3, host prepares to read in a data bit from bus, and at this moment each response apparatus is respectively by the first of ROM code
Position is output on monobus.ROM1 and ROM4 output 0 is to bus, and ROM2 and ROM3 output 1 is to bus.Output knot in bus
Fruit by be all slave devices logical AND, so what host read from bus will be 0.Then, host starts to read another one,
I.e. each slave device exports primary complement code in ROM code respectively.ROM1 and ROM4 output 1 at this time is to bus, and ROM2
With ROM3 output 0 to bus.Bit complement or 0 for reading of host in this way.Thus host determines some slave devices in bus
ROM code first be 0, some are then 1.
The data bit read twice has following meanings:
00: there are device conflicts at this
01: having slave device in this place is 0
10: having slave device in this place is 1
11: any slave devices are not present in monobus
4,0 (specific bit) is written in host, so that prohibiting ROM2 and ROM3 responds remaining search command, only in bus
Leave ROM1 and ROM4.
5, host executes read operation twice again, is subsequently received 0 and 1.This shows ROM1 and ROM4 in the second of ROM code
It is all 0.
6, then host write-in 0, continues to keep ROM1 and ROM4 in bus.
7, host executes read operation twice again and receives two 0, shows that the ROM code of connected equipment is existing in third position
0 also has 1.
8, host is written 0 again, so that prohibiting ROM1 responds remaining search command, only leaves in bus
ROM4。
9, host runs through the remaining ROM data position ROM4, and this completes first times to search for, and has found positioned at bus
On first equipment ROM4.
10, the 1st is repeated to step 7, starts the ROM search command of a new round.
11, host write-in 1 keeps ROM4 offline, and ROM1 is only left in bus.
12, host runs through the remaining ROM data of ROM1, and this completes secondary ROM search, has found second
ROM code.
13, the 1st is repeated to step 3, starts the ROM search command of a new round.
14, host write-in 1 specifically prohibits ROM1 and ROM4 and responds remaining search command, only leaves in bus
ROM2 and ROM3.
15, host executes read operation time slot twice again, reads two 0.
16, host write-in 0, prohibits ROM3 in this way and leaves ROM2.
17, host runs through the remaining ROM data of ROM2, and this completes the ROM of third time search, has found third
ROM code.
18, the 13rd is repeated to step 15, starts the ROM search command of a new round.
19, host write-in 1, specifically prohibits ROM2, and leaves ROM3.
20, host runs through the remaining ROM data of ROM3, and this completes the 4th ROM search, has found the 4th
ROM code.
It should be noted that Search ROM operation, host are only able to find the ROM generation of some monobus slave device every time
Code, required shortest time are as follows:
960u s+ (8+3*64) * 61u s=13.16ms
So host can read the ROM code of 75 slaves within 1 second.
Fig. 2-4 is please referred to, is the software flow pattern of base unit search step in the present embodiment monobus communication means.
Step 2.1: host, which executes, resets operation, reset signal is issued, to notify slave to prepare.
Step 2.2: the transponder pulse of Host Detection to slave illustrates to be connected with slave in bus.
Step 2.3: judging whether LastDeviceFlag is 1, does not go to step 2.4 for 1;It is primary before 1 explanation
The slave searched is the last one slave, executes step 2., carries out reset operation.
Step 2.4: id_bit_number value is set as 1, if last_zero value is 0.
Step 2.5: sending search command.
Step 2.6: reading id_bit the and cmp_id_bit value in bus.
Step 2.7: judging whether id_bit and cmp_id_bit is all 1.If so, thening follow the steps 2.;If it is not, then
Go to step 2.8.
Step 2.8: judging whether id_bit and cmp_id_bit is all 0.If it is, going to step 2.9;If not,
Then go to step 2.10.
The principle of step 2.7 and step 2.8 can refer to table 1.
Step 2.9: judging whether id_bit_number is equal with LastDiscrepancy.If it is, going to step
2.11;If it is not, then going to step 2.12.
Step 2.10: setting search_direction to the value of id_bit.After step 2.10, step 2.17 is gone to.
Step 2.11: setting search_direction data bit value as 1, i.e. 1 path of direction of search selection.
Step 2.12: judging whether id_bit_number is greater than LastDiscrepancy.If it is, going to step
2.13;If it is not, then going to step 2.14.
The principle of step 2.9 and step 2.12 can refer to table 2.
Step 2.13: setting search_direction data bit value as 0, i.e. 0 path of direction of search selection.
Step 2.14: the i-th d_bit_number in ROM_NO value is assigned to search_direction.
After step 2.11, step 2.13, step 2.14, step 2.15 is gone to.
Step 2.15: judging whether search_direction is equal to 0, if it is, going to step 2.16;If not,
Then go to step 2.17.
Step 2.16: the value of the current position id_bit_number being assigned to last_zero, goes to step 2.18 later.Step
Rapid 2.17: by search_direction the i-th d_bit_number be assigned in ROM_NO, and search is participated in in bus
Slave send the position, i.e., transmission specific bit.After step 2.17, step 2.20 is gone to.
Step 2.18: judging last_zero whether less than 9, if it is, going to step 2.19;If it is not, then going to step
Rapid 2.17.
Step 2.19: the value of last_zero being assigned to LastFamilyDiscrepancy, later, goes to step 2.17.
Step 2.20: being incremented by the value of id_bit_number.
Step 2.21: judging whether id_bit_number is greater than 64, if it is not, then returning to step 1., read slave
The next bit of ROM code;If it is, illustrating that host has read 64 ROM codes of current slave, step 2.22 is gone to.
Step 2.22: the value of last_zero being assigned to LastDiscrepancy, later, goes to step 2.23.
Step 2.23: judging whether LastDiscrepancy is 0, if it is, going to step 2.24;If it is not, then turning
3. to step.
Step 2.24: setting LastDeviceFlag is labeled as having found the last one slave.
Step 2.25: judge whether LastDiscrepancy is equal with LastFamilyDiscrepancy, if it is,
Go to step 2.26;If it is not, then going to step 2.27.
Step 2.26: setting LastFamilyDiscrepancy value as 0, later, go to step 2.27.
Step 2.27: judging whether CRC8 identifying code is correct in ROM_NO, if it is, going to step 2.28;If not,
Then go to step 2.29.
Step 2.28: setting TURE for return value, complete primary search.
Step 2.29: search process resets, and LastDiscrepancy=0, LastFamilyDiscrepancy=is arranged
0, LastDeviceFlag=0, later, go to step 2.30.
Step 2.30: setting FALSE for return value, this search terminates.
(2) it matches
Host sends the Identity Code for needing matched slave to slave, and slave is by the body of the Identity Code and the machine
Part identification code is matched, if it does not match, into sleep state, if it does, then into wait state.
(3) data transmission
Host sends communications command to slave, and slave enters preparation state according to communications command, and host is led to slave
Letter, i.e. progress data transmission.The data of slave receiving host in interruption, one reception flag position of juxtaposition, slave can basis
This flag bit is to determine whether there is communication.
It should be noted that communication is divided into broadcast and communicates two ways with specified clump machine.When broadcast, host sends communication
Order, all slaves receive after order all in preparation state, and respond next communication request, at this point, without carrying out
With step.And when being communicated with specified clump machine, it needs to match with the slave to be communicated, specified clump machine is allowed to be in preparation state, and its
His clump machine is in sleep state.
It will be understood by those skilled in the art that all or part of the steps of various methods can pass through in above embodiment
Program instructs related hardware to complete, which can be stored in a computer readable storage medium, storage medium can wrap
It includes: read-only memory, random access memory, disk or CD etc..
The foregoing is a further detailed description of the present application in conjunction with specific implementation manners, and it cannot be said that this Shen
Specific implementation please is only limited to these instructions.For those of ordinary skill in the art to which this application belongs, it is not taking off
Under the premise of from the present application design, a number of simple deductions or replacements can also be made.
Claims (4)
1. a kind of monobus communication means characterized by comprising
Search step comprising sub-step below:
Host sends reset signal to slave;The capacitance for only allowing relative level to pass through is provided between host and slave;
Using the length of time between dipulse as 1 and 0 and the difference of reset signal;
Host sends search command to slave;
Host reads the present bit and its complement code of the Identity Code for the slave that slave returns;The Identity Code of slave includes producing
Product code, serial codes and CRC validation code, product code, serial codes and CRC validation code are successively sent;
The present bit and its complement code of the Identity Code that host is returned according to slave generate specific bit, and by specific bit be sent to from
Machine;Wherein, the present bit and its complement code for the Identity Code that host is returned according to slave generate specific bit, specifically: when current
When position and its complement code are all " 1 ", host, which is judged as in bus, does not have slave response;It is main when present bit and its complement code are all " 0 "
Machine is judged as that the present bit of the Identity Code of slave includes " 0 " and " 1 ";When present bit and its complement code are respectively " 0 " and " 1 "
When, host is judged as that the present bit of the Identity Code of slave is " 0 ";When present bit and its complement code are respectively " 1 " and " 0 "
When, host is judged as that the present bit of the Identity Code of slave is " 1 ";Host determines binary search according to above-mentioned judging result
Bit pointer in tree algorithm, and specific bit is generated according to the bit pointer;
Slave continues to participate in search process when the next bit for the present bit for determining its Identity Code is matched with specific bit,
Otherwise, into wait state;The least significant bit of the data bit of the Identity Code indicates with the 1st, so that host
Difference place value counter initial value is set to 0;
Host sends the next bit for reading slave Identity Code and its order of complement code to slave, until being only left only in slave
A one by one not enter wait state, host reads and records all positions of the Identity Code of the slave for not entering wait state
Value enters next step after reading and recording most significant bit;
It repeats the above steps, up to the Identity Code of all slaves under host record;
Host sends the Identity Code for needing matched slave to slave, and slave is by the identity mark of the Identity Code and the machine
Know code to be matched, if it does not match, ignore the next order of host into sleep state, if it does, then into etc.
To state;In described search step, host is using binary search tree algorithm search to all slaves;
Data transmission step: host sends communications command to slave, and slave enters preparation state, host according to the communications command
It is communicated with slave.
2. monobus communication means as described in claim 1, which is characterized in that the Identity Code includes 8 bytes
Data, and the data of the 1st byte are used to indicate the device type of slave.
3. monobus communication means as described in claim 1, which is characterized in that host reads the identity for the slave that slave returns
In the present bit and its complement code of identification code, the data value that the present bit and its complement code are read from bus for host, the number
According to the result for the logical AND that value is the data value that all slaves are sent.
4. a kind of monobus communication system, including a host and multiple slaves, the host are connected with slave by monobus;
It is characterized by:
The host is used for using the slave in binary search tree algorithm search bus;Slave in the base unit search bus
When, host successively sends reset signal and search command to slave, and the Identity Code for reading the slave of slave return is worked as
Anteposition and its complement code, the present bit and its complement code of the Identity Code returned further according to slave generate specific bit, and by specific bit
It is sent to slave;The capacitance for only allowing relative level to pass through is provided between host and slave;Using between dipulse
Length of time is as 1 and 0 and the difference of reset signal;The Identity Code of slave includes that product code, serial codes and CRC are tested
Code is demonstrate,proved, product code, serial codes and CRC validation code are successively sent;Wherein, host is used for the Identity Code returned according to slave
Present bit and its complement code generate specific bit when: when present bit and its complement code are all " 1 ", host be judged as in bus not from
Machine response;When present bit and its complement code are all " 0 ", host be judged as the Identity Code of slave present bit include " 0 " and
"1";When present bit and its complement code are respectively " 0 " and " 1 ", host is judged as that the present bit of the Identity Code of slave is
"0";When present bit and its complement code are respectively " 1 " and " 0 ", host is judged as that the present bit of the Identity Code of slave is
"1";Host is used to determine the bit pointer in binary search tree algorithm according to above-mentioned judging result, and is generated according to the bit pointer
Specific bit;
The slave is used for when the next bit for the present bit for determining its Identity Code is matched with specific bit, is continued to participate in and is searched
Rope process, otherwise, into wait state;The least significant bit of the data bit of the Identity Code indicates with the 1st, so that
The difference place value counter initial value of host is set to 0;
The host is also used to send next bit and its order of complement code of reading slave Identity Code to slave, until slave
In only remaining only one do not enter wait state, host reads and records the identity of the slave for not entering wait state
All place values of code, up to the Identity Code of all slaves under host record, after reading and recording most significant bit, again
Search for the slave in bus;
Before the host is also used to after having searched for all slaves, sends communications command to slave, need to match to slave transmission
Slave Identity Code;Slave is also used to match the Identity Code with the Identity Code of the machine, if not
Matching then enters sleep state, ignores the next order of host, if it does, then into wait state;
The host is also used to after having searched for all slaves, is sent communications command to slave, is ordered in slave according to the communication
It enables after entering preparation state, is communicated with slave.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510323725.9A CN104932997B (en) | 2015-06-12 | 2015-06-12 | A kind of monobus communication means and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510323725.9A CN104932997B (en) | 2015-06-12 | 2015-06-12 | A kind of monobus communication means and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104932997A CN104932997A (en) | 2015-09-23 |
CN104932997B true CN104932997B (en) | 2018-12-14 |
Family
ID=54120168
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510323725.9A Active CN104932997B (en) | 2015-06-12 | 2015-06-12 | A kind of monobus communication means and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104932997B (en) |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105354163A (en) * | 2015-11-17 | 2016-02-24 | 江苏工程职业技术学院 | Method for achieving plug and play of single bus equipment |
CN106528478B (en) * | 2016-12-06 | 2019-04-30 | 天津北芯微科技有限公司 | A kind of monobus asynchronous serial communication system and its communication means |
CN107009901A (en) * | 2017-03-31 | 2017-08-04 | 武汉理工大学 | A kind of SCM Based electric automobile combination electronic instrument |
CN107332746B (en) * | 2017-06-02 | 2019-12-06 | 上海申矽凌微电子科技有限公司 | single bus system based on data transmission protocol |
CN108536085A (en) * | 2018-04-23 | 2018-09-14 | 北京和利时智能技术有限公司 | A kind of monobus means of communication and system |
CN109992534B (en) * | 2019-03-22 | 2020-10-20 | 华北电力大学 | Method and system for rapidly searching serial number of single-wire device on line |
CN113515467A (en) * | 2021-01-14 | 2021-10-19 | 青岛鼎信通讯股份有限公司 | Single-bus ROM address search algorithm for platform area intelligent fusion terminal |
CN114448943B (en) * | 2021-12-28 | 2024-01-19 | 汉威科技集团股份有限公司 | Device physical address quick retrieval method based on universal address bus |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102088383A (en) * | 2010-11-23 | 2011-06-08 | 深圳市豪恩安全科技有限公司 | Online slave query and response method and device, bus system |
CN104657303A (en) * | 2014-10-13 | 2015-05-27 | 江苏瑞微电子有限公司 | Unibus data communication method |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN202711246U (en) * | 2012-07-31 | 2013-01-30 | 深圳市赛格导航科技股份有限公司 | Application expanding system with 485 buses and 232 buses |
-
2015
- 2015-06-12 CN CN201510323725.9A patent/CN104932997B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102088383A (en) * | 2010-11-23 | 2011-06-08 | 深圳市豪恩安全科技有限公司 | Online slave query and response method and device, bus system |
CN104657303A (en) * | 2014-10-13 | 2015-05-27 | 江苏瑞微电子有限公司 | Unibus data communication method |
Non-Patent Citations (3)
Title |
---|
一线总线结构的DS18B20的序列号搜索算法研究;刘晓阳等;《计算技术与自动化》;20100315;第39页,附图1 * |
二叉树算法在DS18B20地址搜索中的运用;盛磊等;《计算机系统应用》;20100215;第19卷(第2期);第143-146页 * |
实现单总线搜索ROM命令的一种算法;左冬红等;《电子技术》;20011012(第10期);第625-627页,附图1-3 * |
Also Published As
Publication number | Publication date |
---|---|
CN104932997A (en) | 2015-09-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104932997B (en) | A kind of monobus communication means and system | |
TWI481245B (en) | Address setting method for slave devices of communication network | |
US6665742B2 (en) | System for reconfiguring a first device and/or a second device to use a maximum compatible communication parameters based on transmitting a communication to the first and second devices of a point-to-point link | |
US7020076B1 (en) | Fault-tolerant communication channel structures | |
US6233635B1 (en) | Diagnostic/control system using a multi-level I2C bus | |
US5629685A (en) | Segmentable addressable modular communication network hubs | |
US6760838B2 (en) | System and method of initializing and determining a bootstrap processor [BSP] in a fabric of a distributed multiprocessor computing system | |
JP4086472B2 (en) | Method, system, and program for determining system configuration | |
JPS61225946A (en) | Diagnosis of second node from first node in local area network | |
CN115587065A (en) | Master-slave machine control method, master-slave machine control system and blood cabinet | |
CN108287800B (en) | A kind of bus arbitration system and method based on single bus communication protocol | |
EP0435037B1 (en) | Master slave industrial token passing network | |
CN105320624B (en) | The electronic device controlled using data I/O management | |
CN110532211A (en) | Bus system | |
US7602736B2 (en) | Method for testing a network, and corresponding network | |
US5680113A (en) | Dynamic address assignments to serially connected devices | |
US20040225813A1 (en) | Method and apparatus for configuring multiple segment wired-and bus systems | |
US6449289B1 (en) | Multi-processor bus protocol system | |
CN105912492A (en) | Extension method of AXI interconnected bus | |
WO2014012203A1 (en) | Method, device and system for determining drive letter | |
TW201413457A (en) | Assigning addresses to devices on an interconnect | |
CN116303207A (en) | Bus transmission method, device, equipment and storage medium | |
CN117111539B (en) | Control method and device for Ethernet physical layer chip | |
CN112699695B (en) | RFID reader-writer software verification device and method and electronic equipment | |
CN103488505B (en) | Patch method, equipment and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20220304 Address after: 1303, yuemeite building, No. 1, Gaoxin South seventh Road, high tech Zone community, Yuehai street, Nanshan District, Shenzhen, Guangdong 518000 Patentee after: Shenzhen Baite Rui Intelligent Control Technology Co.,Ltd. Address before: 518055 2 building, A3 tower, Nanshan Zhiyuan, 1001 Nanshan District Xue Yuan Avenue, Shenzhen, Guangdong. Patentee before: BSB POWER Co.,Ltd. |