Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16F870 frequency counter

Status
Not open for further replies.

metiz

Junior Member level 1
Joined
Aug 5, 2010
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
hhd
Activity points
1,401
Disclaimer: this is schoolwork, so I'm not sure if it's in the right segment.

I need to write a frequency counter for a PIC16F870 microcontroller that can read frequencies from 0 to 255hz (8 bit, at least they had some mercy there...). This is for a school project where we have to build a capacitive pick-up and then output the RPM of a DC motor on a LCD screen. We've had SOME training in assembly language, but pretty much everyone (lots of project groups) is having a realy hard time with this and as far as I know, no-one has figured it out yet. The capacitor setup is done and we have a square-wave output, 5v=1 and 0v=0

Can someone assist us with this, maybe points us to some examples, give us a few tips? The controller is 8 bit, runs on 4mhz and uses a RISC instruction set (basically the same you find on a wide range of PIC's).

Any help is greatly appreciated, this project is realy grinding us down...
Joost.
 

Hi,

0...255 Hz means 0...255 low-to-high transitions of your input signal.
On the one hand the task is relatively simple, on the other hsnd there are a lot of solutions to do this with a PIC.

Technically you need a exact timing window of 1.00 seconds. With a clock frequency of 4MHz this means 1 second is equal to 4.000.000 clock cycles. (Please use capital letters where they should be. M = mega = 1 million, m = milli = 1/1000)
Use the integrated timer/counter periferal to get the exact timing of 1.000 seconds.
Now to the counting of the pulses: you need a loop that lasts the 1.000 seconds. It needs to check the timeout condition of ghe timer/counter hardware.
Within this loop you need a variable to safe the state of the input signal of the previous loop run. If now the previous state is low and the current state is high, then you found the transition and you have to increment your frequency counter variable.

I think this is enough information to go on.
For sure you need to declare and initialize all your variables...


Klaus
 

Thanks for the help guys
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top