Sign in
Wordblogger | Guest Blogging Hub for Quality Content & Cross-Industry Collaboration
Wordblogger | Guest Blogging Hub for Quality Content & Cross-Industry Collaboration
Your Position: Home - Measurement & Analysis Instruments - High Resolution Frequency Counter - Instructables
Guest Posts

High Resolution Frequency Counter - Instructables

High Resolution Frequency Counter - Instructables

The old school way to measure the frequency of a signal is to use a logic AND-gate, feed the signal to be measured into one port and a signal with an exactly 1 second high time to the other port and count the output. This works quite well for signals of a few kHz well into the GHz. But what if you want to measure a low frequency signal with good resolution? Say you want to measure the frequency of mains (here 50 Hz). With the old school method you will see a constant 50 on your display if you are lucky, but more likely you will see the display switch from 49 to 50 or 50 to 51. The resolution is 1 Hz, and that's it. You will never see 50.002 Hz unless you are willing to increase the gate time to a seconds. That's more than 16 minutes, for a single measurement!

With competitive price and timely delivery, SUIN sincerely hope to be your supplier and partner.

A better way to measure low frequency signals is to measure the period of it. Taking mains as an example again, has a period of 20 millisecond. Take the same logic AND-gate, feed it with, say 10 MHz (0.1 us pulses) and your signal on the other port and out come pulses, so the period time is .0 uS and that translates back into 50Hz. When you measure just pulses the frequency is 50.087 Hz, that's a lot better, and it is in just one second measuring time.
Unfortunately this does not work well with higher frequencies. Take for example, we now want to measure 40 kHz. With the same 10 MHz input frequency as the reference we now measure just 250 pulses. When we count just 249 pulses the calculation gives Hz and with 251 the result is Hz. That's not an acceptable resolution. Of course increasing the reference frequency improves the results but there is a limit to what you can use in a micro controller.

A solution that works for both low and higher frequencies is a reciprocal frequency counter. I'l try to explain its principle.
You start off with a measuring time that is approximately 1 second, it does not have to be very precise but it is a reasonable time for a measurement. Feed this 1 Hz signal into a D-flipflop on the D-input. Nothing happens as yet on the output(s). Connect the signal that you want to measure to the CLOCK input of the D-flipflop.

As soon as the this signal goes from LOW to HIGH, the output of the D-flipflop transfers the state of the D-input to the output (Q). This RISING signal going is used to start counting the input signal as well as a reference clock signal.

So you are counting TWO signals at exactly the same time, the signal you want to measure and a reference clock. This reference clock has to have a precise value and be stable, a normal crystal oscillator is fine. The value isn't very important as long as it is a high frequency and its value is known well.

After some time, say a few milliseconds, you make the D-input of the D-flipflop low again. At the next CLOCK-input the output Q follows the state of the input, but nothing else happens because the micro controller is set to react to a RISING signal only. Then, after the measuring time is over (approx. 1 second) you make the D-input HIGH.

Again at the next CLOCK-input the Q output follows and this RISING signal triggers the micro controller, this time to end the counting of both counters.

The result is two numbers. The first number is the number of pulses counted from the reference. As we know the reference frequency, we also know the time it took to count those pulses.

The second the number is the number of pulses from the input signal we are measuring. As we started exactly on the RISING edges of this signal we are very confident about the number of pulses of this input signal.

Now it is just a calculation to determine the frequency of the input signal.

An example, lets say we have these signals and we want to measure f-input. The reference is 10 MHz, generated by a quartz crystal oscillator. f_input = 31.416 Hz f_reference = Hz (10 MHz), the measuring time is approx. 1 second

In this time we counted 32 pulses. Now, one period of this signal takes 1 / 31.416 = .9 uS. So 32 periods took us 1. seconds, which is just over 1 second.

In this 1. second we also will have counted pulses of the reference signal.

This gives us the following information: input_count = 32 reference_count = f_reference = Hz

The formula to calculate the resulting frequency is this: freq = ( input_count * f_reference ) / ref_count

In our example that is: f-input = (32 * ) / = 31.416 Hz

