
Originally Posted by
Joe Hershberger
In the process of looking at the state of the InterruptableSensorBase class to explain this to you, I discovered that the class was never finished. I'm not sure if or how it has ever worked. It never reserves an interrupt number and it uses an uninitialized variable as the interrupt number. I guess no one is using interrupts since no one has complained about the total lack of functionality yet.
This doesn't surprise me -- given all of the functionality that WPILib provides, there is generally very little reason to use interrupts.
Actually, we were using interrupts for 4 hall effect sensors we were using -- interrupts do appear to work, at least partially. We *did* have mysterious bugs with it, however we were blaming that on hardware errors -- since we kept finding malfunctioning sensors. Go figure.

Originally Posted by
Joe Hershberger
It sounds like what you are wanting is actually exactly what the interrupts do (time stamp events). Counters do something similar (or rather the timers attached to the counters) but presumably more useful... they return the time between edges. It is asumed that you are interested in the difference, not the absolute times. You would just subtract the edge times once you get them anyway, right? Because it is a difference, you don't have to make sure you read two consecutive edges. You can just read whenever, and it is still valid.
You could also use two counters (one for high semi-period and the other for low semi-period) and use DMA to transfer the samples so you know they are consistent.
Well to be honest, I'm not exactly sure what it is that I want -- but I'd like it to work.
The idea I had came up with (that I cant test until monday) is call "SetPulseLengthMode(1.0)" on two seperate counters, and then get the period from them.
Code:
// specify the source
countXhi.SetUpSource(3);
countXlow.SetUpSource(3);
// specify the edge
countXhi.SetUpSourceEdge(true, false);
countXlow.SetUpSourceEdge(false, true);
// setup the counters
countXhi.SetPulseLengthMode(1.0);
countXlow.SetPulseLengthMode(1.0);
countXhi.Start();
countXlow.Start();
... stuff here ...
double axH = countXhi.GetPeriod();
double axL = countXlow.GetPeriod();
// convert to m/s^2 -- 50% duty cycle is 0g
double ax = (((axH / (axH + axL)) - .5) * 8.0) * 9.81;
The document at http://zone.ni.com/reference/en-XX/h...ps/measperiod/ discusses these various counter types, and it would seem to me that semi-period mode is *not* what I'm wanting, since I care only about the duty cycle of the output from the accelerometer.
*sighs*
It would be nice if FIRST just would have given our team the accelerometer with the kit of parts...