
4. Programming Reference
The LabJack U12 CD installs high-level drivers (ljackuw.dll), an ActiveX interface to the high-
level drivers (ljackuwx.ocx), and LabVIEW6 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 LabVIEW6 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.
There are 21 functions exported by the LabJack DLL., and matching functions in the OCX and
LabVIEW VIs. There are two additional support functions in the OCX, required 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.
•
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.
4.1 AISample
Reads the voltages from 1,2, or 4 analog inputs. Also controls/reads the 4 IO ports. Execution
time for this function is 20 milliseconds or less.
Declaration:
long __cdecl AISample (
long *idnum,
long
demo,
long
*stateIO,
long
updateIO,
long
ledOn,
long
numChannels,
long
*channels,
long
*gains,
long
disableCal,
long
*overVoltage,
float
*voltages
)
Parameter Description:
Returns:
LabJack errorcodes or 0 for no error.
Inputs:
•
*idnum –
Local ID, serial number, or -1 for first found.
•
demo –
Send 0 for normal operation, >0 for demo mode. Demo mode allows
this function to be called without a LabJack.
•
*stateIO –
Output states for IO0-IO3.
•
updateIO –
If >0, state values will be written. Otherwise, just a read is
performed.
•
ledOn –
If >0, the LabJack LED is turned on.
•
numChannels –
Number of analog input channels to read (1,2, or 4).