On Fri, 31 Aug 2018 08:35:06 -0700 (PDT),
trem...@lonestartracking.com declaimed the
following:
>Hello,
>I am interested in using the BBB to monitor a sensor (geophone) at about
>200-400sps. I am currently using the Adafruit_BBIO.ADC library to do this
>in Python. Ultimately, there are two goals for this project, and I would
>love some input on how to approach this.
>
>1) Time stamp when the input voltage reaches 0.5v - The geohone is
>generating a sine wave, the stronger the vibration/movement of the
>geophone, the higher the amplitude/voltage of the signal is produced. I
>would hope to accurately place a timestamp at the exact moment the voltage
>crossed that threshold. As far as timing goes, I am using onboard GPS with
>1 PPS output and Chrony for sync.
>
At 400 samples/second you have 2.5msec between samples (and a whopping
5msec at 200 samples/second). The only way I see to get more precise timing
would be to interpolate the crossing point of two samples (one before the
threshold, the other immediately after threshold crossing) and also
interpolate the timestamps of those samples. I don't know the resolution of
the BBB OS clock -- time.time, time.clock, and datetime module are likely
limited to the OS clock.
https://www.pythoncentral.io/measure-time-in-python-time-time-vs-time-clock/
time.clock may not be appropriate since it is not wall-clock time on
Linux/UNIX (also not the caveat -- if you have something else that adjusts
the system clock backwards, you'll get anomalous times.
You don't state the frequency of the sine wave; if it is faster than
100Hz you may fall afoul of Nyquist sampling theory. Rectifying and
filtering the sine wave to produce a DC voltage may be advisable.
>2) I also have a contact closure that I would like to monitor. Right now,
>I am pushing 1v through the closure, and monitoring the ADC for a voltage
>change from 0v to 1v, then applying a timestamp. Any thoughts here?
>
Push it to 3.3V (level shifter?) and use a regular GPIO -- then setup
add_event_detect for rising edge with a callback function to create the
timestamp. You can also provide a debounce time for the switch before it
activates the callback. (wait_for_event will probably block your ADC
reading unless you put it into a separate thread -- but that then limits
your timing to the Python interpreter thread switching logic.
--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/