Timing Channels on the iDSC 1816Technical Note TN-243 Version 1.10 | |||||||||
The iDSC 1816 has two timing channels, External Timing Channel 0 and External Timing Channel 1, which can be utilized for triggering and correlating the clock signal from an external device to the sample clock onboard. They are TTL pulses, which are rising-edge triggered and the falling edges are not detected. They record the number of clock ticks of the clock onboard of the iDSC, or counts, elapsed between consecutive rising edges. The internal clock of the iDSC runs at 19.66 MHz, whereas the analog-to-digital converters run at half the clock speed (i.e. 9.8 MHz) because that is about the fastest they can run. The two timing channels run at the full clock rate of 19.6 MHz because they do not need to be digitized by the analog-to-digital converters. One count of the timing channel is equivalent to the period of the clock onboard, which is approximately 50.8 ns. With no rising edge detected the value of the timing channel is at its maximum, which is equivalent to the ratio between the input clock and the sample rate specified by the user. This maximum value is called
You can see that
The valid sample rates on the iDSC range from 8 to 153,600 Hz, which leads to a range between 2,457,600 and 128 for The timing channels need to be enabled in software before they can be used. The Once the timing channels are enabled, they are interleaved in the data stream of the iDSC with the eight inputs on the board. The The relative time of the rising edges in the timing channel can be determined by calculating the number of counts elapsed between the time at which the iDSC starts (time = 0 s) and the arrival of the event. The relative time of the nth sample in the timing channel can be calculated by the following equation: relative time = [((n-1) x For example, the iDSC is sampling at 12.8 kHz per channel and also reading one of its timing channels. The value of 1460 1536 1536 1536 193 The data stream indicates that rising edges were detected at the 1st and 5th sample and their relative times are 74.2 and 321.9 ms from the time at which the iDSC was started. Unlike the eight analog inputs, the timing channels do not have group delay because they do not go through the low-pass filters. It leads to a skew in the relationship between the sample count in the timing channel and the data value in any of the input channels; the data value that corresponds to each sample count in the timing channel comes in at one group delay after the sample count. So in order to match up the data value and the sample count, the group delay needs to be added to the same count after it is converted to the time domain. The group delay can be determined by the The timing channels can be connected to the terminals on the iDSC termination board (i.e. MSXB042) or directly to pin 12 and 13 of the input/output connector of the iDSC board. The two timing channels are independent of each other; they can be used for two different inputs at the same time. Refer to the pinout of the connector in the iDSC Reference Manual. The following example was implemented using Visual C++ 6.0. It reads from External Timing Channel 0 and reports the relative time of a rising edge if it is detected. #include <stdio.h> #include <stdlib.h> #include <windows.h> #include "Dscio.h" #define MAXSIZE 8192 const char DSC_ADDRESS[] = "\\\\PC83\\Dap1"; void main() { HDSC hDsc; TBufferGetEx bge; long TcMax, Tc, CountAccum, SampleRate; double TimeEvent; short Data[MAXSIZE], i, j, BlockPerCh, blocksize; hDsc = DscHandleOpen(DSC_ADDRESS); // Open handle to iDSC. // Enable Tc0 and force the width of the channel to be 4-byte if ( !DscTcEnabledSet(hDsc, DscTc_Tc0|DscTc_TcWidth32) ) printf("Error enabling Timing Channel A.\n"); //DscSampleRateSet(hDsc, 800); // Set sample rate to 800 S/s. DscFilterDialogShow(hDsc); // Design filters and configure system. // Determine TcMaximum TcMax = DscTcMaximum(hDsc); // Read 5 values per channel. // One timing channel equals to two word values. BlockPerCh = 5; blocksize = (DscPinEnabledCount(hDsc) + 2 ) * BlockPerCh; DscStructPrepare(&bge, sizeof(bge)); bge.iMinBytes = blocksize*2; bge.iMaxBytes = blocksize*2; bge.iTimeWait = 1000; bge.iTimeOut = 1000; // Number of counts that should have been // accumulated from the timing channel CountAccum = 0; SampleRate = DscSampleRateGet(hDsc); if (DscStartAcquiring(hDsc)) { // Read a data block from the iDSC. The pattern // of the stream is one short integer for // each active input, followed by two short // integers making up the long timing channel. DscBufferGetEx(hDsc, &bge, Data); i = 0; while(i<blocksize) { // Read and display the active inputs for(j=0; j<DscPinEnabledCount(hDsc); j++) { printf("%d\t", Data[i]); i++; } // Read and display the timing channel. // Shift the second word value, which // represents the higher order of the // timing channel, to the left by 16 bits. // Then add it to the lower order. Tc = ((unsigned short)Data[i]) | (Data[i+1] << 16); printf("Tc = %d\n", Tc); i = i + 2; // An event is detected if Tc is less // than TcMax. One count = 50.8 ns if ( Tc < TcMax ) { TimeEvent = (double)(CountAccum + Tc) * 0.0000000508; printf("An event has been detected at %f second.\n", TimeEvent); } // Update the amount of time elapsed. CountAccum = CountAccum + TcMax; } DscHandleClose(hDsc); // Close handle to iDSC. } }
View other Technical Notes. |