CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC16F876 receive 100K digital signal?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Einly



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

PIC16F876 receive 100K digital signal?
PostPosted: Tue Jan 04, 2005 10:18 am     Reply with quote

Hi, I want to use PIC16F876 to receive digital frequencies from TSL-235. The maximum pulses received will be 100K.

Is PIC16F876 fast enough to solve this problem? How?

If not, what's about PIC18F1220? Because it is using 40MHz crystal.

Thanks a lot!

Regards: Einly,
_________________
Einly
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Jan 04, 2005 10:26 am     Reply with quote

And do what what with the signal?
Ttelmah
Guest







Re: PIC16F876 receive 100K digital signal?
PostPosted: Tue Jan 04, 2005 11:21 am     Reply with quote

Einly wrote:
Hi, I want to use PIC16F876 to receive digital frequencies from TSL-235. The maximum pulses received will be 100K.

Is PIC16F876 fast enough to solve this problem? How?

If not, what's about PIC18F1220? Because it is using 40MHz crystal.

Thanks a lot!

Regards: Einly,

I'd assume you just want to measure the frequency. If so, then 'yes'. Use Timer1 as a counter, running asynch, from the external clock input. Feed the signal from the chip into the T1OSI pin. Run an interrupt using timer2, at a fixed interval (say 1/10th second), and then at the entry to this interrupt, just record the value in timer1.
In the main code, when the recorded value changes, you can then determine that the count, over the timer2 interval, is the current count less the last count (if the new count is less than the old count, add 65536).
Depending on the period chosen, you have a direct measure of the incoming frequency.

Best Wishes
Einly



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

Maximum speed?
PostPosted: Wed Jan 05, 2005 6:26 am     Reply with quote

Thanks for your reply..

ya, I just want to measure the frequency of the input signal. Like to confirm with u: So 16f876 can measure input frequencty of 100kHz?

Just like to know, what is the maximum frequency that can be 'read' by PIC16f876 (ex.through the way u suggested) ?

"Use Timer1 as a counter, running asynch, from the external clock input. Feed the signal from the chip into the T1OSI pin. Run an interrupt using timer2, at a fixed interval (say 1/10th second), and then at the entry to this interrupt, just record the value in timer1. "

How should I calculate theoretically?
_________________
Einly
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Jan 05, 2005 7:57 am     Reply with quote

The chip datasheet will tell you the maximum frequency input for the counters. You DO have the datasheet memorized, don't you? ;-)
_________________
The search for better is endless. Instead simply find very good and get the job done.
Ttelmah
Guest







Re: Maximum speed?
PostPosted: Wed Jan 05, 2005 8:10 am     Reply with quote

Einly wrote:
Thanks for your reply..

ya, I just want to measure the frequency of the input signal. Like to confirm with u: So 16f876 can measure input frequencty of 100kHz?

Just like to know, what is the maximum frequency that can be 'read' by PIC16f876 (ex.through the way u suggested) ?

"Use Timer1 as a counter, running asynch, from the external clock input. Feed the signal from the chip into the T1OSI pin. Run an interrupt using timer2, at a fixed interval (say 1/10th second), and then at the entry to this interrupt, just record the value in timer1. "

How should I calculate theoretically?


The maximum frequency useable on the timer1 input, is dependent on whether you are using the 'F', or 'LF' chip. The former, allows rates up to 16.6MHz, while the latter only supports 10MHz.
If (for instance), you use a 1/10th second sampling period, then the frequency, is just the count recorded change*10 (because you are sampling 10times/second). However the resolution, is then limited to 10Hz. If instead you sample over 1 second, you would need to add a handler for timer1 overflowing, and increment a 'high' bit, to generate a 32bit count value, when this happens, since otherwise the count will overflow if the frequency is over 65535Hz. The frequency is then just the recorded change in count. The 'downside' of this, is that the update rate, is then only 1Hz.
Using 1/10th second, gives a 'range', of 10Hz, to 655350Hz, with a resolution of 10Hz, without having to handle the overflow in the counter. Given that binary multiplication is 'efficient' in processor terms, you might consider using a 0.5 second sample interval, and multiplying by 2, which then gives a range of 2Hz, to 131070Hz, with a resolution of 2Hz, and still avoids the need to handle the overflow in the interrupt code. However in all cases, the final arithmetic will need to be 32bit.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group