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.

Help with computing frequency of square wave using PIC16F887 in Mikrobasic + LCD

Status
Not open for further replies.

philcul

Newbie level 5
Joined
Sep 29, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,333
Hi guys. I've been looking for a Mikrobasic example for computing the frequency of a square wave input on PIC16F887 but can't seem to find any. The frequency must be displayed on LCD. please help
 

You may need two different loops. One for the condition when incoming signal is low (below a halfway volt level).

As soon as the incoming signal is high (above the threshold), you call that the beginning of a cycle.

Start a loop that repeats as long as incoming is high. Have a timer going while you are in this loop.

When it goes low, exit that loop and begin a new loop that you stay in while incoming is low.

When incoming signal goes high, call that one cycle. Get the timer value. Divide it into one. Now you have the frequency.

====================

If you cannot be stuck in a loop, then set a flag for the condition of the incoming signal, whether it is hi or low. Examine the signal's state every so often.

It is up to you to figure out how often you need to come back and check whether it is hi or low.
You have to make sure you don't miss a change of state.

You have to figure out whether you need to count cycles per given time period, or count time increments per cycle.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top