Frequency counter 35 Mhz

Moderator: Benj

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

What is your target device please?

18F252?
Martin

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

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Contact:

Re: Frequency counter 35 Mhz

Post by STibor »

The target can be any microcontroller 18F series, 18F252, 18F1330, 18F2620, 18F4550.
Crystal frequency can be anything, but it is difficult to purchase a crystal 19.6608MHz.
Ex-3.2768MHz and frequencies would be perfect to be divided into binary.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

I was only asking for target device, so I could alter configuration settings so it would work on your hardware.

If you don't have a particular device in mind, I will just pick a random one.

As for availablility of 19.6608MHz crystal:
RS components :
PN 130-8917

Or a wider range from Farnell
http://uk.farnell.com/jsp/search/browse ... 1%2B203436

(That's if you have access to these componies in your country of course :) )
Martin
Martin

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

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Contact:

Re: Frequency counter 35 Mhz

Post by STibor »

Hi!
Of course, you can buy from Farnell, but expensive.
Added to the frequency meter, based on your program.
Attachments
frekimero18f252_2.fcf
(14.64 KiB) Downloaded 200 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Hi Simpi,
I was working on the frequency counter this morning to extend the low frequency range.

Now the frequency counter works from 1Hz to several MHz

Still not sure on upper limit as simulation stops working at greater than 5MHz.

As for using on 18F range.

It should work with no adjustments to the flowchart except to configuration settings for your target device.

Thanks for your Flowchart, will take a look at it.

Martin
Attachments
High Frequency Counter 16F877A FC5 V3.fcf
(22.11 KiB) Downloaded 229 times
High Frequency Counter 18F252.fcf
(22.39 KiB) Downloaded 210 times
Martin

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

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Contact:

Re: Frequency counter 35 Mhz

Post by STibor »

Thanks!
Problem in the 18F252fcd file, and all fcd file.
Timer1 int

Code: Select all

Opt1_2Val="st_bit(intcon, PEIE);\nst_bit(t1con, T1OSCEN);\nst_bit(t1con, TMR1ON);\ncr_bit(t1con, TMR1CS);\n"
And configuration:

Code: Select all

Opt2_1Val="t1con = t1con & 0b10000111;\n"

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

I tried your frequency counter with a 18F2523 at 40MHz (10MHz xtal, 4xPLL)
It works well. Tested up to 2MHz (displays 2000856Hz)
Martin

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

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Contact:

Re: Frequency counter 35 Mhz

Post by STibor »

The final version.
System clock frequency: 40.96 MHz
Attachments
frekimero18f2620_6_p.fcf
(17.52 KiB) Downloaded 175 times
18F252.fcd
(14.62 KiB) Downloaded 153 times
frekimero18f252_6_p.fcf
(17.51 KiB) Downloaded 173 times

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Contact:

Re: Frequency counter 35 Mhz

Post by STibor »

18F2620 modified FCD file.
Attachments
18F2620.fcd
(14.83 KiB) Downloaded 145 times

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Contact:

Re: Frequency counter 35 Mhz

Post by nc56 »

Hi some pic of te family 18F contain 4 TMR , so can I do a Frecouncy counter with four channels with te same pic ?
thanks :)

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Contact:

Re: Frequency counter 35 Mhz

Post by nc56 »

Hi
in medelec35's program , there are 2 lines
which one give us the result ? !
for exemple for 9khz I have this result
Attachments
2.rar
(169.96 KiB) Downloaded 139 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Hi nc56,
Its only the top line that displays the frequency, the bottom line was for testing purposes, and and be removed or ignored.
As for displaying the wrong frequency, You need to connect signal generator (set as frequency not period) to T1CKI (Pin 11) which is not connected to anything in your picture.

As for using 4 channels, I would guess no, since its using a timer (clock in) for the frequency input.

As its only a guess, I could be wrong of course

Martin
Martin

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

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Contact:

Re: Frequency counter 35 Mhz

Post by nc56 »

Hi modelec
when I connect the generator to T1CKI (Pin 11) ; the LCD shows always 0 Hz with any frequency
what's the problem ? I used the "High Frequency Counter 18F252.fcf" program
Thank you

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Have you tried with real hardware, or just a simulator.
Simulators sometimes don't work as well as we would like them too.

Can you try with real hardware please.
If then it still does not work, I will see if I can find the issue.
Martin

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

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Contact:

