How could this freq counter work? - Page 1
Forum section: electronics / beginners

author: kfitch42
author_rank: Frequent Contributor
timestamp: June 14, 2013, 05:35:03 pm
content: I was thinking about building a simple frequency counter. I have seen a few designs floating around based on 74 series logic, and others using a micro, and I mostly understand the concept. e.g. sparkfun has a kit with a micro running at 16Mhz that they say is good up to about 6.4Mhz, which sounds quite reasonable. But then I ran across this:http://www.electronics-diy.com/50MHz_Frequency_Meter_Counter.phpThat has a PIC using a 4Mhz crystal that supposedly can measure up to 60Mhz. There is a schematic, but no code or any detailed information about how it works.I tried reproducing the input circuitry in LTSpice, but when I feed it a 1Mhz input signal I get spikes over 300V. At 1KHz is produced sane voltages, that mostly looked like an inversion of the input.So clearly my LTSpice skills are a bit lacking.But, that being said, is this freq counter a joke, or am I missing something?

author: millerb
author_rank: Regular Contributor
timestamp: June 14, 2013, 05:45:39 pm
content: Is the input to the pic on one of the ADC lines?

author: Bored@Work
author_rank: Super Contributor
timestamp: June 14, 2013, 06:19:58 pm
content: This particular PIC has an internal prescaler for the timer input. The input frequency is internally divided by something like 256 (I am too lazy to check the datasheet), and then measured.As for the SPICE junk, use the real transistor's model and model the PIC's input as a load on p3

author: Rufus
author_rank: Super Contributor
timestamp: June 14, 2013, 06:32:04 pm
content: The circuit is a bit crap and you are putting a huge square wave into it.The PIC provides clamp diodes between P3 and VDD and GND. Add them to the simulation and the signal at P3 will look more reasonable.The circuit is abusing the clamp diodes but won't be exceeding the abs max data sheet rating.

author: kfitch42
author_rank: Frequent Contributor
timestamp: June 14, 2013, 06:39:10 pm
content: Don't think its on an ADC. In the spec sheet for the PIC16F628A (http://ww1.microchip.com/downloads/en/devicedoc/40044f.pdf), pin 3 is listed as "RA4/T0CKI/CMP2" where RA4 is a "bidirectional IO port", T0CKI is "Timer0 clock input", and CMP2 is "comparator 2 output"Of those Timer0 clock input seems the most reasonable to me.So, I started reading a bit more about Timer0, and it mentions a prescaler: this seems to be the part I was missing. In table 17-8 it lists the period of T0CKI as the greater of:20ns (which translates to 50Mhz)or(Tcy+40)/Nwhere Tcy is the instruction cycle time, if I am reading it right, that is 1000ns in our case. And N is a power of 2 between 2 and 256.So, the ability to go beyond 50Mhz seems very slightly dubious given those specs, but 50Mhz should be achievable.EDIT:Thanks Bored@Work and Rufus I think you are both right.

author: jimmc
author_rank: Frequent Contributor
timestamp: June 18, 2013, 07:17:56 pm
content: See Microchip application note 592dhttp://ww1.microchip.com/downloads/en/AppNotes/00592d.pdffor the genesis of all these designs.Also Google for 'Weeder Frequency Counter'.Seehttp://home.exetel.com.au/marknac/50MHz-Frequency-Meter.htmfor a more sophisticated version.Jim

author: Unknown
author_rank: Unknown
timestamp: June 18, 2013, 08:05:12 pm
content: The input circuit design actually works, having purchased this kit out of interest; I installed it in my sine signal generator... as a kit it has an input level problem however, providing a fixed level across the input band-width, it performs okay for a basic frequency meter.I provided a pre-input level attenuator, and diode squaring for my needs... with a 4k7 across my generator square output source = 4 volts PtP, with a series 2k2 in the signal path, and two back to back IN4148 diodes into C4, that I changed value for 1 Mfd non-polarized for the 10 Htz reading resolution; this gave an input level at the diode input junction, of 1.24 volts at 10 Htz, to 494 mV at 1.18 Mhz, the max frequency my generator can produce.T1 collector levels with the input supplied = 4.8 Volts from 10 Htz to 1.18 Mhz.