And this works well for low frequencies as well as high frequencies, only when the input signal comes close (or even higher than) to the reference frequency it is better to use the standard "gated"way of measuring. But then we could also simply add a frequency-divider to the input signal as this reciprocal method has the same resolution for any frequency (up to the reference again). So whether you measure 100 kHz directly of divided by an external x divider, the resolution is the same.

The code was written in C with Atmel (Microchip) Studio 7 and programmed into the ATTINY using an OLIMEX AVR_ISP (clone?). Open the (main.c) in the zip file below if you want to follow the description here.


INITIALIZATION

First the ATTINY was set to use an external crystal as the internal RC-oscillator is useless for measuring anything. I use a 10 MHz crystal that I tune to the correct 10 000 000 Hz frequency with a small variable capacitor. The initialization takes care of setting ports to inputs and outputs, setting up the timers and enabling interrupts and initialization of the MAX. TIMER0 is setup to count an external clock, TIMER1 the internal clock and also to capture the value of the counter at the rising edge of ICP, coming from the D-flipflop.

I'll discus the main program last, so next are the interrupt routines.

TIMER0_OVF

As TIMER0 counts up to 255 (8 bits) and then rolls over to 0 we need an interrupt to count the number of overflows. That's all TIMER0_OVF does, just count the number of overflow. Later this number is combined with the value of the counter itself.

TIMER1_OVF

TIMER1 can count up to (16 bits), so the interrupt TIMER1_OVF also counts the number of overflows. But it does more. It also decrements from 152 to 0 which takes about 1 second and then sets an output pin, going to the D-input of the flipflop. And the last thing that is done in this interrupt routine is to decrement the timeout-counter, going from 765 to 0, which takes about 5 seconds.

TIMER1_CAPT

This is the TIMER1_CAPT interrupt that is triggered everytime the D-flipflop sends it a signal, at the rising edge of the input signal (as explained above). The capture logic takes care of saving the value of the TIMER1 counter at the moment of the capture, it is saved as well as the overflow counter. Unfortunately TIMER0 does not have an input capture function so here its current value and its current value of the overflow counter is read. A message-variable is set to one for he main program to tell it these is new data.

Next are two functions to control the MAX

SPI

While there is an Universal Serial Interface (USI) available in the chip I chose not to use it. The MAX display needs to be controlled via SPI and that is possible with the USI. But bitbanging SPI is so simple that I didn't take the time to do it with the USI.

MAX

The protocol to setup the MAX also is quite simple once you have read the manual of it. It needs a 16 bit value for every digit that consists of 8 bits for the digit number (1 to 8) followed by 8 bits for the number it needs to display.

MAIN-PROG

The last thing is to explain the main program. It runs in an infinite loop ( while(1) ) but only actually does do something when there is a message (1) from the interrupt routine or when the timeout counter has run down to zero (no input signal).

The first thing to do when the variable message is set to one, is reset the timeout counter, after all we know that there is a signal present. The D-flipflop is reset to make it ready for the next trigger that will come after the measuring time (wait-a-second).

The numbers registered in the capture interrupt are added to give the reference count and input-frequency count. (we have to make sure that the reference never can be zero as we will divide by it later on)

Next is a the calculation of the actual frequency. I surely do not want to use floating numbers on a microcontroller with just 2kbytes of flash and only 128 bytes of ram I use integers. But frequencies can be like 314.159 Hz, with several decimals. Therefore I multiply the input-frequency not only with the reference frequency but also with a multiplier, and then add a number to where the decimal point should go. These numbers will get very very large when you do that. E.g. with an input of 500 kHz, a reference of 10 MHz and a multiplier of 100, this gives 5 x 10^14, that's really huge! They will no langer fit in a 32 bit number so I use 64 bit numbers that will go all the way up to 1.8 x 10^19 (that works fine on an ATTINY)

And the last thing to do is to send the result to the MAX display.

The code compiles into some bytes, so it fits into the bytes flash available in the ATTINY.

The fuse-registers should read like this:


EXTENDED 0xFF

