CN102904766A - Baud rate identification method and device for serial communication and monitoring equipment - Google Patents

Baud rate identification method and device for serial communication and monitoring equipment Download PDF

Info

Publication number
CN102904766A
CN102904766A CN2011102117891A CN201110211789A CN102904766A CN 102904766 A CN102904766 A CN 102904766A CN 2011102117891 A CN2011102117891 A CN 2011102117891A CN 201110211789 A CN201110211789 A CN 201110211789A CN 102904766 A CN102904766 A CN 102904766A
Authority
CN
China
Prior art keywords
baud rate
greatest common
common divisor
data
default
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
CN2011102117891A
Other languages
Chinese (zh)
Other versions
CN102904766B (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.)
Shenzhen Infinova Ltd
Original Assignee
Shenzhen Infinova Ltd
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 Shenzhen Infinova Ltd filed Critical Shenzhen Infinova Ltd
Priority to CN201110211789.1A priority Critical patent/CN102904766B/en
Publication of CN102904766A publication Critical patent/CN102904766A/en
Application granted granted Critical
Publication of CN102904766B publication Critical patent/CN102904766B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Communication Control (AREA)

Abstract

The invention is applicable to the technical field of communication and provides a Baud rate identification method and device for serial communication and monitoring equipment. The method comprises the following steps: (1) carrying out width acquisition of preset times on received high-low level pulse signals respectively; (2) carrying out minimization on the acquired data, and obtaining the greatest common divisor of the minimized data; (3) obtaining a first Baud rate corresponding to the greatest common divisor according to the corresponding relationship between a preset greatest common divisor and a preset Baud rate; (4) re-executing the previous two steps, and obtaining a second Baud rate according to the corresponding relationship between the preset greatest common divisor and the preset Baud rate; and (5) when the first Baud rate is different from the second Baud rate and the number of acquisition times of the second Baud rate is less than that of the preset Baud rate, updating the first Baud rate to the second Baud rate, and returning to execute the step (4) until the first Baud rate and the obtained second Baud rate are the same. Thus, the flexibility and universality of the Baud rate identification method are improved.

Description

