Dangerous Prototypes

In development => Project development, ideas, and suggestions => Topic started by: alank2 on February 05, 2012, 05:43:59 pm

Title: Input for my frequency counter questions...
Post by: alank2 on February 05, 2012, 05:43:59 pm
Hi Everyone,

I've been working on a reciprocal frequency counter and all the digital work is done.  Here is a breadboard picture showing 80 Mhz (or near it!)  The top led to the right is the "MHz" indicator.



It is AVR based and automatically enables or disables a prescaler to handle frequencies from 0.5 Hz to 100 MHz.  It can give the same precision whether the signal is fast or slow unlike my old BK counter I've been using.

The question is about the front end.  I've tried various input circuits, I've tried biasing inverters, schottky inverters, etc.  I want the input to support even measuring mains voltages if possible.  The problem with the circuits I've tried is that they don't amplify enough to get down to 50mV signals.  I was thinking about trying an opamp or a very fast comparator next, but I don't see opamps/comparators usually mentioned in the searching I've done for frequency counter input stages.  What advice do you guys have?

Thanks,

Alan
Title: Re: Input for my frequency counter questions...
Post by: sqkybeaver on February 05, 2012, 06:01:03 pm
a comparator capable of high voltages, or a resistor divider would be the most simple,

use a pot and an opamp in voltage follower configuration to have a reference for trigger level.

input could be fed through a differential amp. but your bandwidth needs to be super high. you probably have to use smt.
Title: Re: Input for my frequency counter questions...
Post by: Bertho on February 07, 2012, 01:35:05 am
[quote author="alank2"]
The question is about the front end.  I've tried various input circuits, I've tried biasing inverters, schottky inverters, etc.  I want the input to support even measuring mains voltages if possible.  The problem with the circuits I've tried is that they don't amplify enough to get down to 50mV signals.  I was thinking about trying an opamp or a very fast comparator next, but I don't see opamps/comparators usually mentioned in the searching I've done for frequency counter input stages.  What advice do you guys have?
[/quote]

Just some thoughts:
1) Opamps are not fast enough if you need large signal gain. The gain-bandwidth product will simply not allow it. From 2..5MHz up you usually use discrete transistor/jfet amplifiers to get the signal to acceptable level. The cost of an opamp is somewhat exponential with the gain-bandwidth product. For (small) signals from 10..50MHz and up you will probably need specialized analogue amplifier design to get a good signal out.
2) Measuring mains is dangerous and you should use an isolation transformer on the input (50:1 or 100:1). You know the approx frequency anyway. Using transformer isolation is more difficult if you want to do it over a large frequency range, but still possible.
3) You put a (large) capacitor in the input-line to get the DC component off of the measurement source. This is normally a 1..2kV type for isolation purposes. You then add your own DC bias as required.
Title: Re: Input for my frequency counter questions...
Post by: alank2 on February 07, 2012, 01:55:48 am
Hi,

What about something like this:

http://pdfserv.maxim-ic.com/en/ds/MAX961-MAX999.pdf (http://pdfserv.maxim-ic.com/en/ds/MAX961-MAX999.pdf)

I have some of these on hand I was going to play around with:

http://www.ti.com/lit/ds/symlink/tlv2470a.pdf (http://www.ti.com/lit/ds/symlink/tlv2470a.pdf)

You don't think they will be able to handle faster speeds?

I know measuring mains is dangerous, and I'm not planning on it, but I would like to design if possible an input stage that tolerates it...

Thanks for the help!!

Alan
Title: Re: Input for my frequency counter questions...
Post by: Bertho on February 07, 2012, 03:22:58 am
[quote author="alank2"]
http://pdfserv.maxim-ic.com/en/ds/MAX961-MAX999.pdf (http://pdfserv.maxim-ic.com/en/ds/MAX961-MAX999.pdf)
[/quote]

This one is nice. The MAX961 is a specialized comparator with hysteresis. You still need at least filtering to get nice results, but it should be able to reach about 100MHz peak (maybe a little more). However, as warned, the price is according ($5..$8 single, ~$3.5 bulk). Making a layout to support small signals at high frequency, without getting into noise, will be a chalange and a breadboard may kill any nice signal. The hysteresis is only 3.5mV, so any noise will make hell.

[quote author="alank2"]
I have some of these on hand I was going to play around with:
http://www.ti.com/lit/ds/symlink/tlv2470a.pdf (http://www.ti.com/lit/ds/symlink/tlv2470a.pdf)
You don't think they will be able to handle faster speeds?
[/quote]

The TLV2470 has a GBP of 2.8MHz and is very slow. You might press a few hundred kHz out of this one with appreciable amplification.
Title: Re: Input for my frequency counter questions...
Post by: sqkybeaver on February 07, 2012, 04:38:02 am
the maxim part is very nice for <100 MHz

