PDA

View Full Version : Timer1 - frequency measurement



-Dan-
- 27th October 2008, 11:54
Hi,

Has anyone got a sample program showing how to measure the frequency of an input, i want to measure the frequency of a transmitter.

i'm using a pic16f870, i've been reading the information on timer1 but i don't totally understand how to accomplish what i need.

Thanks

Dan

skimask
- 27th October 2008, 13:29
Hi,
Has anyone got a sample program showing how to measure the frequency of an input, i want to measure the frequency of a transmitter.
i'm using a pic16f870, i've been reading the information on timer1 but i don't totally understand how to accomplish what i need.
Thanks
Dan

Straight from the manual...


COUNT Pin,Period,Var
Count the number of pulses that occur on Pin during the Period and
stores the result in Var. Pin is automatically made an input. Pin may
be a constant, 0-15, or a variable that contains a number 0-15 (e.g. B0)
or a pin name (e.g. PORTA.0).................
But seriously, what frequency range are you planning on counting?

-Dan-
- 27th October 2008, 16:53
Straight from the manual...

But seriously, what frequency range are you planning on counting?


I considered using count, but i do not no its limitations what will it count up to?.

I want to measure in the 88-200mhz range, i doubt the pic can support this kind of range so i have got an external prescaler which will divide by 256 or 64.

skimask
- 27th October 2008, 17:02
I considered using count, but i do not no its limitations what will it count up to?.


COUNT Pin,Period,Var
Count the number of pulses that occur on Pin during the Period and
stores the result in Var. Pin is automatically made an input.........

Does that give you a clue as to the answer?


so i have got an external prescaler which will divide by 256 or 64.
You're going to divide RF using an 'external prescaler'?
Good luck with that...

Acetronics2
- 27th October 2008, 17:12
Hi, Dan

The Web is full of Ham Freqmeters ...

"Google is you friend."

EPE's last edition show a nice 50 Mhz one ... w/o prescaler.
µChip ANs show the original idea for those ones.

just yours to choose which one !!!

Alain

-Dan-
- 27th October 2008, 17:13
Does that give you a clue as to the answer?


You're going to divide RF using an 'external prescaler'?
Good luck with that...

See the below image

http://hem.passagen.se/communication/pic/fct_sch.gif

this is a project i found that does what i wanted, but it does not explain the programming side of capturing the frequency, which i want to understand.

I only want to learn :( lol

Acetronics2
- 27th October 2008, 17:19
Looking at this ...pic. I do think PbP has not its place inside the 870 !!!

125 Khz * 256 = ... 32 Mhz

Alain

skimask
- 27th October 2008, 17:19
That link doesn't work so good for me...might for some, not for me at the moment...


COUNT Pin,Period,Var
Count the number of pulses that occur on Pin during the Period and
stores the result in Var. Pin is automatically made an input.........


So what did you get out of this?

-Dan-
- 28th October 2008, 00:30
Looking at this ...pic. I do think PbP has not its place inside the 870 !!!

125 Khz * 256 = ... 32 Mhz

Alain

What do you mean?

and the 125khz is that the maximum frequency the 16f870 can capture?

Bruce
- 28th October 2008, 14:35
Timer1 can work with some pretty quick external input clocks. Check the electrical specs
section TIMER0 AND TIMER1 EXTERNAL CLOCK REQUIREMENTS.

Look at the specs for T1CKI High Time, T1CKI Low Time, and T1CKI Input Period.

With a pickup coil tuned to the frequency you're measuring, and the /64 output, it should
be pretty simple to measure your freq range.

-Dan-
- 28th October 2008, 15:14
Timer1 can work with some pretty quick external input clocks. Check the electrical specs
section TIMER0 AND TIMER1 EXTERNAL CLOCK REQUIREMENTS.

Look at the specs for T1CKI High Time, T1CKI Low Time, and T1CKI Input Period.

With a pickup coil tuned to the frequency you're measuring, and the /64 output, it should
be pretty simple to measure your freq range.

Hi Bruce,

I've read that, but i don't totally understand it, thats why i wanted some help in getting started, i no timer1 would do what i need, but i don't no how to control timer1, i've never written a program that uses it.

aratti
- 28th October 2008, 16:54
Visit the given link, schematic and code available.


http://digilander.libero.it/alfred73/eprojects.htm#1300 Mhz Frequencymeter with prescale

Al.

Bruce
- 28th October 2008, 18:07
I've read that, but i don't totally understand it
Which part are you having trouble with? I'll be happy to explain it.


thats why i wanted some help in getting started, i no timer1 would do what i need, but i don't no how to control timer1

T1CON on the 16F870 only has 6-bits that control the timer. Let me know what you don't understand that's in the data sheet, and I'll do my best to explain it. It would help if you tried a few code examples, and indicated which part you're having trouble with.

-Dan-
- 30th October 2008, 13:07
Which part are you having trouble with? I'll be happy to explain it.



T1CON on the 16F870 only has 6-bits that control the timer. Let me know what you don't understand that's in the data sheet, and I'll do my best to explain it. It would help if you tried a few code examples, and indicated which part you're having trouble with.

I don't understand how i work out, what the maximum frequency timer1 could capture from that data

Bruce
- 30th October 2008, 13:52
The datasheet shows T1CKI High Time min is 30nS for asynch mode with a prescaler of 1:1.

T1CKI Low Time is 30nS. And T1CKI minimum Input Period is 60nS.

So 1/60nS = the max input clock frequency it could handle. With your max freq at 200MHz
divided by 64, you should be well below the max clock input limit.

Look for AN592. Microchip shows an example using an old PIC1C5x with Timer0 that counts
up to 50MHz.

-Dan-
- 5th November 2008, 10:31
The datasheet shows T1CKI High Time min is 30nS for asynch mode with a prescaler of 1:1.

T1CKI Low Time is 30nS. And T1CKI minimum Input Period is 60nS.

So 1/60nS = the max input clock frequency it could handle. With your max freq at 200MHz
divided by 64, you should be well below the max clock input limit.

Look for AN592. Microchip shows an example using an old PIC1C5x with Timer0that counts
up to 50MHz.

Is there any examples written in picbasic pro, that you know of.