Author Topic: How could this freq counter work?  (Read 3275 times)

0 Members and 1 Guest are viewing this topic.

Offline kfitch42Topic starter

  • Frequent Contributor
  • **
  • Posts: 300
  • Country: us
How could this freq counter work?
« on: June 14, 2013, 05:35:03 pm »
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.php

That 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?
 

Offline millerb

  • Regular Contributor
  • *
  • Posts: 71
  • Country: us
Re: How could this freq counter work?
« Reply #1 on: June 14, 2013, 05:45:39 pm »
Is the input to the pic on one of the ADC lines?
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: How could this freq counter work?
« Reply #2 on: June 14, 2013, 06:19:58 pm »
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
« Last Edit: June 14, 2013, 06:22:00 pm by Bored@Work »
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: How could this freq counter work?
« Reply #3 on: June 14, 2013, 06:32:04 pm »
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.
 

Offline kfitch42Topic starter

  • Frequent Contributor
  • **
  • Posts: 300
  • Country: us
Re: How could this freq counter work?
« Reply #4 on: June 14, 2013, 06:39:10 pm »
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)/N
where 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.
 

Offline jimmc

  • Frequent Contributor
  • **
  • Posts: 304
  • Country: gb
Re: How could this freq counter work?
« Reply #5 on: June 18, 2013, 07:17:56 pm »
See Microchip application note 592d http://ww1.microchip.com/downloads/en/AppNotes/00592d.pdf for the genesis of all these designs.
Also Google for 'Weeder Frequency Counter'.

See http://home.exetel.com.au/marknac/50MHz-Frequency-Meter.htm for a more sophisticated version.

Jim
 

vlf3

  • Guest
Re: How could this freq counter work?
« Reply #6 on: June 18, 2013, 08:05:12 pm »
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.
« Last Edit: June 18, 2013, 08:29:35 pm by vlf3 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf