CN1556608A - Method of realizing RS485 master slave multi machine communication using universal asynchronous recerver transmitter - Google Patents
Method of realizing RS485 master slave multi machine communication using universal asynchronous recerver transmitter Download PDFInfo
- Publication number
- CN1556608A CN1556608A CNA2004100002145A CN200410000214A CN1556608A CN 1556608 A CN1556608 A CN 1556608A CN A2004100002145 A CNA2004100002145 A CN A2004100002145A CN 200410000214 A CN200410000214 A CN 200410000214A CN 1556608 A CN1556608 A CN 1556608A
- Authority
- CN
- China
- Prior art keywords
- bit
- uart
- character
- frame format
- address
- 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
Links
Images
Landscapes
- Communication Control (AREA)
Abstract
The invention discloses a method for realizing RS485 master-slave multi-computer communication with universal asynchronous transceiver in communication field, when the UART is used as the master computer to call address number, the UART letter frame format is arranged as address frame format; when the UART transmits the information data to the bus or receives the information data from the bus, the UART letter frame format is arranged as information data frame format. When the letter frame format received from the RS485 bus by the UART is not the same to the format of itself, the frame format error will occur, it is abolished in the interrupt receiving procedure. The invention overcomes the deficiencies that the efficiency is low, the reliability is bad, hard to be realized, and the waste of bus is big in current technology. The invention has transplantation, versatility, compatibility. The protocol is simple, easy to be realized, the efficiency is high, and the application range is large, the function is strong.
Description
Technical field
The present invention relates to communication field, relate in particular to the method for RS485 principal and subordinate multi computer communication in the communication field.
Background technology
RS485 principal and subordinate multi computer communication system is widely used in the systems such as remote data acquisition, process control, energy conservation, safety system, automation.In these principal and subordinate's multi computer communication systems, main frame and Duo Tai slave are connected on the same RS485 bus, and the RS485 bus is managed and dispatched by main frame, when main frame has message need send to certain slave, earlier this slave are called out the numbers; Slave generally is in called state, waits for calling out the numbers of main frame.After slave receives to call out the numbers in main frame RS 485 addresses,, then receive the information data on the follow-up bus, call out the numbers otherwise continue the wait host address if identical with own RS 485 addresses.After the slave of being called out the numbers is received a complete packets of information,, then information data can be sent on the RS485 bus for the main frame reception if there is information need send to main frame.Have only the slave of being called out the numbers just to have the right to send information data to main frame, main frame must be called out the numbers to each slave in turn, and this has just guaranteed all slaves main frame of all having an opportunity to send data to.Therefore, for guaranteeing communication one to one reliably between principal and subordinate's machine, just must guarantee that the slave communication interface has the Address Recognition function.
Traditional RS485 principal and subordinate multi computer communication system generally adopts the MCS-51 series monolithic to realize the automatic recognition function of communication interface.Control bit SM2 among the microcontroller serial port controller SCON aims at the multi computer communication design, and when serial ports was worked with mode 2 or mode 3, the user can realize the communication one to one between main frame and slave easily by using multi computer communication control bit SM2.The typical character frame of MCS-51 series monolithic multi computer communication is made up of a start bit, eight bit data position, a programmable bit, a position of rest, and its form is: " start bit, D0, D1, D2, D3, D4, D5, D6, D7, TB8, position of rest ".
Wherein TB8 is a programmable bit, by be " 0 " or for " 1 " with the address call out the numbers and information data make a distinction.If the serial ports control bit SM2=1 of slave single-chip microcomputer, then when receive be address frame the time, data are just changed over to serial ports buffering SBUF, set is interrupted receiving a position RI and sent interrupt requests; During receiving data frames, do not produce interrupt requests, information is dropped.If SM2=0, then Frame still is that address frame all produces the Data Receiving interrupt requests.
But when RS485 principal and subordinate multi computer communication system all is made of UART (UART Universal Asynchronous Receiver Transmitter), when perhaps constituting (as shown in Figure 1) by single-chip microcomputer and UART mixing, because UART does not possess the automatic recognition function of communication interface hardware of above single-chip microcomputer, can not realize that the communication interface of SCM type discerns automatically, this class RS485 system just can not use single-chip microcomputer principal and subordinate multi computer communication agreement.Therefore their RS485 serial communication protocol adopts following method usually: the message bag that has obvious characteristic of the prior agreement of main frame transmission is set up the RS485 communication to slave and is shaken hands; Slave feature is according to a preconcerted arrangement analyzed the data flow of receiving, it is addressing that main frame the sends message bag of calling out the numbers that the message bag that feature all meets just is identified, and then determines whether setting up the RS485 communication with main frame according to message content.This class is used for the message packet format that communication shakes hands and is generally: " initial symbol, slave addresses, message-length, message body, end mark ".It is constant, the character that acquires a special sense of agreement such as @, $, cr in advance that wherein initial symbol and end mark require, or the combination of a plurality of characters such as 0xFFFF.But when making the RS485 principal and subordinate multi computer communication system that realizes in this way constituting or constitute by UART mixing single-chip microcomputer, exist very big difficulty and a lot of shortcomings: at first be and incompatible, the platform disunity of former single-chip microcomputer principal and subordinate multimachine system by UART.When connecting single-chip microcomputer and UART slave simultaneously on the RS485 bus, system must abandon original single-chip microcomputer principal and subordinate multi computer communication agreement, develops the communications protocol that new employing is shaken hands based on the characteristic message bag again.Because the platform difference of two kinds of communications protocol is too big, from former single-chip microcomputer principal and subordinate multimachine system upgrading and very inconvenience of transition, the slave between two principal and subordinate's multimachine systems can not be transplanted easily.
Next is the agreement complexity, realizes difficulty, the development cost height.Owing to used initial symbol and end mark and so on spcial character in the agreement, just all can not carry the character that these have certain sense in slave addresses, message-length, the message body, this brings very large difficulty for the RS485 communications protocol: (1) slave UART driver must word for word be analyzed the message that the upper strata application delivery sends, this class spcial character of taking suitable method to remove to carry in the message, the UART driver also must be analyzed and reduce each message that receives simultaneously, just can give upper level applications; (2) also must avoid delimiter and end mark in the slave addresses configuration, bring very burden for the whole system data configuration; (3) length of message can not random variation, if message-length just in time equals delimiter or end mark value, also needs to carry out message and unpacks and organize bag and handle.
Once more, this type systematic also takies excess CPU time, cost height.Slave is being set up before the RS485 communication shakes hands with main frame, need to receive all data on the bus, and issue slave handshake information bag feature according to main frame data stream is analyzed, only receive the message bag that feature all meets, think that just main frame sets up communication with this slave and shake hands.Like this, before the chance of slave acquisition and host communication, need monitoring and analyze all data flow on the bus, comprise that main frame sends to the message and the message of other slave loopbacks to main frame of other slaves, during slave CPU will be in always and have much to do.Along with increasing of slave quantity on the RS485 bus, this situation will be very serious.
In addition, also efficient not high, reliability is low, range of application is little shortcoming.Above-mentioned various shortcoming has been doomed that this class methods efficient is low, poor reliability, realization difficulty, and extra delimiter and end mark expense have also taken the many bandwidth of RS485 bus.Adopt the RS485 supervisory control system of these class methods can only be applicable to that function is simple, information is few and the content occasions with limited.
Summary of the invention
Technical problem to be solved by this invention be overcome that the efficient that prior art exists is low, poor reliability, realization difficulty, shortcoming that the bus bandwidth waste is big, in the hope of a kind of unified means of communication are provided, realization all is made of UART or mixes the main frame of the RS485 principal and subordinate multi computer communication system that constitutes and the communication between the slave by UART and single-chip microcomputer, and can support efficient height of various types of UART compositions, the RS485 principal and subordinate multi computer communication system that versatility is good.
For achieving the above object, the invention provides a kind of method of utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication, it is characterized in that, may further comprise the steps:
(1) when the RS485 communication begins, the character frame format of main frame and all slave UART all is the address frame form; The UART of main frame and RS232/RS485 transducer all are in transmit status, and all slave UART and RS232/RS485 transducer all are in accepting state;
(2) main frame is called out the numbers to a certain slave (calling called slave in the following text): main frame sends 485 addresses of called slave with the address frame form, and all slaves on the RS485 bus can both be received the byte of calling out the numbers of this address form; After called slave is received the byte of calling out the numbers, the byte of will calling out the numbers and oneself 485 address relatively, find identical, so the frame format of self is set to the information data frame format; Other UART slaves are received the byte and relatively find differently in the back with self 485 address of calling out the numbers, and just abandon the byte of calling out the numbers, and do not do any processing, also are in the address frame form;
(3) after main frame sent 485 address bytes of called slave with address format, frame format was set to the information data frame format, sends complete message; Because all slave frame formats all be the address frame form except that called slave, all produce the frame format mistake when receiving in the message bag each character, have only the correctly message bag sent of reception main frame of called slave;
(4) main frame with the message of called slave send finish after, UART and RS232/RS485 transducer are set to accepting state, frame format is constant, still is the information data frame format; After called slave was received full message bag and verification correctly, UART and RS232/RS485 transducer were set to transmit status, and frame format is constant, still is the information data frame format;
(5) called slave begins to give main frame with information data frame format echo message, main frame and other slaves can both receive the echo message character, but because other slave frame formats are the address frame form, the frame format mistake takes place when receiving character, has only main frame could correctly receive the echo message of called slave;
(6) after this took turns the RS485 communication and finishes, main frame and called slave were got back to initial state again, and main frame can poll or sent message to other slaves.
Described character frame format is made up of 11 bits, start bit, eight bit data position, a communication interface discrimination bit, a position of rest, its form is as follows: " start bit, D0, D1, D2, D3, D4, D5, D6, D7, communication interface discrimination bit, position of rest ".Wherein when the communication interface discrimination bit is 1, as the address frame form; When the communication interface discrimination bit is 0, as the information data frame format.
Principal and subordinate's multi computer communication protocol format is: the address of calling out the numbers of address frame form, the message-length of data frame format, the message body of data frame format.
To having the UART that forces the odd-even check function, described communication interface discrimination bit utilizes parity check bit to realize that the character frame format of UART is set to: a start bit, 8 data bit, a check digit, a position of rest; When forcing odd, the check digit perseverance is 1, and promptly the communication interface discrimination bit is 1, is the address frame format of calling out the numbers this moment; When forcing even parity check, the check digit perseverance is 0, and promptly the communication interface discrimination bit is 0, and be the information data frame format this moment.Parity errors will take place in character frame format that receives from the RS485 bus as this class UART and the character frame format that self is provided with not simultaneously, simply abandon in interruption reception program.
To there not being the UART that forces parity function but have 9 bit data bit functions, described communication interface discrimination bit utilizes position of rest and the 9th data bits to realize, the character frame format of UART is: a start bit, 8 data bit, two position of rests, one of them position of rest is as the communication interface discrimination bit, the communication interface discrimination bit is 1 like this, and this moment, the character frame format was the address frame form.Perhaps the character frame format of UART is: start bit, preceding 8 data bit, the 9th bit data position, a position of rest, use the 9th data bit as the communication interface discrimination bit, guarantee that the 9th data bit perseverance is 0, the communication interface discrimination bit is 0, and this moment, the character frame format was the information data frame format.This class UART will judge the position of rest mistake during character on receiving bus, if when bus receives the character that the position of rest mistake takes place, simply abandon in interruption reception program; When sending character character zero is extended to 16, when sending with 9 bit data bit formats like this, just can guarantees that the 9th bit data position is always 0.
Do not force the odd-even check function to not only having, but also do not have the UART of 9 bit data bit functions, described communication interface discrimination bit utilizes position of rest and parity check bit to realize, when the character frame format of UART is: a start bit, 8 data bit, two position of rests, wherein a position of rest is as the communication interface discrimination bit, the communication interface discrimination bit is 1 like this, and this moment, the character frame format was the address frame form.When the character frame format of UART is: a start bit, 8 data bit, a check digit, a position of rest, use check digit as the communication interface discrimination bit, when dynamically adjusting the verification attribute so that the check bit perseverance is 0 according to sending character, the communication interface discrimination bit is 0, and this moment, the character frame format was the information data frame format.This class UART will judge the position of rest mistake during character on receiving bus, if when bus receives the character that the position of rest mistake takes place, simply abandon in interruption reception program; Dynamically adjust the verification attribute according to the transmission character when sending character and make that the check digit perseverance is 0.
Do not force the odd-even check function to not only having, but also do not have the UART of 9 bit data bit functions, it according to bit in the character 1 number of bits, still odd when being odd number (bit be 1 number of bits) of even parity check when being even number (bit be 1 number of bits) is adopted in decision, thereby generation is tabled look-up before sending character and just can be obtained waiting to send out the parity check attribute of character by 0 to 0xff character parity zoom table.
The present invention utilizes the principle of SM2 control bit realization principal and subordinate multi computer communication in the serial ports controller by the simulation single-chip microcomputer, adopt software approach to realize all constituting or mixing principal and subordinate's multi computer communication of the RS485 system that constitutes dexterously by UART and single-chip microcomputer by UART, unify to use UART or MCS-51 series monolithic to constitute principal and subordinate's multi computer communication protocol platform of RS485 system, overcome many shortcomings of using existing method to realize this class mixing RS485 principal and subordinate of system multi computer communication.The present invention has following advantage:
Portability, versatility, compatible good.The present invention can realize that UART and single-chip microcomputer mix principal and subordinate's multi computer communication of the RS485 system that constitutes, and need not revise the communications protocol of former single-chip microcomputer or UART, can make general module, be independent of other modules in main frame or the slave system, transplant very convenient between system.The present invention supports various types of UART, can use processor to carry the UART controller, does not need built-in single-chip microcomputer or extra serial communication treatment circuit, and cost is low, and exploitation is fast.
Agreement is simple, is easy to realize the efficient height.485 address characters when main frame is called out the numbers to slave are the address frame form, and the frame format that transmits with message is different, needn't consider to contain in the message situation of 485 address characters, greatly reduce the complexity of agreement.The present invention has realized that the communication interface of UART discerns automatically, and other slaves on the bus are not affected, and are in Idle state, and slave only just takies the CPU time when carrying out the RS485 communication with main frame.
Applied range, function are strong.Because message-length and message content are unrestricted, the RS485 serial communication can be applied to the following powerful complicated field of using: host computer using RS485 communication is transmitted IP address, MAC Address etc. to the slave with Ethernet interface and is started configuration parameter; Can be used as the backup path of each intermodule ethernet communication in the system; Can be used for cascade or outband management between system.The present invention can also use many RS485 monitoring bus management One's name is legions, the different slave system of type, adapts to various simple to complicated application.
Description of drawings
Fig. 1 is that UART mixes the RS485 principal and subordinate multi computer communication system construction drawing of forming with single-chip microcomputer;
Fig. 2 is the method for the invention flow chart (selecting Fig. 2 is Figure of abstract);
Fig. 3 is slave UART communication flow figure in the method for the invention.
Embodiment
Be described in further detail below in conjunction with the enforcement of accompanying drawing technical scheme:
The present invention adopts the character frame format to distinguish in the RS485 principal and subordinate multi computer communication shown in Figure 1 address call out the numbers data and information data, with character frame format compatibility in the MCS-51 series monolithic principal and subordinate multi computer communication system.
The principal character of communication character frame format is among the present invention: form by 11 bits, and start bit, eight bit data position, a communication interface discrimination bit, a position of rest, its form is as follows:
Start bit, D0, D1, D2, D3, D4, D5, D6, D7, communication interface discrimination bit, position of rest.
Wherein when the communication interface discrimination bit is 1, as the address frame form; When the communication interface discrimination bit is 0, as the information data frame format.When UART carries out the address when waiting for that main frame is called out the numbers when calling out the numbers or as slave as main frame, UART character frame format is set to the address frame form; When UART sends information data on bus or when bus receives information data, UART character frame format is set to the information data frame format.The frame format mistake will take place in character frame format that receives from the RS485 bus as this class UART and the character frame format that self is provided with not simultaneously, simply abandon in interruption reception program.
Principal and subordinate's multi computer communication protocol format of the present invention is: the address of calling out the numbers of address frame form, the message-length of data frame format, the message body of data frame format.
For having the UART that forces the odd-even check function,, utilize and force parity function can realize the identification of UART communication interface as the ST16C550 of EXAR company etc.Method is as follows:
When UART character frame format is set to: start bit, 8 data bit, one are forced odd parity bit, a position of rest, and the parity check bit perseverance is 1 when forcing odd, and promptly the communication interface discrimination bit is 1, are the address frame format of calling out the numbers this moment; When UART character frame format is set to: a start bit, 8 data bit, a pressure even parity bit, a position of rest, the parity check bit perseverance was 0 when the pressure even parity check was set, and promptly the communication interface discrimination bit is 0, and be the information data frame format this moment.
Concrete steps are as follows, with reference to accompanying drawing 2 and accompanying drawing 3:
(1) when new round RS485 communication begins, the character frame format of main frame and all slave UART all is the address frame form; Main frame UART and RS232/RS485 transducer all are in transmit status, and all slave UART and RS232/RS485 transducer all are in accepting state.
(2) main frame is called out the numbers to slave 0# (called slave): main frame is with 485 addresses of address frame form (the communication interface discrimination bit is 1) transmission slave 0#, and all slaves on the RS485 bus can both be received the byte of calling out the numbers of this address form.After slave 0# receives the byte of calling out the numbers, the byte of will calling out the numbers and oneself 485 address relatively, find identical, so the frame format of self is set to information data frame format (the communication interface discrimination bit is 0); Other UART slaves are received the byte and relatively find differently in the back with self 485 address of calling out the numbers, and just abandon the byte of calling out the numbers, and do not do any processing, also are in the address frame form.
(3) after main frame sent 485 address bytes of slave 0# with address format, frame format was set to the information data frame format, sends complete message.Because all slave frame formats all be the address frame form except that slave 0#, all produce parity error when receiving in the message bag each character, have only the correctly message bag sent of reception main frame of slave 0#.So just having reached main frame calls out the numbers to slave 0# and sends the purpose of message to slave 0# then.
(4) main frame with the message of slave 0# send finish after, UART and RS232/RS485 transducer are set to accepting state, frame format is constant, still is the information data frame format; After slave 0# received full message bag and verification correctly, UART and RS232/RS485 transducer were set to transmit status, and frame format is constant, still is the information data frame format.
(5) slave 0# begins to give main frame with information data frame format echo message, main frame and other slaves can both receive the echo message character, but because other slave frame formats are the address frame form, parity errors takes place when receiving character, and all have only main frame could correctly receive slave 0# echo message.
(6) after this took turns the RS485 communication and finishes, main frame and slave 0# got back to initial state again, and main frame can poll or sent message to other slaves.
Force odd-even check but have the UART that surpasses 8 bit data bit functions for not having, when being UART, use position of rest and the 9th data bits to serve as the communication interface discrimination bit as the Serial Management Controller SMC of MOTOROLA MPC860.
When the character frame format of UART is: a start bit, 8 data bit, two position of rests, wherein a position of rest has served as the communication interface discrimination bit, and the communication interface discrimination bit is 1 like this, and this moment, the character frame format was the address frame form.When the character frame format of UART is: start bit, preceding 8 data bit, the 9th bit data position, a position of rest, use the 9th data bit to serve as the communication interface discrimination bit, guarantee that the 9th data bit perseverance is 0, the communication interface discrimination bit is 0, and this moment, the character frame format was the information data frame format;
Step is as follows, with reference to accompanying drawing 2 and accompanying drawing 3:
(1) when new round RS485 communication begins, main frame is the address frame form, and main frame UART and RS232/RS485 transducer all are in transmit status; All slave UART and RS232/RS485 transducer all are in accepting state, and slave is address frame form (the communication interface discrimination bit is 1).
(2) main frame is called out the numbers to slave 0#: main frame is with 485 addresses of address frame form transmission slave 0#, and all slaves on the RS485 bus can both be received the byte of calling out the numbers of this address form.After slave 0# receives the byte of calling out the numbers, the byte of will calling out the numbers and oneself 485 address relatively, find identical, so will self be made as information data frame format (the communication interface discrimination bit is 0); Other slaves are received the byte and relatively find differently in the back with self 485 address of calling out the numbers, and just abandon the byte of calling out the numbers, and do not do any processing, also are in the address frame form.
(3) after main frame sent 485 address bytes of slave 0# with the address frame form, UART character frame format was set to the information data frame format, sends complete message.Because all slave frame formats all are the address frame form except that slave 0#, all produce the position of rest mistake when receiving each character of message bag, have only slave 0# could correctly receive the message bag that main frame is sent.So just having reached main frame calls out the numbers to slave 0# and sends the purpose of message to slave 0# then.
(4) main frame with the message of slave 0# send finish after, UART and RS232/RS485 transducer are set to accepting state, frame format is constant, still is the information data frame format; After slave 0# received full message bag and verification correctly, UART and RS232/RS485 transducer were set to transmit status, and frame format is constant, still is the information data frame format.
(5) slave 0# begins echo message to main frame, and the character of each transmission zero is extended to 16, and 0x55 expands to 0x0055 as character, when sending with 9 bit data bit formats like this, just can guarantee that the communication interface discrimination bit is always 0.Other slave frame formats are the address frame form, and the position of rest mistake takes place when receiving character, so just have only main frame could correctly receive slave 0# echo message.
(6) after this took turns RS48 5 communications and finishes, main frame and slave 0# got back to the initial address frame format again, and main frame can poll or sent message to other slaves.
Force odd-even check for not having, do not have the UART that surpasses 8 bit data bit functions again,, use position of rest and parity check bit to serve as the communication interface discrimination bit as the UART that Intel IXP1200 carries.
When the character frame format of UART is: a start bit, 8 data bit, two position of rests, wherein a position of rest has served as the communication interface discrimination bit, and the communication interface discrimination bit is 1 like this, and this moment, the character frame format was the address frame form.When the character frame format of UART is: a start bit, 8 data bit, a check digit, a position of rest, use check digit to serve as the communication interface discrimination bit, when dynamically adjusting the verification attribute so that the check bit perseverance is 0 according to sending character, the communication interface discrimination bit is 0, and this moment, the character frame format was the information data frame format.
The UART character only detects the position of rest mistake when receiving and ignores the odd-even check dislocation.Implementation step is similar to last class UART, just some difference when UART transmission information data is on bus: parity check value of setting of each character of calculated in advance (0-0xff) makes the communication interface discrimination bit that sends character be always 0; Then according to the character that sends, look into " character parity zoom table ", see attached list 1, draw its parity check value of setting, as to send character be 0x55, and its parity check value of setting is even parity check, and the transmission character is 0x54, its parity check value of setting is an odd, so just can be always 0 by the communication interface discrimination bit.
Table 1 sends character parity value zoom table
Character to be sent | The parity check value of setting |
0x00 0x01 … … 0x54 0x55 … … 0xfe | The even parity check odd ... the odd even parity check ... odd |
0xff | Even parity check |
Claims (16)
1, a kind of method of utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication is characterized in that, may further comprise the steps:
(1) when the RS485 communication begins, the character frame format of main frame and all slave UART all is the address frame form; The UART of main frame and RS232/RS485 transducer all are in transmit status, and all slave UART and RS232/RS485 transducer all are in accepting state;
(2) main frame is called out the numbers to a certain slave: main frame is with 485 addresses of address frame form this called slave of transmission (please adjust the wording in claims, suitably upper), and all slaves on the RS485 bus can both be received the byte of calling out the numbers of this address form; After called slave is received the byte of calling out the numbers, the byte of will calling out the numbers and oneself 485 address relatively, find identical, so the frame format of self is set to the information data frame format; Other UART slaves are received the byte and relatively find differently in the back with self 485 address of calling out the numbers, and just abandon the byte of calling out the numbers, and do not do any processing, also are in the address frame form;
(3) after main frame sent 485 address bytes of called slave with address format, frame format was set to the information data frame format, sends complete message; Because all slave frame formats all be the address frame form except that called slave, all produce the frame format mistake when receiving in the message bag each character, have only the correctly message bag sent of reception main frame of called slave;
(4) main frame with the message of called slave send finish after, UART and RS232/RS485 transducer are set to accepting state, frame format is constant, still is the information data frame format; After called slave was received full message bag and verification correctly, UART and RS232/RS485 transducer were set to transmit status, and frame format is constant, still is the information data frame format;
(5) called slave begins to give main frame with information data frame format echo message, main frame and other slaves can both receive the echo message character, but because other slave frame formats are the address frame form, the frame format mistake takes place when receiving character, has only main frame could correctly receive the echo message of called slave;
(6) after the RS485 communication was finished, main frame and called slave were got back to initial state again, and main frame can poll or sent message to other slaves.
2, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 1, it is characterized in that, described character frame format is made up of 11 bits, start bit, eight bit data position, a communication interface discrimination bit, a position of rest, its form is: " start bit, D0, D1, D2, D3, D4, D5, D6, D7, communication interface discrimination bit, position of rest ".
3, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 2 is characterized in that, when the communication interface discrimination bit is 1, as the address frame form; When the communication interface discrimination bit is 0, as the information data frame format.
4, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 1 and 2, it is characterized in that principal and subordinate's multi computer communication protocol format is: the address of calling out the numbers of address frame form, the message-length of data frame format, the message body of data frame format.
5, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 1 and 2, it is characterized in that, to having the UART that forces the odd-even check function, described communication interface discrimination bit utilizes parity check bit to realize that the character frame format of UART is set to: a start bit, 8 data bit, a check digit, a position of rest; When forcing odd, the check digit perseverance is 1, and promptly the communication interface discrimination bit is 1, is the address frame format of calling out the numbers this moment; When forcing even parity check, the check digit perseverance is 0, and promptly the communication interface discrimination bit is 0, and be the information data frame format this moment.
6, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 5, it is characterized in that, character frame format that receives from the RS485 bus as UART and the character frame format that self is provided with are not simultaneously, parity errors will take place, and simply abandon in interrupting the reception program.
7, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 1 and 2, it is characterized in that, to there not being the UART that forces parity function but have 9 bit data bit functions, described communication interface discrimination bit utilizes position of rest and the 9th data bits to realize;
8, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 7, it is characterized in that, when the character frame format of UART is: a start bit, 8 data bit, two position of rests, one of them position of rest is as the communication interface discrimination bit, the communication interface discrimination bit is 1, and this moment, the character frame format was the address frame form.
9, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 7, it is characterized in that, when the character frame format of UART is: start bit, preceding 8 data bit, the 9th bit data position, a position of rest, use the 9th data bit as the communication interface discrimination bit, guarantee that the 9th data bit perseverance is 0, the communication interface discrimination bit is 0, and this moment, the character frame format was the information data frame format.
10, according to Claim 8 or the 9 described methods of utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication, it is characterized in that, UART will judge the position of rest mistake during character on receiving bus, if when bus receives the character that the position of rest mistake takes place, in interrupting the reception program, simply abandon; When sending character character zero is extended to 16, guarantees that the 9th bit data position is always 0.
11, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 1 and 2, it is characterized in that, to do not have forcing the odd-even check function, do not have the UART of 9 bit data bit functions again, described communication interface discrimination bit utilizes position of rest and parity check bit to realize.
12, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 11, it is characterized in that, when the character frame format of UART is: a start bit, 8 data bit, two position of rests, wherein a position of rest is as the communication interface discrimination bit, the communication interface discrimination bit is 1 like this, and this moment, the character frame format was the address frame form.
13, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 11, it is characterized in that, when the character frame format of UART is: a start bit, 8 data bit, a check digit, a position of rest, use check digit as the communication interface discrimination bit, when dynamically adjusting the verification attribute so that the check bit perseverance is 0 according to sending character, the communication interface discrimination bit is 0, and this moment, the character frame format was the information data frame format.
14, according to claim 12 or the 13 described methods of utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication, it is characterized in that, UART will judge the position of rest mistake during character on receiving bus, if when bus receives the character that the position of rest mistake takes place, in interrupting the reception program, simply abandon; Dynamically adjust the verification attribute according to the transmission character when sending character and make that the check digit perseverance is 0.
15, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 1 and 2, it is characterized in that, to do not have forcing the odd-even check function, not having a UART of 9 bit data bit functions again, it according to bit in the character 1 number of bits, even parity check or odd are adopted in decision, thereby generation is tabled look-up before sending character and just can be obtained waiting to send out the parity check attribute of character by 0 to 0xff character parity zoom table.
16, the method for utilizing UART Universal Asynchronous Receiver Transmitter to realize RS485 principal and subordinate multi computer communication according to claim 15, it is characterized in that, when bit is that 1 number of bits adopts even parity check during for even number, when bit is that 1 number of bits adopts odd during for odd number.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2004100002145A CN1306753C (en) | 2004-01-05 | 2004-01-05 | Method of realizing RS485 master slave multi machine communication using universal asynchronous recerver transmitter |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2004100002145A CN1306753C (en) | 2004-01-05 | 2004-01-05 | Method of realizing RS485 master slave multi machine communication using universal asynchronous recerver transmitter |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1556608A true CN1556608A (en) | 2004-12-22 |
CN1306753C CN1306753C (en) | 2007-03-21 |
Family
ID=34350369
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2004100002145A Expired - Fee Related CN1306753C (en) | 2004-01-05 | 2004-01-05 | Method of realizing RS485 master slave multi machine communication using universal asynchronous recerver transmitter |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN1306753C (en) |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101136735B (en) * | 2006-09-12 | 2010-05-12 | 中兴通讯股份有限公司 | Semi-duplex serial port communication system and method using UART |
CN103546354A (en) * | 2013-10-22 | 2014-01-29 | 天津七一二通信广播有限公司 | Communicating method being based on Internet of Things electric temperature measurement equipment and enabling RS485 bus and CAN bus to be compatible |
CN104202227A (en) * | 2014-09-05 | 2014-12-10 | 无锡蓝天电子有限公司 | Fixed time slice based RS485 rapid communication method |
CN104219120A (en) * | 2014-08-11 | 2014-12-17 | 宜兴市森维电子有限公司 | Method for implementing non-polarized RS485 bus communication |
CN104794089A (en) * | 2015-05-12 | 2015-07-22 | 中国电子科技集团公司第四十七研究所 | Improved UART communication method, device and system suitable for single chip microcomputers |
CN105759691A (en) * | 2016-04-18 | 2016-07-13 | 广东芬尼克兹节能设备有限公司 | Master-slave switching communication method and system implemented through 485 port |
CN106708652A (en) * | 2016-12-29 | 2017-05-24 | 清华大学 | No-parity controller and parity server serial port communication method |
CN106899239A (en) * | 2017-03-28 | 2017-06-27 | 哈尔滨工业大学 | A kind of motor remote parameter control system and its method |
CN108055237A (en) * | 2017-11-08 | 2018-05-18 | 长春希达电子技术有限公司 | Advices plate control method based on XML format |
CN109152137A (en) * | 2018-09-03 | 2019-01-04 | 深圳市汇德科技有限公司 | A kind of anti-interference decoding apparatus and a kind of LED control system based on LED control system |
CN110048923A (en) * | 2019-04-19 | 2019-07-23 | 博能传动(苏州)有限公司 | A kind of high speed serialization asynchronous communication solution of the more baud rate self-adaptings of multimode |
CN110554984A (en) * | 2019-07-26 | 2019-12-10 | 深圳震有科技股份有限公司 | Serial port bridging method and system based on CPLD |
CN112291256A (en) * | 2020-11-06 | 2021-01-29 | 北京中航通用科技有限公司 | UART gateway data transmission method |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2738106B2 (en) * | 1990-02-06 | 1998-04-08 | 日産自動車株式会社 | Multiplex communication controller |
GB9521057D0 (en) * | 1995-10-14 | 1995-12-20 | Rover Group | Vehicle electrical systems |
JP3269530B2 (en) * | 1997-10-17 | 2002-03-25 | 日本電気株式会社 | Serial communication system and serial communication method |
-
2004
- 2004-01-05 CN CNB2004100002145A patent/CN1306753C/en not_active Expired - Fee Related
Cited By (19)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101136735B (en) * | 2006-09-12 | 2010-05-12 | 中兴通讯股份有限公司 | Semi-duplex serial port communication system and method using UART |
CN103546354A (en) * | 2013-10-22 | 2014-01-29 | 天津七一二通信广播有限公司 | Communicating method being based on Internet of Things electric temperature measurement equipment and enabling RS485 bus and CAN bus to be compatible |
CN103546354B (en) * | 2013-10-22 | 2016-06-29 | 天津七一二通信广播有限公司 | Based on the communication means that the RS485 of Internet of Things electric power temperature measuring equipment is compatible with CAN |
CN104219120A (en) * | 2014-08-11 | 2014-12-17 | 宜兴市森维电子有限公司 | Method for implementing non-polarized RS485 bus communication |
CN104202227A (en) * | 2014-09-05 | 2014-12-10 | 无锡蓝天电子有限公司 | Fixed time slice based RS485 rapid communication method |
CN104794089A (en) * | 2015-05-12 | 2015-07-22 | 中国电子科技集团公司第四十七研究所 | Improved UART communication method, device and system suitable for single chip microcomputers |
CN105759691B (en) * | 2016-04-18 | 2018-11-20 | 广东芬尼克兹节能设备有限公司 | A kind of the master-slave swap communication means and system existing by 485 causes for gossip |
CN105759691A (en) * | 2016-04-18 | 2016-07-13 | 广东芬尼克兹节能设备有限公司 | Master-slave switching communication method and system implemented through 485 port |
CN106708652A (en) * | 2016-12-29 | 2017-05-24 | 清华大学 | No-parity controller and parity server serial port communication method |
CN106708652B (en) * | 2016-12-29 | 2019-01-04 | 清华大学 | No parity controller and the serial port communication method for having even-odd check servomechanism |
CN106899239A (en) * | 2017-03-28 | 2017-06-27 | 哈尔滨工业大学 | A kind of motor remote parameter control system and its method |
CN108055237A (en) * | 2017-11-08 | 2018-05-18 | 长春希达电子技术有限公司 | Advices plate control method based on XML format |
CN109152137A (en) * | 2018-09-03 | 2019-01-04 | 深圳市汇德科技有限公司 | A kind of anti-interference decoding apparatus and a kind of LED control system based on LED control system |
CN109152137B (en) * | 2018-09-03 | 2020-12-15 | 深圳市汇德科技有限公司 | Anti-interference decoding device based on LED control system and LED control system |
CN110048923A (en) * | 2019-04-19 | 2019-07-23 | 博能传动(苏州)有限公司 | A kind of high speed serialization asynchronous communication solution of the more baud rate self-adaptings of multimode |
CN110554984A (en) * | 2019-07-26 | 2019-12-10 | 深圳震有科技股份有限公司 | Serial port bridging method and system based on CPLD |
CN110554984B (en) * | 2019-07-26 | 2023-11-03 | 深圳震有科技股份有限公司 | CPLD-based serial port bridging method and system |
CN112291256A (en) * | 2020-11-06 | 2021-01-29 | 北京中航通用科技有限公司 | UART gateway data transmission method |
CN112291256B (en) * | 2020-11-06 | 2023-12-01 | 北京中航通用科技有限公司 | UART gateway data transmission method |
Also Published As
Publication number | Publication date |
---|---|
CN1306753C (en) | 2007-03-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN1306753C (en) | Method of realizing RS485 master slave multi machine communication using universal asynchronous recerver transmitter | |
EP1189393B1 (en) | Accessing and/or controlling CAN node arrangements, including vehicle control units, during vehicle operation | |
CN1219361C (en) | Bluetooth adaptor for infrared interface and communication method therefor | |
CN1151449C (en) | System and method allowing server remote access to assets information in computer system | |
CN1770062A (en) | Method for controlling data communication between two processor and bi-processor device | |
CN102195946A (en) | Intelligent communication controller based on ARM (Advanced RISC Machines) technology | |
CN1650584A (en) | Method and apparatus for header compression in a wireless LAN | |
CN1883154A (en) | Method and apparatus of communicating security/encryption information to a physical layer transceiver | |
CN1545268A (en) | A method and system for Ethernet interface node backup | |
CN1538703A (en) | Hybrid-type data transmission appartus andmethod for high performance wireless LAN | |
CN1342938A (en) | Plug-and-play method for measuring-controlling module in RS-485 bus type measuring-controlling system and its measuring-controlling module | |
CN101080073A (en) | A between-module communication circuit and method of dual-mode communication terminal | |
CN1925386A (en) | Clock synchronizing method and first part and second part using this method | |
CN1276635C (en) | Priority enhanced information transfer device and its method | |
CN100351824C (en) | Bus system and bus interface connected to bus | |
CN1705306A (en) | A protocol automatic adapting method and apparatus | |
CN1499751A (en) | Data transmitting device and method for transmitting and receiving data and data communication system | |
CN106850660B (en) | Design method of SAE J1939 transmission protocol based on SocketCAN | |
CN1455523A (en) | Method and system of controlling network communication of automation based on blue-tooth technique | |
CN1813456A (en) | Method and system for establishing a data link layer protocol on a i2c physical layer connection | |
CN101060500A (en) | A communication socketing method and system | |
CN2450713Y (en) | Monitoring module in RS-485 bus type monitoring system | |
CN1627282A (en) | Method and equipment for carrying out synchronous data communication between one or more mobile terminals and computer | |
CN101686187A (en) | Method, device and system for prevention of interruption of service | |
CN1266883C (en) | Method for controlling network port flow |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20070321 Termination date: 20150105 |
|
EXPY | Termination of patent right or utility model |