period measure

Post
marianotisera
New Member
2007/10/24 13:50:53
hi, i need to know which is the best way to measure period with 1 mSec accuracy using pic16f627, i need to measure a external clock period.
i actually use timer 1 and 4Mhz crystal but is hard to calibrate and measure two or more times the same period
thanks
 
P Lameijn
Super Member
RE: period measure 2007/10/24 14:32:02
What is the min-max period length? (mS, secs, mins, hours...)
 
Olin Lathrop
Super Member
RE: period measure 2007/10/25 04:49:52
i need to know which is the best way to measure period with 1 mSec accuracy using pic16f627  ...   4Mhz crystal  ...

That PIC doesn't have a CCP module, so you have to do this in firmware.  Fortunately your accuracy requirement isn't that stringent, so this is easy to do.  Set up a periodic interrupt at least every 500uS, which is every 500 instructions.  This can be done with timer 2.  In the interrupt count the number of ticks each full cycle of the input, which will yield the period in units of 500uS.  There can be up to 500uS error in capturing each end of the period, so your worst case error is within the 1mS you specified.
DarioG
Allm├Ąchtig.
RE: period measure 2007/10/25 05:04:49
Hmmm, I can see a CCP module in that PIC (627/628)... though I never used it.
Olin Lathrop
Super Member
RE: period measure 2007/10/25 05:19:24
Hmmm, I can see a CCP module in that PIC (627/628)... though I never used it.

Oh, OK, then he can capture the pulse period using the CCP peripheral in capture mode.  I didn't remember if the '627 had a CCP module so I took a quick look in the linecard and didn't see one listed.  Fortunately the OP can tolerate 1mS error in the period, so he can do this with a '627 whether it has a CCP module or not.
DarioG
Allm├Ąchtig.
RE: period measure 2007/10/25 05:51:12
ORIGINAL: Olin Lathrop
Fortunately the OP can tolerate 1mS error in the period, so he can do this with a '627 whether it has a CCP module or not.


Yep, agreed!
breyno2
Super Member
RE: period measure 2007/10/26 03:11:42