HIGH 0xDF

LOW 0xBF

Repair and look at HP A & HP A time/frequency counters

  • Intro
  • Disclaimer
  • Manuals references, firmware dumps and service information
  • HP A with channel 3 input option with 3 GHz range
  • Agilent A Counter
  • Quick look inside current Keysight A and option 015
  • Difference between A and A and possible DIY upgrade
  • Some measurements and benchmarks
  • Summary and conclusion

Intro

Frequency and timing counters are useful tools for electronics engineering. With xDevs.com’s main focus in the DC metrology domain, it’s not the first instrument that comes to mind for the bench, so until today there was no good low-frequency counter in the lab. Now, this shortcoming was alleviated to support with some timings and delay measurements for new in-house ADC/DAC projects.

Thanks to friendly support, I’ve got now working HP A unit and broken Agilent A. In this article we will take a look inside the both units, work on possible repairs and perhaps take few measurements to get overall idea of these counters performance.

Model X and A counters are obsoleted now and replaced by newer fancy Keysight series instruments which bring better performance, newer LCD-based UI and additional options. /A still are very capable instruments and can be purchased on secondary used market for anything from few hundred USD up to 1k$ depending on condition, faults and included options. A is cheaper two channel version of the counter. Main difference for options is for additional third port input with frequency range from 3 GHz to 12.4 GHz and various ovenized internal time base options for more precise measurements.

These half-rack sized instruments can also have a number of the options available for additional functionality:

  • Option 001 – Medium stability timebase
  • Option 002 – External DC power supply option, 10 to 32 VDC, 4 A inrush
  • Option 010 – High stability timebase
  • Option 012 – Ultra high stability timebase
  • Option 015 – 1.5GHz 50 Ω Input 2 for A only
  • Option 030 – Input 3 with 100 MHz to 3 GHz 50 Ω BNC input frequency range, -21 dBm to +13 dBm
  • Option 050 – Input 3 with 100 MHz to 5 GHz 50 Ω N type input frequency range, -27 dBm to +13 dBm
  • Option 124 – Input 3 with 100 MHz to 12.4 GHz 50 Ω N type input frequency range
  • Option 060 – Rear-panel connectors option
A A A A Channels 1 to 3 1 to 3 1 to 2 1 to 3 Input sensitivity 20 mVRMS to ±5 VAC-DC for 50 Ω Trigger level ±5.125V with 5mV resolution Gate time 1ms to s 1 µs to s Bandwidth 1 mHz to 225 MHz (1.5, 3, 5, 12.4 GHz opt) 1 mHz to 350 MHz (6, 15 GHz opt) Resolution 10 digits/s 12 digits/s 10 digits/s 12 digits/s, max 15 digits Time interval resolution 500 ps 150 ps 500 ps 20 ps Timebase stability ±5 ppm (<2.5 ppb option) ±1 ppm (<0.3 ppb option 010) Timebase ageing ±0.3 ppm/month (0.02 ppm/year optional) ±0.2 ppm/month (±0.05 year option 010) Speed 200 measurements/sd - readings/s Interfaces GPIB, RS-232 USB,LXI LAN, GPIB optional Battery power None Option 300 Released price Obsolete, no longer supported USD

Table above shows comparison of key parameters between different models, including modern replacement improved A. Cheaper Keysight A ( USD) provide performance similar to A and mid-range Keysight A ( USD) replaces A.

Disclaimer

Redistribution and use of this article or any images or files referenced in it, in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of article must retain the above copyright notice, this list of conditions, link to this page (/fix/hpX/) and the following disclaimer.
  • Redistributions of files in binary form must reproduce the above copyright notice, this list of conditions, link to this page (/fix/hpX/), and the following disclaimer in the documentation and/or other materials provided with the distribution, for example Readme file.

All information posted here is hosted just for education purposes and provided AS IS. In no event shall the author, xDevs.com site, or any other 3rd party, including HP/Agilent/Keysight be liable for any special, direct, indirect, or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortuous action, arising out of or in connection with the use or performance of information published here.

