piclist 2001\02\23\155503a >
Thread: Frequency counting
face BY : Dan Michaels email (remove spam text)

Brusque wrote:

>    The maximum frequency this would have to count would be about 20khz.
>The strange fact is that when I suply a 100hz square wave to the circuit,
>the countings turns a lot random.

I'll take a closer look at your algorithm tonite, and see what I can see.

>    Could you please suply some code excerpts from your frequency
>counting routines?

see other answer for basics.

>> Using (float)casting, I guess round-off errors during division
>> isn't going to be a problem.
>    I'm only using it because of the need for a 32 bit counting. Maybe
>I'll try to make some kind of 32 bit integer maths with CCS.

No, actually, I meant you are probably better off using float, since
integer math more easily gives round-off errors and overflows, etc.

>> But given your algorithm with all of its inversons/etc, do you
>> have any idea how many Timer1 ticks is the difference between
>> measuring 2480 and 2500?
>    That values are in ticks. The input on the PIC was a 1000hz square
>wave. Every cycle takes 1ms. The Timer1 tickles 2500 times in one 1ms
>with 10mhz clock.

Hmm, so then 2500-2480 = 20 amounts to 20*.4usec = 8 usec. Something
so short could be due to overhead problems. I look at it more closely
tonite [and hopefully someone else will have fixed it by then :)].

- dan michaels

http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


See also: www.piclist.com/techref/microchip/time.htm?key=count
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Frequency counting

month overview.

new search...