Start position triggered sampling

<< Click to Display Table of Contents >>

Navigation:  NmxDLL Reference Guide > HowTo > Sampling >

Start position triggered sampling

Instead of recording the measured values at constant time intervals, the position-triggered measurement enables the acquisition at constant position intervals, e.g. in 0.1° or 10µm distances.

 

If position-triggered 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. Position triggered sampling then reads all the sampled data and processes it. The processed data is then read by the application / measurement software. The accuracy of the position distance depends on the time interval used for sampling.

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.

 

Setting up the trigger

For position triggered sampling, it is required to provide the NMX DLL information about the trigger. That information is:

1.Which measurement channel does provide the position information? -> Which encoder or probe does provide the position information, which is required to identify the trigger points?
In the function call of NMX_Sampling_PreparePosition_1, this is the parameter ulTriggerChannelNumber.

2.Where / at which position shall triggering be started?
In the function call of NMX_Sampling_PreparePosition_1, this is the parameter fdStart.

3.What is the position distance between two trigger points?
In the function call of NMX_Sampling_PreparePosition_1, this is the parameter fdDistance.

Optionally, the unit for the parameters fdStart and fdDistance can be set via a scale factor. In the function call of NMX_Sampling_PreparePosition_1, this is the parameter fdScale. If fdScale = 1, then no scaling is used.

 

With these parameters, sometimes several possibilities lead to the same goal. Thus not every possibility for setting up the trigger can be discussed here. However, following two examples are provided:

 

Example 1:

A measurement system consists of 8 inductive + 4 incremental measurement channels. A rotational incremental encoder is connected to the 2nd incremental channel. The encoder has a resolution of 400000 increments per revolution. Measurement shall be started at 0° and end after one rotation with a position distance of 0.5°. Then the following parameters could be used:

ulTriggerChannelNumber = 9;        // 10-1 = 9, since channel numbering is 0-based

fdScale = 400000.0 / 360.0;                // = 1111.1111

fdStart = 0.0;

fdDistance = 0.5;

udMaxSamples = 360.0 / 0.5;                // = 720.0

 

Example 2:

A measurement system consists of 4 incremental measurement channels + 32 inductive measurement channels. A linear encoder is connected to the 1st incremental channel. Measurement shall be started at the position 7500 increments towards the negative direction with a position distance of 100 increments. Measurement shall be stopped at -423600 Then the following parameters could be used:

ulTriggerChannelNumber = 0;        // 1-1 = 0, since channel numbering is 0-based

fdScale = 1.0;                                // No scale factor is used

fdStart = 7500.0;

fdDistance = -100.0;                        // Minus due to negative direction

udMaxSamples = 4312;                // = ((7500 - (-423600) / 100) + 1

 

 

Coding position-triggered sampling

Basically, position-triggered sampling is used in the same way as standard low-level sampling. Therefore most of the low-level functions can be used:

NMX_Sampling_GetMaxSpeed_1

NMX_Sampling_Reset_1

NMX_Sampling_AddChannelsAll_1

NMX_Sampling_AddChannel_1

NMX_Sampling_AddDigiInAll_1

NMX_Sampling_AddDigiInByte_1

NMX_Sampling_AddDigiOutAll_1

NMX_Sampling_AddDigiOutByte_1

NMX_Sampling_Start_1

NMX_Sampling_Stop_1

NMX_Sampling_ReadColumn32_1

NMX_Sampling_ReadRow32_1

NMX_Sampling_GetStatus_1

The major difference is that the function NMX_Sampling_PreparePosition_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.

Stop sampling

Reading sampled data

Get sampling status

 

Following one example is provided for starting position-triggered sampling:

 

C / C++: Start with all measurement channels, 250µs sample period, first encoder as trigger source, scale factor 200.0, start position 0°, distance 0.5° and stop after one rotation


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;

}

 

NMX_STATUS NMX_Sampling_PreparePosition_1(

 NMX_PHANDLE pHandle,

 unsigned long ulSamplePeriod,

 unsigned long ulArrayLength,

 unsigned long long udMaxSamples,

 unsigned long ulTriggerChannelNumber,

 double fdScale,

 double fdStart,

 double fdDistance);

 

// ###-> 4. Prepare sampling

if (NMX_Sampling_PreparePosition_1(pHandle, 250/*µs*/, 720, 720/*MaxSamples*/, 0 /*first channel*/, 200.0, 0.0, 0.5) == 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;

}