128
M2i.30xx / M2i.30xx-exp Manual
Combination of Memory Segmentation Options with Timestamps
Timestamps
Gated Sampling and Timestamps
Gated Sampling and the timestamp mode fit very good together. If timestamp
recording is activated each gate will get timestamped as shown in the draw-
ing on the right. As you can see, both beginning and end of the gate interval
are timestamped. Each gate segment will therefore produce two timestamps
showing start of the gate interval and end of the gate interval. By taking both
timestamps into account one can read out the time position of each gate as
well as the length in samples. There is no other way to examine the length of
each gate segment than reading out the timestamps.
Please keep in mind that the gate signals are timestamped, not the beginning
and end of the acquisition. The first sample that is available is at the time po-
sition of [Timestamp1 - Pretrigger]. The last sample of the gate segment is at the position [Time Posttrigger]. The length of the gate
segment is [Timestamp2 - Time Pret Posttrigger]. When using the standard gate mode the end of recording is defined by
the expiring memsize counter. In standard gate mode there will be an additional timestamp for the last gate segment, when the maximum
memsize is reached!
The programming details of the timestamp mode are explained in an extra chapter.
Example Gated Sampling and Timestamps
The following example shows the setup of the Gated Sampling mode together with activated timestamps recording and a short display of the
the acquired timestamps. The example doesn’t care for the acquired data itself and doesn’t check for error:
ABA Mode and Timestamps
The ABA mode is well matching with the timestamp option. If timestamp
recording is activated, each trigger event and therefore each B time base
segment will get time tamped as shown in the drawing on the right.
Please keep in mind that the trigger events - located in the B area - are time
tamped, not the beginning of the acquisition. The first B sample that is
available is at the time position of [Timestamp - Pretrigger].
The first A area sample is related to the card start and therefore in a fixed
but various settings dependant relation to the timestamped B sample. To
bring exact relation between the first A area sample (and therefore all
area A samples) and the B area samples it is possible to let the card stamp
the first A area sample automatically after the card start. The following table shows the register to enable this mode:
// setup of the Gated Sampling mode
spcm_dwSetParam_i32 (hDrv, SPC_CARDMODE, SPC_REC_STD_GATE); // Enables Standard Gated Sampling
spcm_dwSetParam_i32 (hDrv, SPC_PRETRIGGER, 32); // 32 samples to acquire before gate start
spcm_dwSetParam_i32 (hDrv, SPC_POSTTRIGGER, 32); // 32 samples to acquire before gate end
spcm_dwSetParam_i32 (hDrv, SPC_MEMSIZE, 4096); // 4 kSamples in total acquired
// setup the Timestamp mode and make a reset of the timestamp counter
spcm_dwSetParam_i32 (hDrv, SPC_TIMESTAMP_CMD, SPC_TSMODE_STANDARD | SPC_TSCNT_INTERNAL);
spcm_dwSetParam_i32 (hDrv, SPC_TIMESTAMP_CMD, SPC_TS_RESET);
// now we define a buffer for timestamp data and start acquistion, each timestamp is 64 bit = 8 bytes
// as we don’t know the number of gate intervals we define the buffer quite large
int64* pllStamps = new int64[1000];
spcm_dwDefTransfer_i64 (hDrv, SPCM_BUF_TIMESTAMP, SPCM_DIR_CARDTOPC, 0, (void*) pllStamps, 0, 1000 * 8);
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_CARD_START | M2CMD_CARD_ENABLETRIGGER | M2CMD_EXTRA_STARTDMA);
// we wait for the end of timestamps transfer and read out the number of timestamps that have been acquired
int32 lAvailTimestampBytes;
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_WAITDMA);
spcm_dwSetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lAvailTimestampBytes);
// as we now have the timestamps we just print them and calculate the time in milli seconds
int32 lSamplerate, lOver, i;
spcm_dwGetParam_i32 (hDrv, SPC_SAMPLERATE, &lSamplerate);
spcm_dwGetParam_i32 (hDrv, SPC_OVERSAMPLINGFACTOR, &lOver);
// each 1st timestamp is the starting position of the gate segment, each 2nd the end position
for (i = 0; (i < (lAvailTimestampBytes / 8)) && (i < 1000); i++)
if ((i % 2) == 0)
printf ("#%d: %I64d samples = %.3f ms", i, pllStamps[i], 1000.0 * pllStamps[i] / lSamplerate / lOver);
else
printf ("(Len = %I64d samples)\n", (pllStamps[i] - pllStamps[i - 1] + 64));
Register
Value
Direction
Description
SPC_TIMESTAMP_CMD
47000
read/write
Programs a timestamp setup including mode and additional features