Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

send trigger via virtual serial port using an adapter/trigger box for parallel port

Dear folks,

i must admit that i am a complete noob in sending triggers. πŸ˜—

I have put an adapter to my parallel port. This makes it possible to connect it with any computer via USB. This adapter makes the system believe it is connected via serial port 'COM6' ;)

I used an old script from 2014 which was written by Edwin and tried to adapt it with the modern python codes/OS version. Well, of course this did not work. I am not sure whether i was close or whether i missed something. I did not receive any error messages, but i did not see any triggers in the BrainVision Recorder neither. In other posts it was mentioned that triggers are only send if they changed. So i tried to send 3 triggers. I also tried to implement what i found here. This is my code:


# we will need to import the 'serial' module,
# which allows us to send and receive
# information via the serial port
import serial

#checkout which ports are available
#serial.tools.list_ports #does not work this way

# next, we will need to start a connection to
# the serial port
#var.trigger = serial.Serial('COM3')
trigger = serial.Serial()
trigger.port = 'COM6'
trigger.open()
trigger.write(0)
trigger.read()

# finally, we want to make sure that the
# connection to the serial port will be stopped
# when the experiment is aborted or finished
var.cleanup_functions.append(trigger.close)



# this sends a trigger with value 0
# if you require a different value, please
# use a number between 0 and 255
trigger.is_open
trigger.write(0)
trigger.readline()

#send stim with picture
keepQuiet=canvas()
path = pool['keepQuiet.tif']
keepQuiet.image(path)
keepQuiet.show()

#send trigger to other computer
trigger.write(1)
trigger.readline()

#get response
enter = keyboard(keylist = ['RETURN'])
key, time=enter.get_key()

#send response trigger
mber between 0 and 255
trigger.write(255)
trigger.readline()


Comments

  • Further i found python codes from BrainVision. However, i do not know what to do with it:

    import serial
    import time
    import threading
    
    Connected = True
    PulseWidth = 0.01
    
    def ReadThread(port):
       while Connected:
          if port.inWaiting() > 0:
             print '0x%X' %ord(port.read(1))
    
    port = serial.Serial('COM6')
    
    thread = threading.Thread(target=ReadThread, args=(port,))
    thread.start()
    
    port.write([0x00])
    time.sleep(PulseWidth)
    
    port.write([0x01])
    time.sleep(PulseWidth)
    
    port.write([0x00])
    time.sleep(PulseWidth)
    
    port.write([0xFF])
    time.sleep(PulseWidth)
    
    Connected = False
    thread.join(1.0)
    
    port.close()
    

    It runs without error messages and gives my some debug output:

    [2019-08-03 15:10:00,835:process:152:INFO] Starting experiment as ExperimentProcess-2
    Expyriment 0.9.1b2-11-gc100ee8 (Python 2.7.13) 
    Scripts/safelaunch-opensesame.py
    [2019-08-03 15:10:23,549:legacy:185:INFO] sampling freq = 48000, buffer size = 1024
    [2019-08-03 15:10:24,460:experiment:450:INFO] experiment started
    [2019-08-03 15:10:24,461:experiment:454:INFO] disabling garbage collection
    0x24
    0x47
    0x50
    0x47
    0x47
    0x41
    0x2C
    0x2C
    0x2C
    0x2C
    0x2C
    0x2C
    0x30
    0x2C
    0x30
    0x30
    0x2C
    0x30
    0x2E
    0x35
    0x2C
    0x2C
    0x4D
    0x2C
    0x2C
    0x2C
    0x2C
    0x2A
    0x30
    0x30
    0xD
    0xA
    [2019-08-03 15:10:29,496:experiment:462:INFO] experiment finished
    [2019-08-03 15:10:30,052:experiment:538:INFO] enabling garbage collection
    [2019-08-03 15:10:30,229:process:158:INFO] experiment finished!
    

    Any suggestions, how i can get and see the triggers in the Recorder? It works fine for a colleague who uses presentation. So the hardware is correctly connected. ;)

  • after 2 weeks of intensive trying:

    i had to install the drivers for the parallel port adapter from neurospec. 🀣

    With the correct driver, the neurospec adapter, BrainVision Recorder, BrainVision ActiChamp and OpenSesame 3.2.8 it works! πŸ€—

  • This is my final code which did send triggers.

    test_stim=canvas()
    test_stim.text('test stim')
    test_stim.show()
    clock.sleep(1000)
    
    try:
    	import serial
    	exp.port= serial.Serial('COM8')
    	print 'serial port read', exp.port.baudrate, exp.port.bytesize, exp.port.parity
    except: 
    	print 'serial port not read'
    
    try:	
    	exp.port.write(chr(0))
    	print 'trigger has been sent'
    	clock.sleep(50)
    except:
    	print 'trigger not sent'
    exp.port.write(chr(1))
    self.sleep(200)
    exp.port.write(chr(9))
    
    exp.port.close()
    
Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games