CN107229586B - Communication means based on RS485 bridge circuit device - Google Patents
Communication means based on RS485 bridge circuit device Download PDFInfo
- Publication number
- CN107229586B CN107229586B CN201710432863.XA CN201710432863A CN107229586B CN 107229586 B CN107229586 B CN 107229586B CN 201710432863 A CN201710432863 A CN 201710432863A CN 107229586 B CN107229586 B CN 107229586B
- Authority
- CN
- China
- Prior art keywords
- bridge circuit
- circuit device
- data packet
- port
- data
- 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
- 238000004891 communication Methods 0.000 title claims abstract description 48
- 238000000034 method Methods 0.000 claims abstract description 20
- 230000004044 response Effects 0.000 claims description 29
- 230000003993 interaction Effects 0.000 claims description 8
- 230000005611 electricity Effects 0.000 claims description 6
- 230000000295 complement effect Effects 0.000 claims description 2
- 238000012545 processing Methods 0.000 claims description 2
- 230000005540 biological transmission Effects 0.000 description 5
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 2
- 241001269238 Data Species 0.000 description 1
- 208000033748 Device issues Diseases 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 239000011248 coating agent Substances 0.000 description 1
- 238000000576 coating method Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 238000012856 packing Methods 0.000 description 1
- 235000020004 porter Nutrition 0.000 description 1
- 238000012805 post-processing Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 230000017702 response to host Effects 0.000 description 1
- 230000011664 signaling Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
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/42—Bus transfer protocol, e.g. handshake; Synchronisation
-
- 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/382—Information transfer, e.g. on bus using universal interface adapter
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Small-Scale Networks (AREA)
Abstract
Disclose a kind of communication means based on RS485 bridge circuit device, comprising: when bridge circuit device initially receives data packet from bus, judge whether data packet is the data packet for carrying the command code of automatic distribution address;If not being, bridge circuit device by since the data packet that its port P receives by the N-port for being first forwarded to it of unit information length for delivery to next bridge circuit device;When bridge circuit device receives the end mark in data packet from its port P, parsing received the communication data packets UID and command code that are parsed;By the UID of parsing compared with the UID of the bridge circuit device, such as the two is identical, then the bridge circuit device executes order representated by the command code in the data packet to carry out the communication with host;As not identical, ignore the order.The method provides the new traffic mode based on RS485 bridge circuit device, can be excessive to avoid junk information, can also the newly-increased bridge circuit device of automatic identification and distribution address automatically again.
Description
Technical field
The present invention relates to serial communication technology, in particular to a kind of communication means based on RS485 bridge circuit device.
Background technique
RS485 is two-wire system, half-duplex, differential signal communication interface (physical layer).Referring to Fig. 1, traditional RS485 bus permits
Perhaps multiple equipment is connected in same bus, these equipment are communicated usually using ModBus protocol format, and each equipment is preparatory
One 485ID is set.Host, with the equipment interaction in bus, distinguishes each equipment by 485ID by the way of poll.Host
All devices will receive when sending request, but that equipment response that only 485ID matches, and 485 buses are half-duplexs
, the same time can only have a data sender.The all the sensors of traditional RS485 bus connect in a data wire, line
Longer, signal decaying is more serious, and it is easier by outside electromagnetic interference to communicate.
In addition, there is also following disadvantages according to traditional RS485 bussing technique: junk information on broadcast type communication bus
Excessively, the sensor that is crashing because of busy can often be encountered;When encountering the sensor for distributing data arbituarily because of failure, drag
Tire out whole bus and is unable to normal communication;Safeguard that the ID of each sensor is not easy to, especially after increase new sensor when
It waits;The number amount and type (namely plug and play) of sensor in " automatic identification " bus difficult to realize.
Therefore, existing in the prior art can use new communication mode to eliminate the prior art one kind based on RS485
The needs of the communication means of existing defect.
Summary of the invention
In view of this, the present invention provides a kind of communication means based on RS485 bridge circuit device, the prior art can be overcome
There are the problem of.
Technical solution of the present invention is specifically achieved in that
A kind of communication means based on RS485 bridge circuit device, wherein m bridge circuit device is connected by RS485 bus
Together and it is connected to host, a bridge circuit device includes processor;As the first RS485 serial ports of the port P, for passing through
Bus connects a upper bridge circuit device;As the 2nd RS485 serial ports of N-port, for connecting next bridge electricity by bus
Road device;And the third serial ports of the port L as bridge circuit device, it is used for the matched sensor of connection type, the processing
Device and the first RS485 serial ports, the 2nd RS485 serial ports and third serial ports carry out signal interaction, this method comprises:
When bridge circuit device initially receives data packet from bus, judge whether the order first symbol in data packet shows
Data packet is to carry the data packet of the command code of automatic distribution address;
If it is determined that data packet is not to carry the data packet of the command code of automatic distribution address, bridge circuit device will be from it
The port P receive the data packet when immediately begin to the N-port for being first forwarded to it by unit information length for delivery under
One bridge circuit device;
When bridge circuit device receives the end mark in data packet from its port P, the received communication data packets of parsing institute
With the UID and command code parsed;By the UID of parsing compared with the UID of the bridge circuit device, the UID and this that such as parse
The UID of bridge circuit device is identical, then the bridge circuit device executes order representated by the command code in the data packet to carry out
With the communication of host;As not identical, ignore the order;
Wherein, the data packet is to be sent from host in RS485 bus, the format of the data packet are as follows: successively sequentially
The order first symbol of arrangement, the UID of bridge circuit device, command code, first content and end mark;Wherein, order first symbol and
For data between end mark by transcoding, the highest order of order first symbol is " 1 ", other for indicating the beginning of a data packet
Byte is all the byte started with " 0 ";The transcoding is that be converted to the data of 8 bit, one byte with 7 bits be a byte
Data.
Preferably, the method further comprises the steps of:
If it is determined that data packet is to carry the data packet of the command code of automatic distribution address, bridge circuit device is to the bridge
The party awarding the contract that circuit device sends data packet sends response message to notify the party awarding the contract to have been received by the data packet;Wherein, give out a contract for a project
Side is a device before the bridge circuit device, nearest, as host and a upper bridge circuit adjacent thereto dress
One of set;
UID value in the data packet received is added the UID value in " 1 " updated data package by the bridge circuit device, then will
The data packet is sent to next bridge circuit device adjacent thereto, and using updated UID value as its address;
The bridge circuit device such as receives the response data packet that next bridge circuit device adjacent thereto is sent, then will
The response data packet is transmitted to the party awarding the contract adjacent thereto;
If bridge circuit device is not received by response message, then response data packet is sent to the party awarding the contract adjacent thereto, it should
The UID value of the bridge circuit device is carried in response data packet.
Wherein, the UID such as parsing is identical as the UID of the bridge circuit device, then the bridge circuit device executes in the data packet
Command code representated by order include:
If the order is the automatic reading sensing data instruction for the bridge circuit device, bridge circuit device note
Firmly the automatic reading sensing data instructs and automatically repeats to send to the sensor connecting with the bridge circuit device, with automatic
From sensor access evidence, and will be saved after the data of reading progress transcoding.
Wherein, the UID such as parsing is identical as the UID of the bridge circuit device, then the bridge circuit device executes in the data packet
Command code representated by order include:
Such as order is the unlatching direct channel instruction for the bridge circuit device, then the bridge circuit device opens its L
Its N-port and is closed to the two-way converting channel of the port P in port;
Bridge circuit device will be sent to its sensor after data packet inversion code that host is sent, and will be from its sensing
Host is transmitted to after the data of device progress transcoding.
Further, the method includes:
After the bridge circuit device is completed the data forwarding from its sensor to host, if received to come independently
The data packet of machine and from resolve packet go out be different from open direct channel instruct instruction when, which closes its
And its N-port is opened to the two-way converting channel of the port P in the port L.
Further, the method includes:
If the bridge circuit device receives the signal of request deallocation from its N-port, by the request
The signal of deallocation is forwarded to its party awarding the contract;
Wherein, it if the bridge circuit device has maximum address value, is in the N-port of the bridge circuit device and reads shape
State.
Preferably, the bridge circuit device is in P and N-port bi-directional data forwarding state when powering on.
Wherein, the unit information length is 1 byte or 1 bit.
In addition, the method further include:
Using command determination representated by command code, whether it is in idle condition the bridge circuit device;
If so, the bridge circuit device sends communication request to the bridge circuit device with the address greater than it to carry out
Communication.
Wherein, the response data packet has format identical with the data packet, the order in the response data packet
Code is the radix-minus-one complement of the command code numerical value in responded data packet.
As above as it can be seen that the communication means based on RS485 bridge circuit device in the present invention, providing, which can be used for, is based on
The new traffic mode of RS485 bridge circuit device.Since sensor is not directly coupled in bus, but filled by bridge circuit
It sets and is connected in bus, therefore it is excessive to can be avoided junk information in the prior art;In addition, each bridge circuit device with
The communication of host is all relatively independent, and since bridge circuit device is by the way of " first forwarding post-processing ", even if a certain
The sensor of a bridge circuit device connection is problematic, nor affects on the operation of bus;Moreover, after new bridge circuit device increase,
Host can distribute automatically address with automatic identification and again.
Detailed description of the invention
Fig. 1 is the conventional bus circuit diagram in the prior art based on RS485.
Fig. 2 is the composition schematic diagram of the bridge circuit device based on RS485 in the embodiment of the present invention.
Fig. 3 is the bus circuit schematic diagram of the bridge circuit device based on RS485 in the embodiment of the present invention.
Fig. 4 is the flow chart of the communication means based on RS485 bridge circuit device in the embodiment of the present invention.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention more comprehensible, right hereinafter, referring to the drawings and the embodiments,
The present invention is further described.
In the present invention, bridge circuit device based on RS485 tool is there are three port, the respectively port L, the port P and N-port, P
Port and N-port are respectively used to connect one and next bridge circuit device, and the port L is for being connected to sensor.It is based on
The bridge circuit device of RS485 is directly connected in RS485 bus.In this way, sensor is no longer directly connected in RS485 bus,
Host is no longer directly interacted with sensor, but is interacted using 485 bus protocols with bridge circuit device.Bridge circuit device and and its
The sensor of connection is properly termed as a node in RS485 bus.Between every two bridge circuit device in RS485 bus all
It is one section of independent data line, that section of line i.e. port L for being based even on the bridge circuit device connection sensor of RS485 is also one section
Independent data line, the bridge circuit device based on RS485 transmit data among the nodes by way of relay.As it can be seen that using
The present invention, the data line length between node shortens, therefore signal declines and reduces, the signal anti-interference ability on signal wire
It mutually strains strong.
In the present invention, the bridge circuit device based on RS485 in bus is data porter i.e. data transfer equipment,
RS485 bus be also using RS485 physical interface, but do not use ModBus agreement, but use custom protocol.Customized association
View is not required in the present invention, and the utility model can also use other agreements by those skilled in the art, therefore
The introduction to custom protocol is omitted here.Bridge circuit device is bridge of the host with sensor communication, it is host and sensing
Device provides the communication line of a difference and tradition RS485 bus.Only bridge circuit of the connection based on RS485 fills in RS485 bus
It sets, is directly connected to sensor unlike traditional RS485 bus.When using RS485 bus, host is no longer directly handed over sensor
Mutually, but use RS485 bridge agreement with the interaction of bridge circuit device.Bridge agreement provides order for host for the " sensor after packing
Instruction " is transmitted to sensor to realize interaction of the host with sensor.
It describes in detail below with reference to Fig. 2 and Fig. 3 to the bridge circuit device of the invention based on RS485.
The composition schematic diagram of Fig. 2 shows the according to an embodiment of the present invention bridge circuit device based on RS485.Bridge circuit dress
It sets including processor, the first RS485 serial ports and the 2nd RS485 serial ports.First RS485 serial ports is used to connect upper one by bus
2nd RS485 serial ports of bridge circuit device, the 2nd RS485 serial ports are used to connect the first of next bridge circuit device by bus
RS485 serial ports.The bridge circuit device further comprises the third serial ports of the port L as bridge circuit device, more for providing
The interface of seed type is for the matched sensor of connection type.
In the present invention, P port of the first RS485 serial ports as bridge circuit device, for connecting a upper bridge by bus
Circuit device;N-port of the 2nd RS485 serial ports as bridge circuit device, for connecting next bridge circuit device by bus.
The processor and the first RS485 serial ports, the 2nd RS485 serial ports and third serial ports carry out signal interaction.Wherein, the third string
Mouth is the set serial ports of RS485, RS422 and RS232 serial ports, for connecting the sensor based on RS485 work, is based on RS422
The sensor of work and the sensor to be worked based on RS232.Preferably, the bridge circuit device further comprises auxiliary serial ports,
For connecting the sensor of desired type.Preferably, the processor is C51 chip, the first RS485 serial ports and second
RS485 serial ports is RJ45 interface.According to an embodiment of the invention, the first RS485 serial ports, the 2nd RS485 serial ports and third serial ports
Be it is independent of each other, data communication can be carried out simultaneously independently of one another.Preferably, bridge circuit device further includes being located at the port L
Dry node port, for connecting dry node.
In the embodiment of the present invention, although the interface based on RS485 is half duplex communication, the bridge electricity based on RS485
Three interfaces inside the device of road be it is independent, they can carry out data communication simultaneously, that is to say, that bridge circuit device is by P
When the data forwarding of port is to N-port, the sensor that still can be connected with the port L be communicated.This working method is than half
Traditional RS485 bus of duplex signaling is more efficient.
Traditional RS485 bus can only connect the sensor of RS485 interface, and be typically only capable to be led to Modbus agreement
News.And in the present invention, the port L of the bridge circuit device based on RS485 can support a plurality of types of sensors, these sensors
Agreement can be arbitrary.Alternatively, the port L also can be configured to only connect a type of sensor.In RS485 bridge
In bus, between host and these dissimilar sensors communication will not generate it is any conflict because practical directly with sensor
The bridge circuit device of communication is only limitted to that RS485 bridge circuit device that it is connected.
Fig. 3 shows the bus circuit schematic diagram of the bridge circuit device according to an embodiment of the present invention based on RS485.Such as figure
Shown in 4, the bus circuit based on RS485 includes the m nodes and host being connected in series in RS485 bus, and m is positive integer.
Each node is foregoing bridge circuit device, and the port P of first node is connect with the host, m-th of node
The port L it is hanging, the port P of i-th of node is connected to the port L of (i-1)-th node, i 2,3,4 ..., m-1.K-th of section
Data line between point and -1 node of kth is independent data line segment, k 2,3,4 ..., m.Preferably, the port P of node, L
Each of port and N-port port are configured with 4 lines, wherein 2 lines are signal wire, in addition 2 one, line is ground wire, and one
Root is 5V power supply line.Preferably, the host carries out data interaction by bridge circuit device and sensor.Preferably, in host
Data interaction is carried out by bridge circuit device and sensor, the bridge circuit device can also be logical with bridge circuit device thereafter
Letter.
It is all a Duan Duli between every two bridge circuit device, that is, node in the bus circuit based on RS485 referring to Fig. 3
Data line, that section of line for being based even on the i.e. port the L connection sensor of the bridge circuit device of RS485 is also one section of independent data
Line, bridge circuit device transmit data among the nodes by way of relay.Clearly as the data line length between node becomes
It is short, thus signal decaying becomes smaller, anti-interference ability also just becomes strong.
According to an embodiment of the invention, the data packet basic format that host is sent to bridge circuit device is as follows:
[order first symbol]+[bridge module UID]+[command code]+[content]+[end mark]
Data between bridge protocol requirement [order first symbol] and [end mark] will carry out transcoding, in order to avoid go out in these data
Now with the character of first symbol, end mark conflict.In the present invention, transcoding rule is that 8bit turns 7bit, and each byte of computer is by 8
Bit composition, transcoding is to reorganize one group of byte with every 7 bits, then forms one group of new data, new data
Each byte only uses low 7, highest order always 0 (highest order be 1 be bridge agreement Special controlling symbol, such as order first symbol
And end mark), the data byte after transcoding can be more than former data byte, but can guarantee accord with the Special controlling of bridge agreement
Conflict.
It may include two parts of [content] data in the data packet that bridge circuit device is responded.Because RS485 communication is half pair
Work, question-response formula, in order to avoid conflict, bridge circuit device actively cannot send data packet to host.Sometimes bridge electricity
Road device is needed to host report some events, such as a bridge circuit device has newly been accessed in bus, this event can be in master
When machine issues order and awaits a response, event is placed in the 2nd part of [content] data and reports to host by bridge circuit device.
Main RS485 bridge communication command code and function in the present invention is described below.
Host communicates by the way that UID is specified with some bridge circuit device, and each bridge circuit device has one to distribute automatically
UID.In the present invention, [command code] is individual character section value, and the parameter of needs is ordered to be placed in [content] field.Bridge circuit device
The data packet of response, [command code] are the radix-minus-one complements for responding the command code numerical value of order.
Main RS485 bridge communication command and function are as follows:
1, the bridge circuit device in bus is required to distribute address (i.e. UID) automatically.
2, the hardware information (information such as version number, type, date of production) of " specified bridge circuit device " is taken.
3, the data carried in " specified bridge circuit device " original sample commands in return are required, measurement circuit communication quality is used for.
4, the IO input state (such as dry node input state) of all bridge circuit devices of bus is obtained with an order.
5, the input state (such as dry node input state) of the assigned I/O of " specified bridge circuit device " is taken.
6, sensors command is told to " specified bridge circuit device ".Bridge circuit device is remembered to instruct and automatically be repeated to biography
Sensor sends these instructions, realizes and fetches automatically from sensor.The order is suitble to changeless sensors command.
7, the sensor reply data that " specified bridge circuit device " receives is read.Bridge circuit device is got from sensor automatically
After data, first data are stored in the memory field of oneself, can save how many historical datas will see the size of single data.It is main
Machine sends the order and reads these sensor historic data from bridge circuit device.This article of order keeps up with one article of order i.e. the life
Order is pairs of.
8, " specified bridge circuit device " is required to open host to the Direct Communication channel of sensor.Some sensor communications need
It repeatedly to interact, or, sensing data amount is too big, and bridge circuit device can not execute automatic access to such sensor.It is main
Machine can establish Direct Communication channel with sensor with this order, and bridge circuit device is responsible for two-way between host and sensor
Data forwarding.
9, bridge circuit device internal event notifies, some events being mainly used between bridge circuit device is linked up.
Referring to fig. 4, the flow chart of the communication means based on RS485 bridge circuit device in the embodiment of the present invention is shown.
In step 10, host sends data packet in bus, and the bridge circuit device in bus starts received data packet.In the present invention, always
When any one bridge circuit device on line initially receives data packet, first judge order first symbol in data packet whether table
Bright data packet is to carry the data packet of the command code of automatic distribution address.According to an embodiment of the invention, the data packet is
It is sent from host in RS485 bus, the format of the data packet are as follows: successively the order first symbol of arranged in sequence, bridge circuit dress
UID, command code, first content and the end mark set;Wherein, the data between order first symbol and end mark are by transcoding, life
The highest order for enabling first symbol is " 1 ", and for indicating the beginning of a data packet, other bytes are all the bytes started with " 0 ";Institute
State transcoding be the data of 8 bit, one byte are converted to be with 7 bits a byte data.Preferably, the embodiment of the present invention
Be with the value of order first symbol come judge command code that the data packet is included whether be automatic distribution address order, and
The value expression of byte where order first symbol is what type of command code.
If it is determined that data packet is not to carry the data packet of the command code of automatic distribution address, bridge circuit device will be from it
The port P receive the data packet when immediately begin to the N-port for being first forwarded to it by unit information length for delivery under
One bridge circuit device, step 20.Data forwarding between P and N-port can " byte is unit " or " bit is unit " into
Row.In the present invention, unit information length is 1 byte or 1 bit.In the embodiment of the present invention, RS485 is based on when most of
Bridge circuit device be in P and N-port bi-directional data forwarding state (this state is entered after in general powering on), the port P
The data received can be forwarded to N-port, and vice versa.The port L be it is closed, data do not issue sensor, will not be sensing
In the data forwarding to 485 buses that device issues, i.e., it will not be dealt into the port P and N-port.
When forwarding data as unit of byte, one about 1 byte time of bridge module needs delay of the every process of data (such as
The communication of 9600 baud rates is per second to transmit 960 bytes, and 1 byte time is 1/960 second).When forwarding data as unit of bit,
Data are every by bridge module to be needed to postpone about 1 bit time (such as the time of the every transmission 1 of 9600 baud rates is 1/
9600 seconds).
In step 30, when bridge circuit device receives the end mark in data packet from its port P, parsing institute is received logical
Interrogate UID and command code of the data packet to be parsed.Next, bridge circuit device is by the UID of parsing and the bridge circuit device
UID compare, such as parsing UID it is identical as the UID of the bridge circuit device, then the bridge circuit device executes the life in the data packet
Order representated by code is enabled to carry out the communication with host;As not identical, ignore the order, step 40.
The order that host issues always needs some bridge circuit device in RS485 bus to respond, to reduce data
Passing time, bridge circuit device, which is taken, first forwards the mode executed afterwards to handle command request.The order that host issues is by multiple words
Section composition, always the sequential delivery of one byte of a byte, bridge electric installation (receive 1 byte after receiving data on the data line
Or 1 bit) it is directly passed to next bridge circuit device.When Host Command is transmitted, that is, bridge circuit device is received
When to order end mark, all bridge circuit devices in bus all have received the copy of the order.Then, all bridge circuit devices
All start solution and write this order, only UID can execute this order, other bridge circuits with oneself that matched bridge circuit device
Device then ignores this order.
In the embodiment of the present invention, the UID of such as parsing is identical as the UID of the bridge circuit device, and bridge circuit device will judge
Order representated by command code in data packet, and execute corresponding order.If the order is for the bridge circuit device
The instruction of automatic reading sensing data, then the bridge circuit device remembers that the automatic reading sensing data is instructed and automatically weighed
It is multiple to be sent to sensor connect with the bridge circuit device, to fetch evidence from the sensor automatically, and by the progress of the data of reading
It is saved after transcoding.
Such as order is the unlatching direct channel instruction for the bridge circuit device, then the bridge circuit device opens its L
Its N-port and is closed to the two-way converting channel of the port P in port;The data packet that bridge circuit device sends host inverts
It is sent to its sensor after code, and host will be transmitted to after the data that its sensor carries out transcoding.Bridge circuit device
After completing the data forwarding from its sensor to host, if receiving the data packet from host and from data packet solution
When the instruction for being different from opening direct channel instruction is precipitated, which closes its port L to the two-way converting of the port P
Channel, and open its N-port.
The most sensors for being connected to bridge circuit device are fetched using fixed instruction, such as temperature sensor, to
Sensor sends fixed instruction to obtain current temperature data.Bridge circuit device can automatically fetch to such sensor, main
Machine tells temperature sensor load instruction to bridge circuit device, such as temperature sensor by RS485 bus and bridge circuit device
Load instruction is packaged into data packet back warp bus and sends.Receive the data packet comprising temperature sensor load instruction
Afterwards, bridge circuit device can obtain temperature data automatically, and can save historical data for several times recently.Bridge circuit dress
The data that does not need to understand and obtain from sensor are set, it is only stored data into memory, when host asks for these to it
Again response to host when data.This access mode does not need to establish a host to the immediate data transmission channel of sensor.
Some sensors cannot be fetched automatically by bridge circuit device, for example sensor load instruction is not fixed and invariable,
Or sensors command data volume is excessive, has exceeded the caching capabilities of bridge circuit device.With this sensor communication, need to allow
Bridge circuit device establishes a host to the Direct Communication channel of sensor.
For example, with reference to Fig. 3, host sends to RS485 bus and orders, it is desirable that node 3 establishes a host to sensor
The direct bi-directional data forwarding for opening host and its connect sensor (is to open node 3 in fact by direct data channel, node 3
Data forwarding between left side serial ports and the port L), node 3 will not forward subsequent data (namely to stop to the serial ports on the right of it again
Only continue to forward data backward) because the bridge circuit device that host is transmitted to back with the data communication of sensor is that do not have
Meaning.Node 1 and 2 is still within the bi-directional data forwarding state of the left side and the right serial ports, because of the data of host and node 3
Them are needed to forward.
After establishing host to the direct data channel of sensor, transmission of the data in RS485 bus is still with data
Packet format is packaged and carries out the Data Format Transform of 8bit to 7bit.What sensor actually received is unpacked by bridge circuit device
Raw sensor instruction.Complete sensor access after, host does not need this direct channel of explicit closing, as long as host to
Other bridge circuit devices in RS485 bus send order, this direct channel can be automatically closed in node 3.
If it is determined that data packet is to carry the data packet of the command code of automatic distribution address, bridge circuit device is to the bridge
The party awarding the contract that circuit device sends data packet sends response message to notify the party awarding the contract to have been received by the data packet, step 50.Its
In, the party awarding the contract is before the bridge circuit device a, nearest device, as host and a upper bridge electricity adjacent thereto
One of road device.
Next, the UID value in the data packet received is added the UID value in " 1 " updated data package by bridge circuit device, then
Send the packet to next bridge circuit device adjacent thereto, and using updated UID value as its address, step
60。
According to an embodiment of the invention, bridge circuit device UID is used to the node in unique identification bus, UID is automatic point
Match.When host, which sends " distributing address automatically " to bus, orders, the numerical value initial value in data packet is 0, nearest from host
Bridge circuit device receive data packet after ,+1 will be worth, this value is the UID of the bridge circuit device and it is suitable in bus
Serial number.Data packet after+1 is sent to next bridge circuit device by bridge circuit device, and so on, until last in bus
One bridge circuit device.At this point, all bridge circuit devices of bus are all assigned with UID, bridge circuit device it is also known that oneself
Position in bus.For bridge circuit device, that serial ports for receiving order is exactly the port P (the upper module of connection),
In addition the serial ports on one side is N-port (connecting next module).
Next, bridge circuit device judges whether to receive the number of responses that next bridge circuit device adjacent thereto is sent
According to packet.It, will if the bridge circuit device receives the response data packet that next bridge circuit device adjacent thereto is sent
The response data packet is transmitted to the party awarding the contract adjacent thereto, step 70;If bridge circuit device is not received by response message, then to
The party awarding the contract adjacent thereto sends response data packet, and the UID value of the bridge circuit device, step are carried in the response data packet
80.Specifically, after bridge circuit device receives " distributing address automatically " order, a node is first responded, it is told to receive this
Item order, the data that then forwarding back bridge circuit device is responded further along, end bridge circuit device are easy to after judging it
While there is no node, because responding " receiving " to it without bridge circuit device.End bridge circuit device, which is responsible for sending to host, orders
The response packet of order, the content of packet include the UID of own, this UID is also equal to the quantity of node in bus.Respond coating transmitting
After returning host, all bridge circuit devices both know about the quantity of bus node on host and bus.Bridge circuit device knows bus
Upper number of nodes is beneficial, such as host, to when the node being not present a transmission request, this request reaches first bridge
Circuit device is just intercepted, and then bridge circuit device reports mistake to host response data.Bridge circuit device is actively to master
Machine report mistake can be reduced the unnecessary waiting time because under normal conditions, host need to be arranged a comparison exaggeration etc.
Response timeout is judged to the time.
According to an embodiment of the invention, making the N-terminal of the bridge circuit device if bridge circuit device has maximum address value
Mouth is in read states.In the present invention, bridge circuit device can be increased in bus.Generally, newly-increased bridge circuit device connection
To the N-port of the bridge circuit device of end.Whenever, bridge circuit device is connected to the N-port of the bridge circuit device of end
When, it can send the signal of request deallocation.
In the embodiment of the present invention, if a bridge circuit device receives request deallocation from its N-port
Signal, then the signal of the request deallocation is forwarded to its party awarding the contract.
According to the present invention, bridge circuit device is in P and N-port bi-directional data forwarding state when powering on.
According to the present invention, bridge circuit device during the work time, can use command determination representated by command code it
Whether it is in idle condition;If so, the bridge circuit device sends communication to the bridge circuit device with the address greater than it
Request is to be communicated.
Specifically, every section of route in RS485 bus is all independent, can be with transmitting data in parallel.And RS485 itself is
Semiduplex, transmitting-receiving cannot carry out simultaneously, and in order to avoid conflict, bridge circuit device must carry out parallel transmission number according to some rules
According to:
1, by the order on solution read bus, bridge circuit device may determine that idle section.
2, the node on idle section must first be initiated to request by node in front.For example, with reference to Fig. 3, node 4 can be led
Trend node 5 initiates request, then not all right in turn, because node 4 can determine when idle the serial ports on the right of it is, and saves
Point 5 cannot determine when that node 4 can send out data to it, so node 5 actively cannot initiate to request to node 4.
3, endpoint node (node 5 in Fig. 3) cannot send out data to the right serial ports, and the right serial ports will keep reception data.
Because the bridge circuit device newly accessed will send an access signal, (module to two ports P and N all sends out this letter after powering on
Number), serial ports on the right of endpoint node is in order to receive this access signal, it is necessary to be in read states.
In addition, referring to Fig. 3, according to an embodiment of the invention, when the sensor communication of host and node 3, from host to
The route " busy " of node 3, and the route of node 3 to node 5 be it is idle, the bridge circuit device of node 4 and node 5 is necessary
When idle section can be utilized to carry out data communication, such as execute " automated sensor access " or " status exchange between node "
Deng operation.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention
Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the present invention.
Claims (10)
1. a kind of communication means based on RS485 bridge circuit device, wherein m bridge circuit device is connected on by RS485 bus
Together and it is connected to host, a bridge circuit device includes: processor;As the first RS485 serial ports of the port P, for passing through
Bus connects a upper bridge circuit device;As the 2nd RS485 serial ports of N-port, for connecting next bridge electricity by bus
Road device;And the third serial ports of the port L as bridge circuit device, it is used for the matched sensor of connection type, the processing
Device and the first RS485 serial ports, the 2nd RS485 serial ports and third serial ports carry out signal interaction;
This method comprises:
When bridge circuit device initially receives data packet from bus, judge whether the order first symbol in data packet shows data
Packet distributes the data packet of the command code of address for carrying automatically;
If it is determined that data packet is not to carry the data packet of the command code of automatic distribution address, bridge circuit device will be from its P
It immediately begins to be forwarded to its N-port first by unit information length for delivery to next when the data packet that port receives
Bridge circuit device;
When bridge circuit device receives the end mark in data packet from its port P, the received communication data packets of parsing institute are to obtain
To the UID and command code of parsing;By the UID of parsing compared with the UID of the bridge circuit device, UID and the bridge electricity of such as parsing
The UID of road device is identical, then the bridge circuit device executes order representated by the command code in the data packet to carry out and master
The communication of machine;As not identical, ignore the order;
Wherein, the data packet is to be sent from host in RS485 bus, the format of the data packet are as follows: successively arranged in sequence
Order first symbol, bridge circuit device UID, command code, first content and end mark;Wherein, order first symbol and end
Data between symbol are by transcoding, and the highest order of order first symbol is " 1 ", for indicating the beginning of a data packet, other bytes
It is all the byte started with " 0 ";The transcoding be the data of 8 bit, one byte are converted to be with 7 bits a byte data.
2. according to the method described in claim 1, further comprising the steps of:
If it is determined that data packet is to carry the data packet of the command code of automatic distribution address, bridge circuit device is to the bridge circuit
The party awarding the contract that device sends data packet sends response message to notify the party awarding the contract to have been received by the data packet;Wherein, the party awarding the contract is
A device before the bridge circuit device, nearest, as host and a upper bridge circuit device adjacent thereto it
One;
UID value in the data packet received is added the UID value in " 1 " updated data package by the bridge circuit device, then by the number
Next bridge circuit device adjacent thereto is sent to according to packet, and using updated UID value as its address;
The bridge circuit device such as receives the response data packet that next bridge circuit device adjacent thereto is sent, then by the sound
Data packet is answered to be transmitted to the party awarding the contract adjacent thereto;
If bridge circuit device is not received by response message, then response data packet, the response are sent to the party awarding the contract adjacent thereto
The UID value of the bridge circuit device is carried in data packet.
3. according to the method described in claim 2, wherein, the UID of such as parsing is identical as the UID of the bridge circuit device, then the bridge
Circuit device executes order representated by the command code in the data packet
If the order is the automatic reading sensing data instruction for the bridge circuit device, which remembers this
The automatic sensing data that reads instructs and automatically repeats to send to the sensor connecting with the bridge circuit device, automatically from this
Sensor access evidence, and will be saved after the data of reading progress transcoding.
4. according to the method described in claim 2, wherein, the UID of such as parsing is identical as the UID of the bridge circuit device, then the bridge
Circuit device executes order representated by the command code in the data packet
Such as order is the unlatching direct channel instruction for the bridge circuit device, then the bridge circuit device opens its port L
To the two-way converting channel of the port P, and close its N-port;
Bridge circuit device will be sent to its sensor after data packet inversion code that host is sent, and by from its sensor into
The data forwarding of row transcoding is to host.
5. according to the method described in claim 4, further comprising:
After the bridge circuit device is completed the data forwarding from its sensor to host, if receiving the number from host
When going out the instruction for being different from opening direct channel instruction according to Bao Bingcong resolve packet, which closes its port L
To the two-way converting channel of the port P, and open its N-port.
6. according to the method described in claim 2, further comprising:
If the bridge circuit device receives the signal of request deallocation from its N-port, again by the request
The signal of distribution address is forwarded to its party awarding the contract;
Wherein, if the bridge circuit device has maximum address value, the N-port of the bridge circuit device is made to be in read states.
7. according to the method described in claim 1, wherein, the bridge circuit device is in P and N-port bi-directional data when powering on
Forwarding state.
8. according to the method described in claim 1, wherein, the unit information length is 1 byte or 1 bit.
9. according to the method described in claim 1, further comprising:
Using command determination representated by command code, whether it is in idle condition the bridge circuit device;
If so, the bridge circuit device sends communication request to the bridge circuit device with the address greater than it to be led to
Letter.
10. the response data packet has format identical with the data packet according to the method described in claim 2, wherein,
Command code in the response data packet is the radix-minus-one complement of the command code numerical value in responded data packet.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710432863.XA CN107229586B (en) | 2017-06-09 | 2017-06-09 | Communication means based on RS485 bridge circuit device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710432863.XA CN107229586B (en) | 2017-06-09 | 2017-06-09 | Communication means based on RS485 bridge circuit device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107229586A CN107229586A (en) | 2017-10-03 |
CN107229586B true CN107229586B (en) | 2019-07-30 |
Family
ID=59935901
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710432863.XA Active CN107229586B (en) | 2017-06-09 | 2017-06-09 | Communication means based on RS485 bridge circuit device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107229586B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107483313B (en) * | 2017-10-14 | 2023-09-08 | 中船重工信息科技有限公司 | Data acquisition method and system based on cascade Ethernet equipment |
CN110166338B (en) * | 2019-05-17 | 2022-06-14 | 华东师范大学 | Cascading method of serial communication interface |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101345680A (en) * | 2008-07-29 | 2009-01-14 | 人民电器集团有限公司 | Operation method of communication system |
CN101345681A (en) * | 2008-07-29 | 2009-01-14 | 人民电器集团有限公司 | Operation method for main unit of intelligent electric appliance serial bus |
CN101668014A (en) * | 2009-09-24 | 2010-03-10 | 桂林电子科技大学 | Communication method of manufacturing grid service center and resource nodes |
-
2017
- 2017-06-09 CN CN201710432863.XA patent/CN107229586B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101345680A (en) * | 2008-07-29 | 2009-01-14 | 人民电器集团有限公司 | Operation method of communication system |
CN101345681A (en) * | 2008-07-29 | 2009-01-14 | 人民电器集团有限公司 | Operation method for main unit of intelligent electric appliance serial bus |
CN101668014A (en) * | 2009-09-24 | 2010-03-10 | 桂林电子科技大学 | Communication method of manufacturing grid service center and resource nodes |
Non-Patent Citations (1)
Title |
---|
《一种改进型RS485总线设计》;张莉 等;《自动化与仪表》;20161031;第32-35页 |
Also Published As
Publication number | Publication date |
---|---|
CN107229586A (en) | 2017-10-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107147538B (en) | Fault Locating Method based on RS485 bridge circuit device | |
AU2007278728B2 (en) | Method and apparatus for distributing usb hub functions across a network | |
CN107707447A (en) | A kind of slave station system and control method based on EtherCAT | |
US9807036B2 (en) | Apparatus and method for encoding MDIO into SGMII transmissions | |
CN105939253A (en) | Industrial wireless gateway device and protocol conversion method thereof | |
CN104641360A (en) | Dual casting PCIe inbound writes to memory and peer devices | |
US6401159B1 (en) | Method of half-duplex serial signal control with multi-baud rate and multi-configuration | |
CN102035688B (en) | Design method for rapidly controlling network link access | |
CN110635982B (en) | Double-host communication method and system on communication bus, industrial control gateway and storage medium | |
CN107948059A (en) | EtherCAT and Modbus protocol conversion gateways based on SPARC architecture microprocessors | |
CN107229586B (en) | Communication means based on RS485 bridge circuit device | |
CN109787981A (en) | Protocol conversion system, method, apparatus, equipment and storage medium | |
CN108228521A (en) | A kind of Serial Communication at High Speed on MS network | |
CN110474828A (en) | A kind of MBUS bus communication and system | |
CN207853917U (en) | A kind of slave, communication expansion card and group network system | |
CN202282789U (en) | SOE (SERCOS OVER EtherCAT) communication conversion card for servo driver | |
CN105141483B (en) | Multinode network minimal communications measuring space method based on CAN bus | |
CN113194048B (en) | Device for dynamically switching CPU and GPU topology and use method | |
CN116633968A (en) | Industrial control system and method based on FPGA | |
CN102724090A (en) | Process field bus (PROFIBUS) DP/PA integrated embedded slave node communication device based on DP controller with integrated 8031 core (DPC31) | |
CN109802877A (en) | A kind of CAN bus based Communication System Design | |
Qingmei et al. | The Design of Communication Nodes in the Tractor Control Network Based on ISO11783 Protocol | |
CN206863734U (en) | Bridge circuit device and its bus circuit based on RS485 | |
CN114338265B (en) | Program downloading system and method based on TTP/C bus | |
Depari et al. | IEEE1451 smart sensors supporting USB connectivity |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
PE01 | Entry into force of the registration of the contract for pledge of patent right | ||
PE01 | Entry into force of the registration of the contract for pledge of patent right |
Denomination of invention: Communication method based on RS485 bridge circuit device Granted publication date: 20190730 Pledgee: Agricultural Bank of China Xiamen Financial Center Branch Pledgor: XIAMEN SUNWE TECHNOLOGY CO.,LTD. Registration number: Y2024980032117 |