If you willing to contribute or add your experience regarding HP/Agilent/Keysight instruments repairs or provide extra information, you can do so following these simple instructions

Manuals references, firmware dumps and service information

Before we begin digging into hardware it is always useful to read some documentation and manuals from the manufacturer.

Firmware image dumps

Latest firmware for A is but I don’t have this firmware dump available. If you have one, please feel free to upload to xDevs.

Software and tools

Service information

If you want to learn more, please visit our website Universal Frequency Counter.

There is also number of service notes/engineering changes were published during years of product lifecycle. If your unit is old, worth to check if any of them required to do:

HP A with channel 3 input option with 3 GHz range


Image 1: Counter as received


Image 2: Top side view with PSU assembly removed


Image 3: Bottom side view on mainboard


Image 4: Close-up on the bottom side near Xilinx logic devices area

Powersupply, input IEC mains jack and fan are all mounted on metal frame making it very nice and modular. Frame is mounted to counter’s chassis with three torx head bolts, one inside of the chassis and two externally from the rear of the instrument. Only connection between power supply and mainboard is pin header cable on the side. Overall very serviceable design.


Image 5: Delta DPS-43DP-2 power supply assembly

This power supply is designed by Delta Electronics for HP, marked as revision B1 and accepts universal 100 – 240 VAC input with frequency up to 440 Hz. Output power rating is 47 W. There are four DC voltages available at the output of the module. HP assigned custom part number -.

  • V1 : +5 V with nominal current rating 5 A.
  • V2 : +12 V with nominal current rating 2.1 A.
  • V3 : -9 V with nominal current rating 0.25 A.
  • V4 : -12 V with nominal current rating 0.28 A.


Image 6: Disassembled front panel with PCBA, plastic frame and lens


Image 7: Front panel PCBA bottom side


Image 8: Main 10 MHz oscillator and adjustment capacitor trim near the I/O ports

Newer X boards use updated design with soldered on PROM memory chips and DC-DC converter for display.


Image 9: EEPROM chips in sockets and DC-DC module

Both inputs in A are pretty identical and have very similar layout. J16 and J17 are positions for rear BNC input connectors option.


Image 10: Input switching and front end components

Newer units have integrated DC-DC supply in the right back corner, but in this old unit it’s still separate module HP P/N - near to J6 and C129 capacitor. This module converts main +5 V DC input voltage into +38 V DC for segment drivers and AC voltage for filament heater.


Image 11: DC-DC module with TDK transformer, used for VFD glass


Image 12: Xilinx XC logic device and space for U59 and U60/U61/U5 devices reserved for A


Image 13: Active devices for the inputs front-end

Also a quick look on the 3 GHz third channel option 030 module that came with this A. There are also number of aftermarket PCB modules such at these that provide this option ch3 functionality but we got original HP-made 030 module in this counter.


Image 14: High resolution panoramic image of A mainboard, top side


Image 15: Optional channel 3 GHz preamp/divider PCBA, top component side

It is original HP - module done on two layer PCB with row of RF amplifiers and frequency divider. TheSignalPath blog has this very nice video explaining the design, functionality and performance of this option 030. I’d recommend to watch it for details about 030 option operation. This optional PCBA is mounted with four bolts and components facing towards metal frame of the counter.


Image 16: Optional channel 3 GHz preamp/divider PCBA, bottom solder side

On the bottom side we have just solid copper ground pour, providing good and low impedance reference plane to maintain 50 Ω signal transmission environment. Only component here is J1 – SMB connector for the input cable connection. Higher 12.4 GHz frequency option using similar design concept with RF input amplification and frequency prescaler.

Agilent A Counter

Other than updated lens with Agilent branding and A model number front panel is completely identical to older HP A.


Image 17: Agilent A front panel user interface


Image 18: Agiletn A rear connectors and fan exhaust vent


Image 19: Top side view on A hardware, with PSU assembly installed


Image 20: Power supply view with isolation plastic folded away


Image 21: Top side with PSU assembly removed


Image 22: Bottom side view in A counter

