Frequency counter 35 Mhz

Moderator: Benj

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Frequency counter 35 Mhz

Post by mtqc76 »

Hi, all

Have a look at this file:

http://www.google.com.pk/url?sa=t&rct=j ... 1g&cad=rja

It describe technique to measure frequency from 10 Hz to 35 MHz by using 16f84a chip. (though seems to be not possible), but it is.

My question is how to implement this technique to flowcode. It is for all senior and experts using flowcode. If someone already did, plz upload fcf file for other to review and knowledge.

Thanks
wasee

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Frequency counter 35 Mhz

Post by dazz »

Hi

if you look at page 2 and 3 of the pdf you linked to it gives the program steps and timing diagram, look at page 3 there is a also flowchart listing the steps taken by the program, you need to replicate this in flowcode , have a go at it and then post your flowchart as that way people will be able to help more or advise other ways of doing it hth
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

Sir, You are right. I am hobbyist. New to programming due to flowcode. I am looking same flowchart for days, but could not figure out how to impliment it on flowcode. That was why I posted on forum if some experts can do the job. I hope this project will be a valuable assest not only to our lab, but the whole community willing to have F meter like so.

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

Plz look at :
http://www.hamradio.in/circuits/freq_counter_lcd.php


I downloaded hex file and run it on Proteus simulator. It really worked for 30 MHZ. It is working example.

It would be great if someone can make fcf file from it.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Basically how the frequency counter works is:
Prescaller of timer 0 interrupt is set to 1:256
In effect although timer 0 is a 8 bit its acting like a 16bit counter.
Since T0cki pin is used, each time T0ck goes from low to high (or high to low depending on source edge selection setting) then prescaller register counts up 1 (equivalent to Low byte of a 16bit timer)
When prescaller rolls over from 255 to 0 (256 changes of T0CKI) then timer 0 register is incremented by 1 (equivalent of high byte of 16bit counter).
This is the same as feeding a frequency into a divide by 256 counter.
So in effect what happens is T0CKI is gated (an output from a different pin is also connected to T0CKI is repeating forcing it low after a set period of time).
So there must be a resistor connected in series with frequency being measured and T0CKI pin.
Gating is automatically adjusted (gating time increased) if timer0 rolls over before gating time has elapsed.
Then frequency is calculated since set time period of gating is known and from reading timer0.
Frequency is displayed on LCD or LED (since T0CKI is in effect not now running it won’t be interfering). Decimal point is in a position determined by which gating time is used
This is how the higher frequencies can be read and displayed.
I would say Something like this is fairly easily achievable with Flowcode.

If I can find so spare time I will create a high frequency counter using the above method.

Martin
Martin

Gary Freegard
Posts: 45
Joined: Mon Nov 07, 2011 6:36 pm
Has thanked: 1 time
Been thanked: 30 times
Contact:

Re: Frequency counter 35 Mhz

Post by Gary Freegard »

Hi all

