Best Microcontroller Projects


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

Home
LCD-KEYS OnePort
C Course
Schematic Tool
PIC Introduction
PIC Programming
PIC Programmers
PIC Compilers
PIC BASIC
Tips & Techniques
PIC Tutorials
PIC Projects
Store
My SECRET
Oscilloscopes
Web Directory
MicroBlog
Problem?-Solution
Books
Wish List
Contact Me
About Me
Terms of Use
Search This Site
Freebies
Articles
Resource Links
Site Map
Your Projects
Rant/Rave
Video du Jour
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.

Google

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





Multitasking for PIC micros


Every time you turn on your computer it is multitasking and all the tasks that the PC performs are done using one instruction at a time.

Multitasking simply means switching attention from one task to another to make it appear that many tasks are happening all at the same time.

To make it work in a PC the task manager shares out the processing time between each task giving it a set amount of time and then moving on to the next task.  The key to its operation is the speed of the processor - the faster it is the more tasks it can handle and the more complex they can be.  For really difficult tasks a separate processor may be involved e.g. a graphics processor or a floating point co-processor (built into Pentium chips now).

You can use the same idea for a PIC microcontroller but since it is not going at GHz speeds you have to carefully decide what tasks you need to do and how to make it work distributing a fair share of processing time to each task (or peripheral).

RTOS

An RTOS (Real Time Operating System) is the ultimate multitasking system and it makes writing code easier using flag signals for inter-process communication and provides prioritized task scheduling.

The penalty for using an RTOS is that it takes up code space and RAM resource (and there is a learning curve as there are a lot of details for RTOS control and task switching).



On the web you can find RTOS code for PIC micros but this is probably more appropriate for the larger 18F series micros as RTOS's tend to require larger RAM and program resources (Ram is used to save all the current task data between task switching) so you won't fit many tasks into a mid-range PIC micro.

Simple Multiple task scheduling

You can make a simple multiple task scheduler using interrupts and careful coding and it won't need a huge amount of memory or resources.

The advantage of this method is that you have full control over the code generated and can therefore fit it into tiny devices.

The disadvantage is that you have to be completely on top of how your code is working.  With an RTOS time slices are assigned to each task giving them a fair share of processing time.  With this method you need to decide how tasks are assigned processor time as you design the code.

All you do is place all your code in an loop and use variables within the loop to test the conditions you need e.g polling an input.  Each test section is more or less equivalent to a task in an RTOS.

Interrupts

As with any multitasking system the heart of a task scheduler is the main timer that can assign time slices to each process.  For this method a timer interrupt e.g. Timer 0 operating every n milliseconds calls subordinate functions that require the highest priority.  Everything else is a low priority task that gets interrupted by the highest priority task.

When you use this multitasking method you have to balance the processing time of the interrupt routine against the processing needed by subordinate tasks so that enough time is spent doing the subordinate tasks.  All this really means is make the ISR (Interrupt Service Routine) as short as possible and as infrequent as possible. 

You can find more information from the website here.

Copyright © John Main 2006

Free to distribute if the article is kept complete.

http://www.best-microcontroller-projects.com


Jump from multitasking page 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.