View Full Version : measure the xtal
savnik
- 7th June 2007, 15:59
I want to use timer0 in order to see in the LCD the frequency of crystal (internal clock). Or external on RA4
But I do not know how I begin.
I want use it , for measure xtal.
' 16F877A
DEFINE LCD_DREG PORTD ' Selection of the port D
DEFINE LCD_DBIT 4 ' Selection one RD4 with RD7
DEFINE LCD_RSREG PORTD ' RS on port D
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTD ' E on port D
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4 ' Mode 4 bits
DEFINE LCD_LINES 2 ' 2 lines
DEFINE OSC 4
OPTION_REG = %00001000
start:
LCDOUT $FE,1,#TMR0
goto start
skimask
- 7th June 2007, 16:06
To measure something, anything, you have to have an accurate timebase. To measure the internal clock of the PIC, using that same internal clock as your timebase as you've shown in your brief example, doesn't work.
Do you have an o'scope?
savnik
- 7th June 2007, 16:10
To measure something, anything, you have to have an accurate timebase. To measure the internal clock of the PIC, using that same internal clock as your timebase as you've shown in your brief example, doesn't work.
Do you have an o'scope?
Yes i have.
Or how to measure a xtal on RA4;
I want to measure the frequency of a oscillator with xtal or from a signal connecting to RA4
skimask
- 7th June 2007, 16:13
Yes i have.
Or how to measure a xtal on RA4;
I want to measure the frequency of a xtal or from a signal connecting to RA4
So you want to make a frequency counter then...not measure the internal frequency of your PIC...
savnik
- 7th June 2007, 16:15
So you want to make a frequency counter then...not measure the internal frequency of your PIC...
Yes.I want to measure the frequency of a oscillator with xtal or from a signal.
skimask
- 7th June 2007, 16:22
Yes.I want to measure the frequency of a oscillator with xtal or from a signal.
One of the easiest ways I can think of off the top of my head...
Use PBP's COUNT command...
But that's only good up to about 125Khz when the PIC is running at 20Mhz.
So, you could 'pre-divide' (like the various prescaler/postscalers inside the PIC) the incoming signal using a divide-by-x chip, like maybe a 74193 or something similar.
Feed the input signal into the 74193, take the output from the 74193's Qd output, which will be a divide-by-16 output, and will effectively increase PBP's COUNT commands range up to about 2Mhz (with a decrease in resolution of course).
Cascade 2 of the 74193's back-to-back, and you should be able to measure signals up to about 32Mhz (which is the effective limit of the 74LS193), using PBP's COUNT command.
Acetronics2
- 7th June 2007, 16:52
Hi, Savnik
An easy solution is to use an external RC circuit and use ... RCTime ( 16 Bits result ...) !!!
calibrate RCTime ( low drift components !!! ) with a Known Freq XTal ...
With another XTal The Result will be proportionnal to the XTal Freq change ...
That's all, Folks !!!
Alain
skimask
- 7th June 2007, 17:12
Hi, Savnik
An easy solution is to use an external RC circuit and use ... RCTime ( 16 Bits result ...) !!!
calibrate RCTime ( low drift components !!! ) with a Known Freq XTal ...
With another XTal The Result will be proportionnal to the XTal Freq change ...
That's all, Folks !!!
Alain
Won't the output from RCTime be a logarithmic response, in other highly non-linear? You'd probably have to do some serious math to get accurate results.
Acetronics2
- 7th June 2007, 19:59
Won't the output from RCTime be a logarithmic response, in other highly non-linear? You'd probably have to do some serious math to get accurate results.
Hi, Skimask
you Just forgot The XTal range won't be from zero to infinite ... 1 to 20 ... may be.
But, as always, I'm not so sure of what our friend intends to do ...
Alain
savnik
- 7th June 2007, 20:44
But, as always, I'm not so sure of what our friend intends to do ...
I have done a frequency meter with prescaler (256) from 10-1400Mhz.
I did it with pbp(tmr0) and asm.
But now i want to make a frequency meter from 0 -10 Mhz with only pbp.
skimask
- 7th June 2007, 21:18
I have done a frequency meter with prescaler (256) from 10-1400Mhz.
I did it with pbp(tmr0) and asm.
But now i want to make a frequency meter from 0 -10 Mhz with only pbp.
Well, I gave you an idea that I thought was fairly good...whether you use it or not is up to you...either run with it or don't...
Acetronics2
- 8th June 2007, 10:22
Hi, Skimask
I'm out on this one ...
I thought at first Savnik wanted to build some kind of XTal "identifying Gizmo" ...
For a Freq meter, I never found simpler than The µChip AN 50 Mhz freq meter :
1 16F84
1 74HC 132
1 Input Fet
1 LCD ...
rather simple. But works fine. ASM program ...of course.
links to clones :
http://www.sixca.com/eng/articles/fc50/index.html
Note their PCB is to re-design ... too close layers in the P.A. section ... I couldn't measure over 7-8 MhZ with their design.
Got 50+ Mhz with a re-design of PCB ...
and :
http://www.sprut.de/electronic/pic/projekte/frequenz/freq.htm
Also simplified ...
http://l.lefebvre.free.fr/freq/freq_01.html
And the last one :
http://www.artra-qrp.com/fp50/fp50.html
Alain
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.