touble with a time calculation


Closed Thread
Results 1 to 40 of 59

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: touble with a time calculation

    the reason for the enable is that until the time = > the setting , the output is not displayed , also the enable flag is used for other routines , hardware options and other timers., also if the values of the Set time all are 0 then that disables the flag for this timer for display on the Glcd's and other outputs

    there are several timer clock options that need to show - time in secs only , mins+ sec only , hours,min, sec only ,currently these options turn off / on flags inside the main up/ down timer counter code to enable hours, mins ,sec changes

    by changing the values to 59 from 60 for say the secs this results in the following

    if set_hour= 0 set_min = 0, Set_sec = 10

    if main elapsed time now shows = 0 hour, 1 min , 0 sec

    If OT_sec = 60 - Set_sec + Seconds(main elapsed ) then

    OT display = 50 (60 - 10 + 0)

    if OT_sec = 59 - Set_sec + Seconds(main elapsed ) then

    OT display = 49 (59 - 10 + 0)

    if the event time was set for 10 sec and the main time is now 1 min then the overtime should read 50secs , not 49 sec

    I think i have this correct , but i am still testing
    cheers

    Sheldon

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Default Re: touble with a time calculation

    if you have a clock running
    try this
    h m s var bytes (current time )
    x y z var byte (old time )
    a b c var byte ( time difference)
    carry var bit

    time_difference: (assumes current time > old time)
    carry=0
    c=s-z
    if c>127 then
    c=c+60
    carry=1
    endif
    b=m-(y+carry)
    if b>127 then
    b=b+60
    carry=1
    else
    carry=0
    endif
    a=h-(x+carry)
    if a>127 then
    a=a+24
    carry=1 ;extra day needed to be added
    else
    carry=0
    endif
    return
    Last edited by richard; - 13th May 2014 at 14:04. Reason: typo needed brackets

  3. #3
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: touble with a time calculation

    time problem sorted , thanks steve for your help on that , cheers m8

    next part flash / data transfer from program mem to flash - problems never seems to stand still for long

Similar Threads

  1. Help with calculation
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th August 2012, 17:10
  2. CHECKSUM CALCULATION, Please Help!
    By wasilus in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd August 2012, 07:55
  3. Calculation Problem - value goes to zero after 65
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 12th March 2010, 05:10
  4. calculation
    By lerameur in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 20th May 2008, 16:28
  5. CRC Calculation - Need a little help
    By Steve43 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 13th March 2005, 01:23

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