Connect with us

Speed of object with PIC 16F877a: Stuck with Timer

Discussion in 'Microcontrollers, Programming and IoT' started by Kashif, Apr 28, 2011.

Scroll to continue with content
  1. Kashif

    Kashif

    4
    0
    Feb 18, 2011
    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
     
  2. loop

    loop

    4
    0
    May 31, 2011
    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...
     
  3. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,482
    2,830
    Jan 21, 2010
    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.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-