Best Microcontroller Projects


XML RSS
What is this?
Add to My Yahoo!
Add to My MSN
Add to Google

Home
LCD-KEYS OnePort
Digital Downloads
C Course
State Machines
Interrupt Secrets
Schematic Tool
PIC Introduction
PIC Programming
PIC Programmers
PIC Compilers
PIC Projects
Tips & Techniques
Store
My SECRET
Oscilloscopes
Contact Me
About Me
Terms of Use
Search This Site
Freebies
Articles
Problem?-Solution
MicroBlog
Books
Resource Links
Site Map
Your Projects
Video du Jour
Rant/Rave
Privacy Policy

I use and
recommend Firefox
for the best internet
browsing experience. Click below for your
free copy today:

CLICK THE IMAGE:


Note: I find it faster
and easier to use and
it has great plugins.  

It even imports all your current
browser settings!

There's no risk as your existing browser is not affected in any way - you can just choose which one to use.


Find Out How This
Site Works
Like any engineering problem with the right tools it's Easy.
CLICK HERE 

Social Bookmarking
Click & Add:
add to BlinkBlink
add to Del.icio.usDel.icio.us
add to DiggDigg
add to FurlFurl
add to GoogleGoogle
add to SimpySimpy
add to SpurlSpurl
Bookmark at TechnoratiTechnorati
add to YahooY! MyWeb
Find out Why social bookmarking is
Useful For You.

Readers comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."


- Ranish Pottath


"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com

Learn PIC C Now
Wondering how to program your next project using C and need a great start?


"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

Learn Microcontrollers
"Interested in
Microcontrollers?"


Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon





Schematics and C code for a PIC frequency counter operating up to about 50 MHz.

A Liquid Crystal Display Based
frequency counter
project...

Project Update:

"Measuring Analogue Voltages

Without An ADC"


FREE )

Warning: This project could be Removed at
any time and will NOT be available indefinitely.
To avoid disappointment get it Now.


Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.


To get exclusive access enter your
Name and Primary email Now:


Primary Email
First Name

Don't worry -- your e-mail address is totally secure.
I promise to use it only to send you MicroZine
Note: Look through the back issues for your
No-ADC method).


P.S. The newsletter also has essential information for you as well.

More Resources...

This PIC frequency counter project uses an LCD to display the frequency and PIC timer 1 (TMR1) to measure the input signal.

PIC frequency counter block diagram

It uses TMR1 in 16 bit counter mode to count the input signal edges and overflows of the counter are accumulated to give the total count in multiples of 65536.

Adding the current value of the counter at the end gives the total count.

Since the measurement time is 1 second the final count is actually the frequency of the input signal. 

Using the 1 second measurement time also gives a frequency resolution of 1 Hz.

Get a frequency counter now

Here's a selection of frequency counters that you can buy on Ebay (if you don't want to make up your own then you can get a bargain here - and it will have all the front end circuitry made for you).  

Just click on the Counter you want and start bidding.



Click here to see more frequency counters on ebay.

Specification

Min frequency 1Hz
Max frequency ~50MHz (limited by input pin characteristics).
Input signal level TTL


Note: The exact maximum operating frequency is determined by the PIC input pin characteristic.

Compiler Mikroelectronika C compiler V5.0.0.3 Free!
Target 16F877A (retargetable to other PICs that have TMR1)
Software level Advanced.
Software notes Constant time code.
Hardware level Easy.
Hardware notes LCD will work with LVP (if PGM pin is pulled high).
Project version 1.01
Project files Enter your details to get the Download Link
and get the microcontroller newsletter:
:
:
(Note: Your email is safe it will never be sold or rented).
You will get All the C source code and hex file.

Essential
C Programming Course:

For a tutorial on compiling these files click here.

You only need to recompile the pic frequency counter files if you want to change the source code or examine how the code works using the built in simulator since the hex file to program the chip is included in the download.

For the general theory of operation of this circuit and notes on frequency counting of this pic frequency counter click here.

PIC frequency counter schematic using LCD and TMR1.
(Click diagram to open a pdf.)
PIC frequency counter schematic using LCD and TMR1.

Learn about the tool used for creating this diagram

Pic frequency counter Hardware

The hardware is simple and the main blocks are shown in the diagram below.

pic frequency counter

Learn about the tool used for creating this diagram

The LCD is used in 4 bit mode interface so you only need 4 data lines and three control lines and it then fits into a single 8 bit port.

The crystal oscillator is simply a crystal and two capacitors connected to the PIC oscillator port at OSC1 and OSC2. The capacitors can both be fixed at the same value unless you want to tune it using a frequency reference. If you don't have an accurate reference then use fixed capacitors.

The PIC micro can be any type that has a Timer 1 hardware and and has enough memory to hold the program.

The LED is toggled at the end of every gate time to indicate that the processor is alive - so if there is no input signal you can tell that the software is working.

You can program the PIC in circuit through the ICSP connector.

PIC frequency counter Software

Project files for the PIC frequency counter

Compiler project files
Frequency_counter_4MHz_LCD_TMR1.ppc

C Source files.
Frequency_counter_4MHz_LCD_TMR1.c
bcd.c
delay.c

Header files.
bit.h
bcd.h
delay.h

Output files
Frequency_counter_4MHz_LCD_TMR1.hex

Brief description

  • frequency_counter...c : contains the code start point (in routine 'main') and the 1 second delay (measurement time) - gate_loop.
  • bcd.c : contains machine code to convert a long to a bcd.
  • delay.c : contains code to create fixed delay times.
  • bit.h : contains macros for bit manipulation.

All other header files contain prototypes.

PIC frequency counter code operation.

The code uses the built in LCD driver routines which are automatically included by the compiler. Note automatic include is unusual but it seems to work well in mikroC.

Interrupts are not used only the flags that can be polled (timer overflow) are activated.

frequency_counter_4MHz_LCD_TMR1.c

This file contains the port initialization, gate loop and main routine.

After initialization the code enters an endless loop where it continuously performs a measurement and display operation. After an accurate 1 second delay the counter result is processed and displayed on the LCD.

The gate loop is tuned to just below a millisecond so that the caller (in main) can adjust the exact delay taking account of any delays caused by calling the gate loop routine itself.

Note that the timer overflow is polled within the gate loop - the extra statements in the else part of the if statement allow constant execution time whether the condition was true or false. This allows the loop time to be accurately calculated since it always has the same execution time.

delay.c

Delay routines were created using machine code so that they have a fixed execution time i.e. they do not change as the compiler re-optimizes the code. They are also fixed in memory location to avoid bank change problems.

bcd.c

This routine was created in machine code to save space on the smaller chips and it also results in faster code than using the built in routines for long multiply and divide.

It uses the Add 3 method to convert the unsigned long into an ASCII value that can be displayed on the LCD.

bit.h

This contains macros for bit manipulation which should be compiler independent.


Jump from pic frequency counter page to
to Best Microcontroller Projects Home Page.


Don't forget to Sign Up for your

Microcontroller Newsletter

With "Essential tips and techniques",

..."New Site Info" and more...

Including a free project :

How to drive an LCD and 12key keypad using "Only One 8 Bit Port" with no interface logic!...

(Works for any microcontroller)

This costs you : Nothing...
Just fill out the form below and you'll get full C source code and project schematic and description.



Email

Name

Then

Don't worry -- your e-mail address is totally secure.
I promise to use it only to send you MicroZine.
Google
 
  Best Microcontroller projects.