Counting time via external pulses


Closed Thread
Results 1 to 3 of 3

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Counting time via external pulses

    Pseudo code.

    IF PULSE THEN
    SEC = SEC + 1

    IF SEC = 60 THEN
    SEC = 0
    MIN = 1
    ...
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Aug 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Counting time via external pulses

    I did that, now my main problem is counting backwards......problem is if I count backward evrytime secounds passes 59 to 00 minute raises for 1, same happend if I go backward, but if should decrese

    this is my code:

    loop1:
    if porta.1=0 then
    counter=counter+1
    if counter == 12 then
    sekunda = sekunda +1
    counter = 0
    endif
    if sekunda == 60 then
    minuta = minuta +1
    sekunda = 0
    endif
    IF minuta == 60 then
    sat = sat +1
    minuta =0
    endif

    goto lcd
    endif

    if porta.0=0 then
    if counter == 0 then
    counter = 12
    if sekunda == 0 then
    sekunda = 60
    endif
    sekunda = sekunda -1
    endif
    counter=counter-1
    goto lcd
    endif

    goto loop1

    lcd:

    lcdout $fe,$c0,dec2 counter,"TCR:",DEC2 sat,":", dec2 minuta,":",dec2 sekunda
    while (porta.0=0 or porta.1=0)ause 10:wend
    goto loop1

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