I have code written to measure the time period of a square waveform using pulsin . I measure the low time and the high time and add them together and send it to an LCD. It is quite accurate (comparing to scope) and the refresh time is fast as the frequency varies. Knowing that frequency is 1/time, how can one go about doing the math in PBP to calculate the frequency of this waveform? Thanks.
This is either very easy or a bigger problem than it seems.
Here is the main loop: I found that I needed to do the 4/5ths thing to get the time more accurate.
loop: pulsin PORTA.1,0,x
x = x / 100
pulsin PORTA.1,1,y
y = y / 100
z = x + y
z = z * 4
z = z / 5
LCDOUT $fe, $C0
LCDOUT " "
LCDOUT $fe, $C0
LCDOUT #z
Goto loop
Bookmarks