Timestamps
Combination of Memory Segmentation Options with Timestamps
(c) Spectrum GmbH
127
This special sampling option requires the option BaseXIO to be installed. All enhanced timestamps are not
longer integer 64 values. Before using these stamps for calculations (such as difference between two stamps)
one has to mask out the leading byte of the stamps first.
Selecting the timestamp data format
The selection between the different data format for the timestamps is done with a flag that is written to the timestamp command register. As
this register is organized as a bitfield, the data format selection is available for all possible timestamp modes.
Combination of Memory Segmentation Options with Timestamps
This topic should give you a brief overview how the timestamp option interacts with the options Multiple Recording, Gated Sampling and
ABA mode for which the timestamps option has been made.
Multiple Recording and Timestamps
Multiple Recording is well matching with the timestamp option. If timestamp
recording is activated each trigger event and therefore each Multiple Re-
cording segment will get timestamped as shown in the drawing on the right.
Please keep in mind that the trigger events are timestamped, not the begin-
ning of the acquisition. The first sample that is available is at the time position
of [Timestamp - Pretrigger].
The programming details of the timestamp option is explained in an extra
chapter.
Example Multiple Recording and Timestamps
The following example shows the setup of the Multiple Recording mode together with activated timestamps recording and a short display of
the acquired timestamps. The example doesn’t care for the acquired data itself and doesn’t check for error:
Register
Value
Direction
Description
SPC_TIMESTAMP_CMD
47100
r/w
SPC_TSXIOACQ_ENABLE
4096
Enables the trigger synchronous acquisition of the BaseXIO inputs with every stored timestamp in the upper byte.
SPC_TSXIOACQ_DISABLE
0
The timestamp is filled up with leading zeros as a sign extension for positive values.
// setup of the Multiple Recording mode
spcm_dwSetParam_i32 (hDrv, SPC_CARDMODE, SPC_REC_STD_MULTI); // Enables Standard Multiple Recording
spcm_dwSetParam_i32 (hDrv, SPC_SEGMENTSIZE, 1024); // Segment size is 1 kSample, Posttrigger is 768
spcm_dwSetParam_i32 (hDrv, SPC_POSTTRIGGER, 768); // samples and pretrigger therefore 256 samples.
spcm_dwSetParam_i32 (hDrv, SPC_MEMSIZE, 4096); // 4 kSamples in total acquired -> 4 segments
// 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
int64* pllStamps = new int64[4];
spcm_dwDefTransfer_i64 (hDrv, SPCM_BUF_TIMESTAMP, SPCM_DIR_CARDTOPC, 0, (void*) pllStamps, 0, 4 * 8);
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_CARD_START | M2CMD_CARD_ENABLETRIGGER | M2CMD_EXTRA_STARTDMA);
// we wait for the end timestamps transfer which will be received if all segments have been recorded
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_WAITDMA);
// 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);
for (i = 0; i < 4; i++)
printf ("#%d: %I64d samples = %.3f ms\n", i, pllStamps[i], 1000.0 * pllStamps[i] / lSamplerate / lOver);