View Single Post
  #3   Spotlight this post!  
Unread 30-12-2012, 17:37
nathan_hui nathan_hui is offline
Registered User
AKA: Nathan Hui
FRC #2473 (CHS Robotics)
Team Role: Alumni
 
Join Date: Feb 2012
Rookie Year: 2009
Location: Cupertino, CA
Posts: 228
nathan_hui will become famous soon enoughnathan_hui will become famous soon enough
Send a message via AIM to nathan_hui
Re: Recording times from a timer

I'm not too familiar with LabView, so I can't help you with the technical details. However, I do see a potential problem. If (and I may not be thinking correctly here) your program sits there and continues reading the sensor, you could simply count cycles until state change. Problem is, you take up the processor doing this. The way I think you should approach this problem (and it may be beyond your capability) is to use a hardware interrupt to handle the timing. The idea is that every time the sensor causes a hardware interrupt, the interrupt handler stores the time at which the interrupt occurred in a variable and stores the difference between that interrupt and the interrupt before that. So have two vars (prevTime and interval). Every interrupt takes current time, subtracts prevTime from that and sticks that in interval, then sticks the current time in prevTime.

What this does is frees up the board to do other stuff while waiting for reads, instead of sitting there waiting for state changes. Hope this helped.