CN107621570A - A kind of digital frequency meter - Google Patents
A kind of digital frequency meter Download PDFInfo
- Publication number
- CN107621570A CN107621570A CN201710897083.2A CN201710897083A CN107621570A CN 107621570 A CN107621570 A CN 107621570A CN 201710897083 A CN201710897083 A CN 201710897083A CN 107621570 A CN107621570 A CN 107621570A
- Authority
- CN
- China
- Prior art keywords
- frequency
- chip microcomputer
- signal source
- digital frequency
- measurement
- 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
Landscapes
- Measuring Frequencies, Analyzing Spectra (AREA)
Abstract
The invention discloses a kind of digital frequency meter, and it is made up of signal source, single-chip microcomputer, drive circuit and display, and the signal source is connected with the single-chip microcomputer, and the single-chip microcomputer is connected through the drive circuit with the display.Signal source is connected to AVR single chip during measurement and catches input pin, when capture events occur, hardware records the time-stamp that event occurs automatically, then is converted into frequency and can complete to measure.Repeatedly continuous to measure by automatic measuring range, the control technology such as Validation of Data is added in the middle of measuring method, further improves systematic function.The measuring method has the advantages that occupying system resources are few, frequency range is wide, measurement accuracy is high, strong antijamming capability.
Description
Technical field
The present invention relates to frequency measurement and single-chip microcomputer control technology, more particularly to a kind of digital frequency meter.
Background technology
In scm application system, often a continuous pulse wave frequency rate is measured.In practical application, for
The measurement of the physical quantitys such as rotating speed, displacement, speed, flow, it is typically also that pulse electrical signal is first converted into by sensor, then uses
The method of measurement frequency is realized.Using measuring frequency of single-chip or cycle, typically using the Timer/Counter of single-chip microcomputer come
Complete, the basic skills and principle of measurement have it is following two, first, Measuring Frequency Method:Within the time of restriction(Such as 1 s)Detect arteries and veins
The number of punching;First, cycle test method:The time tested between the pulse number limited.Although both approaches principle is identical,
During actual use, it is necessary to according to treat the scope of measured frequency, the clock cycle of system, counter length, and required survey
The progress of the factors such as accuracy of measurement is comprehensive, specifically considers, finds and design the measuring method of suitable specific requirement.
Design and produce a frequency meter, can meet tested frequency input range it is wider, change greatly in the case of make
With, then solely it can not all reach requirement using a certain measuring method.In addition above-mentioned measurement frequency method all must
MCU 2 hardware resources must be taken, this is also method used by general single-chip microcomputer frequency measurement.The T/C1 of AVR single chip is added
Capture function, when carrying out frequency measurement using the function, not only only need to use 1 hardware resource(T/C1)Just can the execution cycle
Measurement, and more preferable measurement accuracy can also be obtained.
The content of the invention
In view of the shortcomings of the prior art, the technical problems to be solved by the invention are to propose that one kind is based on AVR single chip T/
The frequency measurement method of C1 input capture functions.Measured signal is connected to AVR single chip during measurement and catches input pin, when catching
When catching event and occurring, hardware records the time-stamp of event generation automatically, then is converted into frequency and can complete to measure.Will amount
Journey automatic conversion, repeatedly continuous to measure, the control technology such as Validation of Data is added in the middle of measuring method, is further carried
Systematic function is risen.
In order to solve the above technical problems, the present invention adopts the following technical scheme that:
A kind of digital frequency meter, it is characterised in that it is made up of signal source, single-chip microcomputer, drive circuit and display, the signal
Source is connected with the single-chip microcomputer, and the single-chip microcomputer is connected through the drive circuit with the display;During measurement, signal source is connected
It is connected to AVR single chip and catches input pin, when capture events occur, hardware records the time-stamp of event generation automatically, then
Being converted into frequency can complete to measure.
Preferably, automatic measuring range has been increased in frequency measuring process, repeatedly continuous measurement, Validation of Data etc.
Control technology, further improve systematic function.
Preferably, the signal source is pulse square wave, and its frequency range is the MHz of 1 Hz ~ 1.
Preferably, the single-chip microcomputer is AVR single chip, and concrete model selects ATmega16.
Preferably, the drive circuit is made up of reverse drive chip, model selection ULN2003A.
Preferably, the display is six common anode charactrons, and entering line frequency by the way of dynamic scan shows.
Above-mentioned technical proposal has the advantages that:Frequency measurement method is merely with one timer/counting of AVR single chip
The input capture function of device carries out frequency measurement, and super wide range frequency measurement is realized using automatic range switching, because input is caught
It is that hardware automatic synchronization replicates to catch function, and counting process is not affected, so with higher measurement accuracy;Simultaneously
System further improves measurement accuracy using repeatedly continuous measurement, and checking data validity improves the antijamming capability of measurement.Always
It, the frequency measurement method based on AVR single chip Timer/Counter capture function is that a kind of occupying system resources are few, frequency model
Enclose wide, the high measuring method of measurement accuracy.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention,
And can be practiced according to the content of specification, below with presently preferred embodiments of the present invention and coordinate accompanying drawing describe in detail such as
Afterwards.The embodiment of the present invention is shown in detail by following examples and its accompanying drawing.
Brief description of the drawings
Fig. 1 is structural representation of the embodiment of the present invention.
Fig. 2 is timer/counter input capture unit of the embodiment of the present invention.
Fig. 3 is that the embodiment of the present invention catches interrupt routine flow chart.
Fig. 4 is frequency measurement process chart of the embodiment of the present invention.
Embodiment
The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.
As shown in figure 1, a kind of digital frequency meter of the present invention its shown by 1 signal source, 2 single-chip microcomputers, 3 drive circuits and 4
Show that device forms, the signal source is connected with the single-chip microcomputer, and the single-chip microcomputer is connected through the drive circuit with the display.
Signal source is connected to AVR single chip during measurement and catches input pin, when capture events occur, hardware records event hair automatically
Raw time-stamp, then be converted into frequency and can complete to measure.By automatic measuring range, repeatedly continuous measurement, data have
The control technologies such as effect property checking are added in the middle of measuring method, further improve systematic function.The measuring method, which has, to be accounted for
With system resource is few, frequency range is wide, measurement accuracy is high, the advantages that strong antijamming capability.
The signal source of the present embodiment for pulse square wave, its frequency range is the MHz of 1 Hz ~ 1.AVR single chip is a kind of base
In enhanced risc architecture, low-power consumption, CMOS technology 8 8-digit microcontrollers, select AVR series monolithic typical products
Observing and controlling chips of the Atmega16 as the present embodiment, the frequency of its external crystal is 8 MHz.The display of the present embodiment is six
Common anode charactron, by the way of dynamic scan entering line frequency is shown, its drive circuit is made up of reverse drive chip, model choosing
Select ULN2003A.
As shown in Fig. 2 ATmega16 T/C1 is 16 Multifunction timed/counters, its input capture function is
Another very characteristic function of AVR Timer/Counters, it can be applied to accurately catch the generation of an external event, note
The time-stamp that copyist's part occurs.The trigger signal that external event occurs is caught to be inputted by pin ICP1, or analog comparator
The trigger signal that the output signal of AC0 units can also capture as external event.When an input capture event occurs, such as
Logic level change or the change of analog comparator output level on external pin ICP1(Event occurs)When, T/C1 counter
TCNT1 count value is written into input capture register ICR1, and set input capture flag bit ICF1, is produced and is interrupted Shen
Please.Input capture function can be used for frequency and the accurate measurement in cycle.
The accurate cycle is carried out using input capture function(Frequency)Measurement is actually using measured signal as ICP1's
Input, the rising of measured signal(Decline)Along the trigger signal as input capture.T/C1 is operated in conventional counter mode, right
The known system clock pulse of setting is counted.In counter course of normal operation, once input signal on ICP1 by
It is low to uprise(It is assumed that rising edge triggers input capture event)When, TCNT1 count value has synchronously been copied in register ICR1.
In short, when ICP1 input signals are by low uprise each time, TCNT1 count value all can copy to ICR1 by subsynchronous again
In.If data record in 2 continuous ICR1 can be got off in time, then 2 ICR1 difference is multiplied by known counter
In the count pulse cycle, it is exactly the time of input signal a cycle.Due in whole process, the Counts of counter not by
To any influence, the time-stamp that capture events occur is also to be copied to by hardware automatic synchronization in ICR1, therefore resulting
Periodic quantity be point-device.
Frequency measurement based on input capture function is used only the measurement that 16 T/C1 carries out the cycle, will be by during measurement
Survey signal and be connected to T/C1 seizure input pin ICP1 (PD6).T/C1 is operated in counting mode, and 8 MHz system clocks are carried out
Count, therefore the gate time of every 1 number is 0.125 μ s.T/C1 sets pin ICP1 rising edge touching as external event
Hair, once occurring rising edge on ICP1 pins, T/C1 hardware circuit copies to current TCNT1 value by automatic synchronization
In ICR1, and capture application interrupts.
As shown in figure 3, in T/C1 catches interrupt service routine, 2 ICR1 value is have recorded, one is the 0th triggering
When TCNT1 values (icp_v0), another be n-th trigger when TCNT1 values (icp_vn).When n-th value is also recorded
Afterwards, all interruptions of T/C1 are forbidden immediately, giving 2 record datas to main program carries out the judgement of validity and changing for period frequency
Calculate.The spilling that system also uses T/C1 is interrupted, and the interruption is used to record the number (full_num) that T/C1 overflows interruption, then N
Individual step-by-step counting difference (count_dif) is 65536*full_num+icp_vn-icp_v0.2 of T/C1 interrupt service
All it is very important, any one should all make an immediate response once occurring, it is impossible to be delayed, in addition, this 2 interrupt service journey
The execution time of sequence must be more short better.
Main program mainly includes the parts such as initialization, frequency measurement processing, dynamic scanning displaying, and it is first that system enters main program
First initialized, it includes I/O port initializations, interrupts the program such as initialization, system variable initialization.Enter one afterwards
Infinite Cyclic, it is substantially carried out the execution of the program such as frequency measurement processing and charactron dynamic scan.As shown in figure 4, frequency measurement
Processing procedure mainly includes calculating timer count difference, range adjust automatically, data validity judgement, and frequency calculates, next time
The contents such as measurement initialization.
The scope of frequency measured by system is the MHz of 1 Hz ~ 1, and its span is up to 106Times, to ensure that measurement accuracy is needed to it
Carry out range swithching.Specific method is the count difference value (count_dif) that program calculates N number of pulse first, is removed with count difference value
Individual pulse is obtained with pulse number N and counts number (count_n1), number adjustment frequency measurement amount is counted according to individual pulse
Journey.When system frequency is higher, timer/counter counting number is less, and the effective ways for improving measurement accuracy are repeatedly continuous
Measurement.So the basic skills of range swithching is to count number (count_n1) according to individual pulse, frequency range is substantially determined,
When frequency values are larger, pendulous frequency N is obtained larger, and when frequency values are smaller, pendulous frequency N values are smaller, and minimum value is set to 1,
Maximum is set to 1000.Simultaneously for various disturbing factors are removed, digital filter program is also add in program, i.e., is had to data
Effect property is verified that being counted twice when measured signal frequency is relatively low allows certain error, when measured signal frequency is higher,
Count difference value equal must can just think that measurement data is effective twice.
Frequency measurement based on AVR single chip T/C1 input capture functions passes through its automatic range switching, it is possible to achieve super
The frequency measurement of wide scope.Compared with typical frequency measurement method, a Timer/Counter is not used only, is saved and is
System resource, and its exclusive input capture function so that interruption process has no effect on counting, it is achieved thereby that very high measurement
Precision.In a word, it is that a kind of occupying system resources are few based on Timer/Counter capture function frequency measurement method, frequency range is wide,
The high measuring method of measurement accuracy.
A kind of digital frequency meter of the embodiment of the present invention is described in detail above, for the general technology people of this area
Member, according to the thought of the embodiment of the present invention, there will be changes in specific embodiments and applications, in summary,
This specification content should not be construed as the limitation to invention, and all any changes made according to design philosophy of the present invention are all in the present invention
Protection domain within.
Claims (6)
1. a kind of digital frequency meter, it is characterised in that it is made up of signal source, single-chip microcomputer, drive circuit and display, the letter
Number source is connected with the single-chip microcomputer, and the single-chip microcomputer is connected through the drive circuit with the display;During measurement, by signal source
It is connected to AVR single chip and catches input pin, when capture events occur, hardware records the time-stamp of event generation automatically,
Being converted into frequency again can complete to measure.
2. a kind of digital frequency meter according to claim 1, it is characterised in that increased range in frequency measuring process certainly
Turn is changed, and repeatedly the control technology such as continuous measurement, Validation of Data, further improves systematic function.
3. a kind of digital frequency meter according to claim 1, it is characterised in that the signal source is pulse square wave, its frequency
Rate scope is the MHz of 1 Hz ~ 1.
4. a kind of digital frequency meter according to claim 1, it is characterised in that the single-chip microcomputer is AVR single chip, specifically
Model selects ATmega16.
5. a kind of digital frequency meter according to claim 1, it is characterised in that the drive circuit is by reverse drive chip
Form, model selection ULN2003A.
6. a kind of digital frequency meter according to claim 1, it is characterised in that the display is six common anode numbers
Manage, entering line frequency by the way of dynamic scan shows.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710897083.2A CN107621570A (en) | 2017-09-28 | 2017-09-28 | A kind of digital frequency meter |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710897083.2A CN107621570A (en) | 2017-09-28 | 2017-09-28 | A kind of digital frequency meter |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107621570A true CN107621570A (en) | 2018-01-23 |
Family
ID=61090822
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710897083.2A Pending CN107621570A (en) | 2017-09-28 | 2017-09-28 | A kind of digital frequency meter |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107621570A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109240595A (en) * | 2018-08-24 | 2019-01-18 | 武汉中旗生物医疗电子有限公司 | Single-chip microcontroller frequency collection method and device |
CN110501940A (en) * | 2019-08-06 | 2019-11-26 | 汉腾汽车有限公司 | A kind of circuit control device of wisdom radio car mobile unit |
CN111243494A (en) * | 2019-10-22 | 2020-06-05 | 深圳市越芯电子有限责任公司 | Dynamic scanning method and device for LED nixie tube, electronic equipment and storage medium |
-
2017
- 2017-09-28 CN CN201710897083.2A patent/CN107621570A/en active Pending
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109240595A (en) * | 2018-08-24 | 2019-01-18 | 武汉中旗生物医疗电子有限公司 | Single-chip microcontroller frequency collection method and device |
CN110501940A (en) * | 2019-08-06 | 2019-11-26 | 汉腾汽车有限公司 | A kind of circuit control device of wisdom radio car mobile unit |
CN111243494A (en) * | 2019-10-22 | 2020-06-05 | 深圳市越芯电子有限责任公司 | Dynamic scanning method and device for LED nixie tube, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101976037B (en) | Method and device for measuring time intervals of repeated synchronous interpolation simulation | |
CN107621570A (en) | A kind of digital frequency meter | |
CN103837741A (en) | Equal-precision frequency testing system based on FPGA and design method thereof | |
CN105874341B (en) | Automatization test system with edge guiding | |
CN101464658A (en) | Method and apparatus for time-differential comparison of an analog signal | |
CN214895514U (en) | PWM control sequential sampling period transient frequency measuring circuit | |
US9887701B1 (en) | Frequency offset correction precision of real-time clocks | |
CN208190614U (en) | A kind of single-shot trigger circuit of the Precision Pulse width based on programmable logic chip | |
CN110324026A (en) | A kind of clock frequency detection method of chip interior clock source | |
CN106501605A (en) | One kind is than phase device | |
CN109709393A (en) | Device based on stability of frequency of time domain signal measurement | |
CN203929885U (en) | Based on FPGA etc. precision frequency testing system | |
US8144828B2 (en) | Counter/timer functionality in data acquisition systems | |
CN112505410A (en) | PWM control sequential sampling period transient frequency measuring circuit | |
CN111769822A (en) | Frequency measuring device | |
CN108333425A (en) | A kind of digital frequency meter | |
CN106814248A (en) | A kind of data processing method and device in digital Frequency Measuring | |
CN208314071U (en) | A kind of digital frequency meter | |
US9646717B2 (en) | Memory device with internal measurement of functional parameters | |
CN106443180B (en) | High-precision frequency measuring method and device for measuring self-adaption of gate | |
Teodorescu et al. | Improving time measurement precision in embedded systems with a hybrid measuring method | |
Sundaramurthy et al. | Hard real time implementation of reconfigurable virtual instruments using FPGA | |
CN112448715B (en) | Method and system for calibrating HIRC by using PES (PES) signal | |
CN105760607B (en) | The emulation component and method of emulation bus effective bandwidth based on token bucket | |
Bai et al. | The measurement of transient stability with high resolution |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20180123 |
|
WD01 | Invention patent application deemed withdrawn after publication |