Task Event - WriteString?

289 views
Skip to first unread message

John

unread,
Aug 12, 2013, 11:28:34 AM8/12/13
to e-p...@googlegroups.com
I'm running eprime pro and trying to use task events to trigger an external device.

When the stimulus comes on the screen, I need eprime to send the string "RUN" to the serial port.

In task events, I do the following:
-Add an event
-Select the serial device (COM3)
-Action:  WriteString

...but then how to I define what the string is?  (i.e. "RUN")


(In a terminal window, i can type "echo RUN > COM3" and that triggers the device...I'm just trying to figure out how eprime to do that.)

Thanks! 

David McFarlane

unread,
Aug 12, 2013, 2:26:45 PM8/12/13
to e-p...@googlegroups.com
Try the following in the Task Events dialog box:

- Set Source to "(custom)"
- In Custom, put your string (e.g., "RUN", without the quotes). (You
may also use attribute references here, e.g., "[StimCode]", these
will be resolved just before the stimulus object runs.)
- Set Data Type to "String".
- Set Enabled to "Yes".

Please write back with your results, as I am not set up to test that
myself here.

And if you have not already, look a the seciton 3.1 of the New
Features Guide, and KB4803
(http://www.pstnet.com/support/kb.asp?TopicID=4803 ) for the
documentation from PST.

-----
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (https://twitter.com/EPrimeMaster)

/----
Stock reminder: 1) I do not work for PST. 2) PST's trained staff
take any and all questions at
http://support.pstnet.com/e%2Dprime/support/login.asp , and they
strive to respond to all requests in 24-48 hours, so make full use of
it. 3) In addition, PST offers several instructional videos on their
YouTube channel (http://www.youtube.com/user/PSTNET ). 4) If you do
get an answer from PST staff, please extend the courtesy of posting
their reply back here for the sake of others.
\----

John

unread,
Aug 12, 2013, 5:03:44 PM8/12/13
to e-p...@googlegroups.com
Thanks for your reply, David - No luck.

Action: WriteString 
Parameter - Custom: RUN 
Data Type: String
Enabled:  Yes

David McFarlane

unread,
Aug 12, 2013, 5:13:18 PM8/12/13
to e-p...@googlegroups.com
Thanks for reporting back. Time now to contact PST Web Support and
have them sort it out for you, then please report back here for the
rest of us. Thanks!

-- David McFarlane


At 8/12/2013 05:03 PM Monday, John wrote:
>Thanks for your reply, David - No luck.
>
>Action: WriteString
>Parameter - Custom: RUN
>Data Type: String
>Enabled: Yes
>
>On Monday, August 12, 2013 2:26:45 PM UTC-4, McFarlane, David wrote:
>Try the following in the Task Events dialog box:
>
>- Set Source to "(custom)"
>- In Custom, put your string (e.g., "RUN", without the quotes). (You
>may also use attribute references here, e.g., "[StimCode]", these
>will be resolved just before the stimulus object runs.)
>- Set Data Type to "String".
>- Set Enabled to "Yes".
>
>Please write back with your results, as I am not set up to test that
>myself here.
>
>And if you have not already, look a the seciton 3.1 of the New
>Features Guide, and KB4803
>(<http://www.pstnet.com/support/kb.asp?TopicID=4803>http://www.pstnet.com/support/kb.asp?TopicID=4803
>) for the
>documentation from PST.
>
>-----
>David McFarlane
>E-Prime training
>online:
><http://psychology.msu.edu/Workshops_Courses/eprime.aspx>http://psychology.msu.edu/Workshops_Courses/eprime.aspx
>
>Twitter: @EPrimeMaster
>(<https://twitter.com/EPrimeMaster>https://twitter.com/EPrimeMaster)
>
>/----
>Stock reminder: 1) I do not work for PST. 2) PST's trained staff
>take any and all questions at
><http://support.pstnet.com/e%2Dprime/support/login.asp>http://support.pstnet.com/e%2Dprime/support/login.asp
>, and they
>strive to respond to all requests in 24-48 hours, so make full use of
>it. 3) In addition, PST offers several instructional videos on their
>YouTube channel
>(<http://www.youtube.com/user/PSTNET>http://www.youtube.com/user/PSTNET

John

unread,
Aug 15, 2013, 1:14:55 PM8/15/13
to e-p...@googlegroups.com
Update:  We were able to get it running using inline script -- it needed a carriage return.

Prior to each event, put in an inline script with:
Serial.WriteString "RUN" & ebCrLf

If using multiple pumps in a network, precede run with the address of the pump:  "00 RUN" for the first pump, "01 RUN" for the second, etc.

David McFarlane

unread,
Aug 15, 2013, 2:19:11 PM8/15/13
to e-p...@googlegroups.com
Great, and thanks for posting back! So the issue was not exactly
with E-Prime Task Events, but with including control characters in
the output string.

Hmm, then you should still be able to get it to work with Task Events
by defining your string plus carriage return/newline into an
attribute, and then using the attribute reference in Task
Events. E.g., with inline code (could do this once at the Sesson level),

c.SetAttrib RunString, "RUN" & ebCrLf

and then for "Custom" in Task Events use

[RunString]

Even better, just try either of the following strings for Custom in
Task Events:
RUN\n
RUN\r\n

The generated code shows that it properly includes the escaped
control characters (\n, or \r\n), so this should work, but I need
someone else to run this and confirm.

So the lesson here seems to be that we have to know how to embed
standard escaped control characters in our Custom strings for Task Events.

-----
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (https://twitter.com/EPrimeMaster)

John

unread,
Aug 16, 2013, 11:55:29 AM8/16/13
to e-p...@googlegroups.com
Correct - I was able to take out the inline and use task events by putting RUN/r/n into the custom string.

00 RUN/r/n  triggers the first pump
01 RUN/r/n  triggers the second pump

Success!

John

unread,
Aug 16, 2013, 11:56:34 AM8/16/13
to e-p...@googlegroups.com
(sorry, those should be backslashes  00 RUN\r\n)
Reply all
Reply to author
Forward
0 new messages