Trigger with Usb-to-serial port cable (rs232) with FTDI chipset
Paul Groot
pfc.groot at gmail.com
Wed Apr 9 22:20:41 UTC 2014
Hi Julia,
1) Yes. If you are using en eprime script to handle the serial messages,
both computers should be up and running. On the receiving side you probably
need to put the ReadString function in a loop (often refered as polling).
But see below for an alternative.
2) You are trying to send basic commands over the serial connection. In
theory this would be possible if the receiving side could translate these
strings into executable code (called evaluation). I'm not sure, but if I
remember correctly, E-Basic does not have an 'Eval' function to do this.
Also, even if the eval function would be available, I would strongly advice
against using it this way. Since you only require a simple trigger signal,
it is sufficient to send a single byte. Sending one byte instead of a
complete string simplifies the receiving script significantly. You could
use the ReadString method as described at 1). However, E-Prime also allows
a serial port to be used as input device. The Serial input device will
handle bit-changes as responses or events, just like the keyboard device.
Because it's implemented as input device, there is no need to create a
complex script that interprets the received byte stream. So, the receiving
script should only include an object that waits for any event on the serial
input device, and then continues with the next object to play the sound.
The sending side could be really simple, with only two or three lines of
inline script. However, you might have to use WriteBytes to send a single
byte, instead of WriteString.
3) USB-RS232 conversion should not be an issue. (Although timing accuracy
might be worse.) However, make sure to use a null-modem cable to connect
two PC's. http://en.wikipedia.org/wiki/Null_modem
Note: if both PCs have a parallel printer port, it might be easier to use
those instead of serial/usb ports. Timing would also be more accurate in
that case.
Best,
Paul
On 9 April 2014 22:29, Julia Shin <jshin at psych.udel.edu> wrote:
> Hi all,
>
> So I was fishing through all trigger-related questions in this group, but
> I have yet to find a solution that would help me with my problem :( I am
> also a newbie in running trigger so I apologize in advance if my questions
> look really easy...
>
> So I am trying to run an experiment with a desktop computer that would
> send a trigger signal to another computer telling the other computer to
> play *a sound file* when the signal is sent. Basically the gist of the
> experiment is that we want the other computer to play a sound file which is
> a mp3 file of a metronome (120 bpm) while the main computer sends
> stimulation to the participant and collecting their responses. We can
> easily do this by playing the metronome sound file in mp3 player but we
> want to control when the stimulation would happen in accordance with the
> metronome sound so I think that is why we want to go with the trigger
> option.
>
>
> - My first questions is: for the receiving end of the computer do I
> have to have the E-Prime experiment up and running to receive the signal
> from the main computer?
>
>
>
> - Second question: I used Serial.WriteString SoundOut1.Play (or run)
> and Serial.ReadString SoundOut1.Play (or run) but E-Prime kept saying
> Play/Run was not a property of the object. What syntax do I have to use to
> signal the other computer to play the sound file? And what syntax do I have
> to use for receiving signal from the main computer to run the sound file
> when prompted? Is this why my E-prime keeps crashing whenever I tried to
> run the e-prime experiment for signal receiving computer? I added
> Serial to Device option in Experiment tab in E-Prime with correct com port
> and baud rate. Though, is it common to have different com port number for
> the main computer and the receiving computer?
>
>
> So here is the syntax for Serial.WriteString that is placed in InLine that
> is placed in the beginning of the experiment:
>
>
> Dim strData As String
> strData = "SoundOut1.Play"
> Serial.WriteString strData
>
> Then here is the syntax for Serial.ReadString. I just copied this straight
> from the BasicSerial.es sample in PSTNET:
>
> ' Just hold the experiment here until some bytes
> ' arrive over the serial port.
> Dim str As String
> Dim n As Long
>
> Debug.TimeStampsEnabled = True
> Do While Serial.InputCount = 0
> Loop
>
> ' Read the data that came in
> n = Serial.ReadString(str)
>
>
>
>
> - Third question: Does the trigger syntax for usb-to-serial port cable
> differ from trigger syntax for serial port? I thought they would be the
> same but I just want to confirm that there is no problem with the cable
> here. When I plugged in the cable, both receiving and main computers
> installed the drivers and I didn't see any warning signs saying that the
> cables were not working properly.
>
>
> Sorry that I am asking hundred questions at the same time. But I would
> greatly appreciate your help...I went through the FAQ page relating to
> trigger on PSTNET but they mostly seem to have helpful answers for parallel
> ports.
>
> Thank you!
> Best,
> Julia Shin
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "E-Prime" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to e-prime+unsubscribe at googlegroups.com.
> To post to this group, send email to e-prime at googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/e-prime/8542792e-4210-4527-a09a-4fdc590d4567%40googlegroups.com<https://groups.google.com/d/msgid/e-prime/8542792e-4210-4527-a09a-4fdc590d4567%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe at googlegroups.com.
To post to this group, send email to e-prime at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/CAKAdR-tRU7DxWqfW6MFaeO2oMDwZdvwcbmspbFd3Kr11SXcDHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20140410/ffedb79f/attachment.htm>
More information about the Eprime
mailing list