Frequency counter 35 Mhz

Moderator: Benj

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

Frequency counter 35 Mhz

Postby mtqc76 » Mon Jul 16, 2012 9:17 pm

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: 514 times
Been thanked: 467 times
Contact:

Re: Frequency counter 35 Mhz

Postby dazz » Tue Jul 17, 2012 2:12 pm

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

Postby mtqc76 » Tue Jul 17, 2012 2:24 pm

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

Postby mtqc76 » Tue Jul 17, 2012 6:36 pm

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8824
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2560 times
Been thanked: 3717 times
Contact:

Re: Frequency counter 35 Mhz

Postby medelec35 » Wed Jul 18, 2012 10:21 am

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
These users thanked the author medelec35 for the post (total 2):
Benj (Wed Jul 18, 2012 11:10 am) • prasha920 (Thu Nov 20, 2014 8:50 pm)
Rating: 10%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Postby Gary Freegard » Wed Jul 18, 2012 11:47 am

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/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=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/mmforums/viewtopic.php?f=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

Postby mtqc76 » Wed Jul 18, 2012 1:58 pm

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

Postby Enamul » Wed Jul 18, 2012 2:36 pm

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/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=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

Postby mtqc76 » Wed Jul 18, 2012 3:19 pm

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

Postby mtqc76 » Thu Jul 19, 2012 3:14 pm

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

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8824
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2560 times
Been thanked: 3717 times
Contact:

Re: Frequency counter 35 Mhz

Postby medelec35 » Thu Jul 19, 2012 11:53 pm

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 253 times
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Frequency counter 35 Mhz

Postby mtqc76 » Sat Jul 21, 2012 4:35 pm

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 204 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8824
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2560 times
Been thanked: 3717 times
Contact:

Re: Frequency counter 35 Mhz

Postby medelec35 » Sat Jul 21, 2012 5:48 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Frequency counter 35 Mhz

Postby mtqc76 » Sat Jul 21, 2012 7:19 pm

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: 381 times
Been thanked: 720 times
Contact:

Re: Frequency counter 35 Mhz

Postby JohnCrow » Sat Jul 21, 2012 9:54 pm

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 !

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8824
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2560 times
Been thanked: 3717 times
Contact:

Re: Frequency counter 35 Mhz

Postby medelec35 » Sat Jul 21, 2012 10:13 pm

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
Freq errors.png (2.65 KiB) Viewed 10774 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 231 times
These users thanked the author medelec35 for the post:
STibor (Thu Nov 08, 2012 6:40 pm)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Frequency counter 35 Mhz

Postby JohnCrow » Sun Jul 22, 2012 11:40 am

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

Postby mtqc76 » Thu Jul 26, 2012 4:19 pm

Any progress sir!!

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

Re: Frequency counter 35 Mhz

Postby Jordy101091 » Thu Jul 26, 2012 10:00 pm

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

Postby mtqc76 » Thu Jul 26, 2012 11:37 pm

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8824
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2560 times
Been thanked: 3717 times
Contact:

Re: Frequency counter 35 Mhz

Postby medelec35 » Thu Jul 26, 2012 11:49 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Frequency counter 35 Mhz

Postby mtqc76 » Fri Jul 27, 2012 2:55 pm

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: 262
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 115 times
Been thanked: 112 times
Contact:

Re: Frequency counter 35 Mhz

Postby STibor » Thu Nov 08, 2012 6:43 pm

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?

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8824
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2560 times
Been thanked: 3717 times
Contact:

Re: Frequency counter 35 Mhz

Postby medelec35 » Thu Nov 08, 2012 10:16 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
STibor
Posts: 262
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 115 times
Been thanked: 112 times
Contact:

Re: Frequency counter 35 Mhz

Postby STibor » Thu Nov 08, 2012 11:57 pm

External 10Mhz with Pll.
Thank you!