DateTime in NativeEventHandler() - Netduino Plus 2 (and Netduino Plus 1) - Netduino Forums
   
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

DateTime in NativeEventHandler()


  • Please log in to reply
4 replies to this topic

#1 MLA44

MLA44

    Member

  • Members
  • PipPip
  • 10 posts

Posted 18 November 2014 - 05:09 PM

Hi all,

 

I have been trying to use the timestamp in the NativeEventHandler to detect the time elapsed between two external events.

On an Arduino I would just set-up a timer with input capture, read the input capture register and subtract the previous value to get the elapsed time. That would give me a count in ticks relative to the 16 MHz clock frequency.

 

The NativeEventHandler is specified to have a timestamp of the time at the occurrence of the event. But Is that a timestamp in ms only? I have seen mentioned that DateTime is only measured in ms and therefore the ticks count is not accurate.

However, I have tried to use the "ticks" from DateTime, which is specified on MSDN to be 10.000 ticks/ms, but I'm not sure if I get an accurate time (oldDateTime.ticks - newDateTime.ticks = elapsedTime).

 

Also when I do read the number of ticks elapsed, the last digit is always zero. Indicating a resolution of ticks as 1.000 ticks/ms and not 10.000.

 

Can someone enlighten me as to what the accuracy of the timestamp in NativeEventHandler is.

I need an accuracy between events, much better than 1 ms (on the Arduino Leonardo I can detect better than 0.001 ms. Just for illustration).

Maybe I should be doing this differently. All suggestions are welcome.

 

/Martin



#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 19 November 2014 - 07:44 AM

The time resolution on gen 2 Netduinos is 1 µs.

 

The microcontroller has many timers with multiple capture/compare channels, unfortunately this functionality is not exposed in the current implementation of .NET Micro Framework. For precise measurements you'd need to add the functionality to the firmware or abuse any of the existing hardware modules (UART, SPI?).



#3 MLA44

MLA44

    Member

  • Members
  • PipPip
  • 10 posts

Posted 19 November 2014 - 10:04 AM

Hi,

 

Thanks, for the fast reply. I will assume that by resolution of 1 µs, you also mean accuracy of 1 µs. Please let me know if that is not the case.

I have been thinking about weather it would be necessary to customize the firmware for using hardware features in more advanced ways. Thank you, for confirming that.

For now however, the project is not large enough to justify the time needed for changing the firmware.

 

In the future however, I might very well do so, as we are planing on using the n+2 in some of our products.

 

/Martin



#4 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 19 November 2014 - 03:06 PM

I will assume that by resolution of 1µs, you also mean accuracy of 1 µs.


Unfortunately, I don't know the accuracy.



#5 Spiked

Spiked

    Advanced Member

  • Members
  • PipPipPip
  • 129 posts

Posted 19 November 2014 - 04:53 PM

I remember finding it somewhere and it was 3µs . I don't remember where, or I could be remembering it completely wrong, so take it with a grain of salt.






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.