The TS-MINI is a mini-PCIe form factor card with an Intel Cyclone IV FPGA (EP4CGX22CF19C6N), and SAR ADC capable of simultaneously sampling 4 16-bit analog inputs at 5Msps (Linear Tech LTC2325IUKG-16). The FPGA samples the ADC data and sends it over PCIe to a host CPU for further processing or logging.
This board supports
- 0-4.096VDC single ended, 8Vpp differential, or +-2.048Vpp AC coupled inputs
- 5MSPs simultaneous samples on each channel
- 82dB signal to noise ratio
- Temperature compensated 4.096 Vref
2 Load Driver and Utilities
The Linux driver is kernel module udmabuf which can allocate a 2MB circular buffer that is accessible from userspace at /dev/udmabuf0. This is tested to work on ARM/amd64. A userspace application then pulls the data from /dev/udmabuf0 to stdout where it can be processed, stored, or sent over the network.
Build the driver and example userspace capture tool with:
git clone https://github.com/embeddedarm/tsmini2.git cd tsmini2/udmabuf/ #If you're on an x86 pc: #make ARCH=x86 cp udmabuf.ko ../ cd ../ make
On our systems such as the i.MX6, this module is included by default as part of the default kernel.
If you're using another ARM system this will need to be cross compiled.
cd tsmini2/udmabuf/ export ARCH=arm export KERNEL_SRC_DIR=/path/to/your/kernel-sources/ export CROSS_COMPILE=/path/to/recommended-kernel-cross-compiler make
Copy this udmabuf.ko to the tsmini2 directory on the target system.
2.1 Windows Users
Our git includes a kernel-mode driver suitable for a Windows x64 computer. The necessary files are in the tsmini2/driver-win/x64/ folder, and should be copied to a suitable location on the PC. Locate the TSMiniDriver.inf file in an File Explorer window, right-click the file, and select Install. The TS-MINI-ADC device should then appear in the Device Manager window, as shown below.
See the section Capture Data from Windows below for details on how to use the Windows driver.
3 Capture Data
3.1 Capture Data from Linux
Our git includes a "tsmini2_init" script which should be run before any pcie access. This bash script will load the udmabuf driver with a 2MB buffer, initialize ADC sampling, and configure how the ADC is sampled. This initial configuration determines if each channel will be differential, single ended, and default FIR configuration.
If the TS-MINI-ADC board was detected it will load the udmabuf driver in dmesg:
pci 0000:01:00.0: enabling device (0140 -> 0142) udmabuf udmabuf0: driver installed udmabuf udmabuf0: major number = 238 udmabuf udmabuf0: minor number = 0 udmabuf udmabuf0: phys address = 0xc00000 udmabuf udmabuf0: buffer size = 2097152
The tsmini2 utility is used to capture data from the ADC. This is a C application that runs with realtime priority and constantly pulls samples from the 2MB /dev/udmabuf0 circular buffer and places them in a 512MB FIFO writing output to stdout. Channels cannot be disabled and will always be sampled. The tsmini2 utility will run forever unless it receives an EOF, a signal termination, or if an overflow occurs. If stdout cannot keep up with the 40MB/s samples and and overflow occurs, the remaining of the 512MB FIFO will be output and then the application will terminate. Samples can start again when tsmini2 is reinvoked.
# Generate 100MB of samples ./tsmini2 | dd bs=1M count=100 iflag=fullblock of=samples.out # Output a sample of this data: hexdump samples.out | head -n 10
0000000 0358 0012 3d68 3c7c 035a 0016 3d66 3c80 0000010 0358 0014 3d64 3c78 035a 0012 3d62 3c7c 0000020 035a 0016 3d66 3c80 035a 0018 3d64 3c78 0000030 035c 0016 3d64 3c7c 0358 0016 3d66 3c82 0000040 035a 0012 3d64 3c78 035a 0016 3d66 3c7c 0000050 035a 0014 3d64 3c82 0358 0014 3d66 3c7c 0000060 035a 0014 3d64 3c7e 0358 0018 3d64 3c82 0000070 0358 0014 3d66 3c80 035a 0016 3d66 3c7a 0000080 0358 0010 3d64 3c7e 0358 0010 3d66 3c7e 0000090 035a 0014 3d68 3c78 0358 0014 3d66 3c7e
The output constantly returns 16-bits of ADC data for channel 0-3.
This raw format can be converted to csv with an included utility:
cat samples.raw | ./raw-to-csv > samples.csv head samples.csv
This will output the raw samples, eg:
chan0, chan1, chan2, chan3 856, 18, 15720, 15484 858, 22, 15718, 15488 856, 20, 15716, 15480 858, 18, 15714, 15484 858, 22, 15718, 15488 858, 24, 15716, 15480 860, 22, 15716, 15484 856, 22, 15718, 15490 858, 18, 15716, 15480
The tsmini2 application can be used as is for the majority of applications. This can be paired with netcat to transmit samples over the network:
# Listen for incoming TCP connection on port 1234 and send samples to the remote system nc -l 1234 -e ./tsmini2 # Use netcat to initiate a TCP connection to ip 192.168.1.30 port 1234 and send samples nc -e ./tsmini2 192.168.1.30 1234
If additional filtering is needed, a filter application can be created to read from stdin and modify data before going out.
./tsmini2 | some_filter_process > samples.out
The tsmini2 application can be long on some platforms while it allocates the 512MB. On the i.MX6 this requires about 4-5 seconds before it starts filling the FIFO. The filter app could also be created to look for some external event before saving samples such as trigger voltages, frequencies, or an external GPIO.
If purchasing this peripheral with any Technologic Systems SBC with a mini-PCIe slot such as the TS-7990 or TS-7800v2, the most recent versions of all the above software will be preinstalled and ready to run straight from the default Linux login console.
Sending 40MB/sec of unprocessed samples over TCP on the TS-7990 requires about 60% of one CPU core, on a modern PC desktop it is less than 5%. In this manner, a TS-7990 SBC can be turned into a 4 channel 2.5Mhz analog-to-TCP converter network appliance from one line in a shell script.
3.2 Capture Data from Windows
A Windows version of tsmini2 is provided in our git, located in the tsmini2-win/tsmini2-win/x64/Release folder. The usage is similar to, but not identical to the Linux version; run "tsmini2-win -h" for the correct usage.
By default, tsmini2-win will capture all four channels continuously, and print the output to the terminal in text mode, four 16-bit hex numbers to a line. To produce binary data instead, supply the -b switch. In this case, data is output as a sequence of 16-bit little-endian samples. Typically, when binary mode is selected, the output is redirected to a file to be processed later.
To restrict sampling to fewer channels, use the -S switch. For example, to sample only channels 1,3 and 4, use "-S 1:3:4". (The channels may be separated by a colon, a period, or a hyphen.)
To limit the number of samples, use the -n switch, with a number argument. Note that the actual number of samples produced will be this number multiplied by the number of active channels. For example, if you have used the -S switch to sample three channels, and the -n switch to specify 1000 samples, then 3000 samples will be produced.
# Sample channels 1,3 and 4, for 1000 samples each ./tsmini2-win -S 1:3:4 -n 1000
FFE4 3CF4 3CD4 FFDA 3CF8 3CC8 FFD4 3CF6 3CCC FFDA 3CF6 3CD0 FFDA 3CF4 3CCA FFEA 3CF2 3CD4 FFE6 3CEE 3CCC FFE0 3CEE 3CCE FFD6 3CE8 3CC6 FFE2 3CE2 3CD0 FFD4 3CE4 3CCE FFD0 3CDC 3CCC FFC0 3CD8 3CBC FFC6 3CD8 3CCA FFDE 3CD0 3CD0 FFCC 3CCA 3CBC . . .
4 ADC Channels
The LTC2325IUKG ADC chipset has 4 channels that are all sampled at 5MS/s. The TS-MINI includes some circuitry to support channels as differential/single ended, and AC/DC coupled.
|Channel||Differential||Single Ended||AC coupled||DC coupled|
In single ended the channels + pins sample 0-4.096V, and the - pin is connected to ground.
In differential the channels support 8Vpp.
The absolute max for either DC coupled mode is 0-5VDC.
In AC coupled the channels sample +-2.048Vpp, with an absolute max of +- 2.5Vpp.
To configure the ADC between these modes edit the startup script. At the top of the tsmini2_init script:
This example value configures all 4 channels to use a DC bias, and selects single ended. This 32-bit write sets up the ADC configuration register at offset 0x0 further described here.
5 Digital Outputs
The TS-MINI-ADC includes 14 digital outputs which can be controlled using the same "tsmini2" application under Linux. See these "CN1_##" pins here.
The output value sets offset 0x10 in the #Register Map
# enable all GPIO ./tsmini2 --initcn1 0xffffffff # disable all GPIO ./tsmini2 --initcn1 0xffffffff # Enable only io CN1_29, bit 11 ./tsmini2 --initcn1 0x800
6 FIR Filter
Included in the default configuration of the TS-MINI is the ability to pass the ADC samples through a 37-tap FIR filter. Coefficients can be loaded at runtime. The Linux side can also do this processing (and more) with the "sox" utility. "sox" is originally intended for audio processing, but includes the ability to perform several applicable generic DSP related functions such as companding, resampling, mixing, noise removal, biquad IIR/FIR filtering, and datafile conversions. For the purpose of pipelining to sox and other programs, the output of the sample stream as sent to stdout from the "tsmini" application is: raw, 5000ksps, 16-bit, 4 channels, little-endian.
The TS-MINI FPGA load instantiates a 4 channel, 4 bank 37-tap (148 coefficients) FIR filter with runtime reloadable signed 16-bit fixed point coefficients. The output samples from the FIR are 38 bits so they also must be shifted and saturated to 16-bit samples before being sent to the DMA circular buffer. The shift amount and bank selection can be modified by changing constants at the top of the tsmini2_init startup shell script.
Coefficients can be changed via register offset 0x8 in the #Register Map. To update a coefficient, write a 24-bit value to that register where bits 23-16 correspond to an address 0-147 (bank 0’s coefficients are first in that address space), and bits 15-0 is new the coefficient value. The TS-MINI has the FIR set for unity-gain pass-through.
7 Register Map
The register map is provided for documentation purposes, but the suggested usage is with the tsmini2 application.
|0x4||31:0||32-bit Physical address for 2MB DMA buffer |
|0x8||31:2||Offset of last write in circular buffer with new data|
|0x10||31||CN1 pin 26 output data|
|30||CN1 pin 28 output data|
|11||CN1 pin 29 output data|
|10||CN1 pin 27 output data|
|9||CN1 pin 25 output data|
|8||CN1 pin 23 output data|
|7||CN1 pin 21 output data|
|6||CN1 pin 19 output data|
|5||CN1 pin 17 output data|
|4||CN1 pin 13 output data|
|3||CN1 pin 11 output data|
|2||CN1 pin 9 output data|
|1||CN1 pin 7 output data|
|0||CN1 pin 5 output data|
- Defaults to 15. Appropriate for FIR bank 3
- Defaults to FIR Bank 3, unity gain passthrough
- If 1, Enable DC Coupling
- If 1, select single ended (not differential)
- When an address is written here, samples are enabled and the TS-MINI-ADC will stream samples into this 2MB circular buffer
8 External Interfaces
8.1 CN1 Connector
The CN1 connector is a Molex 5011903017. This is a 30 pin 1mm pitch latching connector. The mating connector is the Molex 501189-3010, and Molex 501193 for the crimp terminals.
The AN# pins are the analog pins. For single ended connections the software will control fets that will ground the "-" pins and the "+" pins should be connected to the signal being sampled.
All of the CN1_## pins are output pins controlled by offset 0x10 in BAR0. These pins all output 0-3.3VDC. The analog pins support a range of 0-2.5VDC.
- Pin 1 is indicated by a white dot on the PCB