Pulse Counter

Status
Not open for further replies.

EDSON

New Member
I need to build a pulse counter with a PIC,employing TIMER0, with the following characteristics :

1) a square wave (0V - 4.7V) amplitude is applied to a unique pin of the PIC (say A4);

2) its frequency varies between 100Hz and 1kHz, (100,200,300,400,...900,1000);

3) the output is given in binary with leds (8 bits) and remains in the configuration during the application of the signal;

4) when the signal is switched off, the leds of the configuration become off;
 
Do you need to employ TMR0? This can be easily done by incrementing registers


eg,
Code:
Repeat
Until PORT.Pin = 0

Repeat
Until PORT.Pin = 1

Repeat
   Inc(Result)
Until PORT.Pin = 0

and of course from there you can add a timeout with something like

Code:
Result = 0
Repeat
   Inc(Result)
Until PORT.Pin = 0 or Result = 0

Result = 0

Repeat
   Inc(Result)
Until PORT.Pin = 0 or Result = 1

Result = 0

Repeat
   Inc(Result)
Until PORT.Pin = 0 or Result = 0

From there you can figure out what the modifier required would be from the code overhead by simulating and scale the Result up to uS or mS as required to find the frequency of the signal
 
Ya 100 to 250 of course ok & when the pulse increase you need to do some multiplication routine (8bit mul) will be fine.Aaaah you are displaying it on 8 LEDs.

I use TMR0 as counter & feeding pulse to RA4 something like that & reads the TMR0 value on certain period of time & do all other calculations.

But for example if the frequency is 300Hz how do you show them from 8 LED's?
 
Thanks for your reply. I would appreciate if you could give-me the source code (in MikroC or CCS C) for a pulse counter with the TIMER0, counting frequencies from, say, 10Hz up to 200Hz, with ranges of 10Hz (10,20,30,.....200) with bynary outputs in 8 leds.
Best regards and thanks for cortesy.
EDSON
 

How much code have you written?
 


I don't do C
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…