CN105512068A - UART simulation method achieving baud-rate self-adoption - Google Patents
UART simulation method achieving baud-rate self-adoption Download PDFInfo
- Publication number
- CN105512068A CN105512068A CN201510839360.5A CN201510839360A CN105512068A CN 105512068 A CN105512068 A CN 105512068A CN 201510839360 A CN201510839360 A CN 201510839360A CN 105512068 A CN105512068 A CN 105512068A
- Authority
- CN
- China
- Prior art keywords
- level
- timer
- baud rate
- duration
- tmin
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/382—Information transfer, e.g. on bus using universal interface adapter
- G06F13/385—Information transfer, e.g. on bus using universal interface adapter for adaptation of a particular data processing system to different peripheral devices
-
- G—PHYSICS
- G08—SIGNALLING
- G08C—TRANSMISSION SYSTEMS FOR MEASURED VALUES, CONTROL OR SIMILAR SIGNALS
- G08C17/00—Arrangements for transmitting signals characterised by the use of a wireless electrical link
- G08C17/02—Arrangements for transmitting signals characterised by the use of a wireless electrical link using a radio link
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- General Engineering & Computer Science (AREA)
- Cable Transmission Systems, Equalization Of Radio And Reduction Of Echo (AREA)
Abstract
The invention discloses a UART simulation method achieving baud-rate self-adoption. By utilizing first 20 edges of data frames, the shortest electrical level in the duration of electrical level is found out during scanning. Smoothing and debouncing operation is performed on the smallest electric level based on an actual communication condition and the condition of a hardware filter. Finally, the baud rate is used for current communication by finally determining whatever matches the duration of shortest electric level.
Description
Technical field
The present invention relates to communication field, be specifically related to a kind of method realizing the simulation UART of baud rate self-adapting.
Background technology
Along with China market economic reform reaches its maturity and the deepening constantly of power industry system reform, electricity market is introduced competition mechanism, electrical network inner management also moves towards commercialization market gradually, and the core of commercialized running be exactly power supply and power purchase both sides using the electric flux of exchange of electric power point as metering settle accounts foundation, originally the meter reading method of manual metering and statistics clearing obviously can not adapt to the needs of market businessization operation, therefore, the electrical energy metering automated system being automated as basis must be set up, to improve the collection of electric flux, transmission, the accuracy of process, reliability and promptness.
Electric Energy Acquisition System is made up of system main website, data channel, plant stand equipment three part, achieve electrical network and electric energy meter real-time data acquisition and monitoring, the functions such as the management of complete independently time-shared charge, electric flux statistics, electric energy balance, electric flux and electric power business examination robotization; And there is the remote management capability such as remote maintenance, mandate Internet user remote inquiry; And by realizing exchanges data with the system such as MIS, SCADA, DMS, EMS and share, for other subsystems provide accurate, complete information data.
Electric energy meter has many communication modes application wherein along with the progress of microelectric technique, comprises infrared communication, wire communication, wireless telecommunications, power carrier communication, serial communication.
Serial communication is a kind of can going out accepting to be converted to continuous print serial data stream from the parallel data character of CPU, can be the device of parallel data character supply CPU by the converting serial data streams of acceptance simultaneously; Baud rate is then the speed being at serial communication, refers to the change in the signal modulated unit interval later, i.e. the number of times of unit interval intercarrier Parameters variation; In the application of electric energy meter, the switching of communication baud rate all can encounter problems, sometimes and do not know electric energy meter inside baud rate and need to each baud rate carry out examination communication to determine correct baud rate, thus waste operating personnel time, add human cost.
Summary of the invention
The object of the invention is in order to provide one can when communication baud rate self-adapting, without the need to the method realizing the simulation UART of baud rate self-adapting of manual switchover.
The present invention is achieved through the following technical solutions: a kind of method realizing the simulation UART of baud rate self-adapting, and step is as follows:
A) by electric energy meter power-up initializing, open a timer, the stepping of timer is determined according to the minimum period of baud rate, and be bilateral externally interrupting input by reception pin configuration, sending pin configuration is common output, open up at least 20 buffer memorys, be T1 to T20 by front 20 cache tag simultaneously, for depositing the duration of front 19 level;
B) detect the look-at-me of electric energy meter, look-at-me detected at every turn, all edge change is charged to the value of recording timer in buffer memory, write front 20 buffer memorys all over;
C) calculate the duration of front 19 level successively, getting duration the shortest level flag is Tmin, carries out filtering process, removes undesired signal;
D) get the baud rate Tb nearest with the Tmin duration, and Tmin and Tb is mated, Tmin ≈ Tb; The match is successful then Tb be just the baud rate of Current communications; Mate unsuccessful, abandon reception data;
E) receive 19 level are resolved, and calculate the data bit of each level representative by ((Tn+1)-Tn)/Tb;
F) fixed time interval arranging timer is Tb, and closes external interrupt input;
G) each in Interruption, read the level of reception pin until finish receiving;
H) data of response send by electric energy meter after complete for the data processing of reception in the timer interruption being spaced apart Tb;
I) after being sent completely, initialize Timer, and reception pin is formulated as bilateral externally interrupting input, enter receiving mode, get back to step b.
As preferably, the filtering in described step c is treated to carries out de-jitter according to communication condition and hardware filter to the level Tmin that the duration is the shortest.
As preferably, the timer in described step a is delicate level timer.
The present invention utilizes front 20 edges of Frame, a shortest level of level duration is found out when scanning, situation according to actual communication condition and hardware filter determines to carry out a filtering de-jitter to minimum levels, the duration of the shortest level finally determined with which baud rate mates, and so this baud rate is exactly the baud rate of Current communications.
Usefulness of the present invention is: 1) utilize a timer and multiple IO edge interrupt, effective implemention multi-channel analog UART function, and efficiency is higher; 2) mated with baud rate by the level the shortest to front 20 middle duration, show that the baud rate matched is exactly the baud rate of Current communications, play the function of energy self-adaptation baud rate, again communication carried out to each baud rate without the need to operating personnel thus determine the baud rate of Current communications, saving human cost.
Embodiment
Below in conjunction with embodiment, the invention will be further described.
Realize a method of the simulation UART of baud rate self-adapting, step is as follows:
A) by electric energy meter power-up initializing, open a timer, the stepping of timer is determined according to the minimum period of baud rate, and be bilateral externally interrupting input by reception pin configuration, sending pin configuration is common output, open up at least 20 buffer memorys, be T1 to T20 by front 20 cache tag simultaneously, for depositing the duration of front 19 level;
B) detect the look-at-me of electric energy meter, look-at-me detected at every turn, all edge change is charged to the value of recording timer in buffer memory, write front 20 buffer memorys all over;
C) calculate the duration of front 19 level successively, getting duration the shortest level flag is Tmin, carries out filtering process, removes undesired signal;
D) get the baud rate Tb nearest with the Tmin duration, and Tmin and Tb is mated, Tmin ≈ Tb; The match is successful then Tb be just the baud rate of Current communications; Mate unsuccessful, abandon reception data;
E) receive 19 level are resolved, and calculate the data bit of each level representative by ((Tn+1)-Tn)/Tb;
F) fixed time interval arranging timer is Tb, and closes external interrupt input;
G) each in Interruption, read the level of reception pin until finish receiving;
H) data of response send by electric energy meter after complete for the data processing of reception in the timer interruption being spaced apart Tb;
I) after being sent completely, initialize Timer, and reception pin is formulated as bilateral externally interrupting input, enter receiving mode, get back to step b.
In present embodiment, the filtering in described step c is treated to carries out de-jitter according to communication condition and hardware filter to the level Tmin that the duration is the shortest.
In present embodiment, the timer in described step a is delicate level timer.
In present embodiment, first open a timer, the stepping of timer was determined according to the minimum period of baud rate, was less than 1/20 of the minimum period; During reception, input signal is arranged to double edge trigger, catch the value of timer and put into a buffer zone, if MCU has DMA function, DMA can be used to add edge capturing function to realize, the value of the timer in subsequent analysis buffer zone, draws the width of each level, thus analyzes the data content of communication; During transmission, according to start bit, data content, parity check bit, position of rest etc., determine the sending duration of each level, according to the comparison trigging signal pattern of timer, compare IO and export.
In present embodiment, according to various different stipulations, one frame data have 20 level changes at least, the present invention mainly utilizes front 20 edges of Frame, and affirmative existence level duration is the level of 1 baud rate in front 20 edges, such as, " DLT645-2007 " agreement in electric energy meter, DLMS agreement etc. all possesses this feature, be exactly when detecting the look-at-me of electric energy meter, find out the level that in front 20 edges, level duration is the shortest, can determine to carry out a filtering de-jitter to minimum levels according to the situation of actual communication condition and hardware filter, the duration of the shortest level finally determined with which baud rate mates, so this baud rate is exactly current baud rate.
In present embodiment, t is filter value, for removing shake, carries out choosing value according to the feature of communication and the parameter of circuit.
In present embodiment, step 1) detects the look-at-me of electric energy meter, gets edge catches, edge change is charged to the value of recording timer in buffer memory, and level minimum value register is set to 0xffff;
Step 2) detect catches whether be greater than 0, if be not more than 0, then enter step 5, as be greater than 0 calculate each level duration t (i)-t (i-1) and compute level continue figure place;
Step 3) detects this level duration and whether is less than t, if be greater than t, enters step 4, if be less than t, catches is subtracted 1, enters step 2;
Step 4) detects this duration and whether is less than minimum value register, if be not less than minimum value register, catches is subtracted 1, enters step 2, if be greater than minimum value register, and progressive step 5;
This level duration of step 5) upgrades minimum value register;
Step 6) show that the time of minimum value register is exactly the baud rate of communication, and arranges the baud rate of communication.
Protection scope of the present invention includes but not limited to above embodiment, and protection scope of the present invention is as the criterion with claims, and any replacement that those skilled in the art will find apparent that, distortion, improvement made this technology all falls into protection scope of the present invention.
Claims (3)
1. realize a method of the simulation UART of baud rate self-adapting, it is characterized in that, step is as follows:
A) by electric energy meter power-up initializing, open a timer, the stepping of timer is determined according to the minimum period of baud rate, and be bilateral externally interrupting input by reception pin configuration, sending pin configuration is common output, open up at least 20 buffer memorys, be T1 to T20 by front 20 cache tag simultaneously, for depositing the duration of front 19 level;
B) detect the look-at-me of electric energy meter, look-at-me detected at every turn, all edge change is charged to the value of recording timer in buffer memory, write front 20 buffer memorys all over;
C) calculate the duration of front 19 level successively, getting duration the shortest level flag is Tmin, carries out filtering process, removes undesired signal;
D) get the baud rate Tb nearest with the Tmin duration, and Tmin and Tb is mated, Tmin ≈ Tb; The match is successful then Tb be just the baud rate of Current communications; Mate unsuccessful, abandon reception data;
E) receive 19 level are resolved, and calculate the data bit of each level representative by ((Tn+1)-Tn)/Tb;
F) fixed time interval arranging timer is Tb, and closes external interrupt input;
G) each in Interruption, read the level of reception pin until finish receiving;
H) data of response send by electric energy meter after complete for the data processing of reception in the timer interruption being spaced apart Tb;
I) after being sent completely, initialize Timer, and reception pin is formulated as bilateral externally interrupting input, enter receiving mode, get back to step b.
2. a kind of method realizing the simulation UART of baud rate self-adapting according to claim 1, is characterized in that: the filtering in described step c is treated to carries out de-jitter according to communication condition and hardware filter to the level Tmin that the duration is the shortest.
3. a kind of method realizing the simulation UART of baud rate self-adapting according to claim 1, is characterized in that: the timer in described step a is delicate level timer.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510839360.5A CN105512068A (en) | 2015-11-27 | 2015-11-27 | UART simulation method achieving baud-rate self-adoption |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510839360.5A CN105512068A (en) | 2015-11-27 | 2015-11-27 | UART simulation method achieving baud-rate self-adoption |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105512068A true CN105512068A (en) | 2016-04-20 |
Family
ID=55720065
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510839360.5A Pending CN105512068A (en) | 2015-11-27 | 2015-11-27 | UART simulation method achieving baud-rate self-adoption |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105512068A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106340177A (en) * | 2016-11-02 | 2017-01-18 | 北京华电知企能源技术服务有限公司 | System for automatically matching Baud rates of ammeter broadband carrier communication interface and control method thereof |
CN108257369A (en) * | 2018-03-26 | 2018-07-06 | 宁波三星医疗电气股份有限公司 | A kind of transparent transmission means of communication of meter and GPRS module |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5649122A (en) * | 1994-06-24 | 1997-07-15 | Startech Semiconductor, Inc. | Universal asynchronous receiver/transmitter with programmable xon/xoff characters |
US20050207356A1 (en) * | 2004-03-17 | 2005-09-22 | Gross Lawrence C Jr | Stand-alone device for determining communication parameters and channel configuration of an asynchronous serial channel using a user determined methodology |
CN101399635A (en) * | 2008-09-28 | 2009-04-01 | 中兴通讯股份有限公司 | Baud rate adaptation method, apparatus and host for communication |
CN102306136A (en) * | 2011-08-03 | 2012-01-04 | 宁波三星电气股份有限公司 | Baud rate self-adaption method based on input capture function of singlechip |
CN102325017A (en) * | 2011-09-06 | 2012-01-18 | 天津汇讯视通科技有限公司 | Communication speed adaption method for ball machine |
CN103684678A (en) * | 2012-11-01 | 2014-03-26 | 国网电力科学研究院 | Baud rate adaptive method for UART, device and UART |
CN104714920A (en) * | 2015-02-13 | 2015-06-17 | 暨南大学 | Baud rate self-adaptation signal receiving method |
-
2015
- 2015-11-27 CN CN201510839360.5A patent/CN105512068A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5649122A (en) * | 1994-06-24 | 1997-07-15 | Startech Semiconductor, Inc. | Universal asynchronous receiver/transmitter with programmable xon/xoff characters |
US20050207356A1 (en) * | 2004-03-17 | 2005-09-22 | Gross Lawrence C Jr | Stand-alone device for determining communication parameters and channel configuration of an asynchronous serial channel using a user determined methodology |
CN101399635A (en) * | 2008-09-28 | 2009-04-01 | 中兴通讯股份有限公司 | Baud rate adaptation method, apparatus and host for communication |
CN102306136A (en) * | 2011-08-03 | 2012-01-04 | 宁波三星电气股份有限公司 | Baud rate self-adaption method based on input capture function of singlechip |
CN102325017A (en) * | 2011-09-06 | 2012-01-18 | 天津汇讯视通科技有限公司 | Communication speed adaption method for ball machine |
CN103684678A (en) * | 2012-11-01 | 2014-03-26 | 国网电力科学研究院 | Baud rate adaptive method for UART, device and UART |
CN104714920A (en) * | 2015-02-13 | 2015-06-17 | 暨南大学 | Baud rate self-adaptation signal receiving method |
Non-Patent Citations (2)
Title |
---|
研创物联: ""UART自适应波特率的设置方法"", 《HTTP://BLOG.CSDN.NET/LINLINGPENG_/ARTICLE/DETAILS/8944993?UTM_SOURCE=TUICOOL&UTM_MEDIUM=REFERRAL》 * |
邓阳: "《高精度数字式电能表的研制》", 《中国优秀硕士学位论文全文数据库工程科技第Ⅱ辑》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106340177A (en) * | 2016-11-02 | 2017-01-18 | 北京华电知企能源技术服务有限公司 | System for automatically matching Baud rates of ammeter broadband carrier communication interface and control method thereof |
CN108257369A (en) * | 2018-03-26 | 2018-07-06 | 宁波三星医疗电气股份有限公司 | A kind of transparent transmission means of communication of meter and GPRS module |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106131083A (en) | A kind of attack message detection and take precautions against method and switch | |
CN110456234B (en) | Fault arc detection method, device and system | |
CN104199298A (en) | Controller area network (CAN) bus Baud rate self-adapting method | |
CN101783969A (en) | Comprehensive monitoring device of signal quality of digital television | |
CN105512068A (en) | UART simulation method achieving baud-rate self-adoption | |
CN104218675A (en) | Real-time online monitoring system for power distribution networks | |
CN105187070A (en) | Manchester encoding signal decoding method and device | |
CN109525803A (en) | Video structural processing unit and method based on FPGA and artificial intelligence | |
CN107566157A (en) | Remote diagnosis processing method of the ammeter completely without data fault under a kind of concentrator | |
CN101635446B (en) | Method for processing sample data based on waveform fitting and secondary sampling | |
CN102368076B (en) | Card feeding speed testing method and device | |
CN102752382B (en) | Message self-adapting method for digital input electric energy meter | |
CN115842339A (en) | Characteristic current signal identification method for distribution room topology combing | |
CN103176014B (en) | A kind of Wave data decoding apparatus and oscillograph | |
CN110658386B (en) | Capacitance switching-based household variable relation identification method and system | |
CN103369036A (en) | Point to point message synchrony-based sampling and controlling method | |
CN105468554A (en) | Method for realizing polarity-adaptive UART simulation | |
CN106405474A (en) | Electric energy meter field detection equipment having automatic quantity value source tracing function | |
CN103595505A (en) | Dynamic adaptive decoding device of FT3 frame of any code rate | |
CN110555787A (en) | Non-invasive load identification method based on improved particle swarm optimization | |
CN110224702B (en) | Time code IRIG-B self-adaptive decoding device and decoding method | |
CN204425517U (en) | Meter reading device, video camera and system | |
CN105006890B (en) | A kind of intelligent substation device program managing and control system | |
CN109474593A (en) | A method of the identification C&C periodically company's of returning behavior | |
CN105743585A (en) | Intelligent detection receiving method and device of optical IRIG (Inter Range Instrumentation Group)-B and FT3 codes |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20160420 |