Using an auxiliary USB DAQ to sample TTL events

We have added an option to sample an additional 8 TTL inputs from Scanbox using an external NI DAQ device.  In our case, we have used and tested the NI USB-6221, but any other devices which support sampled, digital IO should work as well.

The configuration file now contains four lines that specifies the parameters for this feature.

sbconfig.xevents = true;             % external events from NI box
sbconfig.xeventsDev = 'Dev2';        % Device ID
sbconfig.xeventsClock = 'Dev2/PFI9'; % clock input
sbconfig.xeventsRate = 16;           % expected data rate

The first line tells Scanbox if you want to be sampling external signals or not (true/false).  The second defines which NI device is to be used for sampling the signals.  The third line defines which input receives the scan clock input — in this case the PFI9 line in the USB-6221. This line should be connected to the CAM0 output of Scanbox. And the last line is the expected frequency of the clock.

The use of Scanbox remains the same.  However, when you load data using sbxread you will now see the following entries in the info structure.


>> info.xevents

ans =

struct with fields:

code: [300×1 uint8]
binary: [300×8 char]

The code field contains, for each frame, the status of each of the bits in Port1:0-7 of the USB-6221.  The binary field contains the same data, but unpacked so that info.xevents(frame#,bit#) contains the value of bit# during frame#.

If you plan to connect electronics of your own design to Scanbox, instead of commercially available DAQ systems, we ask you use this method to collect external TTL inputs instead of connecting directly to TTL0/1 lines.