Show/Hide Toolbars

Irinos Measurement System

Navigation: Users Manual Irinos-System > Measurement / Control via MscDll > Examples for dynamic measurement

Example 1: Timer-triggered dynamic measurement

Scroll Prev Top Next More

Task

For a working piece with a length of 12cm, the surface planarity of two sides shall be measured. Therefore an incremental probe is used for each side (T2 and T3). The working piece is moved constantly via a servo-drive.

It takes about 2 seconds to move the working piece along the probes. In order to measure very small non-planarity, a sample rate of 5.000 samples/s is required.

The position of the working piece is measured via a linear incremental encoder with 32000 increments/cm (T4). It will be used for determining the surface planarity.

Beispiel dynamische Messung

Example "time-triggered dynamic measurement"

 

Preliminary considerations

It is known that the measurement takes about 2 seconds; an exact duration is unknown. Therefore the dynamic measurement must be started with a longer duration. 4 seconds are chosen. While the dynamic measurement is active, the position of the working piece (T4) is used to check, whether all samples have been taken. If yes, the dynamic measurement will be stopped.

The length of the working piece in increments of the incremental encoder T4 is MscDll_Dyn_Beispiel1_FormelWerkstücklänge. As soon as this value has been reached, the measurement is stopped.

 

Example-Code

// Write channel list 1 using the measurement channels T2, T3 and T4

ansiString = “#1;T2;T3;T4#”;

WriteCommandStr(opcWCL, ansiString);

if (ansiString != “#0#”) return -1; // An error occured: cancel starting measurement

 

// Define trigger:
// TriggerNo 1; time-triggered; * = no input channel required; divisor = 1;

// interval = 0.2ms (-> 5000 values/s); start = 0ms; end = 4000ms
ansiString = “#1;T;*;1;0.2;0;4000#”;

WriteCommandStr(opcDT, ansiString);

if (ansiString != “#0#”) return -2; // An error occured: cancel starting measurement

 

// Define dynamic measurement 1:
// TriggerNo 1; channel list 1; dyn. measurement active;
// 5s * 4000 samples/s = 20000 samples

ansiString = “#1;1;1;20000#”;

WriteCommandStr(opcDDM1, ansiString);

if (ansiString != “#0#”) return -3; // An error occured: cancel starting measurement

 

// Setup data transfer channel for dynamic measurement values
result = MSC_SetupExtendedDynamicChannel(pDevice, opcRDM1, 3, 1, NULL);

if (result != MSC_STATUS_SUCCESS) return -4;

 

// Allocate 3 buffers, each having a size of 20000 * 4 Bytes = 80000 Bytes

// for the measurement values. Assign these buffers to the DLL.

for (i = 0; i < 3; i++) {

 buffer[i] = malloc(20000*4);

 result = MSC_AttachSubChannelBuffer(pDevice, opcRDM1, i, 20000*4, &buffer[i]);

 if (result != MSC_STATUS_SUCCESS) return -5;

}

 

// Activate trigger

ansiString = “#1#”;

WriteCommandStr(opcAT, ansiString);

if (ansiString != “#0#”) return -6; // An error occured: cancel starting measurement

 

// Wait until the dynamic measurement is finished

do {

 result = MSC_GetPosition(pDevice, opcRDM1, &nSamples);

 if (result != MSC_STATUS_SUCCESS) return -7;

 Sleep(50); // Take a break for 50ms

} while ((nSamples < 20000) && (staticValueT4 < 384000));

 

// Inactivate trigger

ansiString = “#1#”;

WriteCommandStr(opcIT, ansiString);

 

// Wait until all measurement values are transferred to the PC.
// Note that if the loop above has been stoped by the second condition

// (staticValueT4 < 384000), not all values may have been transferred to

// the PC yet.

 

It is assumed that the static measurement is running in parallel. The variable staticValueT4 contains the measurement value T4, which is cyclically updated via static measurement.