Page 2 of 3

Re: Frequency counter 35 Mhz

Posted: Fri Nov 09, 2012 12:02 am
by medelec35
What is your target device please?

18F252?

Re: Frequency counter 35 Mhz

Posted: Fri Nov 09, 2012 6:04 am
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.

Re: Frequency counter 35 Mhz

Posted: Fri Nov 09, 2012 8:45 am
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

Re: Frequency counter 35 Mhz

Posted: Sat Nov 10, 2012 9:19 am
by STibor
Hi!
Of course, you can buy from Farnell, but expensive.
Added to the frequency meter, based on your program.

Re: Frequency counter 35 Mhz

Posted: Sat Nov 10, 2012 9:59 am
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

Re: Frequency counter 35 Mhz

Posted: Sat Nov 10, 2012 1:07 pm
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"

Re: Frequency counter 35 Mhz

Posted: Sat Nov 10, 2012 10:01 pm
by medelec35
I tried your frequency counter with a 18F2523 at 40MHz (10MHz xtal, 4xPLL)
It works well. Tested up to 2MHz (displays 2000856Hz)

Re: Frequency counter 35 Mhz

Posted: Mon Nov 12, 2012 6:54 am
by STibor
The final version.
System clock frequency: 40.96 MHz

Re: Frequency counter 35 Mhz

Posted: Mon Nov 12, 2012 6:55 am
by STibor
18F2620 modified FCD file.

Re: Frequency counter 35 Mhz

Posted: Wed Nov 21, 2012 9:17 am
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 :)

Re: Frequency counter 35 Mhz

Posted: Wed Nov 21, 2012 4:58 pm
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

Re: Frequency counter 35 Mhz

Posted: Thu Nov 22, 2012 12:51 am
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

Re: Frequency counter 35 Mhz

Posted: Thu Nov 22, 2012 8:54 am
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

Re: Frequency counter 35 Mhz

Posted: Thu Nov 22, 2012 11:51 pm
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.

Re: Frequency counter 35 Mhz

Posted: Fri Nov 23, 2012 2:18 pm
by nc56
I just tested with the porteus
ok I will try with hardware .

Re: Frequency counter 35 Mhz

Posted: Fri Nov 23, 2012 4:06 pm
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 :)

Re: Frequency counter 35 Mhz

Posted: Sat Nov 24, 2012 5:57 pm
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

Re: Frequency counter 35 Mhz

Posted: Sat Nov 24, 2012 7:14 pm
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.

Re: Frequency counter 35 Mhz

Posted: Sat Nov 24, 2012 10:39 pm
by nc56
ok , I will test it monday , please what about if I want frequency more than 3 MHZ ?

Re: Frequency counter 35 Mhz

Posted: Sun Nov 25, 2012 11:28 am
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

Re: Frequency counter 35 Mhz

Posted: Sun Nov 25, 2012 1:59 pm
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 ?

Re: Frequency counter 35 Mhz

Posted: Sun Nov 25, 2012 9:33 pm
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.

Re: Frequency counter 35 Mhz

Posted: Thu Jan 17, 2013 12:54 pm
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

Re: Frequency counter 35 Mhz

Posted: Thu Jan 17, 2013 9:39 pm
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

Re: Frequency counter 35 Mhz

Posted: Thu Jan 17, 2013 9:54 pm
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