Back side of the motherboard has bunch of circles marked with black sharpie around some resistors and capacitors in the center area. Bunch of other components also have clearly visible flux residue, perhaps by previous modifications or repairs?


Image 23: Front panel plastics comparison between two counters

Interesting to note difference in front panel design. Front panel from older A shown on the top and newer A panel is on the bottom. Older A instrument had shiny metallization layer on the inside surfaces, while newer A front panel is boring plain injection molded plastic plus added thin aluminum plate around BNC connectors area. Maybe HP guys decided to cost-down the front panel tooling to save on plating surfaces process?

Power supply in this A is identical Delta DPS2 unit as we saw in A counter. All counters in these series use same power supply assembly.


Image 24: Power consumption of powered up Agilent A with good power supply, around 22.5 W

Problem with this A is obvious when we take a closer look on Delta power supply. With 120 V mains connected instrument was just generating short 10 W power consumption spikes with zero signs of life.


Image 25: Leaking electrolyte around C103

This pulsed behavior is a tell-tale of broken switch-mode power supply, very often due to damaged active components or old bad electrolytic capacitors. And closer look indeed reveals leaked nasty goo under one of the Rubycon black capacitor. PSU in these counters is always powered on and running as soon as the power cable is plugged which does not help with reliability over the years. It is interesting to note that this PSU with leaked cap was manufactured in late , while still working good PSU in A is 3 years older.


Image 26: Power supply labels

The usual approach for old equipment repairs at xDevs labs is to replace all electrolytic capacitors in power supplies, no questions asked. I don’t even bother checking the capacitors, as the price for replacement caps often is far less than 1% of the overall instrument cost. Unlike good wine, electrolytic and tantalum capacitors do NOT improve with age. So many times a bad $1 capacitor was a cause of destruction to the expensive and hard to find active components or transformers that this refurbishment service for every old instrument is a solid approach to keep the lab up and running. In worst case, you just replaced good old capacitors with good new capacitors, loosing only a little bit of time in return.


Image 27: Blown up R251 next to leaking C103 capacitor

Previous users of these instruments already finished reverse-engineering for this Delta PSU which can be very handy for our repairs.


Image 28: Schematics of this Delta PSU, reverse-engineered by forum member .

Always-on design was implemented on purpose, since high-stability or ultra-stable option in these counters require some hours to get stable and up to temperature. HP designers decided to make instrument always running hot instead of putting a requirement to wait warm-up time on the user. I understand the idea to have an instrument always capable to provide accurate measurements the moment it is powered up, but still am not sure if I like this design approach and constant 10 W of vampire power draw even when not in use. Imagine having a lab with a few dozen of these counters sitting plugged, but turned off. After all, the idea of waiting for multiple hours is very common in DC and resistance metrology, including many HP/Agilent/Keysight DMM. Maybe time/frequency people are not as patient and DC/LF metrologists?

Quick look inside current Keysight A and option 015

I also have few photos of modern Keysight A counter equipped with 15 GHz 3rd input option. This new counter was manufactured in the end of and came with faulty 15 GHz input.

Architecture was refreshed quite a lot with most of components in small SMT packages, with updated to Spartan-3 XC2S350E and XC3S100E FPGAs in the center. Other notable chips are Analog Devices ADCMP567BCPZ ultrafast comparator , ADA , ADFBCPZ 400 MHz PLL/Phase detector , LTC 2-phase DC-DC.

Microwave 15 GHz option came with Keysight P/N - and had properly designed high-speed PCB with Rogers substrate under top copper layer to ensure low loss and good RF performance. Front edge-launched SMA connector had tiny AC coupling capacitor and bunch of proprietary Keysight ASICs.

It was only repaired because of support from Steve who had the donor board from another Keysight product to steal the needed unobtanium ASIC chips. This board was also filled with Hittite RF components such as HMC547A switch , HMC760 4 GSPS 5 GHz Track-and-Hold amplifier , HMC424 digital attenuator and HMC493 InGaP HBT Divider-by-4 and some others. Some of these parts are quite expensive, such as HMC760 at $343.47 each.