the op amp could be any rail to rail, its only function would be to set trigger level. you would want a nice clean reference voltage too.
Title: Re: Input for my frequency counter questions...
Post by: alank2 on February 07, 2012, 05:40:25 am
Hi,

[quote author="sqkybeaver"]the maxim part is very nice for <100 MHz
the op amp could be any rail to rail, its only function would be to set trigger level. you would want a nice clean reference voltage too.[/quote]

Would you mind posting a schematic of something like this?  I am very weak in analog but want to learn!

I've tried using a voltage divider with some diodes to clamp feeding a jfet and then a transistor based on some schematics I've found on the web, but it wasn't as sensitive as I was hoping.

Thanks,

Alan
Title: Re: Input for my frequency counter questions...
Post by: foxit on February 07, 2012, 09:12:48 am
Hi.
I want to repeat your project.
Please Put the schema and the sources of the project.
I'm ready to participate in the debugging and testing.
thank you
Title: Re: Input for my frequency counter questions...
Post by: arakis on February 07, 2012, 09:33:00 am
Thins might be a seriously stupid question, but I am a little unclear at how the actual  frequency is measured...a known frequency used to tick during 1 cycle of the measured frequency, or is the measured frequency used to tick during a one cycle of a known time frame...or is a combination of the tow....two counters are used and some arithmetic is used to calculate the measured value?
Title: Re: Input for my frequency counter questions...
Post by: joushou on February 07, 2012, 12:00:46 pm
Emphasizing that measuring mains is dangerous is okay when we're dealing with newcomers to electronics, but once you reach a certain stage (Such as the ability to see what the hell is going on on that breadboard), it's time to realize that you need to work with it every now and then. Just don't end up with the phase in one hand and neutral/another phase in the other. It hurts, as I have concluded through numerous *cough cough* scientific studies of the subject. (Especially phase-to-phase. 400VAC, surprisingly enough, makes you a little shaky afterwards.)

But, seeing you need some serious input ranges (0-700v peak-to-peak, assuming we're on European mains like me, or ~350v max if you're on American/Japanese/xyz soil.), what about a long resistor ladder with something like zeners/comparators and fast transistors to "select" a voltage scaling on the ladder?
You might want to "hold" the resulted scaling, to avoid confusing your frequency counter with sudden scaling.
Also, you could probably "isolate" the main circuit from this scaler with optocouplers (high linearity ones), in which case the worst thing that could happen is the sudden death of an optocoupler.

Hope some of my ideas are even slightly useful, and try not to have both of your hands in the project when connected to mains. It only hurts/fries nerves if it's one hand, but two can kill. :)
Title: Re: Input for my frequency counter questions...
Post by: alank2 on February 07, 2012, 02:28:49 pm
Hi,

foxit:  The input stage is the last thing I need to finish on this.  Once it is done, I'm going to design a pcb and do the documentation.  When I'm done (hopefully in the next month or so), I'll post the entire project with source code and gerber files for anyone who wants to build one.

arakis:  It is a reciprocal frequency counter so I am measuring the period of a signal (or multiple signals) against the internal uc clock.  I have a timer clocked 1:1 with the uc clock and am using an input capture unit to get a count of cpu cycles for a count of signal cycles.  I am still using a gate time although it merely sets the minimum time to wait and a final trigger is taken after the gate time to get both a (1) count of signal cycles and a (2) count of uc cycles.  Once I have both of those I just do the math to calculate the frequency.  I am using a prescaler that is switched on or off automatically depending on the input signal, and as long as the prescaler doesn't change, successive measurements are taken back to back with no signals ignored.  Whether measuring 10 Hz or 80 MHz, you will get the same precision which is log10(uc clock).  I am currently using a 16.7636 Mhz TCXO because it was reasonably cheap and is very stable, but you can feed it a clock between 10MHz-20MHz from any reliable source.  It has a button to change the gate time, to hold the display, and one to enhance the precision which bumps the number of digits up by 1 if there is room on the display.  Values on the display are rounded and automatically scaled between Hz, kHz, and MHz.  Edit: It also does not require the uC clock to be tuned (or tunable) specifically to a frequency, you can specify the actual frequency and it is stored in eeprom.  It also has a calibration mode where you provide a 10MHz reference clock and it will figure out its internal frequency.

joushou:  It isn't that I really want to measure mains so much as I'd like the input stage to tolerate it.  I was thinking US mains voltages, 400V max.  One of the input stages I've tested (not with mains, but is designed to tolerate it) has a 1.5uF capacitor feeding a 100K/1M divider that is then clamped by a couple of diodes.  It then feeds a jfet/pnp combination.  It isn't bad and I may end up going with it if I can't find something better, but it doesn't give enough amplification for smaller signals such as 50mV rms.  Even though the breadboard picture above looks pretty big, I plan squashing it as small as possible while still sticking with PTH components so it is easy to solder for beginners, so I'm not looking for a 30 part input stage so much as I'd like a durable input stage that can handle decently small input signals in as few parts as possible...

