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.

How to make a timer for PIC 16F84A?

Status
Not open for further replies.

luvyah2187

Newbie level 4
Joined
Aug 17, 2008
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,324
I am making a design project now using the PIC 16F84A. My proposed project was micro controller dust remover, like an automatic vacuum cleaner. My problem is i don't know how to make a timer, which can be set and reset. Please help!!!

Thanks!:D
 

Re: PIC 16F84A

I cant help you with actual code, cause i mainly program AVR chips ...

You will need to set timer interrupt. Check what kind of timer resolution you can achieve using prescaller. When you determine resolution, than use few variables to get correct time passed and another set of variables for activation delay.

For example if you get 256 uS (which is prescaller value 1024 on 4mhz crystal) than you will need one variable with value of 4000 that will decrease each timer interrupt call, and when it reach 0 it will give you aprox 1sec time passed. So now you need variables for sec, min and hour passed ..

Code:
TIMER () //not sure how does timer interrupt call looks like on PIC, but this will give you a hint
{
OneSecRes--;
if (OneSecRes == 0){
   OneSecRes = 4000;
   Sec++;
   if(Sec == 60){
      Sec = 0;
      Min++;
      if (Min == 60){
           Min = 0;
           Hour ++;
           if (Hour == 24)
                Hour = 0;
           }
      }
   }
if (TimerHour == Hour && TimerMin == Min && TimerSec == Sec){
      bInitCleaning;
      Hour = 0; Min = 0; Sec = 0;
      }
}

Now you need to check for bInitCleaning in main code and activate what ever you need to do when it is set.

Basically you will need 3 input buttons or something that will help you set or reset timer.
Two buttons for setting timer and one for set/reset ..


Hope this helped you a bit ...
 

Re: Help!!! timer using assembly programming

thanks for the reply,, i appreciate it very much...

Additional question in our project using PIC 16F84A we use assembly program...
please help me for the timer code...
 

Re: PIC 16F84A

How long do you want a timer to be? Do you just want it to wait awhile?
 

Re: PIC 16F84A

wmmullaney said:
How long do you want a timer to be? Do you just want it to wait awhile?



i want that i will be the one to set the time for the vacuum to clean the floor

Added after 1 minutes:

ScOe said:
I cant help you with actual code, cause i mainly program AVR chips ...

You will need to set timer interrupt. Check what kind of timer resolution you can achieve using prescaller. When you determine resolution, than use few variables to get correct time passed and another set of variables for activation delay.

For example if you get 256 uS (which is prescaller value 1024 on 4mhz crystal) than you will need one variable with value of 4000 that will decrease each timer interrupt call, and when it reach 0 it will give you aprox 1sec time passed. So now you need variables for sec, min and hour passed ..

Code:
TIMER () //not sure how does timer interrupt call looks like on PIC, but this will give you a hint
{
OneSecRes--;
if (OneSecRes == 0){
   OneSecRes = 4000;
   Sec++;
   if(Sec == 60){
      Sec = 0;
      Min++;
      if (Min == 60){
           Min = 0;
           Hour ++;
           if (Hour == 24)
                Hour = 0;
           }
      }
   }
if (TimerHour == Hour && TimerMin == Min && TimerSec == Sec){
      bInitCleaning;
      Hour = 0; Min = 0; Sec = 0;
      }
}

Now you need to check for bInitCleaning in main code and activate what ever you need to do when it is set.

Basically you will need 3 input buttons or something that will help you set or reset timer.
Two buttons for setting timer and one for set/reset ..


Hope this helped you a bit ...




the timer will use assembly language
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top