Re: Frequency counter 35 Mhz

Post by nc56 »

I just tested with the porteus
ok I will try with hardware .

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Contact:

Re: Frequency counter 35 Mhz

Post by nc56 »

Hello medelec35
yes it works in hardware ,minimum value 1hz, maximum value 3MHZ , can I modify somthing to achieve more than 3MHZ ?
thank you :)

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Contact:

Re: Frequency counter 35 Mhz

Post by nc56 »

Hi Martin
I tried to show the values only in HZ , for example 1khz bust be shown 1000 hz... but it didn' work
I changed this code :

FrequencyString = left$ (TempString,1)
FrequencyString = FrequencyString + "."
TempString = right$ (TempString,3)
FrequencyString = FrequencyString + TempString + "KHz "

to
FrequencyString = left$ (TempString,8)
TempString = right$ (TempString,8)
fin = FrequencyString + TempString + "Hz"
and I removed the Switch Gatetiming
it shows for 1200 hz : 12001200
Attachments
testa.fcf
(17.73 KiB) Downloaded 120 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Hi nc56,
I have not tested this Flowchart so its only guessing, but give it a go and let me know how you get on please.

Cheers

Martin

Edit: Removed attachment, and posted new link in a different post.
Martin

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

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Contact:

Re: Frequency counter 35 Mhz

Post by nc56 »

ok , I will test it monday , please what about if I want frequency more than 3 MHZ ?

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Hi nc56
Frequecy counter I posted was only designed to auto range. Eg. show Hz, KHz or MHz.
For just Hz try this:
http://www.matrixmultimedia.com/mmforum ... =25#p41816

As I don't think what I posted will work for just Hz to be honest


Martin
Martin

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

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Contact:

Re: Frequency counter 35 Mhz

Post by nc56 »

ok thank you martin
one only question how can ave a value of frequency > 3 MHZ
I m using a 40MZ external crystal , if I change it can I have better result ?

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Hi nc56,
No problem.
As for greater than 3MHz,
I'm not sure if it can to much higher.

This Frequency counter was only my theory so I wanted to post something that's got a higher range then the usual frequency counter posted.

This frequency counter works differently to the one that the original poster posted a link to, since gate is software controlled rather then hardware controlled.

So may never be as good.
Martin

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

User avatar
Jan Lichtenbelt
Posts: 796
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Contact:

Re: Frequency counter 35 Mhz

Post by Jan Lichtenbelt »

Hi Martin

What a very interesting program to measure frequencies up to higher values.

I tried you version High Frequency Counter 16F877A FC5 V3.fcf, but I found that it failed, due to the fact that it did not trigger on the T1CKI port (which is C0 for PIC12F19639), but on the inner oscillator. I changed the Timer1 settings in a version 4, which now triggers on the external signal. Frequencies up to 1-2 MHz can be measured.
But sometimes the program stops. Especially if you start without a signal the program does not detect any frequency anymore.

Do you have a solution?

Kind regards

Jan Lichtenbelt
Attachments
High Frequency Counter V4.fcf
(25.66 KiB) Downloaded 111 times

User avatar
Jan Lichtenbelt
Posts: 796
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Contact:

Re: Frequency counter 35 Mhz

Post by Jan Lichtenbelt »

In the meantime, I found the problem and solved it.

Please find the timer of Martin, a little bit changed for the PIC12F1939 (19.66 MHz oscl.)
The frequency measured are 100 Hz to 2 MHz (my upper limit of the generator) in 4 digits.
The accuracy up to 1 MHz is <+0.1 % and <+0.6% for the range 1-2 MHz (error compared to the generator).
Additional is that in the range 100 Hz to 1 KHz a sampling time of 10 sec, necessary for the accuracy of 4 digits, will be shown on the LCD screen.

Please find the updated version 4.1

Kind regards

Jan Lichtenbelt
Attachments
High Frequency Counter V4.1.fcf
(25.58 KiB) Downloaded 152 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Frequency counter 35 Mhz

Post by medelec35 »

Jan Lichtenbelt wrote:Hi Martin

What a very interesting program to measure frequencies up to higher values.
Thanks Jan,
It is a better way rather than using internal timers.
Also the auto ranging part is useful.

Thanks for converting it to run on 16F1939.
I'm glad the concept works, and you have solved the issue you had for your target device.
You have done a great job.

Martin
Martin

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

Post Reply