![]() Software Triggering
| ||||||||||||
Home | DAQ Techniques | Download as a PDF | View in multiple pagesTriggering: When Is It Time to Measure?
Some measurements can be taken pretty much any time, and it isn't terribly important when you start and stop. For example, if you are measuring the size of an object, it will be roughly the same size regardless of when you measure it. But not all measurement applications are like this. For some applications, the phenomenon you need to measure is not always present. Until it is, there is no point in recording measurements. These are examples.
Background: Hardware TriggeringThough this article is about software triggering, it is helpful to contrast it with hardware triggering, which is simpler, more familiar, and more limited. If you have just the right digital electronic signal, you can use it to start (and sometimes to stop) data collection. This kind of hardware control of the measurement process is called hardware triggering.
If you don't have an appropriate digital signal, hardware triggering becomes more complicated. Some data acquisition products provide a voltage comparator amplifier for converting an analog signal into a digital form, which might be sufficient. Pre-Event Data and BufferingTo record data before an event occurs, you need two things: 1) sampling that occurs whether or not events occur and 2) memory to record past measurements just in case they are needed. Preserving data requires memory. Hardware-based schemes typically use a circular buffer configuration. In concept, special addressing logic selects memory locations for new measurements sequentially, advancing around a circle. By recovering stored values from the circular buffer, you can obtain measurements preceding the time of an event. When an event signal arrives, the hardware records the address of the most recent sample value, placing this address in a special event register. Also, the hardware informs the host of the event, to let it know that it had better do something – fast!
Actual memory addresses are not circular, rather they are linear up to some maximum, at which point there is a sudden "address wrap around" to zero. Hardware devices typically leave the host software with the burden of tracking the wrapping behavior and dynamically unwrapping it to select stored values. The circular buffer scheme is highly dependent on software to respond to signals for events, determine how to address the data, and fetch data across the data bus into host memory. There is a race condition, and any delay in responding to the hardware event signal results in overwriting and loss of some of the buffered data. Software TriggeringRather than using hardware circuits to determine when to measure, it is tempting to configure a software program and let it determine when to measure. This is the idea behind "software triggering." Software triggering leads to a kind of "chicken or egg" paradox. You don't want the measurements captured until you trigger; but there is no point in triggering until you know you want the measurements! Most data acquisition software that claims to support "software triggering" merely initiates the triggering action using a software command. This leaves you with the decision about when to issue this command – back to the "chicken or egg" paradox. Without seeing the data, how can you know whether you want to trigger or not? The DAPL system breaks the paradox much as hardware circular buffering does. Measurement activity is started well in advance of capturing data. Past data are retained in memory buffers, and the DAPL system manages the data memory. You don't need to worry about how, and you don't need to worry about data locations. Unused data are automatically released to make storage available for new data. The buffering is completely automatic, and can expand to the limits of available memory as needed. There is never a race condition, and new data can never overwrite old data despite any delays that might occur. The principal advantage of the DAPL software triggering is that you can analyze data and detect events intelligently, directly in buffer memory. All of this takes place on the Data Acquisition Processor board, without transferring anything to the host PC. This doesn't eliminate the need to scan through masses of data looking for events, but it avoids overloading your host with intense data transfers and computations when there is nothing of interest. For detecting and reporting events, the DAPL system keeps a
streaming record of event locations in a queuing mechanism
called a
There is one drawback to software triggering. A trigger event determines the location of interesting data in a continuing stream of data, but does not initiate responsive action. There remains a time lag until the event is processed. If you need fast real-time response, software triggering is probably not the right tool for the job. Triggering: How Do You Use It?
To add software triggering to a data acquisition application on a Data Acquisition Processor system, you will add the following additional features to your configuration.
It is presumed here that the application is configured
for input sampling. The sampling configuration can have any
number of channels, and you can pick any channel you want to
detect events. Here, we will presume that triggering scans the
contents of the first channel pipe Defining the Trigger and Pipe A trigger T_VHigh mode=normal Define a pipe P_Select word Define Processing to Detect EventsDefine the processing task that makes the data selection. The possibilities are limitless... but this article covers only the simple case that an extreme signal level indicates an event of interest. Presume that any value higher than +25000 indicates that an event has occurred. In DAPstudio, select the Processing tab and the Procedure sub-tab. Enter the command name Limit(P_Select,inside,25000,32767,T_VHigh,inside,25000,32767)
Define Processing to Respond to Events Let us suppose that the desired action is to capture 100
samples prior to the event and 924 samples from the event
onward, for a total of 1024 samples. To do this, use another
pre-defined processing command called Wait(IPipe1,T_VHigh,100,9024,P_Select)
You will typically go to the Send to PC tab, de-select the usual input channels, and select the retained data pipe (in our example, Your application is configured and ready to test. Once you have the configuration set up correctly, you can copy it into any software application you want, from an embedded application that you write yourself, to a monster GUI application with every conceivable kind of graphical displays and user controls. The performance is embedded in the data acquisition processor. Use Software Triggering to Process Data in BlocksOnce software trigger events are detected they are... in software. This gives the flexibility to do some things easily that would otherwise be enormously difficult, perhaps impossible. Applications can use software triggering to process data in blocks rather than individual samples. Selecting Data in Blocks
Suppose for example that data are captured at 1 million
samples per second. 2048 samples are selected for
processing by an FFT command every 0.1 second, producing
1024 magnitude output terms per input block of 100000 terms.
Most of the time, nothing happens and the FFT data can be
discarded. To this point, no triggering is needed. Just use
a Most of the time, nothing happens. However, if an event occurs any time within the 0.1 second interval spanned by a block of 100000 samples, three FFTs are computed. One FFT is applied to the first 2048 samples from the current block. The other FFTs are applied to the first 2048 samples from the preceding block, and to the first 2048 samples from the block to follow. How can you do this? Thinking about this in terms of blocks, it is relatively easy. For example, if the event occurs in the input block 5 (input samples 500000 through 599999), you want to keep the FFT results for blocks 4, 5, and 6. You can determine the input block number easily from the event location. (event location) / 100000 One FFT every 1/10 second is easy for a DAP board to do. So instead of worrying about when to perform the FFT operations, it is easier just to stream each 2048 point data block into FFT processing as it arrives. The resulting blocks of 1024 FFT output values stream out. If an event occurs, you keep the resulting FFT blocks, otherwise they are discarded. The locations of desired FFT results in the FFT output stream are calculated easily. (block number) * 1024 ![]() Processing Implementation All of this theory is fine, but event locations are not
the same as ordinary data. How can you apply these calculations
to events? Easily, as it turns out. The DAPL system provides
a command called Here are the configuration lines that you would use. Trigscale( RAWtrig, 0, 1024, 100000, FFTtrig ) Wait( FFTresults, FFTtrig, 1024, 2048, FFTselected ) The details:
ExtensionsIn this example, the application captures data when it observes something interesting. However, it is not completely rigorous about capturing all data where anything interesting occurs. If the last block analyzed for an earlier event happens to contain a new event, it will be impossible to respond to this event properly. The data for the "block prior" was taken by previous processing. The DAPL system cannot partially respond, which means that the FFT block following the secondary event will be missed. You can be sure that all events are covered if you use
the Multiple Channel Acquisition with TriggeringThe application is a vehicle crash test. You will observe data for stress, buckling, and fractures at 100 sensor locations on an instrumented vehicle – and in a fraction of a second it is all over. You have just one chance to capture the measurements. There is too much data to collect it all continuously, but you cannot afford to miss any relevant data or risk drowning your system with irrelevant data before the crash event has occurred. ![]() Suppose that you are using a DAP 5400a/627, sampling 8 channels simultaneously, with each of the 100 channels sampled at each 100 microsecond interval. During an experiment covering 0.5 seconds, you will collect about 4 million samples. The host interface can transfer about 2.5 million samples under ideal circumstances. Depending on what your application processing does with the data, you might be able to move perhaps 1 million samples into your application software during the event. The other 3 million samples are captured and buffered on the DAP, and sent when the host software is able to accept them. Reliable Triggering
A high-speed transient glitch propagating along a sensor wire could easily set off an electronic triggering circuit. A glitch of that kind would not be persistent. The real signals of a crash event would be very different. When using software triggering, you can combine processing with triggering, so that real events are distinguished from the meaningless noise glitches. Suppose you select one of the microphone channels that
will respond to early contact, and connect it to signal
channel On the other hand, you don't want a single "spike" to prematurely trigger. You can use a running average with a short time window to smooth out noise spikes. To trigger, the signal must reach the triggering level and stay there for a few samples. The following configuration cancels DC offsets, smoothes out spikes, and triggers when the signal level deviates from the baseline level consistently through a window of 7 samples. pipes pDCoff word, pCleaned word pipes pDiff trigger tCrashEvent ... pdefine CrashCapture raverage(IPipe0, 400, pDCoff) raverage(IPipe0, 7, pCleaned) pDiff = pCleaned - pDCoff ... Now you can trigger reliably on the processed Limit( pDiff, OUTSIDE, -20000, 20000, tCrashEvent ) ... Accounting for Many ChannelsThe crash is detected on just one channel, but data are collected in many channels. As we saw earlier, the position of the data in a triggering channel must be used to determine the associated position of the data in channels where data are taken. The ... Wait(IP(0..99), tCrashEvent, 12000, 4000000, $Binout) end ![]() Intelligent Triggering
Despite its speed limitations, software triggering might still be faster by a wide margin than what your PC host or a Programmable Logic Controller could do. If a response delay of one millisecond is acceptable, a Data Acquisition Processor might have the speed you need to measure AND control your processes. Multi-Input ON-OFF ControlFor this example, an automated manufacturing process will inject a carefully measured amount of liquid into a bottle, and then the bottle will be moved to the next station for subsequent processing. For purposes of filling the bottle, there is a sequence of events.
![]() We will concentrate on the triggering. The problem here is that one sensor starts the fill operation, while a completely different sensor stops it. A Programmable Logic Controller is a suitable alternative for this application if speed requirements are moderate and you don't need to worry about high measurement precision. A PLC can give you 1/30 or 1/60 second time resolution, but a DAP board can give you 1/1000 second time resolution easily. ON-OFF Triggering with DAPL Suppose that the optical sensor readings come in on input
data channel Suppose that the weight sensor readings come in on input
channel The DAPL system provides a special command called
TOGGLE ( IPipe0, inside, 0, 1000, \ IPipe1, outside, -32768, 24000, T_Fill ) The details:
Responding to ON-OFF Events The strictly alternating sequence of TOGGWT ( IPipe1, T_Fill, P_DigPort, "FORMAT=STREAM" ) The The rest is beyond the scope of this article, but to
summarize briefly, the data in pipe Host-Triggered MeasurementSoftware triggering can allow intelligent decisions about when to capture meaningful data, without any intervention from the host system. But there are times when only the host system knows when it is appropriate to measure. In most data acquisition systems, the software triggering is just a slow means for activating hardware triggering across a host interface bus. With a Data Acquisition Processor board, the same kind of triggering is available, and it remains slow. The bus interface is fast, but it has unpredictable setup delays. There is nothing that can be done about this. For example, suppose that the purpose of a test is to measure how well shielding material protects against hard impacts. ![]() There is no point in collecting impact data until the firing mechanism is ready for release. The PC host could activate the release mechanism and at the same time tell the Data Acquisition Processor to expect the event. The problem is, the signals to the release mechanism and to the DAP take different hardware signal paths, and the operating system delays for delivering the messages on each channel are unpredictable. Suppose that the following timing constraints apply:
The following diagram illustrates the two most extreme cases for timing. ![]() In the first case, the Data Acquisition Processor receives its notification almost immediately, while the release mechanism message is delayed 25 milliseconds. The DAP will not start to see any meaningful data until 30 milliseconds later. In the second case, the release mechanism receives its message 25 milliseconds ahead of the DAP, and the entire experiment is completed 10 milliseconds before the DAP is notified. To make sure that the DAP captures all of the data in the case that its notification arrives late, it should retain data starting 20 milliseconds before its notification time. To make sure that the DAP captures all of the data in the case that its notification is early, it should continue to retain data until 40 milliseconds after the notification. The total data collection interval is 60 milliseconds, and 60000 samples are collected. Converting Messages to Events
A message is easily transferred from PC host software into
the Data Acquisition Processor using pre-defined communication
pipe DapBufferPut( DAP_outhandle, 2, &arbitrary ); When this number reaches the Data Acquisition Processor, an
event is constructed in the software trigger PCASSERT( $Binin, T_PCevent ) The For the impact test example, after the trigger event is
posted, a WAIT( IPipe0, T_PCevent, 20000, 40000, $Binout ) Extensions In the example, a captured data set will include 60000
samples, of which only 10000 are relevant. The rest allow
for the uncertainties in PC host timing. Intelligently isolating
relevant data is the specialty of software triggering. The fact
that the selected data came from a triggering process
doesn't matter. You could apply an additional An alternative solution is to let the DAP detect
the impact event by testing a data channel in the usual manner.
To prevent extraneous triggering events between experiments,
use the This concludes the article on software triggering, but hardly exhausts all of the possibilities. Some additional topics covered in the manuals but not covered here include:
A Data Acquisition Processor board can be an excellent platform for technologies and techniques beyond the scope of this article. Take a look at other data acquisition and control techniques. Or take DAPstudio out for a spin.![]() |