CN107229586A - Communication means based on RS485 bridge circuit devices - Google Patents

Communication means based on RS485 bridge circuit devices Download PDF

Info

Publication number
CN107229586A
CN107229586A CN201710432863.XA CN201710432863A CN107229586A CN 107229586 A CN107229586 A CN 107229586A CN 201710432863 A CN201710432863 A CN 201710432863A CN 107229586 A CN107229586 A CN 107229586A
Authority
CN
China
Prior art keywords
bridge circuit
circuit device
packet
data
uid
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.)
Granted
Application number
CN201710432863.XA
Other languages
Chinese (zh)
Other versions
CN107229586B (en
Inventor
张伟
梁军
张才建
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Is Still Polytron Technologies Inc
Original Assignee
Xiamen Is Still Polytron Technologies Inc
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Xiamen Is Still Polytron Technologies Inc filed Critical Xiamen Is Still Polytron Technologies Inc
Priority to CN201710432863.XA priority Critical patent/CN107229586B/en
Publication of CN107229586A publication Critical patent/CN107229586A/en
Application granted granted Critical
Publication of CN107229586B publication Critical patent/CN107229586B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information 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

A kind of communication means based on RS485 bridge circuit devices is disclosed, including:Whether when bridge circuit device initially receives packet from bus, it is the packet for carrying the automatic command code for distributing address to judge packet;If not being, bridge circuit device will first be forwarded to its N-port for delivery to next bridge circuit device since the packet that its P port is received by unit information length;Bridge circuit device from its P ports receive packet in end mark when, parse UID and command code that received communication data packets are parsed;The UID of parsing is compared with the UID of the bridge circuit device, such as the two is identical, then the bridge circuit device performs the order representated by the command code in the packet to carry out the communication with main frame;As differed, ignore the order.Methods described provides the new traffic mode based on RS485 bridge circuit devices, and junk information can be avoided excessive, can also the newly-increased bridge circuit device of automatic identification and automatic distribution address again.

Description

Communication means based on RS485 bridge circuit devices
Technical field
The present invention relates to serial communication technology, more particularly to a kind of communication means based on RS485 bridge circuit devices.
Background technology
RS485 is two-wire system, half-duplex, differential signal communication interface (physical layer).Referring to Fig. 1, traditional RS485 buses Multiple equipment is allowed to be connected in same bus, these equipment are communicated usually using ModBus protocol formats, each equipment is pre- One 485ID is first set.Main frame, with the equipment interaction in bus, each equipment is distinguished by 485ID by the way of poll.It is main All devices can be received when machine sends request, but that equipment response that only 485ID matches, and 485 buses are half pair Work, the same time can only have a data sender.The all the sensors of traditional RS485 buses are connected in a data lines, Line is longer, and signal attenuation is more serious, and it is easier by outside electromagnetic interference to communicate.
In addition, according to traditional RS485 bussing techniques, also having the disadvantage that:Junk information on broadcast type communication bus Excessively, the sensor that is crashing because of busy can often be run into;When running into the sensor for distributing data arbituarily because of failure, drag Tired whole piece bus is unable to normal communication;Safeguard that the ID of each sensor is not easy to, particularly after increase new sensor when Wait;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 prior art to a kind of based on RS485 The need for the communication means of the defect of presence.
The content of the invention
In view of this, the present invention provides a kind of communication means based on RS485 bridge circuit devices, can overcome prior art The problem of existing.
What technical scheme was specifically realized in:
A kind of communication means based on RS485 bridge circuit devices, wherein, m bridge circuit device passes through RS485 bus strings It is linked togather and is connected to main frame, a bridge circuit device includes processor;As the first RS485 serial ports at P ends, for leading to Cross bus and connect a upper bridge circuit device;As the 2nd RS485 serial ports of N-terminal, for connecting next bridge electricity by bus Road device;And the 3rd serial ports at the L ends as bridge circuit device, the sensor matched for connection type, the processor Signal interaction is carried out with the first RS485 serial ports, the 2nd RS485 serial ports and the 3rd serial ports, this method includes:
When bridge circuit device initially receives packet from bus, judge order first symbol in packet whether this is indicate that Packet distributes the packet of the command code of address for carrying automatically;
If it is determined that packet is not the packet for the command code for carrying automatic distribution address, bridge circuit device will be from it P ports receive the packet when immediately begin to the N ports for being first forwarded to it by unit information length for delivery under One bridge circuit device;
Bridge circuit device from its P ports receive packet in end mark when, parse received communication data packets With the UID and command code parsed;The UID of parsing is compared with the UID of the bridge circuit device, such as the UID of parsing is with being somebody's turn to do The UID of bridge circuit device is identical, then the bridge circuit device performs the order representated by the command code in the packet to carry out With the communication of main frame;As differed, ignore the order;
Wherein, the packet from main frame to RS485 buses on send, the form of the packet is:Successively sequentially Order first symbol, the UID of bridge circuit device, command code, first content and the end mark of arrangement;Wherein, order first symbol and Data between end mark are by transcoding, and the highest order of order first symbol is " 1 ", and the beginning for representing a packet is other Byte is all the byte started with " 0 ";The transcoding is to be converted to the data of the byte of 8 bit one using 7 bits as a byte Data.
It is preferred that described method also includes step:
If it is determined that packet is the packet for the command code for carrying automatic distribution address, bridge circuit device is to giving the bridge The party awarding the contract that circuit arrangement sends packet sends response message to notify the party awarding the contract to have been received by the packet;Wherein, give out a contract for a project Side is a device before the bridge circuit device, nearest, as main frame and upper bridge circuit dress adjacent thereto One of put;
Then UID values in UID values in the packet received plus " 1 " updated data package will by the bridge circuit device The packet is sent to next bridge circuit device adjacent thereto, and regard the UID values after renewal 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;
Such as bridge circuit device is not received by response message, then sends response data packet to the party awarding the contract adjacent thereto, should The UID values of the bridge circuit device are carried in response data packet.
Wherein, the UID such as parsing is identical with the UID of the bridge circuit device, then the bridge circuit device is performed in the 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 being connected with the bridge circuit device, with automatic From sensor access evidence, and it will be preserved after the data progress transcoding of reading.
Wherein, the UID such as parsing is identical with the UID of the bridge circuit device, then the bridge circuit device is performed in the 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 in port to the two-way converting passage of P ports;
It is sent to its sensor after the packet inversion code that bridge circuit device sends main frame, and by the sensing from it Device is transmitted to main frame after carrying out the data of transcoding.
Further, described method includes:
The bridge circuit device complete by the data forwarding of the sensor from it to main frame after, if receiving to come independently The packet of machine and from resolve packet go out be different from open direct channel instruction instruction when, the bridge circuit device closes its And its N-port is opened to the two-way converting passage of P ports in L ports.
Further, described method includes:
If the bridge circuit device receives the signal of request deallocation from its N-terminal, by the request weight The signal of new distribution address is forwarded to its party awarding the contract;
Wherein, if the bridge circuit device has maximum address value, it is in the N-port of the bridge circuit device and reads shape State.
It is preferred that the bridge circuit device is in P and N-port bi-directional data forwarding state when upper electric.
Wherein, the unit information length is 1 byte or 1 bit.
In addition, described method also includes:
Using the command determination representated by command code, whether it is in idle condition to the bridge circuit device;
If it is, the bridge circuit device sends communication request to carry out to the bridge circuit device with the address more than it Communication.
Wherein, the response data packet has with the packet identical form, the order in the response data packet Code is the radix-minus-one complement of the command code numerical value in responded packet.
As above visible, there is provided can be used for being based on for the communication means based on RS485 bridge circuit devices in the present invention The new traffic mode of RS485 bridge circuit devices.Because sensor is not directly coupled in bus, but filled by bridge circuit Put and be connected in bus, therefore it is excessive to can be avoided junk information of the prior art;In addition, each bridge circuit device with The communication of main frame is all relatively independent, and because bridge circuit device is by the way of " first forwarding post processing ", even if a certain The sensor of individual bridge circuit device connection is problematic, nor affects on the operation of bus;Moreover, after new bridge circuit device increase, Main frame can distribute address automatically with automatic identification and again.
Brief description of the drawings
Fig. 1 is the conventional bus circuit diagram of the prior art based on RS485.
Fig. 2 be the embodiment of the present invention in the bridge circuit device based on RS485 composition schematic diagram.
Fig. 3 be the embodiment of the present invention in the bridge circuit device based on RS485 bus circuit schematic diagram.
Fig. 4 be the embodiment of the present invention in the communication means based on RS485 bridge circuit devices flow chart.
Embodiment
For the objects, technical solutions and advantages of the present invention are more clearly understood, develop simultaneously embodiment referring to the drawings, right The present invention is further described.
In the present invention, the bridge circuit device based on RS485 has three ports, respectively L ends, P ends and N-terminal, P ends and N End is respectively used to upper one of connection and next bridge circuit device, and L ends are used to be connected to sensor.Bridge circuit based on RS485 Device is directly connected in RS485 buses.So, sensor is no longer directly connected in RS485 buses, main frame no longer directly with Sensor is interacted, but is interacted using 485 bus protocols with bridge circuit device.Bridge circuit device and connected sensor can To be referred to as a node in RS485 buses.All it is one section of independent number between each two bridge circuit device in RS485 buses According to line, that section of line i.e. L ends for being based even on RS485 bridge circuit device connection sensor are also one section of independent data wire, base Data are transmitted among the nodes by way of relay in RS485 bridge circuit device.It can be seen that, using the present invention, between node Data line length shorten, therefore signal attenuation is small, and the signal antijamming capability on signal wire also 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 buses are also to use RS485 physical interfaces, but without using ModBus agreements, but use custom protocol.Self-defined association View is not essential in the present invention, and the present invention can also use other agreements by those skilled in the art, therefore be omitted here Introduction to custom protocol.Bridge circuit device is bridge of the main frame with sensor communication, and it is that main frame and sensor provide one The different communication lines with tradition RS485 buses of bar.The bridge circuit device based on RS485 is only connected in RS485 buses, unlike passing System RS485 buses are directly connected to sensor like that.During using RS485 buses, main frame is no longer directly interacted with sensor, but Interacted using RS485 bridges agreement with bridge circuit device.Bridge agreement provides order and turns " sensors command " after packing for main frame Sensor is issued to realize interaction of the main frame with sensor.
The bridge circuit device based on RS485 of the present invention is described in detail with reference to Fig. 2 and Fig. 3.
Fig. 2 shows the composition schematic diagram of the bridge circuit device according to embodiments of the present invention based on RS485.Bridge circuit is filled Put 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 individual bridge circuit device, the 2nd RS485 serial ports is used to connect next bridge circuit device by bus First RS485 serial ports.The bridge circuit device further comprises the 3rd serial ports at the L ends as bridge circuit device, for providing The sensor that polytype interface matches for connection type.
In the present invention, the first RS485 serial ports as bridge circuit device P ends, for connecting a upper bridge electricity by bus Road device;2nd RS485 serial ports as bridge circuit device N-terminal, for connecting next bridge circuit device by bus.It is described Processor and the first RS485 serial ports, the 2nd RS485 serial ports and the 3rd serial ports carry out signal interaction.Wherein, the 3rd serial ports is The set serial ports of RS485, RS422 and RS232 serial ports, for connecting the sensor worked based on RS485, based on RS422 work Sensor and based on RS232 work sensor.It is preferred that the bridge circuit device further comprises aiding in serial ports, it is used for Connect the sensor of desired type.It is preferred that the processor is C51 chips, the first RS485 serial ports and the 2nd RS485 Serial ports is RJ45 interfaces.Embodiments in accordance with the present invention, the first RS485 serial ports, the 2nd RS485 serial ports and the 3rd serial ports are those This is independent, can enter row data communication simultaneously independently of one another.It is preferred that bridge circuit device also includes the dry section positioned at L ends Point port, for connecting dry node.
In embodiments of the invention, although the interface based on RS485 is half duplex communication, but the electricity of the bridge based on RS485 Three interfaces inside the device of road are independent, and they can carry out data communication simultaneously, that is to say, that bridge circuit device is by P When the data forwarding at end is to N-terminal, the sensor that still can be connected with L ends is communicated.This working method is more logical than half-duplex Traditional RS485 buses of news are more efficient.
Traditional RS485 buses can only connect the sensor of RS485 interfaces, and be typically only capable to be led to Modbus agreements News.And in the present invention, the L ends of the bridge circuit device based on RS485 can support polytype sensor, these sensors Agreement can be arbitrary.Alternatively, L ends can also be configured to only connect a type of sensor.In RS485 bridge buses On, between main frame and these dissimilar sensors communication will not produce it is any conflict because actual directly with sensor communication Bridge circuit device be 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 embodiments of the present invention based on RS485.As schemed Shown in 4, the bus circuit based on RS485 includes the m nodes and main frame being connected in series in RS485 buses, and m is positive integer. Each node is foregoing bridge circuit device, and the P ends of first node are connected with the main frame, the L of m-th of node End is hanging, and the P ends of i-th of node are connected to the L ends of the i-th -1 node, and i is 2,3,4 ..., m-1.K-th of node and kth -1 Data wire between individual node is independent data line segment, and k is 2,3,4 ..., m.It is preferred that in the P ends of node, L ends and N-terminal Each port is configured with 4 lines, wherein 2 lines are signal wire, 2 one, lines are ground wire in addition, and one is 5V power lines.Compared with Goodly, the main frame carries out data interaction by bridge circuit device and sensor.It is preferred that main frame by bridge circuit device with Sensor carries out data interaction, and the bridge circuit device can also communicate with bridge circuit device thereafter.
Referring to Fig. 3, in the bus circuit based on RS485, it between node is all one section of independence that each two bridge circuit device, which is, Data wire, that section of line for being based even on the i.e. L ends connection sensor of RS485 bridge circuit device is also one section of independent data Line, bridge circuit device transmits data among the nodes by way of relay.Clearly as the data line length between node becomes It is short, thus signal attenuation diminishes, antijamming capability also just becomes strong.
Embodiments in accordance with the present invention, the packet basic format that main frame is sent to bridge circuit device is as follows:
【Order first symbol】+【Bridge module UID】+【Command code】+【Content】+【End mark】
Bridge protocol requirement【Order first symbol】With【End mark】Between data to carry out transcoding, in order to avoid go out in these data The character now conflicted with first symbol, end mark.In the present invention, transcoding rule is that 8bit turns 7bit, and each byte of computer is by 8 Individual bit composition, transcoding is to reorganize one group of byte with every 7 bits, then forms one group of new data, new number According to each byte only using low 7, highest order always 0 (highest order be 1 be bridge agreement Special controlling symbol, such as order starts Symbol and end mark), the data byte after transcoding can be more than former data byte, but can ensure will not with bridge agreement Special controlling Symbol conflict.
Two parts may be included in the packet that bridge circuit device is responded【Content】Data.Because RS485 communications are half pair Work, question-response formula, in order to avoid conflict, bridge circuit device actively can not send packet to main frame.Sometimes bridge is electric Road device is needed to host report some events, such as has newly accessed a bridge circuit device in bus, this event can be in master When machine sends order and awaited a response, event is placed on the 2nd part by bridge circuit device【Content】Main frame is reported in data.
Main RS485 bridge communication command codes and function in the present invention is described below.
Main frame is specified by UID and communicated with some bridge circuit device, and each bridge circuit device has one to distribute automatically UID.In the present invention,【Command code】It is single byte numerical value, the parameter that order needs is placed on【Content】In field.Bridge circuit device The packet of response,【Command code】It is the radix-minus-one complement for the command code numerical value for responding order.
Main RS485 bridges communication command and function are as follows:
1st, require that the bridge circuit device in bus distributes address (i.e. UID) automatically.
2nd, the hardware information (information such as version number, type, date of production) of " specifying bridge circuit device " is taken.
3rd, the data carried in " specifying bridge circuit device " former state commands in return are required, for measurement circuit communication quality.
4th, the IO input states (such as dry node input state) of all bridge circuit devices of bus are obtained with an order.
5th, the input state (such as dry node input state) of the assigned I/O of " specifying bridge circuit device " is taken.
6th, sensors command is told " specifying bridge circuit device ".Bridge circuit device is remembered to instruct and automatically repeated to biography Sensor sends these instructions, realizes automatic from sensor access.The order is adapted to changeless sensors command.
7th, the sensor reply data that " specifying 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 preserve how many historical datas will see the size of wall scroll data.It is main Machine sends the order and these sensor historic data is read from bridge circuit device.This article of order keeps up with one article of order i.e. the life Order is paired.
8th, require that " specifying bridge circuit device " opens main frame to the Direct Communication passage of sensor.Some sensor communications are needed Repeatedly to interact, or, sensing data amount is too big, and bridge circuit device can not perform automatic access to such sensor.It is main Machine can be ordered with this and set up Direct Communication passage with sensor, and bridge circuit device is responsible for two-way between main frame and sensor Data forwarding.
9th, bridge circuit device internal event is notified, 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 devices in the embodiment of the present invention is shown. In step 10, main frame starts received data packet to sending the bridge circuit device in packet, bus in bus.In the present invention, always When any one bridge circuit device on line initially receives packet, first judge order first symbol in packet whether table Bright packet distributes the packet of the command code of address for carrying automatically.Embodiments in accordance with the present invention, the packet is Sent on from main frame to RS485 buses, the form of the packet is:The order first symbol of arranged in sequence, bridge circuit are filled successively UID, command code, first content and the end mark put;Wherein, the data between order first symbol and end mark are by transcoding, life The highest order for making first symbol is " 1 ", and the beginning for representing a packet, other bytes are all the bytes started with " 0 ";Institute It is that the data of the byte of 8 bit one are converted to the data using 7 bits as a byte to state transcoding.It is preferred that embodiments of the invention It is to judge whether the command code that the packet is included is the automatic order for distributing address with the value of order first symbol, and The value of byte where order first symbol represents it is what type of command code.
If it is determined that packet is not the packet for the command code for carrying automatic distribution address, bridge circuit device will be from it P ports receive the 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 " enter OK.In the present invention, unit information length is 1 byte or 1 bit.In embodiments of the invention, RS485 is based on when most of Bridge circuit device be in P and N-port bi-directional data forwarding state (being in general put into this state after upper electricity), P ports The data received can be forwarded to N-port, and vice versa.L ports are closings, and data do not issue sensor, also will not be sensing The data forwarding that device is sent will not be dealt into P ports and N-port in 485 buses.
When forwarding data in units of byte, data often need to postpone about 1 byte time (for example by a bridge module The communication of 9600 baud rates is per second to transmit 960 bytes, and 1 byte time is 1/960 second).When forwarding data in units of bit, Data often need the about 1 bit time of delay by a bridge module, and (time that for example 9600 baud rates often transmit 1 is 1/ 9600 seconds).
In step 30, bridge circuit device from its P ports receive packet in end mark when, parse received logical Interrogate UID and command code of the 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 with the UID of the bridge circuit device, then the bridge circuit device performs the life in the packet The order representated by code is made to carry out the communication with main frame;As differed, ignore the order, step 40.
The order that main frame is sent always needs some bridge circuit device in RS485 buses to respond, to reduce data Passing time, bridge circuit device, which is taken, first forwards the mode performed afterwards to handle command request.The order that main frame is sent is by multiple words Section composition, the always sequential delivery of one byte of a byte on the data line, bridge electric installation, which is received after data, (receives 1 byte Or 1 bit) it is directly passed to next bridge circuit device.When Host Command is transmitted, that is, bridge circuit device is received During 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, that bridge circuit device that only UID is matched with oneself can perform this order, other bridge circuits Device then ignores this order.
In embodiments of the invention, the UID of such as parsing is identical with the UID of the bridge circuit device, and bridge circuit device will determine that The order representated by command code in packet, and perform corresponding order.If the order is for the bridge circuit device The instruction of automatic reading sensing data, then the bridge circuit device remember that the automatic reading sensing data is instructed and automatically weighed It is multiple to be sent to the sensor being connected with the bridge circuit device, with automatically from sensor access evidence, and the data of reading are carried out Preserved 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 in port to the two-way converting passage of P ports;The packet that bridge circuit device sends main frame is inverted Its sensor is sent to after code, and main frame will be transmitted to after the data of the sensor progress transcoding from it.Bridge circuit device Complete by the data forwarding of the sensor from it to main frame after, if receiving the packet from main frame and from packet solution When separating out the instruction for being different from unlatching direct channel instruction, the bridge circuit device closes its L ports to the two-way converting of P ports Passage, and open its N ports.
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 fetch to such sensor automatically, main Temperature sensor load instruction is told bridge circuit device, such as temperature sensor by machine by RS485 buses and bridge circuit device Load instruction is packaged into packet back warp bus and sent.Receive the packet for including temperature sensor load instruction Afterwards, bridge circuit device can just obtain temperature data automatically, and can preserve historical data for several times recently.Bridge circuit is filled Put not it is understood that the data obtained from sensor, it is to store data into internal memory, when main frame to it asks for these Again response to main frame during data.This access mode need not set up a main frame to the immediate data transmission channel of sensor.
Some sensors can not automatically be fetched by bridge circuit device, such as sensor load instruction be not it is changeless, Or, sensors command data volume is excessive, beyond the caching capabilities of bridge circuit device.With this sensor communication, it is necessary to allow Bridge circuit device sets up a main frame to the Direct Communication passage of sensor.
For example, with reference to Fig. 3, main frame sends to RS485 buses and ordered, it is desirable to which node 3 sets up a main frame to sensor Direct data channel, the direct bi-directional data forwarding that unlatching main frame is connect sensor by node 3 with it (is to open node 3 in fact Data forwarding between left side serial ports and L ports), node 3 will not forward follow-up data (namely to stop to the serial ports on the right of it again Only continue to forward data backward) because with the bridge circuit device that the data communication of sensor is transmitted to back being not have by main frame Meaning.Node 1 and 2 is still within the bi-directional data forwarding state of the left side and the right serial ports, because the data of main frame and node 3 Them are needed to forward.
Main frame is set up to after the direct data channel of sensor, transmission of the data in RS485 buses is still with data Bag form is packed and carries out 8bit to 7bit Data Format Transform.What sensor was actually received is unpacked by bridge circuit device Raw sensor instruction.Complete sensor access after, main frame does not need this direct channel of explicit closing, as long as main frame to Other bridge circuit devices in RS485 buses send order, and node 3 can close this direct channel automatically.
If it is determined that packet is the packet for the command code for carrying automatic distribution address, bridge circuit device is to giving the bridge The party awarding the contract that circuit arrangement sends packet sends response message to notify the party awarding the contract to have been received by the packet, step 50.Its In, the party awarding the contract is a device before the bridge circuit device, nearest, as main frame and a upper bridge electricity adjacent thereto One of road device.
Next, bridge circuit device adds the UID values in the packet received the UID values in " 1 " updated data package, so Next bridge circuit device adjacent thereto is sent the packet to afterwards, and using the UID values after renewal as its address, Step 60.
Embodiments in accordance with the present invention, bridge circuit device UID is used for the node in unique mark bus, and UID is automatic point Match somebody with somebody.When main frame sends " distributing address automatically " order to bus, the numerical value initial value in packet is 0, nearest from main frame Bridge circuit device receive after packet, will be worth+1, this value is the UID of the bridge circuit device, is also that it is suitable in bus Sequence number.Packet after+1 is sent to next bridge circuit device by bridge circuit device, by that analogy, until last in bus One bridge circuit device.Now, all bridge circuit devices of bus be 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 P ends (the upper module of connection), separately The serial ports on outer one side is N-terminal (the next module of connection).
Next, bridge circuit device judges whether to receive the number of responses that next bridge circuit device adjacent thereto is sent According to bag., 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;Response message is not received by such as bridge circuit device, then to The party awarding the contract adjacent thereto sends the UID values that the bridge circuit device is carried in response data packet, the response data packet, step 80.Specifically, bridge circuit device is received after " distributing address automatically " order, is first responded a node, is told it to receive this Bar order, the data that then forwarding back bridge circuit device is responded further along, end bridge circuit device is easy to judge after 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 main frame, orders The response bag of order, the content of bag includes the UID of its own, and this UID is also equal to the quantity of node in bus.Respond coating transmission Return after main frame, all bridge circuit devices both know about the quantity of bus node on main frame and bus.Bridge circuit device knows bus Upper number of nodes is beneficial, and such as main frame is to during a non-existent node transmission request, and this request reaches first bridge Circuit arrangement is just intercepted, and then bridge circuit device reports mistake to main frame response data.Bridge circuit device is actively to master Machine report mistake can reduce the unnecessary stand-by period, because under normal circumstances, main frame need setting one compare exaggeration etc. The time is treated to judge response timeout.
Embodiments in accordance with the present invention, if bridge circuit device has maximum address value, make the N-terminal of the bridge circuit device Mouth is in read states.In the present invention, bridge circuit device can be increased in bus.Usually, newly-increased bridge circuit device connection To the N-terminal of the bridge circuit device of end.Whenever, when bridge circuit device is connected to the N-terminal of bridge circuit device of end, it The signal of request deallocation can be sent.
In embodiments of the invention, if a bridge circuit device receives request deallocation from its N-terminal The signal of the request deallocation, then be forwarded to its party awarding the contract by signal.
According to the present invention, bridge circuit device is in P and N-port bi-directional data forwarding state when upper electric.
According to the present invention, bridge circuit device is in the course of the work, it is possible to use command determination representated by command code it Whether idle condition is in;Communicated if it is, the bridge circuit device is sent to the bridge circuit device with the address more than it Ask to be communicated.
Specifically, every section of circuit in RS485 buses be all it is independent, can be with transmitting data in parallel.And RS485 is in itself It is semiduplex, transmitting-receiving can not be carried out simultaneously, in order to avoid conflict, bridge circuit device must carry out parallel transmission according to some rules Data:
1st, by solving the order on read bus, bridge circuit device may determine that idle section.
2nd, the node on idle section must first be initiated 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 may decide that when idle the serial ports on the right of it is, and saves Point 5 can not determine when that node 4 can send out data to it, so node 5 actively can not initiate to ask to node 4.
3rd, endpoint node (node 5 in Fig. 3) can not 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, (this letter is all sent out in backward two ports of P and N of electricity in module Number), serial ports on the right of endpoint node is in order to receive this access signal, it is necessary in read states.
In addition, referring to Fig. 3, embodiments in accordance with the present invention, when the sensor communication of main frame and node 3, from main frame to The circuit " busy " of node 3, and the circuit of node 3 to node 5 is idle, the bridge circuit device of node 4 and node 5 is necessary When can just utilize idle section to carry out data communication, for example perform " 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 essences in the present invention God is with principle, and any modification, equivalent substitution and improvements done etc. should be included within the scope of protection of the invention.

Claims (10)

1. a kind of communication means based on RS485 bridge circuit devices, wherein, m bridge circuit device is connected on by RS485 buses Together and it is connected to main frame, a bridge circuit device includes processor;As the first RS485 serial ports at P ends, for passing through bus Connect a bridge circuit device;As the 2nd RS485 serial ports of N-terminal, for connecting next bridge circuit device by bus; And the 3rd serial ports at the L ends as bridge circuit device, the sensor matched for connection type, the processor and first RS485 serial ports, the 2nd RS485 serial ports and the 3rd serial ports carry out signal interaction, and this method includes:
When bridge circuit device initially receives packet from bus, judge the order first symbol in packet whether this is indicate that data Wrap the packet of the command code to carry automatic distribution address;
If it is determined that packet is not the packet for the command code for carrying automatic distribution address, bridge circuit device is by from its P The N-port for being first forwarded to it by unit information length is immediately begun to during the packet that port is received for delivery to next Bridge circuit device;
Bridge circuit device from its P ports receive packet in end mark when, parse received communication data packets with To the UID and command code of parsing;The UID of parsing is compared with the UID of the bridge circuit device, such as UID of parsing and bridge electricity The UID of road device is identical, then the bridge circuit device performs the order representated by the command code in the packet to carry out and master The communication of machine;As differed, ignore the order;
Wherein, the packet from main frame to RS485 buses on send, the form of the packet is:Arranged in sequence successively Order first symbol, the UID of bridge circuit device, 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 ", the beginning for representing a packet, other bytes All it is the byte started with " 0 ";The transcoding is that the data of the byte of 8 bit one are converted to the data using 7 bits as a byte.
2. according to the method described in claim 1, in addition to step:
If it is determined that packet is the packet for the command code for carrying automatic distribution address, bridge circuit device is to giving the bridge circuit The party awarding the contract that device sends packet sends response message to notify the party awarding the contract to have been received by the packet;Wherein, the party awarding the contract is A device before the bridge circuit device, nearest, as main frame and a upper bridge circuit device adjacent thereto it One;
Then the bridge circuit device counts this UID values in UID values in packet received plus " 1 " updated data package Next bridge circuit device adjacent thereto is sent to according to bag, and regard the UID values after renewal as its address;
The bridge circuit device such as receives the response data packet that next bridge circuit device adjacent thereto is sent, then rings this Packet is answered to be transmitted to the party awarding the contract adjacent thereto;
Such as bridge circuit device is not received by response message, then sends response data packet, the response to the party awarding the contract adjacent thereto The UID values of the bridge circuit device are carried in packet.
3. method according to claim 2, wherein, the UID of such as parsing is identical with the UID of the bridge circuit device, then the bridge The order that circuit arrangement performs representated by the command code in the packet includes:
If the order is the automatic reading sensing data instruction for the bridge circuit device, the bridge circuit device remembers this The automatic sensing data that reads instructs and automatically repeats to send to the sensor being connected with the bridge circuit device, with automatically from this Sensor access evidence, and will be preserved after the data progress transcoding of reading.
4. method according to claim 2, wherein, the UID of such as parsing is identical with the UID of the bridge circuit device, then the bridge The order that circuit arrangement performs representated by the command code in the packet includes:
Such as order is the unlatching direct channel instruction for the bridge circuit device, then the bridge circuit device opens its L ports To the two-way converting passage of P ports, and close its N-port;
Its sensor is sent to after the packet inversion code that bridge circuit device sends main frame, and the sensor from it is entered Main frame is transmitted to after the data of row transcoding.
5. method according to claim 4, further comprises:
The bridge circuit device complete by the data forwarding of the sensor from it to main frame after, if received from main frame Packet and from resolve packet go out be different from open direct channel instruction instruction when, the bridge circuit device closes its L ends Mouth arrives the two-way converting passage of P ports, and opens its N-port.
6. method according to claim 2, further comprises:
If the bridge circuit device receives the signal of request deallocation from its N-terminal, the request is divided again Signal with 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 upper electric Forwarding state.
8. according to the method described in claim 1, wherein, the unit information length be 1 byte or 1 bit.
9. according to the method described in claim 1, further comprise:
Using the command determination representated by command code, whether it is in idle condition to the bridge circuit device;
If it is, the bridge circuit device sends communication request to be led to the bridge circuit device with the address more than it Letter.
10. method according to claim 2, wherein, the response data packet have with the packet identical form, Command code in the response data packet is the radix-minus-one complement of the command code numerical value in responded packet.
CN201710432863.XA 2017-06-09 2017-06-09 Communication means based on RS485 bridge circuit device Active CN107229586B (en)

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 true CN107229586A (en) 2017-10-03
CN107229586B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107483313A (en) * 2017-10-14 2017-12-15 连云港杰瑞深软科技有限公司 A kind of collecting method and system based on cascade ethernet device
CN110166338A (en) * 2019-05-17 2019-08-23 华东师范大学 A kind of Cascading Methods of serial communication interface

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101345681A (en) * 2008-07-29 2009-01-14 人民电器集团有限公司 Operation method for main unit of intelligent electric appliance serial bus
CN101345680A (en) * 2008-07-29 2009-01-14 人民电器集团有限公司 Operation method of communication system
CN101668014A (en) * 2009-09-24 2010-03-10 桂林电子科技大学 Communication method of manufacturing grid service center and resource nodes

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101345681A (en) * 2008-07-29 2009-01-14 人民电器集团有限公司 Operation method for main unit of intelligent electric appliance serial bus
CN101345680A (en) * 2008-07-29 2009-01-14 人民电器集团有限公司 Operation method of communication system
CN101668014A (en) * 2009-09-24 2010-03-10 桂林电子科技大学 Communication method of manufacturing grid service center and resource nodes

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
张莉 等: "《一种改进型RS485总线设计》", 《自动化与仪表》 *
贾向成 等: "《浅析采集终端RS485接线方式"并改串"》", 《科技视界》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107483313A (en) * 2017-10-14 2017-12-15 连云港杰瑞深软科技有限公司 A kind of collecting method and system based on cascade ethernet device
CN107483313B (en) * 2017-10-14 2023-09-08 中船重工信息科技有限公司 Data acquisition method and system based on cascade Ethernet equipment
CN110166338A (en) * 2019-05-17 2019-08-23 华东师范大学 A kind of Cascading Methods of serial communication interface

Also Published As

Publication number Publication date
CN107229586B (en) 2019-07-30

Similar Documents

Publication Publication Date Title
CN107147538B (en) Fault Locating Method based on RS485 bridge circuit device
CN104734980B (en) Industrial field bus MPR and multi protocol conversion method
CN107707447A (en) A kind of slave station system and control method based on EtherCAT
CN102360206B (en) Control system with a plurality of spatially distributed stations and method for transmitting data in said control system
US20120102240A1 (en) Fieldbus gateway using virtual serial filedbus port and data transmission method thereof
CN105939253A (en) Industrial wireless gateway device and protocol conversion method thereof
US6401159B1 (en) Method of half-duplex serial signal control with multi-baud rate and multi-configuration
US9807036B2 (en) Apparatus and method for encoding MDIO into SGMII transmissions
CN102053935A (en) MODBUS serial communication protocol-based communication method
CN107948059A (en) EtherCAT and Modbus protocol conversion gateways based on SPARC architecture microprocessors
CN201708820U (en) Protocol converter of MODBUS and PROFIBUS-DP
CN107229586A (en) Communication means based on RS485 bridge circuit devices
CN105553795B (en) A method of the transmission standard Ethernet data in Industrial Ethernet
CN104331028A (en) Control device and bus system
CN103377170B (en) SPI high-speed bidirectional Peer Data Communication system between heterogeneous processor
CN108228521A (en) A kind of Serial Communication at High Speed on MS network
JP3638895B2 (en) Fieldbus interface board
CN205829667U (en) A kind of communication gate of RTEX Yu DeviceNET
CN100490414C (en) Method, device and network for the cyclic transmission of Ethernet telegrams
US20030099229A1 (en) Electrical device
CN101197742B (en) System and method for transmitting additional data between equipments through Ethernet interface
CN202282789U (en) SOE (SERCOS OVER EtherCAT) communication conversion card for servo driver
CN104683266A (en) Bidirectional packet transfer fail-over switch for serial communication
CN204463106U (en) UM-BUS bus run Failure Detection Controller
CN102724090A (en) Process field bus (PROFIBUS) DP/PA integrated embedded slave node communication device based on DP controller with integrated 8031 core (DPC31)

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