Maker Pro
Maker Pro

Speed of object with PIC 16F877a: Stuck with Timer

Kashif

Feb 18, 2011
4
Joined
Feb 18, 2011
Messages
4
HI
I am working on calculating speed of object. I have used two LDRs.
What i am trying to do is that when the object cut of the light of some laser with first LDR the timer starts and when it connect with second the timer stops. I have problem with time calculating. I am using PIC 16F877a which has 8 bit timer. it can only store count between 0-255.
Kindly help that how to use timer and do time calculations. I am stuck with prescaler, timer, polling and time calculations. Need help.
Thanks for time
 

loop

May 31, 2011
4
Joined
May 31, 2011
Messages
4
Im not sure-- but will LDRs do the trick-- LDRs have very slow response time compared to microcontrollers I think itz around 5ms

I think there is a 16 bit timer in PIC16F877a --- Timer1 is a 16bit timer..

if u r only using Timer to calculate time.. I dont think u need that much calculation...
"In Timer mode, Timer1 increments every instruction
cycle."
so if u r running at 4MHz that means every instruction takes 1us that means your timer would run at 1MHz... so each increment of the timer value will be after 1us...
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
I believe you can set an interrupt to go off each time the timer overflows. Each time that happens you can increment a counter. If your counter has 16 bits then you will get a 24 bit count.

Alternatively, as suggested use a 16 bit counter. The same trick can be used to get as many bits as required.
 
Top