Calculating Time for clock's preset


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    How do I define LONG variable?
    What do I do with a situation where start is 10:00 and end is 09:00?
    If using AM/PM sign, what do I do if start is at AM and stop is PM ?

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Cool

    Quote Originally Posted by menta View Post
    How do I define LONG variable?
    It's in your PBP manual...just like you define any other variable.

    What do I do with a situation where start is 10:00 and end is 09:00?
    If using AM/PM sign, what do I do if start is at AM and stop is PM ?
    Time to start thinking a bit...
    If it starts at AM, then the flag would equal AM AND the time would match.
    If it starts at PM, then the flag would equal PM AND the time would match.
    Doesn't matter if it starts or stops, it's all in how you set up your If/Then statement to match what YOU want to do.

  3. #3
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    From the HELP "Size is BIT, BYTE or WORD."
    Does the 16F support 32bit ?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by menta View Post
    From the HELP "Size is BIT, BYTE or WORD."
    Does the 16F support 32bit ?
    Well, you never specified that you were using a 16Fxxx, so I guess you don't get to use a LONG variable.
    And it's not so much if the 16F supports 32 bits, 'cause none of the 10F/12F/16F/18F support 32 bit variables. It's the compiler that either supports them or doesn't.

  5. #5
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    So can I use the 16F with long variables or not ?

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by menta View Post
    So can I use the 16F with long variables or not ?
    ...........................
    Quote Originally Posted by skimask View Post
    Well, you never specified that you were using a 16Fxxx, so I guess you don't get to use a LONG variable.

  7. #7
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    ...it's not so much if the 16F supports 32 bits, 'cause none of the 10F/12F/16F/18F support 32 bit variables. It's the compiler that either supports them or doesn't.
    If its not related to the PIC then why can't I ?
    According to this http://www.microchip.com/stellent/id...cName=en532453
    what does the 32 means if not supporting 32-bit ?

  8. #8
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    I got a solution from a friend:
    This will cover all cases for start: (Same will be for end but with End values)

    HH>StartHH ||
    HH=StartHH & MM>StartMM ||
    HH=StartHH & MM=StartMM & SS>=StartSS

    Should Start programs.
    The only problem is wrap around at 23:59:00 -> 00:00:00
    But this will be handled with a special flag to identify change from PM->AM
    Last edited by menta; - 3rd July 2008 at 17:20.

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Lightbulb

    Quote Originally Posted by menta View Post
    I got a solution from a friend:
    HH>StartHH ||
    HH=StartHH & MM>StartMM ||
    HH=StartHH & MM=StartMM & SS>=StartSS
    Looks like that will work (with some parenthesis added).

    This should work for the rest of it ...
    Code:
    TimeCmpFlags  VAR BYTE
      PastStart   VAR TimeCmpFlags.0
      PastStop    VAR TimeCmpFlags.1
      NextDay     VAR TimeCmpFlags.2
      ProgON      VAR TimeCmpFlags.3
    
    
    CheckTimes:
      TimeCmpFlags = 0  ; clear flags first
    
         ; if the Start and Stop times are the same, then Always OFF 
      if (Stop_H=Start_H) AND _       
         (Stop_M=Start_M) AND _
         (Stop_S=Start_S) then AlwaysOFF                      
    
         ; is it past the Start time?
      if (Hours>Start_H) OR _              
         (Hours=Start_H AND Minutes>Start_M) OR _
         (Hours=Start_H AND Minutes=Start_M AND Seconds>=Start_S) then PastStart=1
    
         ; is it past the Stop time?
      if (Hours>Stop_H) OR _                
         (Hours=Stop_H AND Minutes>Stop_M) OR _
         (Hours=Stop_H AND Minutes=Stop_M AND Seconds>=Stop_S) then PastStop=1
    
         ; does the period end the following day?
      if (Stop_H< Start_H) OR _           
         (Stop_H=Start_H AND Stop_M < Start_M) OR _
         (Stop_H=Start_H AND Stop_M=Start_M AND Stop_S < Start_S) then NextDay=1
        
      ;---------------
      if !NextDay then                               ; same day, use AND
          if PastStart AND !PastStop then ProgON = 1
      else                                           ; next day, use OR
          IF PastStart OR !PastStop then ProgON = 1
      endif
        
      AlwaysOFF:
    return
    Added: You should keep in touch with your "Friend". It was a good "Tip".
    Last edited by Darrel Taylor; - 4th July 2008 at 01:57. Reason: Added:
    DT

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Well, you never specified that you were using a 16Fxxx, so I guess you don't get to use a LONG variable.
    And it's not so much if the 16F supports 32 bits, 'cause none of the 10F/12F/16F/18F support 32 bit variables. It's the compiler that either supports them or doesn't.
    Quote Originally Posted by menta View Post
    If its not related to the PIC then why can't I ?
    According to this http://www.microchip.com/stellent/id...cName=en532453
    what does the 32 means if not supporting 32-bit ?
    With any luck, this should clear it up a bit...
    PBP is a COMPILER....MPASM is an ASSEMBLER.
    PBP supports...PICxxxxx (see their website...way too many to list)
    MPASM supports...well, basically, anything in the Microchip inventory.
    The PIC32 is supported by MPASM, the assembler.
    The PIC32 isn't supported by PicBasicPro, the compiler.
    A program is written (source code), is compiled (by PBP) into assembly code (machine code), and assembled (by MPASM) into hex code (binary to be programmed) by the programmer (PICKIT2 for example).

  11. #11


    Did you find this post helpful? Yes | No

    Default

    once started or stopped, start looking for the next event starting with hour = then min = then second > as DT suggested earlier if then.....
    same logic a human would use looking for an event

    amgen

Similar Threads

  1. I don't understand this code!
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 13th February 2008, 02:55
  2. Measuring time
    By AugustoPedrone in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th July 2007, 23:46
  3. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  4. Calculating elapsed time, how?
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st June 2006, 09:00
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14:24

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