kiteman
- 6th October 2011, 09:27
Hi,
I need to read on a port of pic 18f2620 e frequency and period signal (square wave) from 0 to 200 hz.
Can Someone suggest me a little program in pbp?
Thankyou
Charles Linquis
- 7th October 2011, 01:25
You can get the period and frequency by
DEFINE PULSIN_MAX 32767 ; Don't let the sum overflow
...
pulsin pin,0,LowPeriod
pulsin pin,1,HighPeriod
if !LowPeriod or !HighPeriod then goto NoInput
TotalPeriod = LowPeriod + HighPeriod
a= 1000
b = 100
c = a*b
frequency = div32 TotalPeriod ; divide 100,000 by the Period
...
NoInput:
HSEROUT [CR,LF,"No Input"]
...
You may have to change some of the values, depending on your OSC, since the PULSIN resolution depends on the OSC frequency. Also, there is a lower limit to the frequency you can measure. At 4Mhz, you can go down to 1.52 Hz.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.