Posted 10 October 2008 - 06:11 AM
Posted 10 October 2008 - 09:28 AM
Posted 27 May 2011 - 08:52 AM
Posted 27 May 2011 - 02:27 PM
Hi. I kinda have the same question. I've copied the eprime knowledge base for the answer, but I'm a little confused about it. Eprime scripts are written in "E-Basic - Underlying scripting language of E-Prime (nearly identical to Visual Basic for Applications™)." So all your devices "should" work with E-Prime... Right? If so, could you provide a visual basic script that ramps an analog output from -max to +max, and another that does a step from -max to +max? I'm putting together a lab here at University of Maryland Baltimore.
(Also if you didn't know, there is only one company that makes an analog output easy to use for E-prime. They want 3k for it and most labs are basically stuck to use it. Papers are written about using it. So other researchers are forced to use the same over priced equipment. I'm trying to break that cycle... and I like your color scheme.)
E-Prime Knowledge Base
1316 - INFO: How do I send a signal to an external device?
Support for sending a signal to an external device (e.g., another machine, EEG) is available in E-Prime via port communications or through writing your own Windows DLLs.
For port communications, a small amount of script must be used in an InLine Object. To send a signal to the port, you should use the WritePort command in an Inline in your experiment. The parameters for WritePort are as follows:
WritePort address, value
The address of your port can be found by selecting "System" from the Windows Control Panel, clicking on the Device Manager tab, and navigating to Ports. Select the parallel (LPT or printer) port, click the Properties button, and select the Resources tab. The address of the currently accessible port will be shown.
In the WritePort command, the port address may be specified in decimal or hexadecimal notation. Please refer to the Val function in the E-Basic Help file for further explanation. When using hexadecimal notation, E-Basic requires "&H" to be inserted prior to the address:
WritePort &Haddress, value
The most common parallel port address is (in decimal) 888, which translates in hexadecimal notation to 378. However, we strongly recommend that you refer to your own System properties to find the available port address on your own machine.
You must also remember that, when writing to the parallel port, you are sending 8 bits of data at once. For the WritePort command, the value parameter is translated into binary notation to determine the bit pattern. Since this binary representation corresponds to a specific bit representation, you must send a value which translates (in binary) to send the appropriate bit representation. Essentially, you should write a "1" to any bit whose corresponding pin you wish to turn "on." A "0" is written to any bit whose corresponding pin you wish to turn "off". If you were to send all "0"'s to the port, the binary notation for this would be 000000000. To send a signal to bit number '2', the binary notation would translate to 00000010.
The bit pattern then corresponds to the pin connections. Bits are either 0-based or 1-based. Pins are always 1-based.*****Please note: The first available bit to pin connection begins at bit number 1 and at pin number 2. You cannot send a signal to pin number one.
Therefore, if you wanted to turn on bit number one an a 1-based bit pattern, and leave the rest off, you would send a signal of "1" to pin 2, and a signal of 0 to pins 3-9. In binary notation, this would be written as 00000001. In decimal or hexadecimal notation, this would translate to "1". If your port address were (in hexadecimal) 378, the Write Port syntax for this would be:
WritePort &H378, 1
Bit to pin mapping is relatively standard for the parallel port. Please refer to documentation for your hardware and/or port address for a mapping of bits to pins.
E-Prime is capable of sending a signal to the port for interfacing with an external device. The receipt and handling of the signal by the other machine is the responsibility of the user. With the WritePort command, E-Prime may be used to trigger an event (e.g., signal an external device to begin data acquisition) or notify an external device of an event (e.g., in order to mark the event in the data collected by the external device).
When sending more than a TTL pulse to the port, you must write your own Windows DLLs. The only information and/or support PST can offer is to direct you to the DECLARE statement in E-Basic Help. Essentially, you can bring the library of calls from into E-Prime by copying and pasting them into the User script of your experiment. In doing so, you will likely no longer use E-Prime's "WritePort" command for port communications, but will rather use the specific commands you have imported. Writing Windows DLLs is best done by a professional programmer, and is beyond the scope of PST's support for E-Prime.
Generally speaking, any language or program that can call functions from a .dll can communicate with a LabJack since almost all the functionality is wrapped in that .dll.
There are two ways to link to a .dll (generally). The first is statically linking. This is typically done by referencing a .lib file for the .dll which imports the functions. The other way (more common for applications like this) is dynamically linking, where in your code you specify the .dll and function to import and that function is loaded from the .dll and then called by the program.
It sounds like e-prime supports calls from .dlls (since it mentions you can build your own) so it's likely somewhere they show you how to call functions from your own .dll (or ours) it should work. Since it sounds close to VB you might start with this download of our visual basic 6 examples which has some code that might help.
If you need any more help please let us know.
(Thanks for the comments about our color scheme!)
Posted 05 May 2015 - 04:15 PM
I know this is way late for both people who have posted in this thread, but in case anyone ends up here looking to use a LabJack with E-Prime, I wrote a little E-Prime function that allows the LabJack to trigger other lab machines. The function just does digital outputs right now, but if you wanted more functionality you could expand it to do other things, or just use this as an example and write another function.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users