How to test a counter - Page 1
Forum section: electronics / projects

author: Sbampato12
author_rank: Regular Contributor
timestamp: November 17, 2013, 01:41:52 am
content: Hi everybody,I'm working in a digital counter (maybe in future becomes a frequency counter, who knows...) to my workbench, and I got this question:How can I test my circuit?Working on that I thought, if I use a function generator, I can feed a square wave (example), with a determined frequency, but can I determine how many pulses (or transitions, or level changes) did I feed in my hardware?I do not have any function gen here, just some dmm, psu and a scope.The function gen have some configurations that allow me do that?PS: The project will be published when it is finished, open hardware.Thanks in advance!

author: dannyf
author_rank: Super Contributor
timestamp: November 17, 2013, 02:11:41 am
content: QuoteDepending on how your counter works. If it counts pulses within a given period of time, you can simply use a pulse generator (a crystal oscillator for example).If the counter requires gating, you can use the oscillator and then divide it up to generate the gating information and feed both to your counter.

author: Sbampato12
author_rank: Regular Contributor
timestamp: November 17, 2013, 02:33:01 am
content: Ok, but I need to know if me readings are ok. Like if I need another (good) counter, to compare the readings.I need this, because I want to test how far I can go with frequency in the input.I will get higher frequencies, and need to know if the counter still getting good readings, if it is not loosing any pulse. Or at what frequency it starts to loose pulses.

author: Paul Moir
author_rank: Frequent Contributor
timestamp: November 17, 2013, 03:21:20 am
content: How close do you want to know? If 2x is enough, feed a high frequency crystal oscillator into a (or a few ganged) 74HC4040, which will provide osc/2, osc/4/ osc/8, etc. You can validate the counter at lower frequencies with a stopwatch or wall clock. Then move up until it doesn't read right.If you want to go beyond say 40MHz, you'll need to get careful.

author: Sbampato12
author_rank: Regular Contributor
timestamp: November 17, 2013, 12:57:10 pm
content: I was thinking in something like this, but as I never needed or never saw someone doing something like this, I just wanted to check if there is a more elegant way to do this.I never worked in a high frequency project (or at least, nothing above 20MHz), so I don't know how hard it could be to do the board layout to get this working above 30 or 40Mhz, but by the datasheets, the ICs should work at least 60MHz...I will finish the layout until the components doesn't arrive (about 20 days), and then start some tests.

author: G0HZU
author_rank: Super Contributor
timestamp: November 17, 2013, 01:10:44 pm
content: Why not program up a PIC/AVR chip to send out a predetermined qty of pulses from one of its ports? You could have anything you like from 1 pulse to something like 2^32 pulses (or even more if you wanted)You could get it to keep repeating the test and you could log the results and maybe do hundreds of repeated tests per second to see how repeatable it is.

author: Sbampato12
author_rank: Regular Contributor
timestamp: November 17, 2013, 01:46:54 pm
content: Quote from: G0HZU on November 17, 2013, 01:10:44 pmThis is good if the frequency is low. But I need to generate the pulses at least 40 or 50MHz, which is the frequency that I expect start to get some errors.

author: dannyf
author_rank: Super Contributor
timestamp: November 17, 2013, 02:00:48 pm
content: QuoteYour mcu would not count above 20Mhz or so, without external help (a prescaler for example).The first design you have to answer is if you want to read prescalers (both internal and external).

author: Sbampato12
author_rank: Regular Contributor
timestamp: November 17, 2013, 03:41:19 pm
content: Quote from: dannyf on November 17, 2013, 02:00:48 pmI'm not using a mcu to count.I'm doing this using a dedicated ICs (binary counters, 7 seg. decoders and dividers).

author: dannyf
author_rank: Super Contributor
timestamp: November 17, 2013, 04:07:52 pm
content: Then google sc3610 for an all-in-one digital solution; Or use a F-to-V chip or even a PLL for an analog solution.

author: edavid
author_rank: Super Contributor
timestamp: November 17, 2013, 07:33:27 pm
content: There's no magic way. Probably the simplest thing is to borrow a commercial counter and make sure your design gives the same results. You could also use a good logic analyzer or DSO.

author: codeboy2k
author_rank: Super Contributor
timestamp: November 18, 2013, 09:20:17 am
content: if you are using dedicated chips, then it will count as fast as the chips can transition, and it will be as accurate as your reference clock is.For example, you need a crystal clock as a reference, and counters and a gate. You can easily do that up to 50Mhz, if that is your goal.50Mhz is a 20ns period, or a transition every 10ns. Typical logic level counters and dividers are much faster than this.The only way to check the accuracy of your unit is to compare it to a known good frequency counter.If you have a good reference clock, it will be as accurate as that clock is.

author: ajc
author_rank: Contributor
timestamp: November 18, 2013, 09:27:24 am
content: Quote from: Sbampato12 on November 17, 2013, 01:41:52 amDoes your DMM have a frequency counter function? If it does, you could use it to cross check. Might not go up to the higher frequencies though...

author: dannyf
author_rank: Super Contributor
timestamp: November 18, 2013, 11:36:22 am
content: Good frequency sources are fairly easy: use crystals / crystal oscillators or TC(V)XO.The counting / latching / displaying can be done with a variety of means, from very simple (FPGA/MCU) to moderately challenging (40110) to quite challenging (discrete ring oscillators).

author: Sbampato12
author_rank: Regular Contributor
timestamp: November 18, 2013, 04:34:14 pm
content: Yeap, I think I will find a good oscilator, and use this method to confirm that the counter is ok.Thanks for everyone!

author: olsenn
author_rank: Frequent Contributor
timestamp: November 18, 2013, 04:38:24 pm
content: QuoteThis is definately your best option. Works far better than "one mississippi, two mississippi..."Make sure to get at least an ovenized crystal, and preferably an atomic clock (Rb Std. oscillator). The latter has better long term stability, so it's probably what you want. Frankly though, you likely won't need 9 digits of resolution, so even the 1KHz square wave calibrator on your DSO will probably be good enough for most purposes.

author: dannyf
author_rank: Super Contributor
timestamp: November 18, 2013, 05:02:43 pm
content: A (stand-alone) crystal oscillator is cheap and easy to find. You can get a few (or one + a divider) to get a sense of your counter's range.Alternatively, you can use one crystal / oscillator on HC4060 and get a variety of frequency output.

author: Jon86
author_rank: Frequent Contributor
timestamp: November 18, 2013, 05:55:03 pm
content: AD9850 module? They're a few bucks on ebay and supposedly go up to 40Mhz. I've no experience with them myself, but if someone knows more about them then please pitch in.

author: dannyf
author_rank: Super Contributor
timestamp: November 18, 2013, 10:38:07 pm
content: The sine output from a ad9850 doesn't have a sufficient swing to drive a gate directly. Designing an afe isn't easy.The square wave output doesn't go sufficiently high in frequency.

author: Sbampato12
author_rank: Regular Contributor
timestamp: November 19, 2013, 12:20:48 am
content: I have access to a function generator up to 20MHz, an old agilent (or hp).I'll try to get a function gen with more Hz, and check if anywhere in my work the could have a easy access to a good stable oscillator.Maybe use the function gen (20MHz) as a base, and one with higher freq to drive the inputs.