16F877 elapsed time control


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    8

    Default 16F877 elapsed time control

    Hello everyone,

    I am pretty new with Pic Programming . I have to measure the time elapsed between V0-V voltages. I am planning to use a POT as an input and display the time on 2x16 display. I am planning to use 16 F877 .


    Any ideas?


    Thanks

    Berkay

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    What are the minimum and maximum times you will be needing to measure?

    Will you be needing anything else going on at the same time?

    Maybe something like
    Code:
    for X = 1 to 255
    pause 10
    t = t + 1
    do whatever, pot
    if whatever =  thisorthat then tCalc
    next x
    tCalc:
    display t
    I know, not real code But an idea for you to try.

    So if "t" equals 100 , that would mean about a second has passed.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default thanks

    This is for my master thesis project.

    My time range is between 300 - 700 microseconds . Depending on the elapsed time value i will control the valves.

    Thanks for your help

  4. #4
    Join Date
    Jan 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    how can i start the timer for example when the analog input from the pot is 3 V and stop the timer when it is 5 V ?

    thanks

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Code:
    loop:
    If pot value => 3V then time
    goto loop
    
    time:
    for X = 1 to 255
    pauseus 10
    t = t + 1
    do whatever, pot
    if pot value =  5V then tCalc
    next x
    tCalc:
    display t
    goto time
    You may want to consider using ADCIN in place of POT.
    Notice I changed the example to PAUSEUS.
    And someplace around here there is a discussion about code execution time, or just test it to adjust the PAUSEUS.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jan 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Thanks for your idea,

    One more question. How am i gonna define the voltage. I have added a loop like but it didnt work. What can be the problem ?

    ADC_READ:

    ADCIN 0, ADCINFO
    D=ADCINFO*100/51

    timeloop:
    if D>3 then
    T1CON.0=1
    if D>=4 then
    T1CON.0=0
    endif
    ELSE
    goto timeloop
    endif

  7. #7
    Join Date
    Jan 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default continuous counting

    Hi mackrackit

    i tried this
    Quote Originally Posted by mackrackit View Post
    Code:
    loop:
    If pot value => 3V then time
    goto loop
    
    time:
    for X = 1 to 255
    pauseus 10
    t = t + 1
    do whatever, pot
    if pot value =  5V then tCalc
    next x
    tCalc:
    display t
    goto time
    You may want to consider using ADCIN in place of POT.
    Notice I changed the example to PAUSEUS.
    And someplace around here there is a discussion about code execution time, or just test it to adjust the PAUSEUS.
    but it doesnt stop counting for a defined voltage once it is triggered it does not stop for the final voltage.

    loop:

    adcin 0, adval

    If adval => 500 then time
    goto loop

    time:
    for X = 1 to 1023
    pauseus 10
    t = t + 1
    If adval = 1000 then tcalc
    next x


    tCalc:
    LCDOUT $fe, 2,"Time" ,":",DEC t
    goto time
    Once i stop it i ll adjust the pauseus value
    Anything missing? any suggestions?

Similar Threads

  1. using a pot to control a time range
    By glkosec in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th June 2008, 19:59
  2. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  3. Control unlimited servos at the same time
    By mrx23 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th September 2006, 14:14
  4. Calculating elapsed time, how?
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st June 2006, 09:00
  5. Button pressed time control
    By tanero in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 15th August 2005, 15:17

Members who have read this thread : 0

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