Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
Macro Array Edge/Event/Trigger Detection
To obtain the location (sample or array index number) of a Trigger-type event in a waveform in BufN, use the form X=BufN?E to scan for the initial occurence in the array buffer. Use X=BufN?e to scan for the next occurence, starting from the previous result.
You may repeat the BufN?e scan for multiple events in the buffer. You may change a buffer's trigger parameters (such as slope) between scans, for example to find the leading and trailing edges of a pulse of either polarity.
The returned value is the position of the trigger event relative to the start of the buffer. If no event is found, the return value is 0. (No valid trigger can ever be found at the 0th element because there must be at least one earlier value to establish that the trigger is on the proper slope.)
The return is a real value that may have a fractional part. It is obtained by interpolation from the value prior to the trigger, the specified trigger level, and the actual value that met or exceeded that level. For example, if the specified trigger level is 1000 on a positive slope, and the array buffer holds a value of 950 at index 123 and 1050 at index 124, the returned value will be 123.500.
You can convert the buffer-relative return value to an absolute sample number by adding the absolute sample number corresponding to the start of the buffer, obtained via Posn?D from the Miscellaneous Position read-only variables. That way, you can measure the distance (and hence time, using the sample rate SmplRate) between triggers found in buffer waveform data acquired on different display updates. This method is used by the _Multi_Mtr_Task of the Multiple Meters mini-app to measure very low frequencies.
Note that when the main display is operating in Triggered mode there is an unknown number of samples between display updates, since the display waits as long as needed for the next trigger event. The array buffers can't obtain data that is not captured for display (even though the main Trigger can examine it), so you may have to toggle Trigger off (Trig=0) when using a Multitasking Macro task to watch for trigger events.
In the untriggered free-running mode, the display typically updates faster than fresh samples arrive from the sound card, so that one display frame (and hence its buffer copy) may include samples that were previously examined. Thus, the absolute sample number is important to prevent double-counting of events.
There is no absolute guarantee that this sample overlap will always take place. With a simple signal (not a lot of large high-frequency signal or noise lines to be drawn) the untriggered display typically updates about every 480 samples at the default 48000 sample rate and 10 msec trace update interval. Since one display frame is 1024 samples (21.3 msec), each frame has about 50% prior data.
Each buffer uses its own 3 internal trigger parameters to specify trigger slope, level, and hysteresis. These parameters are also used with X=BufN?F for Frequency Counting, and are described in detail there. To summarize here:
Buf0#s=V sets the Buf0 slope to Pos if V=0 and to Neg if V = 1.
Buf0#t=V sets the Buf0 trigger level to V, where V is typically in the +/-32767 range.
Buf0#h=V sets the Buf0 trigger hysteresis.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 30 Years of Innovative Instrumentation
© Copyright 2007 - 2017 by Interstellar Research
All rights reserved