16F877A timer to capture in microseconds


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20

    Default 16F877A timer to capture in microseconds

    I tried on the OLYMPIC TIMER project provided by Melanie in the Sample Code Section, and that is indeed a good one. But, I am currently working on a project which requires me to capture the time in microseconds. While OLYMPIC TIMER project is able to display 1/100 seconds and with 4Mhz clock it will be 1 microsecond ticking.

    I would like to know if there is any possibilities that I can utilize that 1us ticking to capture the time difference in microseconds and display it on LCD?

    Can any experts guide me in this problem? Thanks in advance!

  2. #2
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Perhaps capture the time in microseconds is impossible to do so since no reply from anyone. Anyhow, from the Olympic Timer and Automatic Clock provided by Melanie and Darren, both of the project display the fastest time count of 10ms on LCD.

    Is there any possibility that to display 1ms timer counts on LCD? Meaning that the Stop Watch Timer can capture up to 1ms instead of 10ms.

    Please help me on this matter, urgent. Anyone?

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Three things...

    1. Try it. Build the circuit and change the pre-load value for the Timer for 1mS instead of 10mS and change the display to show the additional digit.

    2. If it is too slow, try (a) connecting the LCD in 8-bit rather than 4-bit mode to reduce the display time, (b) use a 18F part at 40MHz instead of a 16F part at 4MHz, (c) The danger is you may throw data at the LCD too fast and it won't love you, so try displaying the data only every tenth count, or just at the end with the final result.

    3. Consider using the CCP Module of the PIC. You will be able to capture events into the uS range with that. Datasheet of your chosen PIC will explain how to use the CCPM - naturally chose a PIC that has it!

  4. #4
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Method 1 is sufficient to complete my project, as it is possible to capture display the time in milliseconds.

    I am facing a problem here of which, I do not know how to calculate the require timer pre-load value in order for to timer to count on 1 millisecond basis. I tried to apply the value $FC38 which I calculated based on my understanding from $D910 as in the sample codes, but it appears to that the timer counts become slower. I tried with other values such as $FFFE, $03C7, all seems to make the timer count really slow.

    Can anyone guide/teach me in how to calculate the actual pre-load value which I can get 1 millisecond timer and display it on LCD? I am using 16F877A with 4Mhz crystal.

    Sorry for all the question, I am really new to this, hope can help me. Very much thanks.
    Last edited by sycluap; - 19th December 2007 at 06:42.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    And you changed the TickCount Interrupt Handler to account for the fact that Hundredths are now Thousandths and changed the variable from a byte to a word and ensured everything is ticking in 1mS steps? Or have you just changed the pre-load valve and hoped everything would work?

  6. #6
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    I only made changes to the pre-load value, LCDOUT command to display up to 3 digits and the tickcount interrupt handler, where I put in the new:

    Tickcount changes:
    If RunningFlag=1 then
    Thousandths=Thousandths+1

    If Thousandths>9 then
    Thousandths=0
    Hundredths=Hundredths+1

    etc....

    LCDOUT Changes:
    LCDOUT $FE, $C0, DEC3 Thousandths, " Thousandths"

    It doesn't seems right. What went wrong? Did I miss out anything? Getting 1ms counts is very critical for my project, but I just couldn't figure it out.
    Last edited by sycluap; - 20th December 2007 at 06:54.

Similar Threads

  1. mS Timer
    By whmeade10 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th September 2020, 12:12
  2. Using hardware capture
    By Bruce in forum Code Examples
    Replies: 14
    Last Post: - 25th March 2012, 05:52
  3. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  4. Measuring change of frequency with PIC
    By Aussie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th July 2007, 01:47
  5. Reaction timer using 16f877a and pbp
    By sphinxifm in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th July 2007, 14:28

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts