Although, in theory, it would be possible to use the WritePort command
to send bytes to a classical serial (non-USB) RS232 port, it is
definitely not the way to go. Instead you should use a SerialDevice
object to communicate with a COM port. The easiest way is to add such
a Serial device in the following dialog:
E-Studio>Menu>Edit>Experiment>Devices>Add Serial. The default setting
should be OK (9600bps, 8bit, no parity, 1 stopbit). When you add this
device, EPrime will add a global SerialDevice object variable to your
script. The name of this variable will be 'Serial' if there is only
one serial device.
The next thing you should do is to add a single line of inline script
to send the command:
SerialDevice.WriteString "sk0" & ebCr
The ebCr constant is a cariage return that is probably required by the device.
I'm not sure if the external device also needs to be initialised first
(by sending "CPA00000000" for example), but that's up to you to find
out ;-)
Hope this helps,
Paul
2012/2/18 Erin <erin.s...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "E-Prime" group.
> To post to this group, send email to e-p...@googlegroups.com.
> To unsubscribe from this group, send email to e-prime+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.
>
Ah, I described a solution for a 'legacy' ADR device because you
linked to the RS232 example. But if I understand this correctly, you
are using an ADU (USB only) device...
However, if the device you have supports legacy RS232 connections, you
should try the following first because RS232 it is a bit easier to use
than the USB interface DLL: First check which (virtual) COM port is
being assigned by windows after installing the driver. If the USB
device connects as virtual RS232, you should be able to find it under
control panel>device manager->COM and LPT ports. Windows often assigns
a port number >4, which might be problemematic with EPrime (not sure
if this is less critical in EPrime 2.) Just try to change the port
number to the first available value below 4. If the PC has 1 or 2
physical COM ports, you should skip those numbers. Also note that the
port number often changes when a different USB port is used.
If RS232 is *not* an option (i.e. no new COM port is added when you
plugin the USB cable), you should use the DLL interface to connect to
the USB channels. EBasic supports calling functions in external DLL's,
so that should be no problem. To do this, you should declare all DLL
functions first. For example, you can put the following declarations
in the global user script section:
Declare Function OpenAduDevice Lib "AduHid.DLL" (ByVal iTimeout As
Long) As Long
Declare Function WriteAduDevice Lib "AduHid.DLL" (ByVal aduHandle As
Long, ByVal lpBuffer As String, ByVal lNumberOfBytesToWrite As Long,
ByRef lBytesWritten As Long, ByVal iTimeout As Long) As Long
Declare Function ReadAduDevice Lib "AduHid.DLL" (ByVal aduHandle As
Long, ByVal lpBuffer As String, ByVal lNumberOfBytesToRead As Long,
ByRef lBytesRead As Long, ByVal iTimeout As Long) As Long
Declare Function CloseAduDevice Lib "AduHid.DLL" (ByVal iHandle As Long) As Long
(more info here http://www.ontrak.net/ADUSDK/MinimalCompile-VB.html)
When the declarations are defined, you should be able to call the
functions in inline script just as if the functions are part of
EBasic:
' you would probably put this declaration also in the global section
Dim aduHandle As Long
'then in some inline script:
aduHandle = OpenAduDevice(0)
The VisualBasic example contains further details on the WriteAduDevice
function. Also don't forget to close the channel properly by calling
CloseAduDevice(aduHandle) before the end of the experiment.
best,
paul
2012/2/21 Erin <erin.s...@gmail.com>:
I second Paul's suggestion that if possible you use a legacy RS232
connection because, put simply, E-Prime has absolutely no facility for
communicating through USB. Now in principle, such a facility can be
added -- in fact, I have used a USB device with E-Prime, but only
because that device came with a dll file of external routines which
could be accessed by using Declare statements in E-Prime. But short of
that, you are out of luck.
But please do not take my word for any of this. Please contact PST Web
Support at http://support.pstnet.com/e%2Dprime/support/login.asp , and
then write back here with their response.
-- David McFarlane