I am trying to use stimtracker to send a sequence of pulses on two lines. They need to be sent with a precise offset. 1ms precision. The pulse on the second line has to be exactly x ms after the pulse on the first line. And this needs to be repeated y number of times. I attached an example pulse that would need to be repeated.
I tried to use for loop in python and time.sleep function:
for i in range(200):
start = datetime.now()
# send pulse to comp2 first
# wait the delay
stop1 = datetime.now()
itime1 = (stop1-start).total_seconds() * 1000 # time in millisec
print("first waited "+str(itime1)+“ms”)
# send pulse to comp1
stop2 = datetime.now()
itime2 = (stop2-stop1).total_seconds() * 1000 # time in millisec
print("then waited "+str(itime2)+“ms”)
Unfortunately, sleep times are reliant on the system time, and there are +/- 20ms differences.
Would it be possible to create a certain series of pulses and load that to the stimtracker, so that the offset and timing would rely on stimtracker’s timer instead of OS time on the PC?
Maybe I could use some lower level commands with _send_command(self, command, expected_bytes) function from pyxid2?
Thank you in advance