Serial communication baud rate recognition methods, device and watch-dog
Technical field
The invention belongs to communication technical field, relate in particular to a kind of serial communication baud rate recognition methods, device and watch-dog.
Background technology
In protection and monitor field, the control of watch-dog mainly to be realized by serial RS485 or RS422, this has just related to the problem that arranges of baud rate.Because the data of serial communication are the step-by-step sequential delivery, so need strict timing between each data bit, the communication that guarantee is correct only when the communicating pair baud rate is identical, could realize correct transmission and the reception of data.For example, at front end watch-dog (slave), there be special being used for that the hardware dial-up of the baud rate of front end watch-dog is set such as quick, The Cloud Terrace inside, select different baud rates by toggle switch, Configuration of baud rate such as quick, The Cloud Terrace inside is 2400, is 2400 could realize the control to headend equipment and main frame also will arrange baud rate.Yet, the change problem of baud rate is also following, headend equipment, also be that slave is installed in the various varying environments, changing baud rate quite bothers, especially be installed in the position of very high and extremely difficult dismounting such as the roof of stadiums, under suchlike environment, change baud rate and mean that the user will pay great manpower and materials cost, in order to address this problem, produced the baud rate self-adapting technology, and the baud rate that the prerequisite of the baud rate self-adapting technology data that to be requirement send from function identification main frame adopt, and be the baud rate of main frame with himself Configuration of baud rate, thereby realize that main frame is to the monitoring of slave.
The method of the baud rate that the data that traditional slave identification main frame sends adopt mainly contains following two kinds:
1, the real-time detection method of symbol width.The method requires main frame to send a certain data according to agreement, and slave is measured the symbol width of input data on the RXD pin by the timer of MCU, then calculates the baud rate of system communication to be measured.The method is used more extensive at present, but it is unrealistic to be applied in the monitoring field, all sends out fixing data because can not require before the each control of user.
2, the standard baud rate method of exhaustion.The baud rate that the standard baud rate method of exhaustion is applicable to host computer side must change between limited several fixed numbers, such as the standard value between 2400~19200, after signal procedure starts, MCU attempts the specific character that sends with different baud rate Receiving Hosts one by one, until can correctly receive, therefore, the utilization of the method has certain limitation.
Therefore, because existing baud rate recognition methods is higher to the data demand that serial communication device sends, cause flexibility and the lower problem of versatility of baud rate identification.
Summary of the invention
The purpose of the embodiment of the invention is to provide a kind of serial communication baud rate recognition methods, device and watch-dog, be intended to solve because existing baud rate recognition methods is higher to the data demand that serial communication device sends, cause flexibility and the lower problem of versatility of baud rate identification.
The embodiment of the invention is achieved in that a kind of serial communication baud rate recognition methods, and described method comprises the steps:
Step 1: the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtain the data after the collection;
Step 2: described data are carried out minimization, obtain the greatest common divisor of the data after the minimization;
Step 3: according to default greatest common divisor and the corresponding relation between the baud rate, obtain first baud rate corresponding with described greatest common divisor;
Step 4: re-execute step 1, step 2, and according to default greatest common divisor and the corresponding relation between the baud rate, obtain second baud rate corresponding with described greatest common divisor;
Step 5: judge whether described the first baud rate is identical with described the second baud rate, be, then described the second baud rate is effective baud rate, otherwise, when judging that number of times that described the second baud rate is obtained obtains number of times less than default baud rate, described the first baud rate is updated to described the second baud rate, and goes to execution in step 4.
Another purpose of the embodiment of the invention is to provide a kind of serial communication baud rate recognition device, described device comprises collecting unit, data processing unit, the first baud rate acquiring unit, the second baud rate acquiring unit, identification decision unit and baud rate updating block, wherein:
Collecting unit is used for the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtains the data after the collection;
Data processing unit is used for the data of collecting unit output are carried out minimization, obtains the greatest common divisor of the data after the minimization;
The first baud rate acquiring unit is used for according to default greatest common divisor and the corresponding relation between the baud rate, obtains first baud rate corresponding with the greatest common divisor of data processing unit output;
The second baud rate acquiring unit is used for triggering described collecting unit and described data processing unit, according to default greatest common divisor and the corresponding relation between the baud rate, obtains second baud rate corresponding with the greatest common divisor of data processing unit output;
The identification decision unit is used for the second baud rate of exporting when the first baud rate and the described second special rate acquiring unit of described the first baud rate acquiring unit output when identical, judges that described the second baud rate is effective baud rate; And
The baud rate updating block, be used for the second baud rate of exporting when the first baud rate and the described second special rate acquiring unit of described the first baud rate acquiring unit output when not identical, and judge when number of times that described the second baud rate obtains obtains number of times less than default baud rate, described the first baud rate is updated to described the second baud rate, triggers described the second baud rate acquiring unit.
Another purpose of the embodiment of the invention is to provide a kind of watch-dog that comprises above-mentioned serial communication baud rate recognition device.
The embodiment of the invention is by the step 1 of this serial communication baud rate recognition methods: the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtain the data after the collection; Step 2: after these data are carried out minimization, obtain the greatest common divisor of the data after the minimization; Step 3: according to default greatest common divisor and the corresponding relation between the baud rate, obtain first baud rate corresponding with this greatest common divisor; Step 4: re-execute step 1, step 2, and according to default greatest common divisor and the corresponding relation between the baud rate, obtain second baud rate corresponding with described greatest common divisor; Step 5: judge whether this first baud rate is identical with this second baud rate, be, then this second baud rate is effective baud rate, otherwise, when judging that number of times that this second baud rate is obtained obtains number of times less than default baud rate, this first baud rate is updated to the second baud rate, go to execution in step 4, solved because existing baud rate recognition methods is higher to the data demand that serial communication device sends, the flexibility and the lower problem of versatility that cause baud rate identification, thereby broken away from sending the restriction of data, improved flexibility and the versatility of baud rate recognition methods.
Description of drawings
Fig. 1 is the realization flow figure of the serial communication baud rate recognition methods that provides of first embodiment of the invention;
Fig. 2 is the structure chart of the serial communication baud rate recognition device that provides of second embodiment of the invention;
Fig. 3 is the concrete structure figure of data processing unit in the serial communication baud rate recognition device that provides of second embodiment of the invention.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, is not intended to limit the present invention.
The embodiment of the invention is by respectively carrying out the collection of preset times to the high-low level pulse signal width that receives, data after the collection of obtaining are carried out minimization, obtain the greatest common divisor of the data after this minimization, according to default greatest common divisor and the corresponding relation between the baud rate, obtain first baud rate corresponding with this greatest common divisor, after this first baud rate is obtained, the step that repeating signal collection and greatest common divisor obtain, obtain second baud rate corresponding with this greatest common divisor, judge whether this first baud rate is identical with this second baud rate, be, then this second baud rate is effective baud rate, otherwise, when judging that number of times that nursery rhymes the second baud rate is obtained obtains number of times less than default baud rate, this first baud rate is updated to this second baud rate, return and carry out the step of obtaining the second baud rate, until this first baud rate is identical with this second baud rate, so that the flexibility of baud rate recognition methods and versatility obtain larger raising.
The embodiment of the invention provides a kind of serial communication baud rate recognition methods, and described method comprises the steps:
Step 1: the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtain the data after the collection;
Step 2: described data are carried out minimization, obtain the greatest common divisor of the data after the minimization;
Step 3: according to default greatest common divisor and the corresponding relation between the baud rate, obtain first baud rate corresponding with described greatest common divisor;
Step 4: re-execute step 1, step 2, and according to default greatest common divisor and the corresponding relation between the baud rate, obtain second baud rate corresponding with described greatest common divisor;
Step 5: judge whether described the first baud rate is identical with described the second baud rate, be, then described the second baud rate is effective baud rate, otherwise, when judging that number of times that described the second baud rate is obtained obtains number of times less than default baud rate, described the first baud rate is updated to described the second baud rate, and goes to execution in step 4.
The embodiment of the invention also provides a kind of serial communication baud rate recognition device, described device comprises collecting unit, data processing unit, the first baud rate acquiring unit, the second baud rate acquiring unit, identification decision unit and baud rate updating block, wherein:
Collecting unit is used for the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtains the data after the collection;
Data processing unit is used for the data of collecting unit output are carried out minimization, obtains the greatest common divisor of the data after the minimization;
The first baud rate acquiring unit is used for according to default greatest common divisor and the corresponding relation between the baud rate, obtains first baud rate corresponding with the greatest common divisor of data processing unit output;
The second baud rate acquiring unit is used for triggering described collecting unit and described data processing unit, according to default greatest common divisor and the corresponding relation between the baud rate, obtains second baud rate corresponding with the greatest common divisor of data processing unit output;
The identification decision unit is used for the second baud rate of exporting when the first baud rate and the described second special rate acquiring unit of described the first baud rate acquiring unit output when identical, judges that described the second baud rate is effective baud rate; And
The baud rate updating block, not identical with the second baud rate of the described second special rate acquiring unit output for the first baud rate when described the first baud rate acquiring unit output, and judge when number of times that described the second baud rate obtains obtains number of times less than default baud rate, described the first baud rate is updated to described the second baud rate, triggers described the second baud rate acquiring unit.
The embodiment of the invention also provides a kind of watch-dog that comprises above-mentioned serial communication baud rate recognition device.
The embodiment of the invention is by step 1: the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtain the data after the collection; Step 2: after these data are carried out minimization, obtain the greatest common divisor of the data after the minimization; Step 3: according to default greatest common divisor and the corresponding relation between the baud rate, obtain first baud rate corresponding with this greatest common divisor; Step 4: re-execute step 1, step 2, and according to default greatest common divisor and the corresponding relation between the baud rate, obtain second baud rate corresponding with described greatest common divisor; Step 5: judge whether this first baud rate is identical with this second baud rate, be, then this second baud rate is effective baud rate, otherwise, when judging that number of times that described the second baud rate is obtained obtains number of times less than default baud rate, this first baud rate is updated to the second baud rate, and goes to execution in step 4, thereby solved flexibility and the lower problem of versatility of baud rate identification, improved flexibility and the versatility of baud rate recognition methods.
Below in conjunction with specific embodiment specific implementation of the present invention is described in detail:
Embodiment one:
In the serial communication technology field, the serial communication data form is as follows: 1 start bit, 8 bit data positions, 1 position of rest, no parity position.Wherein start bit is always 0, and position of rest is always the level height of 1,8 bit data position by the data decision of transmission.Want the baud rate of data measured, as long as obtain the transmission time of bits per inch certificate, i.e. the bit wide of every bit data.For example, pulse duration realizes by the FPGA counting, when using crystal oscillator to be 48M HZ, the data baud rate is 2400,4800,9600,19200, during 38400Baud, corresponding every bit transmission time is about 26us~417us, and corresponding every bit width counting is 20000,10000,5000,2500,1250 etc.No matter how many baud rates is, collected pulse duration all is 1250 integral multiple in theory.
Fig. 1 shows the realization flow of the serial communication baud rate recognition methods that first embodiment of the invention provides, and details are as follows:
In step S101, the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtain the data after the collection.
Wherein, the pulse signal that this high-low level pulse signal can send for coming from 485 chips, pulse signal width is by being positioned at the FPGA of slave, the counting such as single-chip microcomputer is realized, when high level pulse or the low level pulse deration of signal are gathered, the bit wide of supposing 1bit is t, the pulse duration that the pulse duration that then collects also namely gathers, be m * t, 1≤m≤9 wherein, because the figure place of high impulse all is 19 bit widths to all data bit from 1 bit wide only only having position of rest, limiting case is that data bit all is that the m of 1 high impulse has at most 9 kinds of situations, and in like manner the m maximum of low pulse also is 9, thereby determines that m is 9 to the maximum.Because start bit is always 0 in 485 communication protocols, position of rest is always 1, also namely the data bits of this signal is always 9 low levels or high level, when high level or low level pulse signal are gathered, at least gather 9 times, also namely this preset times for being no less than 9 times, but when considering number of times greater than 9 situation, the pulse data that gathers can duplicate phenomenon, and therefore general times of collection gets 9.
In embodiments of the present invention, before step S101, the recognition methods of this serial communication baud rate also comprises:
Reception is from the solicited message of MCU, judges whether this solicited message is that request is obtained in baud rate identification, when this solicited message is baud rate identification when obtaining request, and execution in step S101, otherwise do not carry out.
Particularly, slave is after self check is finished, for example, the spherical camera self check, the MCU in the slave can issue FPGA solicited message in the slave by serial ports, this solicited message can be obtained or the expanded function information acquisition request such as rotation speed of the fan, warning message for baud rate rate identification, FPGA judges that whether this solicited message is that request is obtained in baud rate identification, is, then the baud rate that adopts of FPGA control signal that RS485 is sent is identified and obtained, otherwise, do not carry out baud rate identification and obtain.
In step S102, these data are carried out minimization after, obtain the greatest common divisor of the data after the minimization.
This step S102 is specially:
These data divided by default divisor, are obtained corresponding merchant and remainder;
When this remainder was in default scope, the merchant that this remainder is corresponding added 1, otherwise discussed constantly, obtained the greatest common divisor of the merchant after the processing.
In specific implementation process, because the value of pulsewidth counting is all larger, these data of also namely obtaining are larger, relatively expend the FPGA resource, so need to carry out minimization to these data, convenient follow-up calculating of obtaining greatest common divisor, and because pulse duration is passed through FPGA, the counting such as single-chip microcomputer is realized, when using crystal oscillator as 48M HZ, corresponding every bit width counting is 20000,10000,5000,2500,1250 etc., then the default divisor of selection is 1250 integral multiple, for example unified divided by 1250, maximum pulse width is 180000 o'clock, and the merchant's who obtains maximum is 144, thereby these data of obtaining have been carried out minimization.Further, in conjunction with actual conditions, wide pulse width theoretical value is 180000, and namely in the situation that baud rate 2400, data are 00, and start bit is 0, totally 9 of low pulses, and every bit width counting is in 20000 the situation, pulsewidth stuck-at-1 80000; Perhaps data are FF, and position of rest is 1, totally 9 of high impulses, add the time interval between byte and the byte, so when count value surpasses 180000, as considering error, when count value surpasses 180050, the data obtained can be forced to change 180000 into, avoid the calculating of larger data.
In addition, owing to using the count frequency of FPGA up to 48MHz, counting is very accurate, most data are not 1250 integral multiples, so to data ask the merchant, this step that rems also is a vital step, can not omit, for example with these data divided by 1250 after, obtain merchant corresponding to each data and remainder, when this remainder is in default scope, for example, for the default scope of embodiment of the invention optimum [625 1250) time, the merchant that this remainder is corresponding adds 1, otherwise, discuss constantly, obtain the greatest common divisor of the merchant after the processing.
Concrete asking in the greatest common divisor process, can directly ask greatest common divisor to all merchants that obtain, also the merchant after this processing can be carried out the size ordering, identical numerical value only keeps one, form an array, owing to only high level and the low level pulse deration of signal are gathered, and the data that gather have repetition, then the length of this array mostly is 9 most, data to this array the inside are asked greatest common divisor, be made as g, then g * 1250 are high level and the low level duration that gathers or are the narrowest pulsewidth in the pulse duration, and this pulsewidth is the integral multiple of 1bit pulsewidth.
In step S103, according to default greatest common divisor and the corresponding relation between the baud rate, obtain first baud rate corresponding with the greatest common divisor of data after this minimization.
Wherein, the greatest common divisor that this is default and the corresponding relation between the baud rate, once be not limited to relation shown in the table one, this table one is 1250 for default divisor, the situation of 1bit bit wide such as following table:
Greatest common divisor Baud rate (Baud) Pulse duration (bit)
1 38400 1250
2 19200 2500
4 9600 5000
8 4800 10000
16 2400 20000
Table one
In step S104, the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtain the data after the collection.
In step S105, these data are carried out minimization, obtain the greatest common divisor of the data after the minimization.
In step S106, and according to default greatest common divisor and the corresponding relation between the baud rate, obtain second baud rate corresponding with this greatest common divisor.
In step S107, judge whether this first baud rate is identical with this second baud rate, is, execution in step S108 then, this second baud rate is effective baud rate; No, execution in step S109 then.
When this first baud rate is identical with this second baud rate, think that then this second baud rate is effective baud rate, and export this baud rate to MCU, at this moment, MCU is effective baud rate of obtaining with self Configuration of baud rate, also is the baud rate of host computer side, and stop to send baud rate identification and obtain request, thereby finished according to the baud rate identification of MCU and obtained request, obtained the baud rate of host computer side, and then realized the purpose of the serial communication of main frame and slave.
In step S109, judge whether the number of times that this second baud rate is obtained obtains number of times greater than default baud rate, and no, then execution in step S110 withdraws from this baud rate identification step, is, then execution in step S111.
In step S111, this first baud rate is updated to this second baud rate, and goes to execution in step S104.
Wherein, should default baud rate obtain number of times for preventing endless loop, set according to the user, in the actual baud rate acquisition process, generally this situation can not appear, in addition, when the number of times that obtains in this second baud rate of judgement obtains number of times greater than default baud rate, withdraw from this baud rate identification step, can export information to host computer side, for example " a baud rate None-identified! " etc. information, with reminding user.
In embodiments of the present invention, this serial communication baud rate recognition methods has solved existing slave when the baud rate that the data of identifying the main frame transmission adopt, the data demand that serial communication device is sent is higher, the flexibility and the lower problem of versatility that cause baud rate identification, thereby the high low pulse signal of energy Real-time Collection, and in identification baud rate process, adopt more practical, also greatest common divisor method more flexibly, broken away from existing baud rate recognition methods to sending the restriction of data, realized the flexibility of baud rate identification and the raising of versatility, have stronger adaptivity, and the validity that has guaranteed the baud rate that identification is obtained.
One of ordinary skill in the art will appreciate that all or part of step that realizes in above-described embodiment method is to come the relevant hardware of instruction to finish by program, described program can be stored in the computer read/write memory medium, described storage medium is such as ROM/RAM, disk, CD etc.
Embodiment two:
Fig. 2 shows the structure of the serial communication baud rate recognition device that second embodiment of the invention provides, and for convenience of explanation, only shows the part relevant with the embodiment of the invention.
This serial communication baud rate recognition device can be used for watch-dog, other safety monitoring equipment that perhaps have the baud rate recognition function, in high-speed dome camera etc., it can be the software unit that runs in these watch-dogs, also can be used as independently, suspension member is integrated in these watch-dogs or runs in the application system of these watch-dogs, this serial communication baud rate recognition device comprises collecting unit 21, data processing unit 22, the first baud rate acquiring unit 23, the second baud rate acquiring unit 24, identification decision unit 25 and baud rate updating block 26, wherein:
Collecting unit 21 is used for the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtains the data after the collection.
Wherein, the pulse signal that this high-low level pulse signal can send for coming from 485 chips, pulse signal width is by counting realizations such as FPGA, single-chip microcomputers, and this preset times is for being no less than 9 times.
Data processing unit 22 after being used for the data of collecting unit 21 outputs are carried out minimization, obtains the greatest common divisor of the data after the minimization.
These data processing unit 22 concrete structures comprise minimization unit 221 and greatest common divisor acquiring unit 222, as shown in Figure 3, and wherein:
Minimization unit 221 is used for these data obtaining corresponding merchant and remainder divided by default divisor; And
Greatest common divisor acquiring unit 222 is used for when in the scope that this remainder is being preset, and the merchant that this remainder is corresponding adds 1, otherwise discusss constantly, obtains the greatest common divisor of the merchant after the processing.
Wherein, the divisor that should preset is 1250 integral multiple, for example, selects this divisor 1250, this moment, the scope of this this remainder was 0~1249, then, select the separation of this default scope of any number conduct in this scope, in conjunction with concrete experiment situation, select this default scope for [625 1250) time, the serious forgiveness that baud rate is obtained the result is the highest, and because maximum pulse width is 180000, the merchant's who then obtains maximum is 144.
The first baud rate acquiring unit 23 is used for according to default greatest common divisor and the corresponding relation between the baud rate, obtains first baud rate corresponding with the greatest common divisor of data processing unit 22 outputs.
Greatest common divisor and the corresponding relation between the baud rate that should be default be set according to default divisor, if should default divisor be 1250, then corresponding relation be as above shown in the table one.
The second baud rate acquiring unit 24 is used for triggering this collecting unit 21 and this data processing unit 22, according to default greatest common divisor and the corresponding relation between the baud rate, obtains second baud rate corresponding with the greatest common divisor of data processing unit output.
Identification decision unit 25 is used for the second baud rate of exporting when the first baud rate and this second special rate acquiring unit 24 of 23 outputs of this first baud rate acquiring unit when identical, judges that this second baud rate is effective baud rate.
Wherein, when this first baud rate is identical with this second baud rate, think that then this second baud rate is effective baud rate, and export this baud rate to MCU, at this moment, MCU is effective baud rate of obtaining with self Configuration of baud rate, also be the baud rate of host computer side, and stop to send baud rate identification and obtain request, obtain request thereby finished according to the baud rate identification of MCU, obtain the baud rate of host computer side, and then realize the purpose of the serial communication of main frame and slave.
Baud rate updating block 26, not identical with the second baud rate of these second special rate acquiring unit 24 outputs for the first baud rate when these the first baud rate acquiring unit 23 outputs, and judge when number of times that this second baud rate obtains obtains number of times less than default baud rate, this first baud rate is updated to this second baud rate, triggers this second baud rate acquiring unit 24.
Wherein, should default baud rate obtain number of times for preventing endless loop, set according to the user, when the number of times that obtains in this second baud rate of judgement obtains number of times greater than default baud rate, withdraw from this baud rate identification step, can export information to host computer side, for example " a baud rate None-identified! " etc. information, with reminding user.
This serial communication baud rate recognition device also comprises:
The request judging unit be used for to receive the solicited message from MCU, when judging that this solicited message is baud rate identification when obtaining request, triggering collection unit 21; Otherwise, do not trigger this collecting unit 21.
Particularly, the embodiment of the invention can be integrated in this collecting unit 21, data processing unit 22, the first baud rate acquiring unit 23, the second baud rate acquiring unit 24, identification decision unit 25, baud rate updating block 26 and request judging unit in FPGA or the single-chip microcomputer, and for satisfying the demand that monitoring is controlled in real time, the judgement that employing is faster than single-chip microcomputer speed, FPGA that have parallel processing capability realizes baud rate, more can greatly reduce the control response time, guarantee the fluency of controlling.
In specific implementation process, FPGA and MCU are arranged in slave, and transmit 485 chip datas with serial ports RX and TX, and FPGA can constantly detect the pulse data that 485 chips send; Use serial ports RX2 and TX2 transmission baud rate information or other expanded function information is arranged, for example, transmit warning message and rotation speed of the fan, the information such as temperature are after ball machine or slave self check are finished, whether the request of using serial ports TX2 to judge that reception MCU sends obtains request as baud rate identification, be, then measure the baud rate of the data of receiving in inside with this baud rate recognition device, and by serial ports RX2 baud rate information is passed to MCU, otherwise, do not need to identify baud rate.
The embodiment of the invention provides a kind of serial communication baud rate recognition methods, by the step 1 of the method: the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtain the data after the collection; Step 2: after these data are carried out minimization, obtain the greatest common divisor of the data after the minimization; Step 3: according to default greatest common divisor and the corresponding relation between the baud rate, obtain first baud rate corresponding with this greatest common divisor; Step 4: re-execute step 1, step 2, and according to default greatest common divisor and the corresponding relation between the baud rate, obtain second baud rate corresponding with described greatest common divisor; Step 5: judge whether this first baud rate is identical with this second baud rate, be, then this second baud rate is effective baud rate, otherwise, when judging that number of times that this second baud rate is obtained obtains number of times less than default baud rate, this first baud rate is updated to the second baud rate, and go to execution in step 4, solved because existing baud rate recognition methods is higher to the data demand that serial communication device sends, cause flexibility and the lower problem of versatility of baud rate identification, thereby improved flexibility and the versatility of baud rate recognition methods.
The above only is preferred embodiment of the present invention, not in order to limiting the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.

Claims (10)

1. a serial communication baud rate recognition methods is characterized in that, described method comprises the steps:
Step 1: the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtain the data after the collection;
Step 2: described data are carried out minimization, obtain the greatest common divisor of the data after the minimization;
Step 3: according to default greatest common divisor and the corresponding relation between the baud rate, obtain first baud rate corresponding with described greatest common divisor;
Step 4: re-execute step 1, step 2, and according to default greatest common divisor and the corresponding relation between the baud rate, obtain second baud rate corresponding with described greatest common divisor;
Step 5: judge whether described the first baud rate is identical with described the second baud rate, be, then described the second baud rate is effective baud rate, otherwise, when judging that number of times that described the second baud rate is obtained obtains number of times less than default baud rate, described the first baud rate is updated to described the second baud rate, and goes to execution in step 4.
2. the method for claim 1 is characterized in that, before described step 1, described method also comprises:
Reception is from the solicited message of MCU, when judging that described request information is baud rate identification when obtaining request, execution in step 1.
3. the method for claim 1 is characterized in that, described preset times is for being no less than 9 times.
4. the method for claim 1 is characterized in that, described data are carried out minimization after, the step of obtaining the greatest common divisor of the data after the minimization is specially:
Described data divided by default divisor, are obtained corresponding merchant and remainder;
When described remainder was in default scope, the merchant that described remainder is corresponding added 1, otherwise discussed constantly, obtained the greatest common divisor of the merchant after the processing.
5. method as claimed in claim 4 is characterized in that, described default divisor is 1250 integral multiple.
6. a serial communication baud rate recognition device is characterized in that, described device comprises collecting unit, data processing unit, the first baud rate acquiring unit, the second baud rate acquiring unit, identification decision unit and baud rate updating block, wherein:
Collecting unit is used for the high-low level pulse signal width that receives is respectively carried out the collection of preset times, obtains the data after the collection;
Data processing unit is used for the data of collecting unit output are carried out minimization, obtains the greatest common divisor of the data after the minimization;
The first baud rate acquiring unit is used for according to default greatest common divisor and the corresponding relation between the baud rate, obtains first baud rate corresponding with the greatest common divisor of data processing unit output;
The second baud rate acquiring unit is used for triggering described collecting unit and described data processing unit, according to default greatest common divisor and the corresponding relation between the baud rate, obtains second baud rate corresponding with the greatest common divisor of data processing unit output;
The identification decision unit is used for the second baud rate of exporting when the first baud rate and the described second special rate acquiring unit of described the first baud rate acquiring unit output when identical, judges that described the second baud rate is effective baud rate; And
The baud rate updating block, not identical with the second baud rate of the described second special rate acquiring unit output for the first baud rate when described the first baud rate acquiring unit output, and judge when number of times that described the second baud rate obtains obtains number of times less than default baud rate, described the first baud rate is updated to described the second baud rate, triggers described the second baud rate acquiring unit.
7. device as claimed in claim 6 is characterized in that, described device also comprises:
The request judging unit be used for to receive the solicited message from MCU, when judging that described request information is baud rate identification when obtaining request, the triggering collection unit.
8. device as claimed in claim 6 is characterized in that, described data processing unit also comprises:
The minimization unit is used for described data obtaining corresponding merchant and remainder divided by default divisor; And
The greatest common divisor acquiring unit is used for when in the scope that described remainder is being preset, and the merchant that described remainder is corresponding adds 1, otherwise discusss constantly, obtains the greatest common divisor of the merchant after the processing.
9. device as claimed in claim 8 is characterized in that, described default divisor is 1250 integral multiple.
10. a watch-dog is characterized in that, described watch-dog comprises each described recognition device of claim 6 to 9.
CN201110211789.1A 2011-07-27 2011-07-27 Baud rate identification method and device for serial communication and monitoring equipment Expired - Fee Related CN102904766B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201110211789.1A CN102904766B (en) 2011-07-27 2011-07-27 Baud rate identification method and device for serial communication and monitoring equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110211789.1A CN102904766B (en) 2011-07-27 2011-07-27 Baud rate identification method and device for serial communication and monitoring equipment

