• Realizes the high resolution frequency meter’s method with the PIC16F87X monolithic integrated circuit

        1 introduction

      Along with electronic technology’s rapidly expand, take the monolithic integrated circuit as the control core’s control component, already comprehensively seeped to the measuring instrument and measurement examination each aspect. At the same time, the frequency meter takes one kind of commonly used tool, in domain and so on engineering technology and radio survey, measurement applications is very widespread. This article introduced one kind realizes the method take the PIC16F87X series monolithic integrated circuit as controller’s high resolution frequency meter.

      This methods design’s frequency meter mainly uses for the measuring impulse frequency. It uses LCD graph liquid crystal display that the clarity is high, the visible scope is broad, but the external connection crystal frequency source, has the survey speed to be quick, resolution high merit.

      2 principles of design

      The PIC16F877A monolithic integrated circuit interior integration has capture/comparison/pulse-duration modulation PWM the (CCP) module. When CCP work when catches the (capture) way, may catch the external input pulse the rise along or the drop along, and has the corresponding interrupt.

      The PIC16F877A monolithic integrated circuit interior also integrated the timer/counter module, uses TMR1 in this plan to take the timer, this timer’s principle of work is “the register is right” TMR1H:TMR1L through TMR1 to increase progressively from 0000H to FFFFH, when again afterward returns to 0000H, will have the top digit overflow, and will establish overflow trap flag bit TMR1IF will be I, simultaneously will cause the CPU interrupt response.

      In the even pulse train, the pulse frequency value is equal to the pulse frequency which in the unit interval/unit time occurs. According to this principle, may use the PIC16F87X series monolithic integrated circuit (this article take the PIC16F877A monolithic integrated circuit as example) the built-in timer module TMR1 time, simultaneously uses the CCP module the capture function, is separated n(n=1,4,16) pulse to catch every time one time and has the interrupt, records 1st to time t1 with the (m-1)*n 1 pulse arrival time timer and tm, as shown in Figure 1.

    Pulse capture schematic drawing

    Figure 1 pulse capture schematic drawing

      With the pulse frequency which catches is divided 1st time the time which is separated with the (m-1)*n 1 inferior pulse between then to obtain the pulse frequency value. Therefore, the pulse frequency value formula is:

    Formula

      3 by frequency measurement rate value scope

      In test procedure, those who need the special attention is, two CCP interrupt’s time-gap must be bigger than 1 interrupt servicing the execution time. Otherwise, if in interrupt service execution time has the CCP interrupt, cannot the normal work.

      According to the above condition, then has:

    Formula

      Obtains by the above equation:

    Formula

      In the formula:

    •   SCCP - expression capture frequency division multiple.
    •   fx - expression by frequency measurement rate t
    •   TCYC - expression system clock cycle.
    •   The N - expression interrupt must the most little finger make the periodicity.

      Hypothesis: SCCP=16, N=40, TCYC= 4/20MHz = 0.2 us, then: fx<2,000,000Hz

      Thus it may be known, actual frequency measuring range between 0-2 MHz.

      If must survey a bigger frequency, may according to need turns on the corresponding multiple in the testing frequency and between the CPU CCP mouth the frequency divider, turns on a 1/n time of frequency divider every time, the observable frequency range may expand n time (as shown in Figure 2). If turns on three 1/10 time of frequency dividers in the testing frequency and between the CCP mouth, then the observable frequency range is 0~2 GHz.

    CPU external connection schematic drawing

    Figure 2 CPU external connection schematic drawing

      4 programmings

      4.1 interrupt routines

      Interrupt routine flow chart as shown in Figure 3.

    Interrupt subroutine flow chart

    Figure 3 interrupt subroutine flow chart

      The interrupt servicing subroutine is as follows:

      void interrupt TMR I_CCP2_ini(void)
    {
    if(TMR1IF==I) // judges whether timer interrupt
    {
    TMRIIF=0; //TMR1 interrupts the flag bit clear 0
    TMR1ON=0; // closes TMR1
    TMR1L=0×00; // establishes TMR1 data register starting value 0×0bdc
    TMR1H=0×00;
    TMR1ON=1;  // opens TMR1
    time_count ; // fixed time counter reduces 1
    }
    if(CCP2IF==1) // judges whether CCP2 interrupt
    {
    if(ccp_count==0)
    {
    TMR1IE=1; // permits the TMR1 interrupt
    TMR1IF=0; //TMR1 interrupts the flag bit clear 0
    T1CON=0×30; // establishes 1:8 frequency division, closes TMR1
    TMR1L=0×00; //TMR1 data register reset
    TMR1H=0×00;
    TMR1ON=1; // opens the TMR1 interrupt
    }
    CCP2IF=0; //CCP2 interrupts the flag bit clear 0
    ccp_count ; // pulse counter adds 1
    }
    }

      4.2 test procedure procedure

      Program flow diagram as shown in Figure 4.
    Master routine flow chart
             Figure 4 master routine flow chart

    The test procedure procedure is as follows:

      unsigned long measure_course (unsigned char
    catch_mode)
    {
    time_count=0; // fixed time counter reset
    ccp_count=O // pulse counter reset
    GIE=1; // permits the overall situation interrupt
    PEIE=1; // permits the periphery interrupt
    TRISC1=0; //CCP2 (RC1) input
    CCP2IE=1; // permits the CCP2 interrupt
    CCP2IF=0; //CCP2 interrupts the flag bit clear 0
    CCP2CON=catch_mode; // establishes the capture pulse pattern
    e(); // interrupts the start
    while(1) // waits for the timer interruption, the time to, then withdraws
    if(ccp_count==2)
    break;
    di(); // interrupted finishes

    TMR1ON=0; // closes TMR1
    CCP2CON=0×00; // closes CCP2
    CCP2IE=0; // closes the CCP2 interrupt
    CCP2IF=0; //CCP2 interrupts the flag bit clear 0
    TRISC1=0; //CCP2 (RC1) output
    TMR1IE=0; // closes the TMR1 interrupt
    TMR1IF=O; //TMR1 interrupts the flag bit clear 0
    PEIE=0; // closes the periphery interrupt
    GIE=0; // closes the overall situation interrupt
    ……
    }

      5 performance evaluations

      The traditional frequency measurement method has two kinds: First, measured that the week seeks the frequency, like this to is requested high by the frequency measurement rate signal’s signal-to-noise ratio, will otherwise have the big error; Another kind is in the Unit of measurement time has the pulse quantity, although this method is not high to the signal-to-noise ratio request, but the demonstration resolution is restricted, and will produce ±1 error.

      This plan has abandoned the traditional measuring technique, uses the measuring impulse integer and the computation was measured that the pulse experiences the time the method, has avoided the conventional routes malpractice completely.

      Outside this plan, CPU meets the frequency scale (as shown in Figure 2), the measuring error is only the time base error, but the good outside frequency scale’s error is smaller than generally ±10-9, thus measurement result’s significant digit most little may reach above 8, causes the low frequency survey to be consistent with the high frequency survey significant digit.

      6 conclusions

      After the test experiment, uses this method development the frequency meter to have the survey accuracy to be high, easy to operate,

    The stable reliable merit, may apply in the measurement test domain. Meanwhile as a result of the use software control, the circuit structure is simple, uses the hardware to be few, causes the cost to be inexpensive, and carries conveniently, therefore may also widely apply in the industry and agriculture production and the resident lives, has the promoted value.

    Share/Save/Bookmark

    Wednesday, October 29th, 2008 at 11:57
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

TOP
Copyright © 51 Research and Design, Electronic Engineers website - Embedded Systems, MCU, DSP, EDA, Test and Measurement, Components, Communications, Power, Microelectronics, Semiconductors
Powered by WordPress | Theme by mg12 | Valid XHTML 1.1 and CSS 3