Home Examples Synchronization of Dexterit-E Data with External Clock
Peripherals

Synchronization of Dexterit-E Data with External Clock

This example demonstrates how to provide a synchronization pulse that can be used to synchronize data collected by two independent data collection systems. Consider, for example, a system in which kinematic data were to be saved by Dexterit-E while simultaneously an external, independent data collection system were to save EEG data.

In order to analyze relationships between the kinematic and EEG data, there would have to be a way to synchronize the data to be sure the events in one data set were related to events in the other.

The problem of synchronization is not necessarily an obvious one. It originates because no two clocks run at exactly the same rate. Two systems that both run nominally at 1 kHz, will always exhibit some amount of drift over time – i.e. one clock will always be slower or faster than the other. In some situations, the amount of drift will be negligible, and so synchronization between two data sets becomes trivial – if both data collection systems start on the same trigger, then the data will be synchronized. However, in most real-life situations, the amount of drift is large enough to be noticeable, and so it must be accounted for.

Many data collection systems avoid the problem of synchronizing multiple data sets by using a single master clock that drives all data collection systems (i.e. synchronization is forced by using only a single clock). This approach requires (a) that all but one of the data collections systems be capable of being driven by a master clock and (b) that the master clock pulse timing is precise and reliable. Many hardware systems do not meet these criteria, and so the problem of synchronizing two independent data sets remains. The example here shows one potential method of addressing this problem.

The solution demonstrated 10.20.1 Simulink Code for Synchronization with an External Clock Example uses the Sync Pulse Generator block to create a set of signals that an external system can make use of. The details of the signals can be found in 11.3 Kinarm I/O..

10.20.1   Simulink Code for Synchronization with an External Clock Example

In this example, which is based upon the ideas presented in 10.19 Digital Input/Output, the Sync Pulse Generator block is used.

The Sync Pulse Generator block makes use of the NI-PCI-6229 block to output a set of digital pulses. See 11.3 Kinarm I/O for a complete description of the generated signals. Within the Simulink model, the Sync Pulse Generator block’s output needs to be saved as an analog_input via the Datalogging block, so that it can be used later to synchronize data.

If your Kinarm Lab does not contain an NI-PCI-6229 card then it is possible to unlink the Sync Pulse Generator from the library and replace the 6229 digital output block with a block that matches the hardware in your Kinarm Lab.

Figure 10.31: Sync Pulse Generator Simulink example

Related Tasks

Coding Tips
Persistent Variables
Persistent variables are ones that hold their value between calls to the embedded MATLAB code they are defined in.
Coding Tips
Custom Control of the Trial Protocol Order
Normally, Dexterit-E manages and controls the order in which Trial Protocols (TPs) execute based on what is defined in the block table of the Task Protocol (see the Dexterit-E User Guide for more details).