Publications (2)

Publication Number Publication Date
CN102904766A true CN102904766A (en) 2013-01-30
CN102904766B CN102904766B (en) 2017-05-17

Family

ID=47576815

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110211789.1A Expired - Fee Related CN102904766B (en) 2011-07-27 2011-07-27 Baud rate identification method and device for serial communication and monitoring equipment

Country Status (1)

Country Link
CN (1) CN102904766B (en)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103559164A (en) * 2013-11-05 2014-02-05 深圳市科曼医疗设备有限公司 Method and device for identifying serial port baud rate
CN106034092A (en) * 2015-03-17 2016-10-19 杭州讯能科技有限公司 Method, equipment and system for automatically identifying serial port baud rate
CN106941399A (en) * 2017-03-15 2017-07-11 广州致远电子股份有限公司 A kind of dual rate CAN FD baud rate measuring method and device
CN107422874A (en) * 2017-07-24 2017-12-01 广东迪控电子科技有限公司 A kind of multifunction push key communication means
CN109389866A (en) * 2018-12-12 2019-02-26 江西理工大学 A kind of system and method for detection unmanned plane shooting
CN109976247A (en) * 2019-04-22 2019-07-05 国网上海市电力公司 A kind of power distribution station communication failure automatic monitored control system and method
CN110958156A (en) * 2019-11-14 2020-04-03 中国航空工业集团公司西安航空计算技术研究所 Baud rate detection method and device of serial communication interface
CN111431783A (en) * 2020-04-02 2020-07-17 希尔塔(苏州)信息技术有限公司 CAN bus baud rate self-adaption method
CN112003954A (en) * 2020-10-27 2020-11-27 苏州纳芯微电子股份有限公司 Data communication method, data communication system, and computer-readable storage medium
CN112448863A (en) * 2019-08-27 2021-03-05 美商安迈国际有限责任公司 Method for establishing area network serial, substrate management controller and system
CN112540641A (en) * 2020-10-29 2021-03-23 珠海格力电器股份有限公司 Clock precision correction method and device and storage medium
CN112941816A (en) * 2019-12-11 2021-06-11 重庆海尔洗衣机有限公司 Control method for laundry treating apparatus
CN115598600A (en) * 2022-11-28 2023-01-13 四川九洲电器集团有限责任公司(Cn) Secondary radar signal dynamic coding system, method, electronic equipment and medium
CN115834441A (en) * 2022-12-08 2023-03-21 珠海格力电器股份有限公司 Baud rate detection method and system, controller and electric equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080288660A1 (en) * 2003-11-12 2008-11-20 Sridhar Balasubramanian Serial port initialization in storage system controllers
CN101399635A (en) * 2008-09-28 2009-04-01 中兴通讯股份有限公司 Baud rate adaptation method, apparatus and host for communication
CN101409716A (en) * 2008-11-25 2009-04-15 中国网络通信集团公司 Method for matching communication velocity of wireless communication module and external application module
CN101710857A (en) * 2009-11-05 2010-05-19 厦门敏讯信息技术股份有限公司 Serial communication baud rate adaptive method and device thereof

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080288660A1 (en) * 2003-11-12 2008-11-20 Sridhar Balasubramanian Serial port initialization in storage system controllers
CN101399635A (en) * 2008-09-28 2009-04-01 中兴通讯股份有限公司 Baud rate adaptation method, apparatus and host for communication
CN101409716A (en) * 2008-11-25 2009-04-15 中国网络通信集团公司 Method for matching communication velocity of wireless communication module and external application module
CN101710857A (en) * 2009-11-05 2010-05-19 厦门敏讯信息技术股份有限公司 Serial communication baud rate adaptive method and device thereof

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
乔渠,等: "串行通信波特率的自动识别", 《单片机与嵌入式系统应用》 *

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103559164A (en) * 2013-11-05 2014-02-05 深圳市科曼医疗设备有限公司 Method and device for identifying serial port baud rate
CN106034092A (en) * 2015-03-17 2016-10-19 杭州讯能科技有限公司 Method, equipment and system for automatically identifying serial port baud rate
CN106034092B (en) * 2015-03-17 2019-11-26 杭州讯能科技有限公司 Method, equipment and system for automatically identifying serial port baud rate
CN106941399B (en) * 2017-03-15 2020-04-24 广州致远电子有限公司 Baud rate measuring method and device for double-rate CAN FD
CN106941399A (en) * 2017-03-15 2017-07-11 广州致远电子股份有限公司 A kind of dual rate CAN FD baud rate measuring method and device
CN107422874A (en) * 2017-07-24 2017-12-01 广东迪控电子科技有限公司 A kind of multifunction push key communication means
CN107422874B (en) * 2017-07-24 2023-10-24 广东迪控电子科技有限公司 Multifunctional key communication method
CN109389866A (en) * 2018-12-12 2019-02-26 江西理工大学 A kind of system and method for detection unmanned plane shooting
CN109976247A (en) * 2019-04-22 2019-07-05 国网上海市电力公司 A kind of power distribution station communication failure automatic monitored control system and method
CN112448863A (en) * 2019-08-27 2021-03-05 美商安迈国际有限责任公司 Method for establishing area network serial, substrate management controller and system
CN112448863B (en) * 2019-08-27 2023-09-26 美商安迈国际有限责任公司 Method for establishing local area network serial, baseboard management controller and system
CN110958156A (en) * 2019-11-14 2020-04-03 中国航空工业集团公司西安航空计算技术研究所 Baud rate detection method and device of serial communication interface
CN112941816B (en) * 2019-12-11 2024-02-13 重庆海尔洗衣机有限公司 Control method for laundry treating apparatus
CN112941816A (en) * 2019-12-11 2021-06-11 重庆海尔洗衣机有限公司 Control method for laundry treating apparatus
CN111431783A (en) * 2020-04-02 2020-07-17 希尔塔(苏州)信息技术有限公司 CAN bus baud rate self-adaption method
CN111431783B (en) * 2020-04-02 2021-12-31 希尔塔(苏州)信息技术有限公司 CAN bus baud rate self-adaption method
CN112003954A (en) * 2020-10-27 2020-11-27 苏州纳芯微电子股份有限公司 Data communication method, data communication system, and computer-readable storage medium
CN112540641A (en) * 2020-10-29 2021-03-23 珠海格力电器股份有限公司 Clock precision correction method and device and storage medium
CN112540641B (en) * 2020-10-29 2024-04-12 珠海格力电器股份有限公司 Clock precision correction method, device and storage medium
CN115598600A (en) * 2022-11-28 2023-01-13 四川九洲电器集团有限责任公司(Cn) Secondary radar signal dynamic coding system, method, electronic equipment and medium
CN115834441A (en) * 2022-12-08 2023-03-21 珠海格力电器股份有限公司 Baud rate detection method and system, controller and electric equipment

