Hi,
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:
dev.set_pulse_duration(pulse_duration_ms)
for i in range(200):
start = datetime.now()
# send pulse to comp2 first
dev.activate_line(lines=computer2_line_no)
# wait the delay
time.sleep(delay_s)
stop1 = datetime.now()
itime1 = (stop1-start).total_seconds() * 1000 # time in millisec
print("first waited "+str(itime1)+“ms”)
# send pulse to comp1
dev.activate_line(lines=computer1_line_no)
print(“Trigger to:”,computer1_line_no)
# wait
time.sleep(5-delay_s)
print(5-delay_s)
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