The method used here is described in an old Microchip application note, written in the late 90s which I remember reading :( .
http://www.microchip.com/stellent/idcpl ... e=en011033
The reason that RA3 is connected to T0CKI is to gate the input signal and also used to get the value of the prescaler, some how (didnt really read it that indepth).

I think the best bet is to use a PIC with a 16bit counter
http://www.matrixmultimedia.com/mmforum ... 46&t=10800
This could be modified so that on an overflow of the counter a byte variable is incremented, combining both the counter and the variable will give you a 24bit frequency counter.

Gary

This site is using the same method, and is very similar in design ???
http://www.qsl.net/om3cph/om3cph.html

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

Great to know that senior members took interest in this project. I would request you to plz lets start to make a project in flowcode V4. I got the sense of medelac's detail, but I am newbie in this field hence problem with creating fcf in this manner.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Frequency counter 35 Mhz

Post by Enamul »

The method used here is described in an old Microchip application note, written in the late 90s which I remember reading :( .
http://www.microchip.com/stellent/idcpl ... e=en011033
The reason that RA3 is connected to T0CKI is to gate the input signal and also used to get the value of the prescaler, some how (didnt really read it that indepth)
Thanks Gary. This removes one of my miss conception.
Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

Enamul:

I actually linked site so that one can know the technique of making F meter. Second, indian site is the practical example. I thought that flowchart would be easy to understand as compared to asm file on indian site. Anyhow, your knowledge and contribution would be greatly appreciated. Plz contribute your valuable experience to community.

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

http://products.foxdelta.com/fc2.htm

Complete design with Hex. Hope it will be of any help

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

This is my first attempt, and it probably wont work to well either.

I have attempted to create an auto range digital frequency counter, but unable to test on hardware so I don't know what frequency will work up to, or how accurate it is (or if it works at all!).

If some one who has access to a frequency generator, would you mind tying this out please.

If it does not work well, you may be able to spot flaws in my theory.

Input is via T1CKI.
For 16f877A is RC0
Flowchart is still using gating, but is software gated rather than hardware which is used in the frequency counters previously mentioned.

I will see if I can set something up tomorrow to generate a frequency, and test counter
When I can get counter to work. I will add notes on the flowchart on how it all works.

Martin
Attachments
High Frequency Counter 16F877A FC5.fcf
LCD version
(19.51 KiB) Downloaded 428 times
Martin

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

Hi, medelac, I made proteus file and loaded Hex file from your fcf file. Nothing happening.
Attachments
High Frequency Counter 16F877A FC5.rar
(13.29 KiB) Downloaded 352 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Hi mtqc76,
I have been able to test up to 1MHz, and all appears ok.
Display is showing correct frequency from 1 KHz to 1MHz

unfortunately I'm struggling to get a signal to go above 1MHz

Have you checked configuration and connections of LCD in Proteus?

Thanks for testing anyway.
Martin

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

Thanks Medelec.

Got it working, nothing wrong with connection. When I changed different frequency input, it did work in proteus, but below 100 hz was not showing anything, similar if i input 100K was showing 10 k hz, lower frequencies were fine. Anyhow, very very good effort to start with flowcode. My teacher in school is also working on it to make a flowchart and do some work on it, lets see if he give any input in this project.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Frequency counter 35 Mhz

Post by JohnCrow »

I'll try and get time test it tomorrow with my xtal standard.

That can generate the following frequencies 2.5k 10K 25k 100k 250k 1M 2.5M 10M

Max level is about 0.8V so should be ok for this.
1 in 10 people understand binary, the other one doesn't !

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Thanks guys for taking an intrest :).
What I did not make clear (sorry mtqc76) is:
I designed with a minimum frequency of 1KHz in mind. Going to extend it later.
So any frequency lower than 1KHz will be displayed as 0
There is one thing I need to add, but not sure if It will improve it or not.
Also there will be following errors:
Freq errors.png
(2.65 KiB) Downloaded 10797 times
These will be fine since variables are wrote to first but in C.
Simulator does not know this since C is not simulated.
Attachments
High Frequency Counter 16F877A FC5 V2.fcf
(20.17 KiB) Downloaded 360 times
Martin

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Frequency counter 35 Mhz

Post by JohnCrow »

Hi Martin

Ive just tried the counter with my xtal standard.
Its ok upto 250kHz but Im not able to get a reading above this.
Think the trouble is the signal level output is a lot lower at these frequencies, maybe not enough to trigger the counter.
250kHz leve = 500 mV
1MHz = 200mV
10MHz = 80mV
1 in 10 people understand binary, the other one doesn't !

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

Any progress sir!!

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Frequency counter 35 Mhz

Post by Jordy101091 »

Hi, all

I have followed this post for a time now and i started to wonder, based on John Crow his post.

When its really so that the average voltage drops when the frequency increases, and therefore the micrcontroller cannot read or react correctly, I suggest the following possible solution.
Why do you mtqc76 make a certain number of amplification circuits to boost the voltage up high enough so that the microcontroller can read you signal correctly,
If the frequency gets higher then you switch over to a different amplifier with a higher gain, the same goes for a lower frequency.

This is what I was thinking maybe you can do something with it.

Regards Jordy
the will to learn, should not be stopped by any price

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

Ture sir,

If we build the circuit on proteus and simulate it then we will know that it is not working as supposed to be (though I am newbie, doing work on proteus is better than making hardware first) but i think there need something professionalism in making such counter. once it is done on proteus, then there should no problem in making rf amplifier of single transistor to make the input signal strong enough.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Hello mtqc76,
I'm not saying counter will work up to high frequencies like 30 MHZ
But one fact is I tested it on hardware from 1 KHZ to 1 MHz, and reading on LCD was correct.

So when you say you tested frequency counter in proteus if you tested frequencies between 1KHz and 1MHz and it did not work,
then I would question Proteus.

Martin

AS for creating a flowchart and you stated your a beginner then there is a great learning resource center at:
http://www.matrixmultimedia.com/lc_index.php?p=7

There you can view examples and even free training courses.

Martin
Martin

mtqc76
Posts: 48
Joined: Fri Jun 17, 2011 11:44 am
Contact:

Re: Frequency counter 35 Mhz

Post by mtqc76 »

Thanks sir! I have been through those tut. Through those tut i was able to make UPS fcf. Senior like you are great assest to our community.

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: Frequency counter 35 Mhz

Post by STibor »

medelec35 wrote:Thanks guys for taking an intrest :).
What I did not make clear (sorry mtqc76) is:
I designed with a minimum frequency of 1KHz in mind. Going to extend it later.
So any frequency lower than 1KHz will be displayed as 0
There is one thing I need to add, but not sure if It will improve it or not.
Also there will be following errors:
Freq errors.png
These will be fine since variables are wrote to first but in C.
Simulator does not know this since C is not simulated.
It is a good example. Thank you!
If the microcontroller 40MHz, I use it, you need to modify the program?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Hi Simpi,
Thanks.
STibor wrote: If the microcontroller 40MHz, I use it, you need to modify the program?
What is your target device and type of osc (internal, external etc).?
As soon as I know that, I will see what I can do for you.

Martin
Martin

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: Frequency counter 35 Mhz

Post by STibor »

External 10Mhz with Pll.
Thank you!

Post Reply