DS1994 Memory/Time iButton - Page 2


Closed Thread
Page 2 of 2 FirstFirst 12
Results 41 to 48 of 48
  1. #41
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    You can find the "final" version in the code examples section:

    http://www.picbasic.co.uk/forum/show...=3041#post3041

    regards:

    Ralph

  2. #42
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie
    Here's the solution to item 2 from my previous post yesterday (as it's the easiest to complete). It's the inverse of the CalculateDateFromLinear subroutine.

    This subroutine takes YEAR, MONTH and DAY and returns with Linear DAYS starting with DAYS=0 for 01/01/2000. Note, it's only good for 100 years as it does NOT account for year 2100 leap anomaly. I'm reusing variables and EEPROM presets previously defined in your program.

    Code:
    	'
    	'	Subroutine Calculates Linear Days from Date
    	'	-------------------------------------------
    CalculateLinearFromDate:
    	DAYS=0
    	For CounterA=0 to YEAR
    		TempA=CounterA//4
    		If CounterA < YEAR then
    			TempB=365
    			If TempA=0 then TempB=TempB+1
    			DAYS=DAYS+TempB
    			endif
    		Next CounterA
    	IF MONTH > 1 then
    		For CounterA=1 to MONTH-1
    			Read (CounterA+20),ByteA
    			If TempA=0 then
    				If CounterA=2 then ByteA=ByteA+1
    				endif
    			DAYS=DAYS+ByteA
    			Next CounterA
    		endif
    	DAYS=DAYS+DAY-1
    	Return
    Oh and in this routine, my MONTHS start counting from 1, so CounterA+20 is valid here!
    I can't seem tp follow the variable delaration of the program
    Can i use this with my DS1307 RTC
    i can read YEAR, MONTH and DAY from my RTC what variable to i send them to before calling the sub.
    i am confused here

    Isaac

  3. #43
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Smile

    Hi Nav / Mel
    I have being reading the trend DS1994 Memory/Time iButton and it is very very interesting and just need your help in using the program.
    I am using a DS1307 RTC of which i read the following variables

    Date =23
    Month=03
    Year=05
    Hour =21
    Mins =30
    Seconds=30
    to give me 23-03-05 21:30:30 (my data & time)
    which are all byte variables

    But i want to convert this to Linear DAYS and add 365 but can't figure out which subroutine to use as from my understand the subroutines are looking for a 32bit number

    Could you be kind enough to explain to me

    Best Regards
    Isaac

  4. #44
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    ISAAC,

    the Subroutine "CalculateLinearFromDate" isn't really that complex, is it?

    with your variables beeing:

    Date =23
    Month=03
    Year=05
    Hour =21
    Mins =30
    Seconds=30

    all you need to do is:
    rename your VAR "Date" to "DAY"
    (or create an alias)
    and declare the following variables in addition:

    CounterA VAR Byte
    TempA VAR WORD
    TempB VAR WORD
    DAYS WAR WORD

    once you have read the DS1307 just

    GOSUB CalculateLinearFromDate

    and you will find the result in "DAYS"
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  5. #45
    Join Date
    Jan 2005
    Location
    Australia
    Posts
    20


    Did you find this post helpful? Yes | No

    Question

    Hi Ralph & Melanie,

    How to calculate the elapsed hours between 16:30:45 (HH:MM:SS), 28/05/2005 (DD/MM/YYYY) and 02:26:38, 01/08/2004.

    Assume the elapsed time is limited to less than one year. Can I use the CalculateLinearFromDate subroutine to do the job?

    Best regards,
    Yuantu Huang

  6. #46
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    CalculateLinearFromDate will account for the DAYS. Multiply by 24 for your TotalHours. Then to account for the Hours...

    If EndDateHours > StartDateHours then TotalHours=TotalHours+(EndDateHours-StartDateHours)

    If EndDateHours < StartDateHours then TotalHours=TotalHours-(StartDateHours-EndDateHours)

  7. #47
    Join Date
    Jan 2005
    Location
    Australia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Hi Melanie,

    Thank you very much.
    Yuantu Huang

  8. #48
    Join Date
    Sep 2006
    Posts
    42


    Did you find this post helpful? Yes | No

    Default ibutton 1990a

    Quote Originally Posted by Melanie
    When you're done, you can create Ralph1994 and send it with a resume of what it does to MeLabs for inclusion in their Submitted Programs section... people must be getting bored with my offerings.
    hi,

    i succeed to read ibutton (1990a) and display it on lcd..but iam not able to store serial# on variable..i want to compare ibutton's serial nos.iam trying to read multiple ibuttons and store their sr# in eprom.. if sr# is 1 of the stored # then do something...

    Thanking you

    Regards.

Similar Threads

  1. Writing & Reading to iButton EEPROM
    By crhomberg in forum Code Examples
    Replies: 2
    Last Post: - 6th October 2008, 19:40
  2. DS1920 IButton
    By scottl in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd November 2007, 00:39
  3. iButton
    By menze in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th June 2006, 23:48
  4. RS485 - ibutton network
    By ccsparky in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th June 2005, 21:48
  5. Dallas DS1994 iButton CLOCK
    By NavMicroSystems in forum Code Examples
    Replies: 0
    Last Post: - 29th September 2004, 22:19

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