HELP with Year counter


Closed Thread
Results 1 to 2 of 2
  1. #1
    sanatana's Avatar
    sanatana Guest

    Default HELP with Year counter

    Hello Everyone
    I Need some of your expert help in solving my problem.
    This what i am trying to do.
    I want to be able to tell when 365 days has being reach on my data logger
    I am using Pic18F452 and my Timer1 has already being used for a different task so i can't use that.
    i am now trying to use the 1Hz pulse coming from my DS1307 connected to RB0 interupt pin.
    But the problem is a word variable can only hold 65536 counts which is just over 18 hours but i want to count 24 hours
    18x 60x60 =64800
    24x60x60=86400
    The idea is that if i can be able to to know when 1 day is reached all i have to do to check for when a year
    has reached is to know when 365 days has being reached.


    Hope to get your help
    Santana

    can i do something like this or any simpler way any of you might have would be much appreciated

    DAY VAR WORD
    TEMP_COUNT VAR WORD ' Count for 18 hrs
    OVER_COUNT VAR WORD' Count for 6 hrs

    DAY =0
    TEMP_COUNT=0
    OVER_COUNT=0


    'MAIN PROGRAM HERE
    '-------------------------------------

    AGAIN:

    GOSUB GET_ALARM
    GOSUB GET_TEMP
    GOSUB GET_TIME
    gosub Get_Batt
    @ SLEEP
    PAUSE 200

    GOTO AGAIN


    END

    ' Interrupt handler
    ' ===========================
    MYINT:

    IF INTCON.1=1 Then
    TEMP_COUNT=TEMP_COUNT+1
    WHILE
    TEMP_COUNT= > 64800 ' COUNT TO 18 HRS
    OVER_COUNT= OVER_COUNT+1 ' IF 18HRS REACHED THEN START COUNT NEXT 6 HOURS
    WEND
    IF OVER_COUNT=21600 THEN
    DAY = DAY +1
    TEMP_COUNT=0 ' RESET COUNTERS
    OVER_COUNT=0 ' RESET COUNTER
    ENDIF
    INTCON.1=0 ' Clear RB0 interrupt flag

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    nested variable and if then... try this

    Code:
    second var byte
    minute var byte
    hours  var byte
    day    var word
    year   var byte
    clear
    
    disable
    Myint:
        IF INTCON.1=1 Then
           if second<60 then
              second=second+1
           else
              second=0
              if minute<60 then
                 minute = minute + 1
              else 
                 minute = 0
                 if hours < 24 then
                    hours = hours + 1
                 else
                    hours = 0
                    if day<365 then
                       day=day+1
                    else
                       day = 0
                       year = year + 1
                    endif
                 endif
              endif
           endif
        endif
    enable
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Counter not counting !!!
    By lerameur in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 20th February 2009, 22:15
  3. Replies: 42
    Last Post: - 14th January 2008, 11:38
  4. 20 Digit Virtual LED Counter
    By T.Jackson in forum Code Examples
    Replies: 9
    Last Post: - 19th November 2007, 05:02
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27

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