<< Click to Display Table of Contents >> Navigation: NmxDLL Referenz > HowTo > Sampling > Start TFT high-level sampling |
TFT sampling is similar to time-limited sampling, but provides 3 features. These are
•triggering by a digital input,
•applying an arithmetic average filter on the measurement values and
•providing additional samples, called "tail samples", after the sampling has been stopped.
Each of them can be disabled individually.
If TFT sampling is started, the NMX DLL internally starts an endless time-triggered sampling via the low-level sampling functions. With the Parameter ulSamplingSpeed, the speed of this sampling is defined. TFT sampling then reads all the sampled data and processes it. The processed data is then read by the application / measurement software.
This is important to know, since the underlying endless time-triggered sampling will only work endless, as long as the sampled data can be transferred from the measurement system to the PC in realtime. For many applications, 1000 samples/s = 1000 µs should be enough and these can almost always be transferred in realtime. In case a higher speed is required, please consult the chapter "Sampling Speed with Irinos" for a more detailed information.
Triggering
TFT sampling provides several possibilities to start / stop the recording of measurement values via a digital input. The trigger modes "Edge", "Level", "Edge Start" and "Level Once" are available. For more information about these, consult the chapter "Trigger Modes".
Here are further notes:
•Triggering can be disabled completely by using the dummy trigger mode "Off".
•Sampling can always be stopped manually by calling NMX_Sampling_Stop_1. The digital input then has no effect.
•Besides using a digital input for triggering, all digital input data can still be included into the list of sampling elements (see NMX_Sampling_AddDigiInAll_1 and NMX_Sampling_AddDigiInByte_1).
Filtering
Via an integrated arithmetic average filter, the measurement values can be smoothened. The results are provided to the user application / measurement software.
Setting the filter is done via the parameters ulSamplePeriod and ulFilterPeriod:
•If ulSamplePeriod = ulFilterPeriod, then filtering is disabled.
•ulFilterPeriod must be an integer multiple of ulSamplePeriod.
Example for ulSamplePeriod = 1000 (=1 ms):
Valid values for ulFilterPeriod are 1000, 2000, 3000, 4000, 5000, ..., 10000. But for example 2500 would be invalid.
•ulFilterPeriod must be ≥ ulSamplePeriod
Example:
ulSamplePeriod = 1000, which is 1ms or 1000 samples/s.
ulFilterPeriod = 5000, which is 5ms or 200 samples/s.
-> The arithmetic average of 5 incoming samples is calculated and provided to the application / measurement software. This means the application receives 200 samples/s.
Note: Digital inputs or outputs are never filtered.
Tail values
Tail values are recorded after stop of sampling, no matter how the stop condition occurred. Typically they are used to apply an additional filter in the application / measurement software.
The parameter ulNTailSamples defines the number of samples recorded after stop. If this value is 0, then recording tail values is disabled.
Tail values can also be used with endless sampling. After endless sampling is stopped manually via NMX_Sampling_Stop_1, the tail values will be recorded.
Basically, TFT high-level sampling is used in the same way as standard low-level sampling. Therefore most of the low-level functions can be used:
•NMX_Sampling_AddChannelsAll_1
•NMX_Sampling_AddDigiOutByte_1
The major difference is that the function NMX_Sampling_PrepareCustomTFT_1 instead of the function NMX_Sampling_PrepareTime_1 is used.
The use of notifications is the same as with low-level sampling.
As a result of this, the following other HowTo's can be used as well:
•Start endless time-based sampling, except that NMX_Sampling_PrepareCustomTFT_1 must be used.
•Start time-limited sampling, except that NMX_Sampling_PrepareCustomTFT_1 must be used.
Following one example is provided for starting TFT high-level sampling:
C / C++: Start with all measurement channels, 1ms sample period, 5ms filter period, trigger "Level Once" and 4 Tail values
unsigned long ulNElements = 0;
// ###-> 1. Reset list of sampling elements
if (NMX_Sampling_Reset_1(pHandle) == NST_SUCCESS) {
// List of sampling elements has been reset successfully.
}
else {
// Failed resetting the list of sampling elements.
// Do some error handling.
return;
}
// ###-> 2/3. Add sampling elements
if (NMX_Sampling_AddChannelsAll_1(pHandle, &ulNElements) == NST_SUCCESS) {
// Successfully added all sampling elements
}
else {
// Failed adding sampling elements
// Do some error handling.
return;
}
// ###-> 4. Prepare sampling
if (NMX_Sampling_PrepareCustomTFT_1(pHandle, 1000/*µs*/, 5000/*µs*/, 10000, 10000/*MaxSamples*/, 4, 0, 3, 4, 2) == NST_SUCCESS) {
// Sampling successfully prepared
}
else {
// Failed preparing sampling
// Do some error handling.
return;
}
// ###-> 5. Start sampling
if (NMX_Sampling_Start_1(pHandleNmx) == NST_SUCCESS) {
// Start successful.
}
else {
// Failed starting sampling
// Do some error handling.
return;
}