Hi fellow Psychopyers,
I came across some trigger sending problems with USB2TTLB adapter.
OS (e.g. Win10): macOS Big Sur 11.6.1
PsychoPy version (e.g. 1.84.x): v2022.1.1
What are you trying to achieve?:
I would like to send triggers with different values to mark the presence of different visual stimuli via a USB2TTL8 adapter.
What did you try to make it work?:
I had a “code” component inserted. In the “each frame” I set different values for different stimuli:
if present.status == STARTED:
sconn.write(b"WRITE %d\n" % 5)
pulse_start_time = globalClock.getTime()
pulse_started = True
if target.status == STARTED:
sconn.write(b"WRITE %d\n" % 20)
pulse_start_time = globalClock.getTime()
pulse_started = True
if pulse_started and not pulse_ended:
if globalClock.getTime() - pulse_start_time >= 0.01:
sconn.write(b"WRITE %d\n" % 0)
pulse_ended = True
I also had a routine for feedback. Here, I had another “code” component to send triggers for different feedback. The following codes were put in the “Begin Routine” tab to check participants’ responses from the last routine and send triggers based on the responses:
pulse_started = False
pulse_ended = False
if not key_resp.keys:
thisFeedback = 'Missed!'
respColor = 'orange'
sconn.write(b"WRITE %d\n" % 40)
pulse_start_time = globalClock.getTime()
pulse_started = True
elif key_resp.corr:
thisFeedback = 'Correct'
respColor = 'greenyellow'
sconn.write(b"WRITE %d\n" % 25)
pulse_start_time = globalClock.getTime()
pulse_started = True
else:
thisFeedback = 'Incorrect'
respColor = 'tomato'
sconn.write(b"WRITE %d\n" % 35)
pulse_start_time = globalClock.getTime()
pulse_started = True
trials.addData('Ans', thisFeedback)
if pulse_started and not pulse_ended:
if globalClock.getTime() - pulse_start_time >= 0.01:
sconn.write(b"WRITE %d\n" % 0)
pulse_ended = True
What specifically went wrong when you tried that?:
i) Trigger pins were activated improperly with some of the hex values. For example, when I tried to send a value of 100 with the codes above, the trigger pins were turned on but could not be turned off leading to continuous trigger peaks, even though the trigger duration was set as 0.01s.
ii) Trigger pins could not be turned on with some of the hex values. For example, no triggers were sent to the port with some specific values, so no trigger peaks presented; or only the very first trigger with some specific values was properly sent to the port but the following triggers with that values could not be sent to the port.
iii) The values that I set for the triggers were not the values that I read in DataEditor. For example, I set a value of 20 for the triggers but the value that I read for these triggers in DataEditor was 100000. Another trigger with a value setting of 5 was read as 40000 or 50000 varied across trials.
I tried a range of values and found 5, 20, 25, 35, 40 could work properly for my experiment. But when I used some of these values for another experiment, some of them did work.
Sorry for the long massage. Please let me know if anything is unclear or if any further information is needed. Thanks in advance!
3.MEG_feedback.psyexp (66.2 KB)