-
Notifications
You must be signed in to change notification settings - Fork 2
TDC1 Documentation
The TDC1 is a combined moderate-speed counter and timetagging device for processing electrical pulses in four independent inputs. It can accept a wide range of standardized signal standards including (NIM and TTL), is completely powered from a USB2 connection. The internal clock source can be disciplined by an external 10 MHz timing reference for precise absolute timing.
In counting mode, the device has 4 independent counters registering events on each of the four inputs, and 4 counting coincidence events between 4 pairs of inputs that register counts for a selectable integration time from 1ms to 65s.
In timetag mode, the device registers the absolute time of the leading edge every signal event (pulse) at any of the input lines with a resolution of 2ns together with the logical state of all four input lines. This allows to identify complex detector patterns with a single device.
Specification overview
Physical parameters: | |
Size | approx 85mm x 45mm x 22mm |
Weight | 150g |
Power consumption | <0.5W (100mA from USB bus) |
Signal inputs: | |
Impedance | 50Ohm (default) and 1kOhm (selectable by jumpers) |
Input standards | TTL, NIM, custom (positive or negative pulses with a trigger level between -3.3V and +3.3V) |
Absolute Maximum Input Amplitude | +4.2V/-4.2V |
Minimal pulse width | 2ns |
Minimal pulse separation | 2ns |
Connector | LEMO00 size coaxial connector (optional: SMA) |
Clock reference: | |
External reference frequency | 10MHz nominal (accepts 9...11MHz) |
External reference amplitude | 100mVpp min, 2.3Vpp max |
Clock selection | automatic or forced manual |
Internal clock accuracy | <50ppm, temperature drift TBD |
Counter mode parameters: | |
Maximal count rate | 250MHz in each channel |
Integration time | 1ms to 65535ms in steps of 1ms |
Timestamp mode parameters: | |
Timing resolution | 2ns |
Timing jitter | <200ps (nominal) |
Maximal counting rate | >10Mevents/s average, >250 Mevents/s in bursts of <256 events |
Dead time between events | None |
Interface: | |
Host connection | USB CDC ACM class / virtual com port (no device driver necessary) |
Data format | Text or binary |
The device does not require a driver to operate, requiring only serial communication between host and device.
Standard Serial Settings Baud Rate : 115200 Data Bits : 8 Parity : None Stop Bit : 1 Flow Control : RTS/CTS
By entering the HELP
command, the device replies with a number of commands:
Usage: Send plaintext commands, separated by newline/cr or semicolon. An eventual reply comes terminated with cr+lf. Important commands: *IDN? Returns device identifier *RST Resets device TIME <value> Set the gate time to <value> in msec. Default is 1000, minimum is 1, max 65535. TIME? Returns the current gate time. COUNTS? Triggers a counting window, and replies with the number of detected events as a list of space-separated integers. ABORT Stops current counting cycle. SINGLES Return only singles (mode 0). PAIRS Return singles and pairs (mode 1). TIMESTAMP Returns timestamps as packed binary patterns (mode 3). MODE? Returns device counting mode. TTL Process TTL inputs (threshold +1.6V, positive edge) NIM Process NIM inputs (threshold -0.5V, negative edge). LEVEL? Returns input threshold voltage and polarity (POS or NEG). REFCLK <value> Sets the reference clock source, where <value> is 0 for autoselect, 1 to force external reference, and 2 to force the internal reference. In auto mode, an external clock is considered ok if 9MHz<f<11MHz. REFCLK? queries the current reference clock setting (reply is 0, 1 or 2). ECLOCK? queries external clock status. returns 1 if an external clock with a frequency 9...1MHz is detected, or 0 otherwise. POS <voltage>, NEG <voltage> Sets input to detect positive or negative edges at a given threshold <voltage> (range -3.3...+3.3V). HELP Print this help text.
Multiple commands can be sent with a semi colon in between with no space. An example command is show below.
*RST;TTL;TIME100;TIMESTAMP;COUNTS?
This prompts device to reset its configuration, triggers with TTL pulse with a gate time of 100ms, works in Timestamp mode, and then returns the data for each event within the gate time.
In singles mode, device will return the counts for each channel in ASCII characters.
Return Character | 0 | 1 | 2 | 3 |
---|---|---|---|---|
meaning | Ch1 | Ch2 | Ch3 | Ch4 |
In pairs mode, device will return the counts for each channel and coincidences of four pairs of detection channels. Note that coincidence events is triggered by overlap in pulses.
Return Character | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---|---|---|---|---|---|---|---|---|
meaning | Ch1 | Ch2 | Ch3 | Ch4 | Ch1-Ch3 | Ch1-Ch4 | Ch2-Ch3 | Ch2-Ch4 |
In timestamping mode, the device will return integer multiples of 32-bit data within the set integration time. Data consists of two 16bit wide words per event, with the following meanig:
MSW (second word) | LSW (first word) | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bit in word | 15 | ... | 2 | 1 | 0 | 15 | 14 | 13 | 12 | ... | 7 | 6 | 5 | 4 | 3 | .. | 0 |
meaning | time (multiple of 2ns, 27 bit) | dummyflag | detector pattern |
The 32 bit result per event results is made up by a 27 bit time (multiples of 2ns), a dummy flag, and four detector bits. The dummy flag indicates that the event had no detector events, but allows for synchronization of a higher level counter to extend the range of the timing information. It guarantees that the most significant bit of the timing information always toggles. Note the order of bits when converting the binary data into time in integers, they might need to be flipped usually.
Simple codes were written in Python and Labview for users to quickly familiarize with the devices. The Python script works across all operating systems since it does not rely on any external libraries in C.
Access to the device is can be made easily through serial communication, which requires NI-VISA package pre-installed in the Labview environment. The Labview sample code is available in the github folder here.
The counting functions of the device can be tested with Counter.vi, which allows user to set basic configurations like standard trigger modes, counter mode, gate timing. Before running the VI, it is important to note the COM port used for your device, then set the correct COM port on VISA resource name. The rough guide to getting the counter running is listed below:
- Check serial settings. The default is already set to work for TDC1.
- Max Read Buffer is the maximum number of bytes to read , which is not important for counter mode because the message reading stops upon reading the termination character. Set default to 100.
- Set gate timing 1ms - 1000ms, counter mode and trigger mode.
- Click "Config SET" button.
- Run VI.
- You will see the return characters of the device updating along with the waveform chart for the readings.
- If you wish to stop counting, or change config, please use the stop button provided.
- Note: Terminating the VI abruptly during run without using the STOP button might cause error in subsequent runs. Run VI again from step 3 and click the stop button before stopping to get around this bug.
The event pattern is
[no signal] [Signal at Ch 4][Signal at Ch 3][Signal at Ch 2][Signal at Ch 1] [27-bit timestamp in nanoseconds]
Steps to use the VI is outlined below:
- Check COM port.
- Set trigger mode to either TTL or NIM, gate time and the path to write the timestamp data.
- Run VI.
- You will see that the spreadsheet string is updated every 0.5 s with timestamp data parsed from binary arrays generated within the gate time.
A https://github.com/s-fifteen-instruments/pyS15 independent of the original C-file was written, giving user the ability to use the counting and timestamp mode independent of software environment. The required packages to use this Python script are below.
Required Packages: tkinter numpy matplotlib time csv pyserial
Note for people totally new to Python: It is easier to install Anaconda, and get the necessary packages via its package manager. Most packages are already included in the initial installation of Python.
In this package, usbcount.py is the main class that is used for accessing various functions in the counter device. The device path must be defined in this class before starting. Examples of device path are shown below:
Windows "COMx" Linux "/dev/serial/by-id/..."
For Windows user, you can identify the COM port the device is connected to via Windows device manager under the Ports list. For Linux users, make sure you have root access to use the device. The device path can be found easily in
/dev/serial/by-id/...
,where the name of the device will be listed if connected to the computer.
NOTE: There is a branch of this depository that has a part that lists down all connected serial port for user selection. This works across all OS theoretically.
The first sample script is counter_FPGA_GUI, this script operates in the pairs mode, where the device is probed periodically to obtain the counts for each devices and also coincidence events between channels. The host starts sending read command upon pressing the start button, and stops reading with the stop button. The set gate time will update the gate time based on the integer in the Gate Time text box. In this file, one can change the trigger mode of the device at the beginning of the script (around line 24), under signal_type string variable.
The GUI calls usbcount to obtain the counter values and updates the text in the front end, which is then represented in the y-axis of the graph. We also note that the time axis of the graph is current UTC time in milliseconds.
The second sample script is timestamp_FPGA , which uses the device in the timestamp mode. This script calls usbcount to record event times. The 27-bit time event is processed into timestamps in ns and then parsed in a CSV file. In the GUI, the start button initializes the script that calls the timestamp function periodically, where the period is defined by the gate time plus a 10 ms delay. Please be careful that the loop will stay running until the stop button is pressed. The Timestamp Snapshot button records values within one loop and the gate time can be set in the text box on the bottom right of the GUI. The path of the CSV file is defined in the GUI script (line 23) Note:For the latest branch, the are two files that are generated, histo parses a collated histogram data, while timeevents collate the individual events detected by counter. Format of histogram data starts with a preamble of binwidth, maxbins, count at channel 1, count at channel 2, coincidence, followed by individual bin values. The bit rate for this script is roughly <120 Mbps, where data is streamed continuously during integration time. When the count rate gets too high, say >2 Mevents/s there might be issues with buffer overflows and the data received will be corrupted. This rate varies from computer to computer as the rate is still far from the USB 2.0 limit of 480 Mbps. One can further process (eg: calculating correlation) the timestamp data by taking data from the GUI or reading from the generated text file.
The event pattern for timestamp is:
[no signal] [Signal at Ch 4][Signal at Ch 3][Signal at Ch 2][Signal at Ch 1] [27-bit timestamp in nanoseconds]
Note: When there is no signal, the device will flag a no signal character on the event pattern after a period of of 135 and 270 ms. If your integration time is less than that, it is unlikely you will see this flag in the event there is no signal.
For details regarding the device and questions, please contact
info@s-fifteen.com
Please include your device model and serial code together with your questions. Any log or screenshots for us would help too. Thank you!