It was also quite tricky to get these soldered in because of massive copper polygon pours with dense via fences. Ideally, such boards should be reworked with good preheating table to avoid stressing sensitive components with excessive heat. Remember, soldering is all about thermal transfer and NOT the temperature. If the solder does not melt at +270 °C then there is too much thermal power loss or not enough heat power applied. Increasing temperature would NOT help and only increase risk of damaging and overheating PCB or components on it.

Difference between A and A and possible DIY upgrade

Both counters capable to measure frequency with resolution up to 12 digits, but cheaper A model needs more time to do it. From hardware perspective difference is in firmware, additional logic array chip, extra 10-bit SAR ADC ICs and few resistors and capacitors for power delivery network for extra chips. Both of these extra chips are long obsolete now and hard to find. The best option for tinkerers would be to find broken A and salvage chips from there, if there is a need to upgrade A a little. All hardware components differences are summarized in a table below.

A counter A counter U5 Empty Obsolete +2.5V Voltage reference, STMicroelectronics MCD in SOIC8, HP P/N - U59 Empty Obsolete in Xilinx XCA-7PC84C 84-pin J-lead LCC FPGA U60 Empty Obsolete Analog Devices ADJP ADC U61 Empty Obsolete Analog Devices ADJP ADC R299 populated, 10 Ω resistor R300 populated, 10 Ω resistor R11 Empty populated, 5.62 kΩ resistor R9 Empty populated, 5.62 kΩ resistor C10 Empty populated, 10 nF capacitor C207 Empty populated, 10 nF capacitor C210 populated, 100 nF X7R capacitor

For this article I’ve just took channel 3 option, good (or bad, but still working?) power supply and nicer whiter front panel from A and transplated into A chassis to get a good working Agilent A counter and project for future repair in shape of bad PSU and ugly browned A FP.

Some measurements and benchmarks

Now that we got nice looking Agilent A unit with three inputs, it is time to do some measurements with it. For first test I’ve checked that all three inputs are functional and provide reasonably accurate reading. This was done with connecting each of the counter inputs to our HP EA ESG-DP RF signal generator and configuring source for +0 dBm sine output with required frequency.


Image 29: Measurement check with 10 MHz signal applied

Basic 10 MHz measurements worked well without any issues. Next is 3 GHz for input 3:


Image 30: Measurement check with MHz +0 dBm signal applied to input 3

Also no problems detected in measuring the MHz signal. References between generator and counters were not locked together, and no ajustments were performed either.

These X series counters as well as newer series supported by very powerful and useful TimeLab software developed by John Miles KE5FX. This software is extremely versatile and can make automated precision time and frequency measurements, including Allan deviation, MDEV, TDEV, MTIE, phase noise, and phase/frequency drift.

Summary and conclusion

Overall this was a fun little evening project swapping some parts in A and A counters, looking at overall design and measuring some GHz signals. These counters will be a valuable addition to xDevs.com lab instrumentation for future AC/DC metrology and digitizer projects.

RF instrumentation is still a very much far out of our main scope of interest, but that does not diminish the interest in circuits and instruments evolved around RF domain of electromagnetic spectrum. In the modern world, RF signals and waveforms are everywhere around us, from the Internet, cell-phones or mundane microwave ovens. And even all the DC voltage metrology is in the end defined by the inverse AC Josephson effect, thanks to JVS cryogenic standards use as ultimate physical implementation of quantum accurate frequency to voltage DAC converter.

Discussion about this article and related stuff is welcome in comment section or at our own IRC chat server: irc.xdevs.com (port six-zero-ten-zero, channel: #xDevs.com).

If you are looking for more details, kindly visit Power Quality Analyzer.

Comments

0 of 2000 characters used

All Comments (0)
Get in Touch

Copyright © 2020 Wordblogger.net

  |   Minerals & Metallurgy   |   Toys & Hobbies   |   Timepieces, Jewelry, Eyewear   |   Textiles & Leather Products   |   Telecommunications   |   Shoes & Accessories   |   Service Equipment   |   Security & Protection   |   Rubber & Plastics   |   Sitemap