Rudimentary Frequency Counter Using the 908QY4 Chip

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Rudimentary Frequency Counter Using the 908QY4 Chip

2,472 次查看
joeburch
Contributor III
Hello folks...
 
Please pardon this very basic question.
 
I would like to know how one might go about designing a rudimentary frequency counter using the QY4 chip.  All I need to be able to do is to measure a frequency between 3500 kHz and 30000 Khz at bench marked intervals to determine if the previous measurement as higher or lower that the one which follows it.  There is no need to display the frequency, just to compute it.  I'll be using the internal oscillator, and measurements need only be made with 1Khz resolution, nothing finer.
 
Will an external hardware prescaler be needed?
 
Which timer mode(s) would be most helpful?
 
Thanks, in advance.
 
Joe Burch - K3JLS
 
 
标签 (1)
0 项奖励
回复
3 回复数

487 次查看
YeOldeBDM
Contributor III
You would have to divide down the frequency to be in range of the parameters specified for the input pins and the timing module you chose to use using digital techniques. There should be a CMOS family of dividers that work to 30 MHZ,
The trick is to condition the input signal so its rise and fall time as well as Vinh(min) and Vinh(max) are within the required specifications of this hardware divider (prescaler).
 
Or you could use a mixer circuit to bring the frequency spectrum of the signal you wish to measure down to an appropriate input range to the micro. Thats much more complex.
 
Certainly one of these techniques is used within the various automatic transmitter antenna tuners on the market.
0 项奖励
回复

487 次查看
bigmac
Specialist III
Hello Joe,
 
The timers used in Freescale MCUs, such as the HC908QY4, are not really suited to direct frequency measurement in the tens of MHz region.  The timers are more suited to period measurement, using the input capture facility, but this has limitations for high frequency signals.
 
I have done some rough calculations for the period measurement process.  To measure the period of a high frequency signal, you will need to use an external prescaler, probably of 16 bit length.  This would mean you would be measuring the duration of 65536 input periods.  However, to achieve 1kHz resolution for an input frequency of 30 MHz, the bus rate would need to be 16 MHz, or above - well outside the capabilities of the device you intended using.  For a bus frequency of 3.2 MHz, and a prescale factor of 1, the resolution at the highest frequency would amount to about 4kHz.
 
As the input frequency decreases, the resolution will increase, but eventually the timer will overflow more than once during each period measurement (i.e. the measurement period will exceed the timer overflow period), with additional complication for the measurement process.  When this occurs, the simplest approach is probably to dynamically increase the timer prescale value until multiple overflows cease.
 
Ultimately, you would need to calculate the frequency as the reciprocal of the period, scaling and sequencing the calculations so that integer operations can be used throughout, without loss of precision.
 
To implement direct frequency measurement, i.e. directly counting the input cycles, the MCU would require the following characteristics -
  1. A timer with an external clock pin is required for the measurement signal.  Many HC08s do have this, but not the QY4 device.
  2. A second, independent timer module is required to provide the gating interval for the frequency measurement.  Generally, only the the higher end devices have more than one timer module (not to be confused with the number of timer channels).
  3. A further restriction is that the external applied frequency must not exceed the bus frequency.  Therefore, it is likely you would need an external divide by four prescaler.
  4. At the input to the external prescaler, two gates will be required, one for the gating period of the measurement, and the other for determining the count within the prescalers, both external and internal.  Since the prescale value cannot be directly read, the value is determined by the firmware applying pulses until the timer register changes state.  The second gate is used for this purpose.
Incidently, the Microchip PIC devices can readily handle direct frequency counting up to 50MHz, requiring only the two external gates.  The prescaler will accept input frequencies of 50MHz, irrespective of the MCU clock frequency.    I actually have a frequency counter that uses the 16F84A device in this manner, that was constructed from a kit.
 
Regards,
Mac
0 项奖励
回复

487 次查看
Alban
Senior Contributor II
Hello Joe,
 
I do not think this is possible to measure from 3MHz to 30MHz on such MCU.
They have a running speed of 8MHz max for the bus and I don't see any information allowing you to run the Timer (through TCLK) to such a high frequency.
I don't think the technonoly is able to support it and maybe an external divider before entering the TIM would be a rich idea.
 
Cheers,
Alban.
0 项奖励
回复