ttl signals vs. sending receiving serial data (case 15992)
ttl signals vs. sending receiving serial data (case 15992)
Hello,
I am currently trying to create an experiment in which media lab sends triggers to a third party program (Testbench- a program used for Emotiv EEG headsets) that receives data from a virtual serial port (Eltima) at different instances in the experiment. I just wanted to better understand the difference between ttl signals and using the comport.txt file to send triggers. In the past, our lab here at York University has used the comport.txt method, however looking at previous files they truncated the lines such that the file looks like this:
comPort, baudRate, parity, dataBit, stopBit
4,19200,n,8,1
input code (1-255), response value (1-12)
0,0
whereas in the manual example, there are several other numbers following the third line. Is there a simple way to explain how this works so I might edit the comport.txt file to best fit my needs? If not, can I use ttl signals instead? How does that parameter work? Your help, as always, is very much appreciated!
Thanks
Alex
Alex,
If you want to send ttl signals in MediaLab, all you need to do is use the ttl signal functionality in the parameter(s) field of the item in your .que file. You can find instructions about this here http://www.empirisoft.com/medialab/help/queparameters.htm#ttl.
Use of the comport.txt file is for MediaLab receiving ttl signals. If that is something you wish, I'll be happy to help there as well.
Alex,
If you want to send ttl signals in MediaLab, all you need to do is use the ttl signal functionality in the parameter(s) field of the item in your .que file. You can find instructions about this here http://www.empirisoft.com/medialab/help/queparameters.htm#ttl.
Use of the comport.txt file is for MediaLab receiving ttl signals. If that is something you wish, I'll be happy to help there as well.
Hello Jason,
Thanks again for your timely reply! I have discovered the issue. We have been sending ttl signals unknowingly. The parameter used is <value> and it properly sends a trigger to our program at the onset of the stimulus. However, oddly, despite not having placed any location or duration it seems to work just fine. Once I do enter a value and a duration for instance <1:9600:5>, Media Lab no longer sends the signal. My question is, how would I determine what serial port location I will be sending the ttl signal to? Somehow just <1> works, but when I try to enter a value for the location, which I believe is either 9600, or 19200 based on this image of our virtual serial port emulator, the ttl signal no longer sends.1741
Again, your responses have been incredibly helpful and I can't stress enough how much I appreciate them!
Alex
Alex,
Could you please clarify a few points for me?
1) Is everything actually functional with your experiment or is there an issue of something broken?
2) Could you please elaborate on what you mean by saying that the program properly sends a trigger at the onset of the stimulus? Does that mean the COM port? Does only the value of <1> work when used in the parameters field of a MediaLab item or do other numbers by themselves work or not? Or does 1 not work when adding port address or time?
Also, the numbers you mentioned are not port addresses, but most likely baud rates. I'm not that familiar with virtual ports, but you should be able to find the addresses like normal ports. Here's how to find it with ports actually installed on your computer:
1) Click the Start button.
2) Click on Control Panel.
3) In that Control Panel window, click on Device Manager.
4) Click on Ports to expand it and double-click on the specific port for which you want to know the address.
5) Click the Resources tab in the new window. Look for the entry that reads I/O Range. To the right of it in the Settings column you will see a potential range of port address in hexidecimal value (e.g., 60E0 to 60E7). If you put them individually in a hex to decimal converter like this one http://www.binaryhexconverter.com/he...imal-converter you should get the decimal values. You can then try each of these decimal values in your DirectRT .csv input file to see if it sends the ttl signal value defined in your stim column to your external devices.
See if there is something similar for your virtual ports and let me know if you have any questions.
Hello Jason,
So I have extensively looked into this, and it seems that the virtual serial port does not have an address. In the control panel and under ports, it doesn't have a resources tab- I am assuming it lacks a location because it is a virtual port!
However it is odd that it send the TTL files anyways. The equipment all works perfectly fine, and adding a comport.txt file allows me to use the <> parameters to input a TTL signal, but only if I put a single character into it; for example <c> sends the trigger 99. I believe its an ASCII conversion. If you could give me some more information as to why the TTLs would work, that would be very helpful! As I said though, the format of <100:888:5> will not work, presumably because the port address location is incorrect. I asked the developers of the virtual serial port software and they said there is no way to determine the HEX port address of the ports.
Just some more information about our setup, we have a program that creates virtual serial port connection, it allows two programs to communicate without a physical serial port. One of our pieces of equipment is a wireless EEG headset, it received markers from Medialab via this virtual serial port program. It creates a pair of ports called COM4 and COM5, where COM4 sends signals and COM5 receives. I believe with the comport.txt file, I have to edit the first number to 4 in order for the TTLs to send. Let me know if this all makes sense!
Alex
Alex,
Could you please clarify a few points for me?
1) Is everything actually functional with your experiment or is there an issue of something broken?
2) Could you please elaborate on what you mean by saying that the program properly sends a trigger at the onset of the stimulus? Does that mean the COM port? Does only the value of <1> work when used in the parameters field of a MediaLab item or do other numbers by themselves work or not? Or does 1 not work when adding port address or time?
Also, the numbers you mentioned are not port addresses, but most likely baud rates. I'm not that familiar with virtual ports, but you should be able to find the addresses like normal ports. Here's how to find it with ports actually installed on your computer:
1) Click the Start button.
2) Click on Control Panel.
3) In that Control Panel window, click on Device Manager.
4) Click on Ports to expand it and double-click on the specific port for which you want to know the address.
5) Click the Resources tab in the new window. Look for the entry that reads I/O Range. To the right of it in the Settings column you will see a potential range of port address in hexidecimal value (e.g., 60E0 to 60E7). If you put them individually in a hex to decimal converter like this one http://www.binaryhexconverter.com/he...imal-converter you should get the decimal values. You can then try each of these decimal values in your DirectRT .csv input file to see if it sends the ttl signal value defined in your stim column to your external devices.
See if there is something similar for your virtual ports and let me know if you have any questions.
So if I understand, you seem to be able to send and receive signals using MediaLab and your equipment, even though your computers have no actual ports and communicate using only virtual reports? Is that correct?
Furthermore, you are still trying to figure out how to use the comport.txt and/or the <value:location:duration> in the parameters field to control the receiving and sending of ttl signals. Is this the primary unresolved issue you still have?
Please tell me the full version number (i.e., 20xx.x.xxx) of your copy of MediaLab. You can find it by opening MediaLab and selecting Help>About MediaLab from the main menu bar.
Hi Jason,
Yes that is correct. The signals are being sent from Medialab to our EEG recording program through our virtual port program and I am not sure how or why it is working. The <> parameter sends the signals, but not the values that I input- for example I placed the parameter <7> into one of my que files, and it is received in my program as 55.
I just wanted to know how the comport.txt file works, I have read through this guide:
http://www.empirisoft.com/medialab/help/miscellaneous_features.htm#serialdata
But it seems to only be a basic overview of the file and discusses more of receiving data then sending it. Also just to note, changing the comPort parameter in the line:
comPort, baudRate, parity, dataBit, stopBit
1,19200,n,8,1
Seems to be important. That is, the virtual port program creates a virtual connection for, say, COM2 and COM4. I would setup my EEG recording program to COM4 so that it receives all data coming from COM2. Then I would go into the comport.txt file and change the first value in line 2 to the number 2, so that Medialab sends signals to COM2. Any other value would not work properly.
Finally, the version number is 2012.4.119
Hope that is enough information! Let me know if you need anything else.
Alex
So if I understand, you seem to be able to send and receive signals using MediaLab and your equipment, even though your computers have no actual ports and communicate using only virtual reports? Is that correct?
Furthermore, you are still trying to figure out how to use the comport.txt and/or the <value:location:duration> in the parameters field to control the receiving and sending of ttl signals. Is this the primary unresolved issue you still have?
Please tell me the full version number (i.e., 20xx.x.xxx) of your copy of MediaLab. You can find it by opening MediaLab and selecting Help>About MediaLab from the main menu bar.
I forgot to add... The main reason why I am asking this is because I would like to run a DirectRT script within Medialab that will also send TTLs. I was hoping that the <value:location:duration> method would somehow work, so that I can simply use the location for the DirectRT script. However it seems that there isn't a location associated with the comport (maybe because it is virtual?) and so I want to figure out how/why the comport.txt method is working, and if I can somehow use that knowledge to send TTLs via DirectRT as well!
Alex
Hi Jason,
Yes that is correct. The signals are being sent from Medialab to our EEG recording program through our virtual port program and I am not sure how or why it is working. The <> parameter sends the signals, but not the values that I input- for example I placed the parameter <7> into one of my que files, and it is received in my program as 55.
I just wanted to know how the comport.txt file works, I have read through this guide:
http://www.empirisoft.com/medialab/help/miscellaneous_features.htm#serialdata
But it seems to only be a basic overview of the file and discusses more of receiving data then sending it. Also just to note, changing the comPort parameter in the line:
comPort, baudRate, parity, dataBit, stopBit
1,19200,n,8,1
Seems to be important. That is, the virtual port program creates a virtual connection for, say, COM2 and COM4. I would setup my EEG recording program to COM4 so that it receives all data coming from COM2. Then I would go into the comport.txt file and change the first value in line 2 to the number 2, so that Medialab sends signals to COM2. Any other value would not work properly.
Finally, the version number is 2012.4.119
Hope that is enough information! Let me know if you need anything else.
Alex
If you want to send a ttl signal with a virtual port, you might be able to by using DirectRT 2014. It has the feature of using a comport.txt function like that of MediaLab that might be compatible with virtual ports.
If you can use DirectRT 2014, I would be happy to give you more information about the details of the process.
Hi Jason,
Thanks for your reply! If that is possible that would be great. I am guessing we would have to purchase a license for the 2014 version?
If you want to send a ttl signal with a virtual port, you might be able to by using DirectRT 2014. It has the feature of using a comport.txt function like that of MediaLab that might be compatible with virtual ports.
If you can use DirectRT 2014, I would be happy to give you more information about the details of the process.
You could download and install a trial copy of DirectRT 2014 first to see if this works. Just download a copy from the Empirisoft download page here: http://empirisoft.com/Download.aspx?index=4. Send the 14-character D-code to me at support@empirisoft.com and I can get you a free 21-day trial code.
Using DirectRT 2014, you can set up a DirectRT .csv input file to send ttl signals as normal (see http://www.empirisoft.com/directrt/help/directrt_samples_of13_ttl_signals.htm). It doesn't matter what you type for the port address in the loc cell or the number in the time cell after the stim cell with ttl: in it.
This is because you will include a .txt file named comport.txt in the same folder as the .csv input file you create. DirectRT 2014 will ignore the values in the loc and time cells as long as the comport.txt file is in the same file folder as the .csv input file that wants to send ttl signals.
When you create your comport.txt file, you will need to define the the proper number to reflect the comport you want the computer to use to send the ttl signal. This is based off of the same functionality in MediaLab used for sending and receiving data over serial ports (for an explanation and example of the comport.txt file see http://www.empirisoft.com/medialab/help/miscellaneous_features.htm).
Hi Jason,
Thanks so much for this! So far, the TTLs are being sent using the comport file through DirectRT so this is fantastic news. One issue I am having, is that DRT also seems to continuously send the TTL 240 along with the TTL I put into the stim column of my .csv- any reason why you think that might be happening? That is, every time it sends the ttl in the stim, it also sends a ttl of 240.
Also I was hoping to use the ttlecho functionality as well, but again we have this issue with me being unable to put in an actual "loc" line. So if I am correct, I believe that if I create a ttlecho.txt file with "loc","time" it will send a TTL to that location for that time when a correct key response is pressed during a trial? Is there someway to create response-locked ttls in the .csv file instead? Or someway to manipulate the echottl.txt file to send to a COM1 address instead of actual DEC locations? Let me know! Again your help is valued and much appreciated!!
Alex
You could download and install a trial copy of DirectRT 2014 first to see if this works. Just download a copy from the Empirisoft download page here: http://empirisoft.com/Download.aspx?index=4. Send the 14-character D-code to me at support@empirisoft.com and I can get you a free 21-day trial code.
Using DirectRT 2014, you can set up a DirectRT .csv input file to send ttl signals as normal (see http://www.empirisoft.com/directrt/help/directrt_samples_of13_ttl_signals.htm). It doesn't matter what you type for the port address in the loc cell or the number in the time cell after the stim cell with ttl: in it.
This is because you will include a .txt file named comport.txt in the same folder as the .csv input file you create. DirectRT 2014 will ignore the values in the loc and time cells as long as the comport.txt file is in the same file folder as the .csv input file that wants to send ttl signals.
When you create your comport.txt file, you will need to define the the proper number to reflect the comport you want the computer to use to send the ttl signal. This is based off of the same functionality in MediaLab used for sending and receiving data over serial ports (for an explanation and example of the comport.txt file see http://www.empirisoft.com/medialab/help/miscellaneous_features.htm).
Disregard that last post! The ttlecho.txt file works fine, I was pressing the numpad keys and it wasn't registering the stroke! Sorry, thanks again for your time!
Alex
Alex,
Will do. Let us know if you have any other questions.