Shop OBEX P1 Docs P2 Docs Learn Events
Is there a way to fix elapsed time with hold Seconds after stopping the clock. — Parallax Forums

Is there a way to fix elapsed time with hold Seconds after stopping the clock.

sam_sam_samsam_sam_sam Posts: 2,286
edited 2008-07-17 19:49 in General Discussion
Here is what i want to it in this post

here is the link
·http://forums.parallax.com/showthread.php?p=736562

·I can see what my current HVAC usage is on a daily basis and see where potential "opportunities" are

* inside temp/humidity
* outside temp/humidity
* system status (on/off)
* heat/cool mode

I am thinking doing something like this

One way to this is to have a Time Counter that runs when you are calling for cooling how get this

·You have optic sensor tie to the contactor this where you get your·signal from

What i have not·figure out is how to stop and start a DS1302 chip to keep track of the time in this way or is there another chip that·I could use to do this with

I have try this couple of time but have not got any where yet

·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·idea.gif·that you may have and all of your time finding them

·
·
·
·
Sam

Post Edited (sam_sam_sam) : 7/18/2008 1:26:13 AM GMT

Comments

  • MSDTechMSDTech Posts: 342
    edited 2008-07-10 22:08
    Why not just record when the unit starts and stops and subtract the times?
  • FranklinFranklin Posts: 4,747
    edited 2008-07-11 00:28
    That's how I'd do it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-11 18:07
    MSDTech·and Franklin

    Thank You for your reply

    I though about doing it that way also

    But what I·want to is to have running total time where

    ·I dd not have to· subtract the times it done for me

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2008-07-11 19:18
    sam_sam_sam,
    ·
    How about an external oscillator to the DS1302 that you can "gate".
    ·
    Last I checked, you can still communicate to the DS1302 without the crystal... the crystal is strictly for timekeeping.
    ·
    You will still need to set some sort of initial reference time, because by default·if·some of the mode registers are not set
    correctly, the clock is·disabled.
    ·



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-12 01:23
    Beau Schwabe (Parallax)

    How about an external oscillator to the DS1302 that you can "gate".

    This sounds just like·what·I looking for do you any info that you can share on how to do this
    ·
    You will still need to set some sort of initial reference time, because by default·if·some of the mode registers are not set
    correctly, the clock is·disabled.


    This··would a great help and thank you for any help that you can give me on this

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2008-07-12 03:17
    sam_sam_sam,
    ·
    Forget my previous post, I took a closer look at the datasheet under the "CLOCK HALT" or CH flag. This is Bit 7 of the second register. If it is set to "1" the clock oscillator is stopped and the DS1302 enters a low power mode <100nA. When the bit is set to "0" the clock will start again.
    ·
    This way you could use any of the Stamps, SX, or Propeller ... The other method that I had mentioned would only have been easier with the Propeller.
    ·
    Starting the Clock and resetting values (first time run):
    Write %10000000 to address 80h·· ... This·stops the clock
    Write %00000000 to address 84h·· ... This initializes the clock in 24 hour mode and clears the hours to "00"
    Write %00000000 to address 82h·· ... This clears the·minutes to "00"
    Write %00000000 to address 80h·· ... This starts the clock and clears the·minutes to "00"
    ·
    Stop the Clock and read elapsed time:
    Read from address 81h and store in 'seconds'
    subtract 128 from 'seconds' and Write the new value of 'seconds'·to address 80h· ... This·stops the clock and preserves the seconds value
    Read from address 82h and store in 'minutes'
    Read from address 84h and store in 'hours'
    ·
    Restart·the Clock resume counting elapsed time:
    add 128 to·'seconds' and Write new 'seconds' value to address 80h· ... This·starts the clock and preserves the seconds value


    If you need to go further, you can access the registers as you normally would out to Days, Months, and Years.
    ·



    Reference:

    http://pdfserv.maxim-ic.com/en/ds/DS1302.pdf
    Page 7 and Page 9



    .

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 7/13/2008 5:47:27 AM GMT
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-12 23:13
    Beau Schwabe (Parallax)

    Thank You for your reply

    Could you give an example of how·I would do this the part


    Starting the Clock and resetting values (first time run):
    Write %10000000 to address 80h·· ... This·stops the clock
    Write %00000000 to address 84h·· ... This initializes the clock in 24 hour mode and clears the hours to "00"
    Write %00000000 to address 82h·· ... This clears the·minutes to "00"
    Write %00000000 to address 80h·· ... This starts the clock and clears the·minutes to "00"


    Stop the Clock and read elapsed time:
    Read from address 81h and store in 'seconds'
    subtract 127 from 'seconds' and Write the new value of 'seconds'·to address 80h· ... This·stops the clock and preserves the seconds value
    Read from address 82h and store in 'minutes'
    Read from address 84h and store in 'hours'
    ·
    Restart·the Clock resume counting elapsed time:
    add 127 to·'seconds' and Write new 'seconds' value to address 80h· ... This·starts the clock and preserves the seconds value

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 7/13/2008 4:49:13 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-12 23:37
    Rather than saying "i do not fully understand how to do", how about describing what you do understand and what you don't understand. Also indicate what references and examples you have looked at.

    Nuts and Volts Column #33 goes into detail on the use of the DS1302 and includes downloadable sample code.

    You will also need the datasheet for the DS1302 from Dallas's website.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-13 05:09
    Mike Green

    Rather than saying "i do not fully understand how to do", how about describing what you do understand and what you don't understand. Also indicate what references and examples you have looked at.

    Nuts and Volts Column #33 goes into detail on the use of the DS1302 and includes down loadable sample code.

    In the Nut and volt #33 and #34 Dose Not talk about how to do what Beau Schwabe·(Parallax) is saying in his post and ALL of the demo·I have seen do not show how to do this and if it dose than·I must be missing something

    I understand that you have to access bit 7 in order to halt the clock but how do you write it
    All i was asking for was an example of how to do it

    You will also need the data sheet for the DS1302 from Dallas's website.

    I read it four time and also read the In the Nut and volt #33

    If this sound rough·I am truly sorry about that

    I had first look at all of the demos on the DS1302

    I do enjoy reading your post and have learn a LOT from reading them and·I thank you for them

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-13 05:29
    On page 375 of Nuts and Volts Column #33, there's are two subroutines called RTCin and RTCout. On pages 372 and 373, there are constant definitions for the DS1302 registers. These are used to set the value of addr which is the DS1302 address for the registers. You can also use the numeric value of the register address, but the name is clearer.

    To write the value %10000000 to the register $80, you do
    addr = $80
    ioByte = %10000000
    GOSUB RTCout
    


    '
    ' send a byte (ioByte) to the DS1302 location specified by addr
    '
    RTCout:    HIGH CS_1302
        SHIFTOUT Dio,Clk,LSBFIRST,[noparse][[/noparse]addr,ioByte]
        LOW CS_1302
        RETURN
    
    ' get a byte (ioByte) from the DS1302 location specified by addr
    '
    RTCin:    HIGH CS_1302
        SHIFTOUT Dio,Clk,LSBFIRST,[noparse][[/noparse]addr]
        SHIFTIN Dio,Clk,LSBPRE,[noparse][[/noparse]ioByte]
        LOW CS_1302
        RETURN
    


    Note that RTCout in the sample code is incorrect. This has been corrected.
    You'll have to define CS_1302, Dio, Clk appropriately and declare addr and ioByte as byte variables.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2008-07-13 05:35
    sam_sam_sam,
    ·
    What I gave you is just a basic programming flow.· There are several examples on how to read and write to the DS1302 registers.
    ·
    In the attachment that you provided, the two read and write routines are as follows:
    ·
    Read:
    RTC_In: 
    HIGH CS1302                            ' Select DS1302 
    SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg] 
    SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]ioByte] 
    LOW CS1302                             ' Deselect DS1302 
    RETURN
    

    Write:
    RTC_Out: 
    HIGH CS1302                                    ' Select DS1302 
    SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg, ioByte] 
    LOW CS1302                                     ' Deselect DS1302 
    RETURN
    

    ·
    Prior to calling the Read or Write subroutine, you need to set the 'reg' (register)·variable , and for a Write, you need to set the 'ioByte' (Data) variable.
    ·
    So for...
    Starting the Clock and resetting values (first time run):
    Write %10000000 to address 80h·· ... This·stops the clock
    Write %00000000 to address 84h·· ... This initializes the clock in 24 hour mode and clears the hours to "00"
    Write %00000000 to address 82h·· ... This clears the·minutes to "00"
    Write %00000000 to address 80h·· ... This starts the clock and clears the·minutes to "00"
    ·
    ·it might look something like this...
    ·
    reg = $80          ' Point to register 80h 
    ioByte = %10000000 ' Set Clock Halt Bit 
    GOSUB RTC_Out      ' Send Command 
    reg = $84          ' Point to register 84h 
    ioByte = %00000000 ' initializes the clock in 24 hour mode and clear the hours to "00" 
    GOSUB RTC_Out      ' Send Command 
    reg = $82          ' Point to register 82h 
    ioByte = %00000000 ' clear the minutes to "00" 
    GOSUB RTC_Out      ' Send Command 
    reg = $80          ' Point to register 80h 
    ioByte = %00000000 ' starts the clock by clearing the Clock Halt bit and clears the minutes to "00" 
    GOSUB RTC_Out      ' Send Command
    

    ·
    The general idea, is that you initially set the clock to 00:00:00 (<- This format is valid only in 24 hour mode).· This would be a timer reset or a first time run.· All subsequent runs would just stop and start the clock.· Since the Clock Halt bit is embedded within the seconds register, you need to preserve the seconds if the seconds are of interest to you... you may just want minute accuracy ... depends on what you want.· By adding or subtracting 128 from the seconds value, you effectively set or clear the Clock Halt Bit and preserve the elapsed seconds value.
    ·
    So for...
    Stop the Clock and read elapsed time:
    Read from address 81h and store in 'seconds'
    subtract 128 from 'seconds' and Write the new value of 'seconds'·to address 80h· ... This·stops the clock and preserves the seconds value
    Read from address 82h and store in 'minutes'
    Read from address 84h and store in 'hours'
    ·
    It might look something like this...
    reg = $81             ' Point to register 81h 
    GOSUB RTC_In          ' Receive Command 
    ioByte = ioByte - 128 ' Clear Clock Halt Bit 
    secs = ioByte         ' Store elapsed Seconds value 
    reg = $80             ' Point to register 80h 
    GOSUB RTC_Out         ' Send Command 
    reg = $82             ' Point to register 82h 
    GOSUB RTC_In          ' Receive Command 
    mins = ioByte         ' Store elapsed Minutes value 
    reg = $84             ' Point to register 84h 
    GOSUB RTC_In          ' Receive Command 
    hrs = ioByte          ' Store elapsed Hours value
    

    ·
    And for...
    Restart·the Clock resume counting elapsed time:
    add 128 to·'seconds' and Write new 'seconds' value to address 80h· ... This·starts the clock and preserves the seconds value
    ·
    It might look something like this...
    reg = $80           ' Point to register 80h 
    ioByte = secs + 128 ' Set Clock Halt Bit 
    GOSUB RTC_Out       ' Send Command
    

    ·
    ·
    Note: I hade erroneously used the number 127, when I should have used 128 instead.
    ·





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 7/13/2008 5:54:28 AM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2008-07-13 05:43
    sam_sam_sam,

    "...In the Nut and volt #33 and #34 Dose Not talk about how to do what Beau Schwabe (Parallax) is saying in his post and ALL of the demo I have seen do not show how to do this and if it dose than I must be missing something..."

    No, your probably not missing anything, the DEMO's are usually a general design angled in a way that will help get you started. Something in the order of stopping or starting the clock is a more specific, specialized application.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-13 09:28
    ·Beau Schwabe (Parallax)

    Thank You for your reply

    Thank You for the example that you gave to me·that help alot i did get it to work the way·I want it to work


    clockstop:
    ··· addr = $80········· ' Point to register 80h
    ioByte = %10000000 ' Set Clock Halt Bit
    GOSUB RTCOut····· ' Send Command
    addr = $84········· ' Point to register 84h
    ioByte = %00000000 ' initializes the clock in 24 hour mode and clear the hours to "00"
    GOSUB RTCOut····· ' Send Command
    DEBUG CLS ,CLS, CR
    DO
    laps = laps + 1
    DEBUG HOME, DEC4 ? laps
    LOOP UNTIL laps = 1000
    addr = $80
    ioByte = %00000000 ' starts the clock by clearing the Clock Halt bit and clears the seconds to "00"
    GOSUB RTCOut····· ' Send Command

    GOSUB start

    Mike Green Thank you as well

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 7/13/2008 10:30:36 AM GMT
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-14 23:32
    I·have this working BUT when input 2 see power it STOPS the clock which it should do BUT·dose not always restart the clock each time some time you need to put power to input again then it will some time start the again

    What am i doing wrong i also try the button command and that did not do ether

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' Program Listing 33.1
    ' Stamp Applications: Nuts & Volts, November 1997
    ' ----[noparse][[/noparse] Title ]
    '
    ' File...... BS2CLOCK.BS2
    ' Purpose... Stamp II-based Alarm Clock
    ' Author.... Jon Williams
    ' E-mail.... jonwms@aol.com
    ' WWW....... http://members.aol.com/jonwms
    ' Started... 20 SEP 97
    ' Updated... 27 SEP 97

    '
    ' ----[noparse][[/noparse] Main Code ]
    '
    Start:
    DEBUG CLS
    · DO
    · GOSUB GetTm
    GOSUB ShowTm
    · INPUT 2······························ ' Make P2 an input
    · DEBUG· CR, CR, "State of P2: ",
    ······· BIN1 IN2, CR
    LOOP UNTIL IN2 = 1
    ·· GOSUB clockstop

    ' ----[noparse][[/noparse] Subroutines ]
    ' showtm:
    · DEBUG HOME,HEX2 hrs, ":", HEX2 mins, ":",HEX2 secs
    · oldSc = secs····· ' reset check value
    · RETURN

    ·clockstop:
    DO
    · INPUT 2
    · PAUSE 1····························· ' Make P2 an input
    LOOP UNTIL IN2 = 0
    ··· addr = $80········· ' Point to register 80h
    ioByte = %10000000 ' Set Clock Halt Bit
    GOSUB RTCOut····· ' Send Command
    addr = $84········· ' Point to register 84h
    ioByte = %00000000 ' initializes the clock in 24 hour mode and clear the hours to "00"
    GOSUB RTCOut····· ' Send Command

    addr = $80
    ioByte = %00000000 ' starts the clock by clearing the Clock Halt bit and clears the seconds to "00"
    GOSUB RTCOut····· ' Send Command
    ·addr = $80·········· ' Point to register 80h
    ioByte = secs + 128 ' Set Clock Halt Bit
    GOSUB RTCOut······ ' Send Command

    GOSUB start

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 7/15/2008 12:25:59 PM GMT
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-15 12:14
    Here is what I have so far and work but what happen is that when you put power to pin # 2 the clock stop like it should
    But the clock dose not alway restart·when you remove··power·from pin # 2 if you power pin agian and remove· then it will restart
    The second stay where they left off but when it dose not restart you will see 89 , 99 or something like that

    I have a 10k ohm rest from pin 2 to vss and from pin 2 a 220· ohm rest to vdd when powering pin 2

    What do I need to add to·fix this problem

    main:
    DO· WHILE· IN2 = 0
    · GOSUB Get_Time
    · DEBUG HOME, HEX2 mins, ":", HEX2 secs

    · LOOP
    · DO WHILE IN2 = 1
    · reg = $81·········································· ·' Point to register 81h
    GOSUB RTC_In····································· ·' Receive Command
    ioByte = ioByte - 128····························· ' Clear Clock Halt Bit
    secs = ioByte········································' Store elapsed Seconds value
    reg = $80··········································· ·' Point to register 80h
    GOSUB RTC_Out·································· ·' Send Command
    reg = $82··········································· ·' Point to register 82h
    GOSUB RTC_In···································· ·' Receive Command
    mins = ioByte······································ ' Store elapsed Minutes value
    reg = $84········································· ·' Point to register 84h
    GOSUB RTC_In·································· ·' Receive Command
    hrs = ioByte·······································' Store elapsed Hours value
    LOOP

    ·reg = $80······································· ' Point to register 80h
    ioByte = secs + 128·························· ' Set Clock Halt Bit
    GOSUB RTC_Out······························· ' Send Command

    GOSUB· main
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 7/15/2008 12:30:30 PM GMT
  • kjennejohnkjennejohn Posts: 171
    edited 2008-07-17 06:54
    Hi. Couldn't you set up a timer that interrupts the processor two or three times a second and use that to read the seconds register in the 1302? After boot up, initialize the 1302 registers just enough to have it increment its seconds count. Use a processor timer's overflow interrupt to get the processor to read the seconds register value 2 or 3 times a second and compare it to the value you saved from the last read. When it differs save the 1302's latest seconds count and increment a "seconds" count in the interrupt routine. Compare the ISR's seconds count for a value of 60. If it is 60, zero the ISR's seconds count and increment a "minutes" count . See if the minutes count is 60. If so, zero the minutes count and increment an "hours" count. This is how most time-of-day clocks are kept on a processor. All you need is a (fairly) reliable clock, which is the 1302's seconds count in this case. This saves you the trouble of reading the entire set of registers, processing the 1302's BCD values into hh[noparse]:mm:[/noparse]ss format and subtracting a finish-time from an end-time, based on when a process starts and ends. Of course you have to dedicate a timer and an interrupt to this, and do this enough times per second to guarantee you don't skip a second here or there. And you have to have a flag that is used to tell the seconds-reading/counting process that it should bother to do this routine when your process of interest is active (furnace on, air conditioner running, whatever...). With this you can just run the 1302 without diddling registers, pins, clocks, or other tomfoolery.

    End $.02
    kenjj
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-17 13:17
    kjennejohn
    Thank You for your reply

    I understand what you are talking about

    Could you give an example of how you would write the routine to·this

    I am open to any··idea.gif·s I just do not know to write them

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • kjennejohnkjennejohn Posts: 171
    edited 2008-07-17 16:35
    Hi. Since I don't own a Stamp I can't say how to do this in PBasic. But I can generalize and use quasi-code.

    You seem to have code to initialize the 1302. I take it for granted you have a grasp of the registers and how they are used. I also suppose that the processor is doing mostly nothing else other than read a temp sensor and/or wait for something like the furnace to turn on. You basically run in a tight loop:
    1. waiting for some input from the user
    2. read a temp sensor
    and/or
    3. monitor an event like the power up of a heating or cooling device

    So, at initialization you create five byte variables: new_sec, old_sec, seconds, mins, and hours (and days, if you want). When an event you want to time happens, you jump into a subroutine where you
    1. read the seconds register in the 1302 and store the value in new_sec.
    2. compare that reading to the previous reading in old_sec. If it's different, take an action. The first time here you're almost guaranteed to have a mismatch, since it may be anywhere from several seconds to several hours since the last measurable event occurred. OK, you're going to be adding a second to all these measurements. I can't see that as a real problem. After this any difference in the value is a real second passing in time.
    3. IF the values differ THEN save new_sec to old_sec and increment the seconds count. If not, return to loop.
    4. IF seconds equals 60 THEN set seconds to zero and increment minutes. If not, return to loop.
    5. IF you incremented minutes, check to see if minutes equals 60. IF yes THEN zero out minutes and increment hours. If not, return to loop.

    And you keep carrying on like this until the event you're timing stops. You now have a running elapsed time counter going. The beauty is, you don't have to stop and convert a bunch of BCD readings from the 1302 into integer numbers and subtract to get this count. If you want you can still read all the 1302 registers at the start and end of each event. Later, when the user asks for a readout, you convert them to time strings, i.e., HH:MM:SS. As for the elapsed time counter here, no conversion is necessary, just print them out after converting from hex to decimal, which is probably just a modifier in PBasic.

    Later!
    kenjj
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-17 19:41
    kjennejohn
    Thank You for your reply

    When i have some time and when·I finish the project that i am working on right
    now and can find the how to convert ·BCD format then i will work on this some more

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 7/19/2008 1:09:56 AM GMT
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-07-17 19:49
    ·Beau Schwabe (Parallax)

    For some reason·I have not able to get this part of the routine to work the way·I would like it to work

    reg = $81············ ' Point to register 81h
    GOSUB RTC_In········· ' Receive Command
    ioByte = ioByte - 128 ' Clear Clock Halt Bit
    secs = ioByte······· ·' Store elapsed Seconds value
    reg = $80··········· ·' Point to register 80h
    GOSUB RTC_Out······· ·' Send Command


    reg = $80· ········ '·Point to register 80h
    ioByte = secs + 128 ' Set Clock Halt Bit
    GOSUB RTC_Out······ ' Send Command


    I also try this and this did not help ether

     reg = $80                                   ' Point to register 80h
    ioByte = secs | 128                          ' Set Clock Halt Bit
    GOSUB RTC_Out                                ' Send Command
    
    

    Likewise for similar reasons, where you have this...
    ioByte = ioByte - 128                              ' Clear Clock Halt Bit
    

    ...use this instead...
    ioByte = ioByte & 127                              ' Clear Clock Halt Bit
    


    The problem that·I am having with this routine is that seconds do not restart or you have like 80 seconds ond nothing happens or if you can get

    the seconds to restart you have power the input on the Basic Stamp one that i am using to restart the clock with code that you gave to try

    is there a away to fix the or do need to just except that this realy can not be done this way with a Basic Stamp



    Now this routine work great and Thank You for helping with this routine

    reg = $80········· ' Point to register 80h
    ioByte = %10000000 ' Set Clock Halt Bit
    GOSUB RTC_Out······' Send Command
    reg = $84········· ' Point to register 84h
    ioByte = %00000000 ' initializes the clock in 24 hour mode and clear the hours to "00"
    GOSUB RTC_Out····· ' Send Command
    reg = $82········ ·' Point to register 82h
    ioByte = %00000000 ' clear the minutes to "00"
    GOSUB RTC_Out···· ·' Send Command



    reg = $80········· ' Point to register 80h
    ioByte = %00000000 ' starts the clock by clearing the Clock Halt bit and clears the minutes to "00"
    GOSUB RTC_Out····· ' Send Command


    Like i said in other post about this that if i change this part to this··%0110000· .......instead of %00000000· this
    I change the clock seconds to 30 and count from

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 7/18/2008 1:39:00 AM GMT
Sign In or Register to comment.