Thanks,

Alan
Title: Re: Input for my frequency counter questions...
Post by: willemite on February 07, 2012, 03:27:38 pm
If you are looking for fast op amps, they do exist. Analog Devices makes one with a 1GHz -3db bandwidth -- of course you have limit the output swing to 0.1 Vpp, but even at 2 Vpp out you can get 200 MHz. I am sure there are others.
Title: Re: Input for my frequency counter questions...
Post by: foxit on February 09, 2012, 07:30:50 am
Would you write a list of components for device?
Title: Re: Input for my frequency counter questions...
Post by: alank2 on February 09, 2012, 02:21:05 pm
Hi,

[quote author="foxit"]Would you write a list of components for device?[/quote]

This list is preliminary, but:

1 main cap

(2) quad cc led 7 segment displays

3 buttons
4 leds
4 led current limiting resistors

max7219
bypass cap
1 resistor for max7219 current setting

atmega168
(2) bypass cap
reset pullup resistor 10k

mc74ac4040n prescaler
bypass cap

mc74ac132n nand
bypass cap

16.3676 MHz TCXO 3V
bypass cap

3V linear voltage regulator
bypass cap

I'll be adding one more button and one more LED for the low/high/average mode I plan to add which when enabled (led lit to indicate enabled), it will keep track of the lowest, highest, average, count, and last measurement and the user can press the button to toggle between them.

Thanks,

Alan
Title: Re: Input for my frequency counter questions...
Post by: alank2 on February 09, 2012, 03:10:36 pm
Hi Mick,

[quote author="MickM"]I would try to copy an oscilloscope input circuit.
Or even better rip one out of an old scope, or get a plug-in module for a TEK (7000 series?)
http://www.barrytech.com/tektronix/tek7 ... copes.html (http://www.barrytech.com/tektronix/tek7000/tek7000scopes.html)
[/quote]

I am hoping to use standard available parts and yet keep the part list down as well, but for a one off I can't see anything better than using a scope input stage type module!  I haven't looked at scope input circuits too much yet, but I may start.

I've been playing around with this input stage:

http://www.piclist.com/techref/piclist/ ... ircuit.htm (http://www.piclist.com/techref/piclist/weedfreq/circuit.htm)

It has a lot of things I like, but yet still falls short in some areas.  My initial problem was that I wanted to support an input signal as small as 50 mV rms and it didn't haven enough gain.  The circuit is designed for 9V operation although I'm using it with 5V.  I changed R4 to 50 ohms last night and R5 to 1K which gave me enough gain and I was feeling pretty good about it until I started testing various speed oscillators that I have.  If anyone has comments on these value changes please let me know, I figured I could probably drop to 50 ohms since my voltage is lower on R4, but truly I don't fully understand the circuit.  I've tried reading the Art of Electronics and other books on it but it hasn't come to me!  To try to understand it better, I tried the PNP without the JFET present making the assumption that the JFET was either open or closed and that also didn't work as I could adjust the pot from range to range without seeing the output move to the middle.  I must assume that the JFET provides a range of resistances for the input signal fluctuating between -.6 and +.6.  I noticed that the range of adjustment was greatly diminished when moving R5 to 1K, but it did give me the gain I wanted.

I noticed that slower (10MHz and lower) did ok, but that the clamping diodes made a mess of the signal around 25 MHz.  I disconnected the jfet gate and was just looking at the signal up to that point where it is clamped by the diodes.




At 80 MHz it didn't seem all that bad however. 




The diodes I am using are the 1N4148's called for by the schematic and their reverse recovery time is 4ns which I would think is fast enough, but it seems to be these diodes that are causing the 26MHz signal to look so bad.  Do I need to look at faster diodes?

Other traces I did:

5Mhz:


24Mhz:


All comments welcome!  I was feeling pretty hopeful last night with it until I saw the signal being changed so much when I tested it at different frequencies...

Thanks,

Alan
Title: Re: Input for my frequency counter questions...
Post by: foxit on February 23, 2012, 12:34:09 pm
Hello. How's the project?
Title: Re: Input for my frequency counter questions...
Post by: foxit on November 06, 2012, 09:37:32 pm
How's the project?

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01742135176session_write_close ( )...(null):0
20.01782266768ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01792267544Database_MySQL->query( ).../DatabaseHandler.php:119
40.07562406280Database_MySQL->error( ).../Db-mysql.class.php:273