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





Beginners guide to the PIC Microcontroller

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...

Part 3 : 

Internal PIC timers 

One of the most important tasks a microcontroller can do is...

...measure time.

The microcontroller can easily do this as it operates using a fixed frequency clock oscillator.

The clock oscillator sets the speed of the microcontroller operation - this can either be an external crystal (up to 20MHz) or for modern PIC devices it can be an internal RC oscillator (from 4MHz to 8MHz).

Note: Using the internal oscillator saves having to wire up external hardware but the clock is less accurate.

Since each instruction executes in a set period of time (for the PIC micro this is 4 cycles of the clock) you can time events by working out how many instructions have executed.

Note: for jump instructions an extra cycle is needed.

Assembler code loop timing

By creating a routine containing an assembler code loop and knowing the clock speed you can create exact delay times since you know the time taken for each instruction to execute (from the datasheet).  

If you repeatedly executed this routine and kept a count of the number of times it's called then you can measure time in multiples of the execution time of the routine.

There's two problems to this method.

1.The microcontroller is not doing
useful work while it is executing the delay routine.

2.Measuring the delay time of the code
is not always easy (especially for complex loops).

Internal Timer Peripherals

The advantage of the timer peripherals is that they make it a trivial task to measure time.  They are hardware modules that operate separately from the CPU part of the microcontroller.

This also means that they are capable of very high speed operation (you can make a 50MHz frequency counter using a timer (even for the obsolete 16F84 device).

In the modern microcontrollers there are three timers; Timer0 Timer1 and Timer2 and each has different operations and capabilities.

You can use the timers to count periods of the internal clock or you can count periods of an external clock (for a signal connected to the correct pin of the microcontroller) i.e. a timer input- for Timer 0 this would be T0CKI  -Timer0 ClocK Input)

Note: Some timers can only count the internal clock - check the datasheet.

N.B. When counting the internal clock it is divided by 4 first Fosc/4.

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...

Using a timer

There are two ways to use a timer polled or interrupt.  

Polling

You can continuously read the timer values until you detect a value you want to measure e.g. to count to 1000 compare the timer registers to 1000 then do something.

Although it's simple the disadvantage is that the microcontroller can do nothing else while polling (or can do very little as it has to keep going back and looking at the timer registers).

Interrupt

When a timer overflows (passes from its maximum value to zero) it generates an interrupt signal which you can use to interrupt the CPU to tell it something has happened.

This means the CPU can go and do other processing tasks while the timer hardware is running in the background.

Although more complex to set up and use an interrupt driven timer is the better way to use a timer if you need to do other processing tasks.  

When you add in other peripherals interrupts are essential e.g. measuring time while servicing a serial interface.

Timer 0,1,2 summary

Timer 0

Timer 0 is an 8 bit timer with an 8 bit prescaler - in total it looks like a 16 bit timer and it was the original peripheral (actually the only peripheral in the 16F84!).  Its slightly tricky to use when starting out as you can not read the prescaler value (there are ways around this).  

So lets just look at the next timer:

Timer 1

Timer1 is a 16bit timer with a prescaler that can be set to 1,2,4 or 8 and it can take an input clock from a pin or use the internal oscillator (Fosc/4).

A prescaler is just a divider so if you had a clock frequency of 8MHz and the prescaler as set to 8 the output from the prescaler would be 1MHz.

Timer 2

Timer 2 is an 8 bit timer that can only count periods of the internal clock Fosc/4.  It has a 2 bit prescaler and a 4 bit postscaler - these make the range out output periods (or frequency) flexible.

In addition it has a period counting register that resets the counter when the counter reaches a programmed count (programmed by you).  This means Timer 2 can generate a wide range of output frequencies easily and this is used to generate the baud clock for the internal USART.

Timers use and limitation

A timer measures out set periods of time or counts periods but they are limited by the maximum count that they can store.

Maximum count

The maximum count is important as it sets a limit on the usefulness of the timer (without extra programming).

So for Timer1 prescaler set to 1 the maximum count is 65535.  So you could count up to a maximum of 65535 events.

To overcome this limit you can use a variable to store the number of times that the Timer overflows - the variable would then store the input event count in multiples of the Timer's maximum value.  

This makes it practical to measure any number of events.

Next time...

... Overview of other Internal Peripherals.

Learn how to control a microcontroller using C.

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...



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.