Also Published As

Publication number Publication date
CN102904766B (en) 2017-05-17

Similar Documents

Publication Publication Date Title
CN102904766A (en) Baud rate identification method and device for serial communication and monitoring equipment
CN103995764B (en) A kind of logic analyser with serial bus protocol continuous trigger function
CN109921915B (en) Method and device for testing wake-up function of real-time clock module and electronic equipment
CN109375151B (en) Monitoring channel scheduling method and device for electric energy meter metering error on-line monitoring technology
CN105117319A (en) Method for realizing real-time monitoring of multi-channel MDIO (Management Data Input Output) devices based on FPGA
CN102122363B (en) Interactive electronic tag technology-based anti-collision method
CN103475747A (en) Electric energy meter networked system capable of automatically sending address information and sending method thereof
CN107766200A (en) A kind of I2C monitoring bus system and monitoring method
CN104035901A (en) TTCAN bus timing and data transmitting method
CN102840992A (en) Satellite-borne self-testing method based on satellite network
CN108011692A (en) A kind of data communications method for microcontroller
CN103017921A (en) Networked multipoint temperature monitoring system and method for performing data communication between upper computer and same
US9628562B2 (en) Data and event gap reconciliation across networks using different communication technologies
CN102385382A (en) Vehicle fault diagnosis device
CN102393732A (en) Vehicle fault diagnosis method
CN110363980A (en) LoRa acquisition device and its acquisition method based on TDMA and Contiki
CN107996021B (en) Data processing method and base station equipment
CN104092589B (en) The monitoring method that a kind of mixed-media network modules mixed-media and mixed-media network modules mixed-media reset
CN101631330B (en) Method and device for collecting and processing performance data
CN106487421A (en) Power line carrier communication test system and its method of testing
CN102880576B (en) Method for simulating multiple groups of UART interfaces based on STM32F103VE chip
CN204290985U (en) A kind of Novel clock synchro system
CN114095300A (en) Adaptive rate data read-write method and device
CN103839388A (en) Multiple-host RS485 perimeter alarming method
CN202662141U (en) Singlechip-based multi-path wireless alarm

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20170517

Termination date: 20210727

CF01 Termination of patent right due to non-payment of annual fee