4 - Programming Reference [U12 Datasheet]
The LabJack U12 CD installs high-level drivers (ljackuw.dll), an ActiveX interface to the high-level drivers (ljackuwx.ocx), and LabVIEW6 (or higher) VIs which call all the DLL functions. The DLL and OCX are installed in the Windows System directory. If the installation program can determine the LabVIEW directory, it copies the LabVIEW VIs into that directory (\vi.lib\addons\) so they show up on the function palette. Otherwise, the LabVIEW drivers are copied into the LabJack installation directory (c:\Program Files\LabJack)\drivers\labview, and can manually be transferred to the LabVIEW directory. LabVIEW5 VIs are also installed and can be found in the \LabJack\examples directory.
There are 38 functions exported by the LabJack DLL, and matching functions in the OCX and LabVIEW VIs. There are two additional support functions in the OCX, provided due to the limitations of ActiveX. All functions are command/response except for AIBurst and AIStreamStart/Read/Clear.
There are 2 parameters that are used by most functions:
* errorcode – A LabJack specific numeric error code. 0 means no error and 2 means no LabJacks were found. Use the function “GetErrorString” to get a description of the error, or see the list in Section 4.24 of this document.
* idnum – Functions with this input take either a local ID, serial number, or -1. A local ID or serial number will specify a specific LabJack, while –1 means the first found LabJack. Every LabJack has a local ID and serial number. The local ID is a value between 0 and 255 that can be changed by the user. The serial number is a value between 256 and 2,147,483,647 that is unique among all LabJacks and cannot be changed by the user. When using multiple U12s, each should be assigned a unique local ID.
To maintain compatibility with as many languages as possible, the every attempt has been made to keep the parameter types very basic. The declarations that follow, are written in C. If there are any differences in the ActiveX version of a function, they are described.
When a parameter name is preceded by a “*”, it means that it is a pointer. In most cases, this means that the parameter is an input and/or output, whereas a non-pointer parameter is input only. In some cases a pointer points to an array of values rather than a single value, and this will be noted in the parameter description.
Some of the digital I/O parameters contain the information for each bit of I/O in one value, where each bit of I/O corresponds to the same bit in the parameter (i.e. the direction of D0 is set in bit 0 of parameter trisD). For instance, in the function DigitalIO, the parameter *trisD is a pointer to a single memory location that sets/reads the direction of each of the 16 D lines:
* if *trisD points to 0, all D lines are input,
* if *trisD points to 1 (2^0), D0 is output, D1-D15 are input,
* if *trisD points to 5 (2^0 + 2^2), D0 and D2 are output, all other D lines are input,
* if *trisD points to 65535 (2^0 + 2^1 + … + 2^15), D0-D15 are output.
The range of the value pointed to by *trisD is 0 to 65535. When calling DigitalIO, if updateDigital is >1, the D lines will be set to input or output based on the value pointed to by *trisD. When DigitalIO returns, the value pointed to by *trisD will have been set to reflect the status of the direction register in the LabJack U12.