Skip to main content
Skip table of contents

Precision timekeeping with GetTime and markers

In the previous section, we talked about how System A, (the local register on your PC) and System B, (the DATAPixx I/O hub device register) communicate by one-way and two-way register writes and updates.

The device register has a central clock, which it uses for all recordings and timestamps. This makes it very easy to align multiple streams of inputs and outputs. The time of this clock can be accessed on the local register following a register update.

Say we want to know the exact moment of the last register update. We can simply call ‘GetTime’, which returns the time, in seconds, between device power-up and the time on the local register.

For example, the following code will return a timestamp of when your audio schedule began.

audioStartTime = Datapixx('GetTime');

As we have just seen, we don’t always want to perform a register update because it can block subsequent code while waiting for data from the device.

In this case, we can create a timestamp or “marker” to be used with a register write. This marker is stored in the device register and can be later accessed with a register update and a call to GetMarker.

Say we want to know exactly when a digital trigger was sent out:

%Set a digital output state (on local register)
doutValue = bin2dec('0101 0101 0101 0101 0101 0101');
Datapixx('SetDoutValues', doutValue); 

%Let’s create our marker here

%push digital output to device register and save a marker


%Now let’s retrieve our timestamp by updating then calling GetMarker
targetOnset = Datapixx('GetMarker');

If we were to use ‘GetTime’ here, the returned timestamp would reflect the time of the register update following the keypress. Since ‘SetMarker’ was called before the previous write, ‘GetMarker’ will instead return the timestamp of that register write, which corresponds to our trigger onset.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.