pic counting

Electronics Computer Programming Q&A
Post Reply
mustang
Posts: 31
Joined: Thu Jan 17, 2002 1:01 am
Location: Santa Ana, CA
Contact:

pic counting

Post by mustang »

Can anyone tell me how to count input pulses with a pic 16F84 using pic basic and read the number of pulses on the output?
bodgy
Posts: 1044
Joined: Tue Dec 04, 2001 1:01 am
Location: Australia
Contact:

Re: pic counting

Post by bodgy »

Which Pic basic? There are many of them out there.<p>In general, you could use the RTCC input (RA3) everytime this input receives either a high or a low (you choose) you can then increment a variable.<p>Colin
On a clear disk you can seek forever.
mustang
Posts: 31
Joined: Thu Jan 17, 2002 1:01 am
Location: Santa Ana, CA
Contact:

Re: pic counting

Post by mustang »

Hello Colin,
The PicBasic Compiler I am using is from Micro Engineering Labs, Inc. There is no version number. I am just curious as to where the count is stored when using RA4 and how you would you move the count to the output. Lets keep it simple by counting pulses between 1 and 10.
I know that you have to preset the "itcon" and "option" registers. How do you accumulate the count?<p>Ray
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: pic counting

Post by philba »

You have to store the count in a variable you define. wait for the pin to transition high, then wait for it transition low (one full cycle) and add one to your count variable.<p>[ March 02, 2005: Message edited by: philba ]</p>
mustang
Posts: 31
Joined: Thu Jan 17, 2002 1:01 am
Location: Santa Ana, CA
Contact:

Re: pic counting

Post by mustang »

would this statement work?<p>If Tock=1 then count=count+1<p>Ray
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: pic counting

Post by philba »

It depends. is it in a loop? You need to see the transition from 1 to 0 (or 0 to 1) to get an accurate count. That's why I suggested wait for a 0, then wait for a 1 and then increment count (and start over for the next pulse).<p>Draw a waveform on a piece of paper and look at it. Think about at what points you want increment your count. Think sequentially.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest