Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Real Time Clock


  • Please log in to reply
11 replies to this topic

#1 Joe Griffith

Joe Griffith

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts

Posted 06 September 2010 - 06:07 PM

The standard handler for the button pushed includes a time-stamp:
private static void Button_OnInterrupt(uint data1, uint data2, DateTime time)

time, does equate to 1/1/2009 and the time since the Netduino was powered up (perhaps reset).

How can the date and time be set?

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 06:18 PM

Great question. I haven't played with this myself, but I believe you use the Utility.SetLocalTime function.

Does that work for you? If not, I can pull together a sample... If you're using an external battery-backed RTC, it's really useful to set the .NET MF's time clock when your Netduino app starts up.

Chris

#3 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 06 September 2010 - 06:21 PM

How can the date and time be set?

Utility.SetLocalTime(...) affects the time passed to interrupt handlers.

Edit: Too late. Hard to beat Chris.

Edited by CW2, 06 September 2010 - 06:22 PM.


#4 Joe Griffith

Joe Griffith

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts

Posted 06 September 2010 - 06:44 PM

Utility.SetLocalTime does the job! I'm running with the Netduino connected to a computer so I can just send the datetime over from the computer. Can't see any way to get at the local time other than as a parameter on an interupt handler.

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 06:45 PM

Utility.SetLocalTime does the job!

I'm running with the Netduino connected to a computer so I can just send the datetime over from the computer.

Can't see any way to get at the local time other than as a parameter on an interupt handler.


Does DateTime.Now give you the local time?

#6 Joe Griffith

Joe Griffith

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts

Posted 06 September 2010 - 07:37 PM

Yes DateTime.Now works as does DateTime.Today

#7 Steven Behnke

Steven Behnke

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts
  • LocationLas Vegas, NV

Posted 06 September 2010 - 10:30 PM

Great question. I haven't played with this myself, but I believe you use the Utility.SetLocalTime function.

Does that work for you? If not, I can pull together a sample... If you're using an external battery-backed RTC, it's really useful to set the .NET MF's time clock when your Netduino app starts up.

Chris


It doesn't persist between loading apps though.

#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 10:32 PM

It doesn't persist between loading apps though.


True. Perhaps it persists when using SoftReboot (v4.1.0.3 beta) vs. HardReboot (v4.1.1 alpha 1) firmware... Which one are you using?

Maybe that's a good reason to enable the user to configure their Netduino for SoftReboot vs. HardReboot...

Chris

#9 stacyh3

stacyh3

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 07 September 2010 - 12:04 AM

And of course, if you're using the DS1307, check out my post w/code here: DS1307 Real Time Clock.

This clock is pretty inexpensive and works well. I'm sure that there are better ones out there with alarms, etc.

#10 H07R0D

H07R0D

    Advanced Member

  • Members
  • PipPipPip
  • 95 posts

Posted 03 May 2011 - 12:19 AM

I know this is a late thread to pull up, but I'm having a heck of a time figuring this out. I want to call Utility.SetLocalTime during my debug sessions as I'm powering everything from usb through PC right now. How on earth do I SetLocalTime using the PC time in a debug session? Is it even possible? I've got a DS1307 on order, so that will alleviate the problem, but in the mean time....I'd really like to figure this out. Cheers,

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 03 May 2011 - 01:10 AM

Hi, The .NET Micro Framework on your Netduino doesn't pull the time from your PC. If you have a comm channel between them, you could push it over manually--or you could retrieve it off the Internet if you're using a Netduino Plus. Of course, adding an external RTC solves all that...you'd just set the time once and be good to go. Chris

#12 H07R0D

H07R0D

    Advanced Member

  • Members
  • PipPipPip
  • 95 posts

Posted 03 May 2011 - 11:34 AM

Hi,

The .NET Micro Framework on your Netduino doesn't pull the time from your PC. If you have a comm channel between them, you could push it over manually--or you could retrieve it off the Internet if you're using a Netduino Plus.

Of course, adding an external RTC solves all that...you'd just set the time once and be good to go.

Chris

Ah, ok. Thanks.
the RTC I ordered should arrive in the next couple days.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.