In an ideal world, we would always have the foresight to select a data acquisition device with enough channels to meet our future needs. Since we know this isn’t easy and system requirements tend to change over time, I have outlined below how to synchronize two similar modules together.
Many MCC analog input DAQ modules have a timing signal that you can wire between two like devices to expand the number of channels collected synchronously. Look for a pin named SYNC (bidirectional) or a pair of channels labeled AICKI and AICKO (unidirectional). The wiring is easy – just connect the two SYNC pins or wire the AICKO (output) from one unit to the AICKI (input) of the other unit.
In your program (UL or ULx) you would run 2 AI scans, each with slightly different settings. First, start a background scan on the slave, the unit with AICKI input wired, specifying it to use External Clock. Since no clock pulses have been generated by the master yet, no data flows. Second, start a scan on the master, specifying it to use Internal Clock. Note that the data comes back separately for the boards as two data streams, but will have been collected in synch. The code snippet below shows an example of this implementation.
/* Example of two Analog Input DAQ devices collecting data concurrently. We have chosen Board 0 to be the master and Board 1 is the slave. We must run a wire between the SYNC pins of both boards, so that the master's clock reaches the slave. */ BoardNum = 1; // start a background scan on the slave board first, specifying external clock (EXTCLOCK) Options = BACKGROUND + EXTCLOCK; // a wire must run between the SYNC pins of the two boards ULStat = cbAInScan (BoardNum, LowChan, HighChan, Count, &Rate, Range, MemHandle1, Options); BoardNum = 0; // now start a foreground scan on the master board using its internal clock (TIMED) Options = TIMED; ULStat = cbAInScan (BoardNum, LowChan, HighChan, Count, &Rate, Range, MemHandle0, Options); /* Since the scan on board 0 is a foreground scan, the program flow will pause until all data from board 0 is collected. Since the scans will run the same number of channels, the same sample count, and via a common clock, we can assume that the scan on board 1 is complete also. */ BoardNum = 1; ULStat = cbStopBackground (BoardNum,AIFUNCTION); // note we must still stop the background scan even though it has already finished. // Now we can access the data that was collected from both boards, each in their respective windows memory buffer
Any restrictions?
For non-simultaneous models, you will need to sample the same number of channels on both units to ensure the number of clock pulses sent on the wire match. Additionally, you should try to keep the wire connecting the timing signals relatively short and shielded to prevent noise. Finally, this synchronization is not supported in menu driven software platforms, such as DAQami and DASYLab.
Questions? Leave a comment below!
Nice article!
is there actually a way to do this with Labview? I cannot find any examples in the ULx guide.
Yes. We do have an example using USB-2533 or USB-2537. The device can be changed with any MCC device supporting external clock such as USB-1608G series, USB-1808 series, USB-1208FS-Plus, USB-1408FS-Plus, etc.
https://kb.mccdaq.com/KnowledgebaseArticle50398.aspx