Skip to content

"Sampling rate" of network TTL events #8

@joschaschmiedt

Description

@joschaschmiedt

I'm wondering what the minimum distance between network TTL events is such that they get associated different timestamps. I.e., what's the "sampling rate" of the network TTL events, what factors determine it, and if it can be improved.

Sending TTL commands with a delay of 1 ms in between resulted in many events associated with the same sample number and timestamp, roughly on the order dt=21 ms (see Python script below and attached data). No events were missing. This was tested with version 0.2.1 and Open Ephys 0.6.7 using a NI-DAQmx source node.

Python script
import zmq
import time


def run_client():

    # Connect network handler
    ip = "127.0.0.1"
    port = 52005
    timeout = 1.0

    url = f"tcp://{ip}:{port}"

    with zmq.Context() as context:
        with context.socket(zmq.REQ) as socket:
            socket.RCVTIMEO = int(timeout * 1000)  # timeout in milliseconds
            socket.connect(url)

            # Start data acquisition
            socket.send_string("StartAcquisition")
            print(socket.recv_string())
            time.sleep(1)

            socket.send_string("StartRecord")
            print(socket.recv_string())

            for line in range(1, 64):
                socket.send_string(f"TTL Line={line} State=1")
                print(socket.recv_string())
                socket.send_string(f"TTL Line={line} State=0")
                print(socket.recv_string())
                time.sleep(0.001)

            for word in range(0, 2**16, 16):
                socket.send_string(f"TTL Word={word}")
                print(socket.recv_string())
                time.sleep(0.001)

            time.sleep(1)
            socket.send_string("StopRecord")
            print(socket.recv_string())

            socket.send_string("StopAcquisition")
            print(socket.recv_string())


if __name__ == "__main__":
    run_client()

TTL.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions